Python -VV
Python 3.12.3 (main, Jan 22 2026, 20:57:42) [GCC 13.3.0]
Pip Freeze
Reproduction Steps
- Make a request via the SDK for a transcription using an online URL, rather than an uploaded file. Include context bias for unusual words
- Request will return successfully, but without context bias being applied.
Expected Behavior
Context bias should be applied
When calling client.audio.transcriptions.complete() with file_url (rather than uploading a file), the context_bias parameter is silently ignored. This is because the SDK sends the request as application/x-www-form-urlencoded instead of multipart/form-data.
Root Cause:
In basesdk.py, the _build_request_with_client method passes both data= and files= to httpx's build_request(). When files is an empty list (which happens when using file_url instead of uploading a file), httpx defaults to application/x-www-form-urlencoded encoding instead of multipart/form-data.
# basesdk.py line ~97
return client.build_request(
method,
url,
params=query_params,
content=serialized_request_body.content,
data=serialized_request_body.data,
files=serialized_request_body.files, # Empty list causes httpx to use urlencoded
headers=headers,
timeout=timeout,
)
Reproduction:
from mistralai import Mistral
client = Mistral(api_key="...")
result = client.audio.transcriptions.complete(
model="voxtral-mini-latest",
file_url="https://example.com/audio.mp3",
diarize=True,
context_bias=["Scriba", "Mistral", "diarization"],
)
# context_bias words are not applied to transcription
Workaround:
Direct curl request with -F flags works correctly:
curl 'https://api.mistral.ai/v1/audio/transcriptions' \
-H "Authorization: Bearer $API_KEY" \
-F 'model=voxtral-mini-latest' \
-F 'file_url=https://example.com/audio.mp3' \
-F 'diarize=true' \
-F 'context_bias=Scriba' \
-F 'context_bias=Mistral'
Suggested Fix:
When serialized_request_body.media_type is multipart/form-data but files is empty, either:
- Pass
files=None instead of files=[] and explicitly set the Content-Type header, or
- Add a dummy empty file to force multipart encoding, or
- Use httpx's
content= parameter with manually-encoded multipart data
Additional Context
No response
Suggested Solutions
No response
Python -VV
Pip Freeze
Reproduction Steps
Expected Behavior
Context bias should be applied
When calling
client.audio.transcriptions.complete()withfile_url(rather than uploading a file), thecontext_biasparameter is silently ignored. This is because the SDK sends the request asapplication/x-www-form-urlencodedinstead ofmultipart/form-data.Root Cause:
In
basesdk.py, the_build_request_with_clientmethod passes bothdata=andfiles=to httpx'sbuild_request(). Whenfilesis an empty list (which happens when usingfile_urlinstead of uploading a file), httpx defaults toapplication/x-www-form-urlencodedencoding instead ofmultipart/form-data.Reproduction:
Workaround:
Direct curl request with
-Fflags works correctly:Suggested Fix:
When
serialized_request_body.media_typeismultipart/form-databutfilesis empty, either:files=Noneinstead offiles=[]and explicitly set the Content-Type header, orcontent=parameter with manually-encoded multipart dataAdditional Context
No response
Suggested Solutions
No response