API for audio transcription.
Create Transcription
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.transcriptions.complete(model="voxtral-mini-latest", diarize=False)
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
model |
str | ✔️ | ID of the model to be used. | Example 1: voxtral-mini-latest Example 2: voxtral-mini-2507 |
file |
Optional[models.File] | ➖ | N/A | |
file_url |
OptionalNullable[str] | ➖ | Url of a file to be transcribed | |
file_id |
OptionalNullable[str] | ➖ | ID of a file uploaded to /v1/files | |
language |
OptionalNullable[str] | ➖ | Language of the audio, e.g. 'en'. Providing the language can boost accuracy. | |
temperature |
OptionalNullable[float] | ➖ | N/A | |
diarize |
Optional[bool] | ➖ | N/A | |
context_bias |
List[str] | ➖ | N/A | |
timestamp_granularities |
List[models.TimestampGranularity] | ➖ | Granularities of timestamps to include in the response. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |
Create Streaming Transcription (SSE)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.audio.transcriptions.stream(model="Camry", diarize=False)
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)| Parameter | Type | Required | Description |
|---|---|---|---|
model |
str | ✔️ | N/A |
file |
Optional[models.File] | ➖ | N/A |
file_url |
OptionalNullable[str] | ➖ | Url of a file to be transcribed |
file_id |
OptionalNullable[str] | ➖ | ID of a file uploaded to /v1/files |
language |
OptionalNullable[str] | ➖ | Language of the audio, e.g. 'en'. Providing the language can boost accuracy. |
temperature |
OptionalNullable[float] | ➖ | N/A |
diarize |
Optional[bool] | ➖ | N/A |
context_bias |
List[str] | ➖ | N/A |
timestamp_granularities |
List[models.TimestampGranularity] | ➖ | Granularities of timestamps to include in the response. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Union[eventstreaming.EventStream[models.TranscriptionStreamEvents], eventstreaming.EventStreamAsync[models.TranscriptionStreamEvents]]
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.SDKError | 4XX, 5XX | */* |