Skip to content

feat(soniox): decode proxy form fields for context, translation and flags - #40605

Merged
mateo-berri merged 11 commits into
BerriAI:mainfrom
dan2k3k4:litellm_soniox_context_proxy_form_params
Oct 16, 2026
Merged

mateo-berri merged 11 commits into
BerriAI:mainfrom
dan2k3k4:litellm_soniox_context_proxy_form_params

Conversation

@dan2k3k4

@dan2k3k4 dan2k3k4 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Proxy users could not send Soniox context, translation, or flags, since form fields arrive as strings

How it solves it:

  • Context objects, translation JSON and flags get real types, decoded once at the handler entry
  • language_hints=en,es becomes a list, and OpenAI language fills the hints only when none are set
  • SDK extra_body dicts sent as bracketed keys like context[terms] become objects
  • A bad flag, polling interval, or JSON value answers 400, or drops under drop_params

Decisions and their alternatives:

  • Non-Soniox context JSON goes as text, since a 400 breaks callers
  • Translation output keeps the base shapes, since SDK callers already parse them
  • Explicit language_hints win over language, as at the base, so pinned strict hints stay as set
  • Flags take pydantic's bool strings, so on and yes work too
  • Bad soniox_max_polling_attempts keeps the default, as before

User Flow

Before: Soniox context and flags reach Soniox as plain strings

  1. In an audio translation app, a developer ticks Soniox's language ID, diarization and translation options and types Kold Brew, Mayne as context terms
  2. The app sends POST http://localhost:4000/v1/audio/transcriptions as form fields
  3. The proxy answers 400, since Soniox reads the flags and translation as strings

After: the fields reach Soniox with real JSON types

  1. The same click, curl, or OpenAI SDK call gets 200, and the transcript spells "Kold Brew" with German lines under each turn

Linear ticket

Resolves LIT-7513

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Both legs call the real Soniox API through a 2-worker proxy with no database, booted from cf1e6b1, the merge base, or 2cbb5c7, the tip. The audio says "cold brew", so Kold Brew shows only when context reaches Soniox as an object

T. The author's audio translation app

The app posts form fields to the proxy in GATSBY_LITELLM_API_URL. Steps on both legs

  1. Open the app and upload coffee_shop.mp3
  2. Pick English to German, model stt-async-v5, and format json
  3. In Soniox options, set Language hints to en and Context: terms to Kold Brew, Mayne, and tick Language identification, Speaker diarization (Soniox), and Translate inside Soniox
  4. Click Process Audio

The app's curl preview

curl -X POST "http://127.0.0.1:$PORT/v1/audio/transcriptions" \
  -H "Authorization: Bearer $LITELLM_KEY" \
  -F "file=@coffee_shop.mp3" \
  -F "model=stt-async-v5" \
  -F "response_format=json" \
  -F "language=en" \
  -F 'language_hints[]=en' \
  -F 'enable_language_identification=true' \
  -F 'enable_speaker_diarization=true' \
  -F 'context={"terms":["Kold Brew","Mayne"]}' \
  -F 'translation={"type":"one_way","target_language":"de"}'

Before (cf1e6b1): Soniox rejects both flags and translation

pr40605-d1478ac69b-tool_before_cf1e6b19ab.png

Before, the raw response
{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_language_identification\",\"message\":\"Input should be a valid boolean\"},{\"error_type\":\"dict_type\",\"location\":\"body.payload.translation\",\"message\":\"Input should be a valid object\"}],\"request_id\":\"20e5f277-06e8-4afd-b864-b3ae33736a93\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'stt-async-v5' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}

After (2cbb5c7): Kold Brew and Mayne, with German lines

pr40605-2cbb5c745a-tool_after_2cbb5c745a.png

After, the raw response
{"text":"Speaker 1:\n[en] What is your best seller here?\n[Translation] [de] Was ist hier euer Bestseller?\n\nSpeaker 2:\n[en] Our best seller here is Kold Brew iced coffee and lattes.\n[Translation] [de] Unser Bestseller hier ist Kold Brew Eiskaffee und Lattes.\n\nSpeaker 1:\n[en] Okay.\n[Translation] [de] Okay.\n[en] And on a day like today, where it's snowing quite a bit—\n[Translation] [de] Und an einem Tag wie heute, wo es ziemlich viel schneit—\n\nSpeaker 2:\n[en] Mm-hmm.\n[Translation] [de] Mhm.\n\nSpeaker 1:\n[en] —do a lot of people still order iced coffee?\n[Translation] [de] —bestellen viele Leute trotzdem noch Eiskaffee?\n\nSpeaker 2:\n[en] Here in Mayne, yes.\n[Translation] [de] Hier in Mayne schon.\n\nSpeaker 1:\n[en] Really?\n[Translation] [de] Wirklich?\n\nSpeaker 2:\n[en] Yes.\n[Translation] [de] Ja.","usage":null,"task":"transcribe","duration":16.079}

Other clients and cases

soniox-stt is soniox/stt-async-v5, and soniox-stt-drop adds drop_params: true

Case Before (cf1e6b1) After (2cbb5c7)
H. terms only 200, cold brew 200, Kold Brew
A. all fields 400 from Soniox 200, translated
B. flag maybe 400 from Soniox 400 from proxy
C. comma hints 400 from Soniox 200
D. JSON hints 400 from Soniox 200
E. text context 200 200
F. no Soniox fields 200 200
G. two_way alone 400 from Soniox 200, source text
I. list context 200 200
J. one_way alone 400 from Soniox 200, source text
K. flag on 400 from Soniox 200
L. interval abc 500 400 from proxy
M. bad flag, drop_params 400 from Soniox 200, flag dropped
N. bad translation, drop_params 400 from Soniox 200, dropped
P. broken JSON hints 400 from Soniox 400 from proxy
R. language plus hints 400 from Soniox 200
O1. SDK, JSON strings 400 from Soniox 200, translated
O2. SDK, dicts 400 from Soniox 200, translated
O3. SDK, dict context 200, cold brew 200, Kold Brew
H. `context` with only `terms`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'context={"terms":["Kold Brew","Mayne"]}'

Before (cf1e6b1)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Mayne, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is Kold Brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Mayne, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
A. Context, one_way translation, and the three flags
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'context={"general":[{"key":"domain","value":"Coffee shop"},{"key":"topic","value":"Ordering drinks"}],"text":"A customer orders drinks at a coffee shop counter.","terms":["latte","espresso","LiteLLM"],"translation_terms":[{"source":"latte","target":"Latte"}]}' -F 'translation={"type":"one_way","target_language":"de"}' -F language_hints=en -F enable_speaker_diarization=true -F enable_language_identification=true -F language_hints_strict=true

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"list_type\",\"location\":\"body.payload.language_hints\",\"message\":\"Input should be a valid list\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.language_hints_strict\",\"message\":\"Input should be a valid boolean\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_language_identification\",\"message\":\"Input should be a valid boolean\"},{\"error_type\":\"dict_type\",\"location\":\"body.payload.translation\",\"message\":\"Input should be a valid object\"}],\"request_id\":\"8b60e45a-6d17-4100-9138-1b45c7013e37\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"Speaker 1:\n[en] What is your best seller here?\n[Translation] [de] Was ist hier euer Bestseller?\n\nSpeaker 2:\n[en] Our best seller here is cold brew iced coffee\n[Translation] [de] Unser Bestseller hier ist Eiskaffee mit Kaltbrau\n[en] and lattes.\n[Translation] [de] und Latte.\n\nSpeaker 1:\n[en] Okay.\n[Translation] [de] Okay.\n[en] And on a day like today,\n[Translation] [de] Und an einem Tag wie heute,\n[en] where it's snowing quite a bit.\n[Translation] [de] wo es ziemlich stark schneit.\n\nSpeaker 2:\n[en] Mm-hm.\n[Translation] [de] Mhm.\n\nSpeaker 1:\n[en] Do a lot of people still order iced coffee?\n[Translation] [de] Bestellen viele Leute immer noch Eiskaffee?\n\nSpeaker 2:\n[en] Here in Maine, yes.\n[Translation] [de] Hier in Maine, ja.\n\nSpeaker 1:\n[en] Really?\n[Translation] [de] Wirklich?\n\nSpeaker 2:\n[en] Yes.\n[Translation] [de] Ja.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
B. A flag set to `maybe`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F enable_speaker_diarization=maybe

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"}],\"request_id\":\"0138eaa1-19fb-45bb-a43b-7469205acc95\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"error":{"message":"litellm.BadRequestError: SonioxException - `enable_speaker_diarization` must be a boolean, got 'maybe'\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400
C. `language_hints=en,es` with `enable_speaker_diarization=1`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F language_hints=en,es -F enable_speaker_diarization=1

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"list_type\",\"location\":\"body.payload.language_hints\",\"message\":\"Input should be a valid list\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"}],\"request_id\":\"f49d11a1-54a0-41bf-b138-8d9a4eef578e\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"Speaker 1:What is your best seller here?\n\nSpeaker 2: Our best seller here is cold brew iced coffee and lattes.\n\nSpeaker 1: Okay. And on a day like today, where it's snowing quite a bit.\n\nSpeaker 2: Mm-hmm.\n\nSpeaker 1: Do a lot of people still order iced coffee?\n\nSpeaker 2: Here in Maine, yes.\n\nSpeaker 1: Really?\n\nSpeaker 2: Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
D. `language_hints` as a JSON array
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'language_hints=["en","es"]'

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"list_type\",\"location\":\"body.payload.language_hints\",\"message\":\"Input should be a valid list\"}],\"request_id\":\"aafc1727-7676-4a90-b9d5-77f4a14ea299\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
E. Free-form text `context`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'context=A customer orders a latte at a coffee shop'

Before (cf1e6b1)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
F. No Soniox fields
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 

Before (cf1e6b1)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
G. `two_way` translation alone
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'translation={"type":"two_way","language_a":"en","language_b":"es"}'

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"dict_type\",\"location\":\"body.payload.translation\",\"message\":\"Input should be a valid object\"}],\"request_id\":\"aa75874b-649b-4cd9-ab86-566f532dbbcb\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
I. `context` as a JSON list, sent as text on both legs
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'context=["Kold Brew","Mayne"]'

Before (cf1e6b1)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Mayne, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Mayne, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
J. `one_way` translation alone
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'translation={"type":"one_way","target_language":"de"}'

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"dict_type\",\"location\":\"body.payload.translation\",\"message\":\"Input should be a valid object\"}],\"request_id\":\"c2c2ba9e-ab27-4169-8f3a-128048d12e2f\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
K. A flag set to `on`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F enable_speaker_diarization=on

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"}],\"request_id\":\"c6fd32c7-e402-4aad-ae3a-3609fd6d830a\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"Speaker 1:What is your best seller here?\n\nSpeaker 2: Our best seller here is cold brew iced coffee and lattes.\n\nSpeaker 1: Okay. And on a day like today, where it's snowing quite a bit.\n\nSpeaker 2: Mm-hmm.\n\nSpeaker 1: Do a lot of people still order iced coffee?\n\nSpeaker 2: Here in Maine, yes.\n\nSpeaker 1: Really?\n\nSpeaker 2: Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
L. `soniox_polling_interval=abc`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F soniox_polling_interval=abc

Before (cf1e6b1)

{"error":{"message":"litellm.APIConnectionError: could not convert string to float: 'abc'\nTraceback (most recent call last):\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/main.py\", line 7996, in atranscription\n    response = await init_response\n               ^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 606, in _async_audio_transcriptions\n    auth_headers, base_url, opt_params, handler_opts = self._prepare(\n                                                       ^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 207, in _prepare\n    poll_interval = float(params.pop(\"soniox_polling_interval\", SONIOX_DEFAULT_POLL_INTERVAL))\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nValueError: could not convert string to float: 'abc'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/router.py\", line 8216, in async_function_with_retries\n    response = await self.make_call(original_function, *args, **kwargs)\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/router.py\", line 8396, in make_call\n    response = await response\n               ^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/router.py\", line 5082, in _atranscription\n    raise e\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/router.py\", line 5064, in _atranscription\n    response = await litellm.atranscription(\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/utils.py\", line 2328, in wrapper_async\n    raise e\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/utils.py\", line 2143, in wrapper_async\n    result = await original_function(*args, **call_kwargs)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/main.py\", line 8019, in atranscription\n    raise exception_type(\n          ^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/litellm_core_utils/exception_mapping_utils.py\", line 2795, in exception_type\n    raise e\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/litellm_core_utils/exception_mapping_utils.py\", line 2761, in exception_type\n    raise APIConnectionError(\nlitellm.exceptions.APIConnectionError: litellm.APIConnectionError: could not convert string to float: 'abc'\nTraceback (most recent call last):\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/main.py\", line 7996, in atranscription\n    response = await init_response\n               ^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 606, in _async_audio_transcriptions\n    auth_headers, base_url, opt_params, handler_opts = self._prepare(\n                                                       ^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 207, in _prepare\n    poll_interval = float(params.pop(\"soniox_polling_interval\", SONIOX_DEFAULT_POLL_INTERVAL))\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nValueError: could not convert string to float: 'abc'\n\nThis looks like a bug in LiteLLM rather than in your request. File it with one click (prefilled, no request data or error text, review before submitting): https://github.com/BerriAI/litellm/issues/new?template=bug_report.yml&labels=bug&title=%5BBug%5D%3A+ValueError+in+litellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py&version=1.107.0&domain=Python+SDK%3A+the+litellm+package+itself&description=Auto-generated+by+LiteLLM%27s+bug+report+link.+It+carries+no+request+data+or+error+text.+Please+describe+what+you+were+doing%2C+and+paste+the+error+message+from+your+log+below+if+it+contains+nothing+sensitive.%0A%0A%60%60%60%0A%0A%60%60%60%0A%0AException%3A+%60ValueError%60%0A%0ALiteLLM+frames%3A%0A%60%60%60%0Alitellm%2Fmain.py%3A7996+in+atranscription%0Alitellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py%3A606+in+_async_audio_transcriptions%0Alitellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py%3A207+in+_prepare%0A%60%60%60%0A%0ASurface%3A+sdk%0AEndpoint+%2F+call%3A+unknown%0AProvider%3A+soniox%0ALiteLLM%3A+1.107.0%0APython%3A+3.12.3%0A&deployment=pip+%2F+Python+SDK\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/main.py\", line 7996, in atranscription\n    response = await init_response\n               ^^^^^^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 606, in _async_audio_transcriptions\n    auth_headers, base_url, opt_params, handler_opts = self._prepare(\n                                                       ^^^^^^^^^^^^^^\n  File \"/private/tmp/claude-501/-Users-mateo-Development-litellm/a9ffa078-6e1e-453f-aa8e-74eac1064d7b/scratchpad/lit-7513/wt_base/litellm/llms/soniox/audio_transcription/handler.py\", line 207, in _prepare\n    poll_interval = float(params.pop(\"soniox_polling_interval\", SONIOX_DEFAULT_POLL_INTERVAL))\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nValueError: could not convert string to float: 'abc'\n\nThis looks like a bug in LiteLLM rather than in your request. File it with one click (prefilled, no request data or error text, review before submitting): https://github.com/BerriAI/litellm/issues/new?template=bug_report.yml&labels=bug&title=%5BBug%5D%3A+ValueError+in+litellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py&version=1.107.0&domain=Python+SDK%3A+the+litellm+package+itself&description=Auto-generated+by+LiteLLM%27s+bug+report+link.+It+carries+no+request+data+or+error+text.+Please+describe+what+you+were+doing%2C+and+paste+the+error+message+from+your+log+below+if+it+contains+nothing+sensitive.%0A%0A%60%60%60%0A%0A%60%60%60%0A%0AException%3A+%60ValueError%60%0A%0ALiteLLM+frames%3A%0A%60%60%60%0Alitellm%2Fmain.py%3A7996+in+atranscription%0Alitellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py%3A606+in+_async_audio_transcriptions%0Alitellm%2Fllms%2Fsoniox%2Faudio_transcription%2Fhandler.py%3A207+in+_prepare%0A%60%60%60%0A%0ASurface%3A+sdk%0AEndpoint+%2F+call%3A+unknown%0AProvider%3A+soniox%0ALiteLLM%3A+1.107.0%0APython%3A+3.12.3%0A&deployment=pip+%2F+Python+SDK\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"500"}}
HTTP 500

After (2cbb5c7)

{"error":{"message":"litellm.BadRequestError: SonioxException - `soniox_polling_interval` must be a number, got 'abc'\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400
M. A flag set to `maybe` on the `drop_params: true` model group
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt-drop -F file=@coffee_shop.mp3 -F enable_speaker_diarization=maybe

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"bool_type\",\"location\":\"body.payload.enable_speaker_diarization\",\"message\":\"Input should be a valid boolean\"}],\"request_id\":\"c35d63c7-841d-4789-a7da-664a3a04212d\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt-drop' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
N. Malformed `translation` JSON on the `drop_params: true` model group
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt-drop -F file=@coffee_shop.mp3 -F 'translation={"type":"one_way"'

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"dict_type\",\"location\":\"body.payload.translation\",\"message\":\"Input should be a valid object\"}],\"request_id\":\"5312c82e-3643-459c-b874-3307d91b4471\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt-drop' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
P. `language_hints=[en, es]`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F 'language_hints=[en, es]'

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"list_type\",\"location\":\"body.payload.language_hints\",\"message\":\"Input should be a valid list\"}],\"request_id\":\"331ff21f-a914-4669-95ce-1ed26fb571bf\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"error":{"message":"litellm.BadRequestError: SonioxException - `language_hints` must be a JSON list, got '[en, es]'\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400
R. `language=de` with `language_hints=en` and `language_hints_strict=true`
curl -s http://localhost:$PORT/v1/audio/transcriptions -H "Authorization: Bearer $LITELLM_MASTER_KEY" -F model=soniox-stt -F file=@coffee_shop.mp3 -F language=de -F language_hints=en -F language_hints_strict=true

Before (cf1e6b1)

{"error":{"message":"litellm.BadRequestError: SonioxException - {\"status_code\":400,\"error_type\":\"invalid_request\",\"message\":\"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.\",\"validation_errors\":[{\"error_type\":\"list_type\",\"location\":\"body.payload.language_hints\",\"message\":\"Input should be a valid list\"},{\"error_type\":\"bool_type\",\"location\":\"body.payload.language_hints_strict\",\"message\":\"Input should be a valid boolean\"}],\"request_id\":\"b6a90f40-7b58-401b-9736-e76c8d6b55c2\",\"more_info\":\"https://soniox.com/docs/api-reference/errors#invalid-request\"}\n\nLiteLLM: model group 'soniox-stt' failed with the error above. No fallback was attempted.","type":null,"param":null,"code":"400"}}
HTTP 400

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","usage":null,"task":"transcribe","duration":16.079}
HTTP 200
O1. OpenAI Python SDK, `extra_body` with JSON strings
client.audio.transcriptions.create(model='soniox-stt', file=open('coffee_shop.mp3','rb'), extra_body={'translation': '{"type": "one_way", "target_language": "de"}', 'enable_speaker_diarization': 'true'})

Before (cf1e6b1)

BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: SonioxException - {"status_code":400,"error_type":"invalid_request","message":"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.","validation_errors":[{"error_type":"bool_type","location":"body.payload.enable_speaker_diarization","message":"Input should be a valid boolean"},{"error_type":"dict_type","location":"body.payload.translation","message":"Input should be a valid object"}],"request_id":"8d98472a-afdc-4125-b4e2-0b132eb313d5","more_info":"https://soniox.com/docs/api-reference/errors#invalid-request"}\n\nLiteLLM: model group \'soniox-stt\' failed with the error above. No fallback was attempted.', 'type': None, 'param': None, 'code': '400'}}

After (2cbb5c7)

{"text":"Speaker 1:What is your best seller here?Was ist hier euer Bestseller?\n\nSpeaker 2: Our best seller here is cold brew iced coffee and lattes. Unser Bestseller hier sind Eiskaffee mit Kaltbrau und Lattes.\n\nSpeaker 1: Okay. Okay. And on a day like today, where it's snowing quite a bit— Und an einem Tag wie heute, wo es ziemlich viel schneit—\n\nSpeaker 2: Mm-hmm. Mhm.\n\nSpeaker 1: —do a lot of people still order iced coffee? —bestellen viele Leute immer noch Eiskaffee?\n\nSpeaker 2: Here in Maine, yes. Hier in Maine, ja.\n\nSpeaker 1: Really? Wirklich?\n\nSpeaker 2: Yes. Ja.","logprobs":null,"usage":null,"task":"transcribe","duration":16.079}
O2. OpenAI Python SDK, `extra_body` with dict values
client.audio.transcriptions.create(model='soniox-stt', file=open('coffee_shop.mp3','rb'), extra_body={'translation': {'type': 'one_way', 'target_language': 'de'}, 'enable_speaker_diarization': True})

Before (cf1e6b1)

BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: SonioxException - {"status_code":400,"error_type":"invalid_request","message":"Your request did not pass validation. One or more fields in the request body are missing or have invalid values. See `validation_errors` for the specific field and retry with corrected values.","validation_errors":[{"error_type":"bool_type","location":"body.payload.enable_speaker_diarization","message":"Input should be a valid boolean"}],"request_id":"da9bf9b2-ddb0-4c89-bbba-df8a81a038f8","more_info":"https://soniox.com/docs/api-reference/errors#invalid-request"}\n\nLiteLLM: model group \'soniox-stt\' failed with the error above. No fallback was attempted.', 'type': None, 'param': None, 'code': '400'}}

After (2cbb5c7)

{"text":"Speaker 1:What is your best seller here?Was ist hier euer Bestseller?\n\nSpeaker 2: Our best seller here is cold brew iced coffee and lattes. Unser Bestseller hier sind Eiskaffee mit Kaltbrau und Lattes.\n\nSpeaker 1: Okay. Okay. And on a day like today, where it's snowing quite a bit— Und an einem Tag wie heute, wo es ziemlich viel schneit—\n\nSpeaker 2: Mm-hmm. Mhm.\n\nSpeaker 1: —do a lot of people still order iced coffee? —bestellen viele Leute immer noch Eiskaffee?\n\nSpeaker 2: Here in Maine, yes. Hier in Maine, ja.\n\nSpeaker 1: Really? Wirklich?\n\nSpeaker 2: Yes. Ja.","logprobs":null,"usage":null,"task":"transcribe","duration":16.079}
O3. OpenAI Python SDK, `extra_body` with a dict `context`
client.audio.transcriptions.create(model='soniox-stt', file=open('coffee_shop.mp3','rb'), extra_body={'context': {'terms': ['Kold Brew', 'Mayne']}})

Before (cf1e6b1)

{"text":"What is your best seller here? Our best seller here is cold brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hm. Do a lot of people still order iced coffee? Here in Maine, yes. Really? Yes.","logprobs":null,"usage":null,"task":"transcribe","duration":16.079}

After (2cbb5c7)

{"text":"What is your best seller here? Our best seller here is Kold Brew iced coffee and lattes. Okay. And on a day like today, where it's snowing quite a bit. Mm-hmm. Do a lot of people still order iced coffee? Here in Mayne, yes. Really? Yes.","logprobs":null,"usage":null,"task":"transcribe","duration":16.079}
The OpenAI SDK script behind O1 to O3, run as python sdk_case.py $PORT .
import json, os, sys
from openai import OpenAI
port, out = sys.argv[1], sys.argv[2]
key = [l.split("=",1)[1].strip() for l in open(".env") if l.startswith("LITELLM_MASTER_KEY=")][0]
client = OpenAI(base_url=f"http://127.0.0.1:{port}/v1", api_key=key)
audio = "coffee_shop.mp3"
cases = {
    "O1_openai_sdk_json_strings": {"translation": json.dumps({"type": "one_way", "target_language": "de"}), "enable_speaker_diarization": "true"},
    "O2_openai_sdk_dict_values": {"translation": {"type": "one_way", "target_language": "de"}, "enable_speaker_diarization": True},
    "O3_openai_sdk_dict_context": {"context": {"terms": ["Kold Brew", "Mayne"]}},
}
for name, extra in cases.items():
    with open(f"{out}/{name}.txt", "w") as fh:
        fh.write(f"client.audio.transcriptions.create(model='soniox-stt', file=open('coffee_shop.mp3','rb'), extra_body={extra!r})\n")
        try:
            r = client.audio.transcriptions.create(model="soniox-stt", file=open(audio, "rb"), extra_body=extra)
            fh.write(r.model_dump_json() + "\n")
        except Exception as e:
            fh.write(f"{type(e).__name__}: {str(e)[:900]}\n")
  • 2cbb5c7 passes /audit (skipped: one provider's mapping on one endpoint family)

Type

🆕 New Feature

Caveats (if any)

Medium

  • An OpenAI SDK dict context keeps only the last general and translation_terms entry
    • The shared proxy form parser keeps one value per repeated key, so its fix is a follow-up. JSON text works
  • translation sent alone returns no translated text, as before
    • Only language ID gives tagged translation lines. With verbose_json, untimed translated tokens sit in words next to the source words

Low

  • A context object with a typo or a future Soniox key goes as text, as before
  • A comma-separated soniox_cleanup string deletes nothing, as before
  • Soniox provider docs need a follow-up

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

  • 2cbb5c7 passes /live-pr-risk


Note

Medium Risk
Changes request parsing and language-hint precedence for all Soniox transcription calls via proxy/SDK forms; scope is isolated to Soniox but affects forwarded API payloads and error behavior.

Overview
Fixes Soniox audio transcription through the LiteLLM proxy when multipart form fields arrive as strings. Soniox was rejecting context, translation, booleans, and language_hints because they were forwarded as plain text instead of typed JSON.

The handler’s _prepare now runs decode_soniox_form_params once (without mutating caller params): booleans from strings (including on/yes), JSON for context/translation, comma- or JSON-list language_hints, and nesting of OpenAI SDK bracket keys like context[terms] and context[general][][key]. Handler-only fields stay out of the Soniox POST body; OpenAI language maps to language_hints only when hints are absent, and explicit hints override language (no more prepending).

Invalid form values return a 400 SonioxException with a clear message; with drop_params, bad fields are dropped (e.g. invalid poll interval falls back to defaults after decode). Adds SonioxContext typing and broad unit/proxy-form tests.

Reviewed by Cursor Bugbot for commit 2cbb5c7. Bugbot is set up for automated code reviews on this repo. Configure here.

@codspeed

codspeed Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing dan2k3k4:litellm_soniox_context_proxy_form_params (2cbb5c7) with main (b5870df)

Open in CodSpeed

@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dan2k3k4

Copy link
Copy Markdown
Contributor Author

@greptileai please review this PR, the automatic review did not start after it was opened.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds form field parsing for audio transcription parameters.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR decodes Soniox multipart form fields into the JSON, list, and boolean values expected by Soniox, adds provider-local request types, and tests the decoding and handler path. The previously reported findings are resolved.

Reviews (8) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment thread litellm/llms/soniox/types.py Resolved
@dan2k3k4

Copy link
Copy Markdown
Contributor Author

@greptileai both findings are addressed in cf33d3f, please review the updated commit.

@dan2k3k4

Copy link
Copy Markdown
Contributor Author

@greptileai added a test covering the new Soniox types in 3d9e261, no behavior change, please re-review.

@dan2k3k4

Copy link
Copy Markdown
Contributor Author

@greptileai the mutable params workflow is replaced in 70f8bce, please re-review.

@dan2k3k4

Copy link
Copy Markdown
Contributor Author

@greptileai the flagged comment is removed in 80c56c0, please re-review.

@dan2k3k4
dan2k3k4 marked this pull request as ready for review September 10, 2026 20:32
@dan2k3k4
dan2k3k4 requested a review from a team September 10, 2026 20:32
@yuneng-berri
yuneng-berri deleted the branch BerriAI:main September 13, 2026 04:51
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@dan2k3k4
dan2k3k4 force-pushed the litellm_soniox_context_proxy_form_params branch from 80c56c0 to 63c0924 Compare September 14, 2026 07:35
@dan2k3k4 dan2k3k4 closed this Sep 14, 2026
@dan2k3k4
dan2k3k4 deleted the litellm_soniox_context_proxy_form_params branch September 14, 2026 12:24
@dan2k3k4
dan2k3k4 restored the litellm_soniox_context_proxy_form_params branch September 14, 2026 12:52
@dan2k3k4 dan2k3k4 reopened this Sep 14, 2026
@dan2k3k4
dan2k3k4 force-pushed the litellm_soniox_context_proxy_form_params branch from 63c0924 to 847eaeb Compare September 14, 2026 12:52
@dan2k3k4
dan2k3k4 force-pushed the litellm_soniox_context_proxy_form_params branch from 7cbbc55 to ef2a39b Compare September 16, 2026 05:44
@dan2k3k4
dan2k3k4 changed the base branch from litellm_internal_staging to main September 16, 2026 05:45
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@dan2k3k4
dan2k3k4 force-pushed the litellm_soniox_context_proxy_form_params branch from 2ad0457 to 9c17c17 Compare October 5, 2026 16:10
@mateo-berri

Copy link
Copy Markdown
Contributor

Nothing more from you. Code review is done. The last step is a live run against Soniox on our account, being set up now

@greptile-apps

greptile-apps Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository.

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@litereview

litereview Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ code-review

5/5 · Ready for human review

Scope: full · Full PR review.

No correctness findings.

Checks and execution details
  • Passed · Real testing evidence (required): The rule applies because the PR changes Soniox request translation in litellm/llms/soniox/audio_transcription/transformation.py and handler.py. It changes how context, translation, language_hints, the bool flags and the polling interval reach Soniox.

The PR description includes inspectable manual E2E evidence. It names the base (cf1e6b19ab) and the reviewed head (2cbb5c745a), and it describes the environment: a 2-worker proxy with no database. It calls the real Soniox API through POST /v1/audio/transcriptions. For each case it gives the exact curl or SDK call and the raw before/after responses. The cases cover:

  • success paths: A, C, D, G, H, J, K, R and O1–O3
  • failures returned as proxy 400s: B, L and P
  • the drop_params paths: M and N
  • regressions: E, F and I

The decisive success evidence is the Kold Brew spelling, which appears only when Soniox receives context as an object.

In the repository, TestProxyFormFields::test_should_send_soniox_types_for_fields_the_proxy_parsed_from_an_sdk_form builds a real multipart body with httpx. It parses that body with the proxy's real get_form_data, then runs it through litellm.transcription. It asserts the JSON body sent to Soniox. Only the Soniox HTTP responses are stubbed.

I ran uv run --frozen pytest tests/unit/llms/soniox -q locally at head: 148 passed.

  • Passed · Soniox unit and integration tests (optional): Ran uv run --frozen pytest tests/unit/llms/soniox -q at head: 148 passed, 13 warnings (pydantic ReadOnly notices).
  • Passed · Decoder edge-case probes (optional): Called decode_soniox_form_params directly at head. An empty bool string returns SonioxInvalidFormParam. JSON context with trailing whitespace decodes to an object. An explicit translation wins over bracketed translation[...] keys and still fails validation when it is invalid. language_hints="[]" decodes to an empty tuple. A lone context[general][][key] is not valid Soniox context, so it stays unnested. A polling interval of 1e400 passes the decoder, then _float_or_default resets it to the default because the value is not finite.
  • Passed · Prior finding history (optional): The three earlier findings are already withdrawn or fixed. At head, soniox_language_hints still gives explicit hints priority over language, and _nest_bracketed_form_fields still nests context[general][][key], so neither earlier decision needs reopening. _build_response_from_payload has no changes in this diff.

View review · Reviewed 2cbb5c745ac4

Validate structured context before sending it as an object, answer 400 for a
bad polling interval or flag unless drop_params is on, nest SDK bracketed
extra_body fields, keep the OpenAI language at the head of language_hints, and
return the translated text for one-way translation without tags.
@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

_STRUCTURED_CONTEXT: Final = TypeAdapter(SonioxContext)
_FORM_BOOL: Final = TypeAdapter(bool)
_LANGUAGE_HINTS: Final = TypeAdapter(tuple[object, ...])
_BRACKETED_FORM_FIELD: Final = re.compile(r"(?P<param>context|translation)\[(?P<field>\w+)\]")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low · SDK dict context silently loses general and translation_terms

  1. A developer calls the proxy with the OpenAI SDK and sets extra_body={'context': {'terms': ['Kold Brew'], 'general': [{'key': 'domain', 'value': 'Coffee shop'}]}}.
  2. The SDK flattens this into the form keys context[terms][], context[general][][key] and context[general][][value].
  3. get_form_data strips only a trailing [], so context[terms][] becomes context[terms]. The general keys keep their [][key] suffix.
  4. The new _BRACKETED_FORM_FIELD regex (context\[\w+\]) matches only context[terms]. Soniox receives context={'terms': [...]}. The two general keys go out as unknown top-level body fields.
  5. The caller gets no error, but Soniox never sees the general context. translation_terms follows the same path.

This is code-derived and confirmed locally against decode_soniox_form_params. I did not observe how Soniox handles the stray top-level keys. The PR caveat says these fields "keep only the last entry", but the code drops them from context entirely. The smallest fix is to nest context[&lt;field>][][&lt;sub>] keys into lists of objects, or return a 400 when bracketed context keys can't be nested.

Evidence

openai SDK _serialize_multipartform output for {'context': {'terms': ['a'], 'general': [{'key': 'k', 'value': 'v'}], 'translation_terms': [{'source': 'a', 'target': 'b'}]}}:
{'context[terms][]': 'a', 'context[general][][key]': 'k', 'context[general][][value]': 'v', 'context[translation_terms][][source]': 'a', 'context[translation_terms][][target]': 'b', ...}

Local run: decode_soniox_form_params({'context[general][][key]':'k','context[general][][value]':'v','context[terms]':['a'], ...}) returned {'context': {'terms': ['a']}, 'context[general][][key]': 'k', 'context[general][][value]': 'v', ...}

litellm/proxy/common_utils/http_parsing_utils.py:497: get_form_data strips only a trailing [] from form keys.

handler.py _prepare forwards every decoded key not in _NOT_FORWARDED_TO_SONIOX into the create body, so the stray keys reach Soniox.

Latest summary by code-review · View this review · Reviewed 008dcd9e6991

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy form parser keeps one value per repeated key, so these entries cannot be rebuilt. A JSON-string context works, listed as a caveat

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding still applies

Thanks for the context. Part of the reply is correct: get_form_data overwrites a repeated key unless it ends in []. With two or more general entries, the proxy can't fully rebuild context[general][][key] and context[general][][value].

That point doesn't refute the finding, which is about the silent failure:

  1. A caller sends extra_body={'context': {'terms': [...], 'general': [{'key': 'domain', 'value': 'Coffee shop'}]}} through the OpenAI SDK.
  2. _BRACKETED_FORM_FIELD (context\[\w+\]) matches only context[terms]. The general keys don't match, so the code leaves them out of context.
  3. _prepare forwards those keys to Soniox as unknown top-level body fields.
  4. The request still succeeds with no error, but Soniox never gets the general context.

The current code can rebuild even a single entry, and the proxy can always reject unnested bracketed context[...] / translation[...] keys with a 400. Either change would close the finding. The PR caveat acknowledges the limitation, but an acknowledged caveat isn't technical evidence, so the finding stays upheld at Low severity.

Evidence

Local run at head: decode_soniox_form_params({'context[terms]':['a'],'context[general][][key]':'k','context[general][][value]':'v'}) returned {'context': {'terms': ['a']}, 'context[general][][key]': 'k', 'context[general][][value]': 'v'}. No error was raised.

litellm/llms/soniox/audio_transcription/transformation.py:75: _BRACKETED_FORM_FIELD = re.compile(r"(?P&lt;param>context|translation)\[(?P&lt;field>\w+)\]") only fully matches single-level keys. _nest_bracketed_form_fields passes every unmatched key through unchanged.

litellm/proxy/common_utils/http_parsing_utils.py get_form_data: keys ending in [] accumulate into lists. Every other key does parsed_form_data[key] = value, so the last repeat wins. This confirms the reply's premise for multi-entry lists only.

litellm/llms/soniox/audio_transcription/handler.py:273: the create body includes every decoded key not in _NOT_FORWARDED_TO_SONIOX, so the stray context[general][][...] keys reach Soniox as top-level fields.

PR caveat: "SDK extra_body context general and translation_terms never reach Soniox ... send JSON text". This acknowledges the defect and does not fix it.

Reviewed 008dcd9e6991 · View follow-up

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d1478ac rebuilds general and translation_terms entries from the SDK's bracketed columns. Lists past one entry keep the last, noted in Caveats

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding withdrawn

Thanks for the fix. The finding said OpenAI SDK extra_body general and translation_terms context never reached Soniox and leaked as unknown top-level fields. That no longer happens at d1478ac69b:

  1. _BRACKETED_FORM_FIELD now matches context[&lt;field>][][&lt;entry_field>].
  2. _nested_form_param and _form_entries zip the matched columns into lists of objects under context.
  3. _nest_bracketed_form_fields removes the matched bracketed keys, so _prepare doesn't forward them as top-level fields.

One limitation remains. The SDK sends repeated context[general][][key] keys, and get_form_data keeps only the last value for each one, so a list with more than one entry arrives as its last entry. The earlier follow-up said that rebuilding a single entry would close this finding, and the PR documents the multi-entry case as a caveat. The proxy parser's handling of repeated keys causes it, and this PR didn't add that behavior. I don't consider that enough to keep this finding open.

Evidence

Local run at head: decode_soniox_form_params({'context[terms]':['a'],'context[general][][key]':'k','context[general][][value]':'v','context[translation_terms][][source]':'s','context[translation_terms][][target]':'t'}) returned {'context': {'terms': ['a'], 'translation_terms': ({'source': 's', 'target': 't'},), 'general': ({'key': 'k', 'value': 'v'},)}}. The result has no stray top-level keys.

litellm/llms/soniox/audio_transcription/transformation.py:74-76: _BRACKETED_FORM_FIELD = re.compile(r"(?P&lt;param>context|translation)\[(?P&lt;field>\w+)\](?:\[\]\[(?P&lt;entry_field>\w+)\])?")

transformation.py:162-209: _form_entries zips the columns into rows. _nest_bracketed_form_fields keeps a key unnested only when it doesn't match or its param was dropped.

tests/unit/llms/soniox/audio_transcription/test_soniox_audio_transcription_transformation.py:852 test_should_rebuild_openai_sdk_list_of_object_context_fields passed locally: 6 passed for -k "bracket or general or nest".

litellm/proxy/common_utils/http_parsing_utils.py:496-501: get_form_data accumulates values only for keys ending in []. For context[general][][key], the last repeat wins. This is the multi-entry caveat.

GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually.

Reviewed d1478ac69b0a · View follow-up

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

Keeping the source transcript in text is deliberate, as at the base, since callers read it there. Live case J at d1478ac shows it

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

)


def soniox_language_hints(language: object, hints: object) -> object:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium · language is dropped when language_hints is also set

  1. A caller runs litellm.transcription(model="soniox/stt-async-v5", language="en", language_hints=["fr"], ...). The proxy form fields language=en and language_hints=fr take the same path.
  2. map_openai_params and the handler's _prepare both call the new soniox_language_hints(language, hints).
  3. That helper returns hints unchanged whenever they are present. The handler then strips language through _NOT_FORWARDED_TO_SONIOX.
  4. Soniox receives language_hints: ["fr"] with no en. At base, map_openai_params prepended the value and sent ["en", "fr"].

The PR description says the opposite: "language joins the hints, as the base map_openai_params and its tests specify". Its Low caveat says sending both now adds language to the hints. The PR also renamed and inverted the base test test_should_prepend_language_to_existing_hints to test_should_keep_explicit_hints_over_language, which locks in the regression.

Smallest fix: have soniox_language_hints prepend language when it is missing from hints, and restore the base test. If dropping language is intended, correct the description and caveat and treat this as a behavior change.

Evidence

Base map_openai_params (removed in the diff): elif language not in existing_hints: optional_params["language_hints"] = [language] + list(existing_hints).

Head transformation.py:93-97: if hints is not None or not isinstance(language, str) or not language: return hints.

Local reproducer through litellm.transcription with the repo's _MockSyncClient, language="en", language_hints=["fr"] and audio_url. The captured POST body was {'model': 'stt-async-v5', 'language_hints': ['fr'], 'audio_url': 'https://x/a.wav'}.

Test diff: test_should_prepend_language_to_existing_hints asserting ["en", "fr"] became test_should_keep_explicit_hints_over_language asserting ["fr"].

Latest summary by code-review · View this review · Reviewed 2cbb5c745ac4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deliberate. Explicit language_hints win over language, as the base did at runtime, so a pinned strict list never widens. Case R covers it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding withdrawn

You're right, and thanks for pointing to Case R. The prepend branch in the base map_openai_params never ran through litellm.transcription:

  1. get_optional_params_transcription calls map_openai_params with optional_params={}. At that point existing_hints is always None, so the base code set language_hints=["en"].
  2. Next, add_provider_specific_params_to_optional_params copied the caller's language_hints=["fr"] over that value, because Soniox is not an OpenAI-SDK provider.
  3. Soniox received ["fr"] at base, and it receives ["fr"] at head. Runtime behavior did not regress.

The base unit test test_should_prepend_language_to_existing_hints called map_openai_params with prefilled optional_params, which the real caller never passes. Changing that test makes it match runtime behavior. The current PR description also states that "Explicit language_hints win over language, as at the base", so the mismatch with the description no longer applies. I'm withdrawing the finding.

Evidence

litellm/utils.py:3632 sets optional_params = {}. Then :3671 calls provider_config.map_openai_params(..., optional_params=optional_params).

litellm/utils.py:3678 and :5196-5200: for providers that don't use the OpenAI SDK, optional_params[k] = passed_params[k] runs for every non-OpenAI param. That overwrites language_hints.

Base simulation (base map_openai_params patched in, uv run) printed base sees existing_hints = None, then {'language_hints': ['fr'], 'model': 'stt-async-v5'}.

Head printed {'language': 'en', 'language_hints': ['fr'], 'model': 'stt-async-v5'}. language is in _NOT_FORWARDED_TO_SONIOX (handler.py), so Soniox gets ['fr'].

transformation.py:93-97 soniox_language_hints returns explicit hints unchanged. test_should_keep_explicit_hints_over_language asserts ['fr'].

The current PR description says: "Explicit language_hints win over language, as at the base, so pinned strict hints stay as set".

GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually.

Reviewed 2cbb5c745ac4 · View follow-up

@mateo-berri

Copy link
Copy Markdown
Contributor

@litereview code-review

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2cbb5c7. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor

@litellm-stampbot

@litellm-stampbot

Copy link
Copy Markdown

litellm-stampbot

the head branch lives on dan2k3k4/litellm, and the stampbot does not run on fork pull requests.

@mateo-berri
mateo-berri enabled auto-merge (squash) October 16, 2026 05:42

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution!

@mateo-berri
mateo-berri merged commit c8b73cd into BerriAI:main Oct 16, 2026
91 checks passed
@dan2k3k4
dan2k3k4 deleted the litellm_soniox_context_proxy_form_params branch October 20, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants