litellm/.github/workflows
Gabriel Creti 0946b7416c
feat(gradium): add text-to-speech support for /v1/audio/speech (#46427)
* feat(gradium): add text-to-speech support for /v1/audio/speech

Gradium (https://gradium.ai) is a voice AI provider whose TTS had no
LiteLLM route. Adds it as a first-class TTS provider behind the existing
BaseTextToSpeechConfig seam, so `litellm.speech(model="gradium/default")`
and the proxy's /v1/audio/speech both work.

The provider targets Gradium's REST TTS endpoint
(POST /api/post/speech/tts) rather than its Python SDK, so the call
flows through base_llm_http_handler and keeps retries, logging and cost
tracking that an SDK-internal HTTP client would bypass.

Notes on the mapping:
- `only_audio: true` is always sent. Without it Gradium answers a
  line-delimited JSON message stream instead of audio bytes, which
  /v1/audio/speech callers cannot read.
- The six canonical OpenAI voice names map to Gradium library voice IDs;
  anything else is forwarded verbatim, so raw Gradium voice IDs work.
- Gradium has no mp3/aac/flac encoder, so those response_formats raise
  UnsupportedParamsError instead of silently returning mislabeled audio.
  `litellm.drop_params` falls back to the default format.
- Pre-stream failures come back as HTTP 500 with a plain-text body, so
  the response transform raises rather than handing the caller an opaque
  binary payload.
- Cost is per character of input text (1 credit/char), priced from the
  published add-on credit rate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(gradium): satisfy CI gates and handle /api-suffixed api_base

- register the provider in provider_endpoints_support.json and claim
  tests/unit/llms/gradium in the llms-providers shard, so the provider
  documentation and CI/shard coverage gates see it
- rework the transformation to build its params and request body
  functionally rather than by mutation, so it clears the type-discipline
  rules; the suppressions that remain are the signatures
  BaseTextToSpeechConfig fixes and the dicts its return types require
- get_complete_url now tolerates an api_base that already ends in /api.
  Gradium documents its regional bases that way
  (https://eu.api.gradium.ai/api), and pasting one produced
  /api/api/post/speech/tts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(gradium): cover the remaining branches, format under the pinned ruff

- ruff format with the pinned 0.15.3 (the suppression comments were long
  enough to push their lines over the limit and get them wrapped)
- cover get_supported_openai_params, get_error_class, the explicit
  api_base/api_key path, and both missing-voice paths, taking the
  provider to 100% patch coverage

The missing-voice tests record where each guard actually fires:
map_openai_params raises ValueError first (same as elevenlabs), so
speech()'s own BadRequestError is reachable only when the provider
config manager returns None.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(gradium): use the local_model_cost_map fixture for the cost test

The cost test wrote litellm.model_cost directly, which the test-quality
gate flags (TQ005): it is a process-wide global, and the leak is exactly
what the save/restore conftest exists to undo. The existing
local_model_cost_map fixture does the same setup with teardown, so the
suite no longer depends on LITELLM_LOCAL_MODEL_COST_MAP being exported.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(gradium): clear the basedpyright and Add Model dropdown gates

- add a provider_create_fields.json entry so gradium appears in the
  proxy UI's Add Model dropdown; test_public_endpoints asserts every
  LlmProviders member is listed there
- parameterize the dict/list annotations copied from
  BaseTextToSpeechConfig and type gradium_models, which basedpyright
  counted as new Unknown-type errors against the merge-base ceiling
- suppress the untyped-argument errors on the shared TTS handler call;
  every provider branch of speech() carries the same ones
- keep extra_body support, matching elevenlabs and minimax, and cover it
  with a test

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor(gradium): take api_key and api_base from the model only

The API key and base are set by whoever creates the model, like any other
deployment credential. Drop the GRADIUM_API_KEY / GRADIUM_API_BASE
environment fallbacks, the litellm.api_key fallback (which could send an
unrelated provider's global key to Gradium) and the hardcoded default
base URL; a missing value now raises a clear error.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(gradium): stream text-to-speech audio when stream is true

#46222 made streamed speech opt-in per provider through
supports_streaming. Gradium's REST TTS endpoint already sends audio as
it is synthesized, so the config opts in and speech() forwards
stream=True to the shared handler. Without stream the clip is still
read in full before it is returned.

Co-Authored-By: Claude <noreply@anthropic.com>

* chore(gradium): regenerate provider endpoint support

provider_endpoints_support.json and its backup are now generated from
the cost map, so Gradium's hand-written entry was stale and missing
from the backup.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(gradium): honor drop_params, reject speed and instructions, bill every character

Gradium counts every input character, spaces included, so the response reports billed_characters and the shared cost path no longer under-bills by the stripped whitespace

A deployment's drop_params now drops an unsupported response_format, speed or instructions. Without it those params answer 400, the litellm convention for a param the provider cannot honor

The Pro Voice Clone row is removed because Gradium has no such model name. The XS add-on rate is $7 per 100k credits, and the Add Model form now asks for the API base

* fix(gradium): accept native formats, map current OpenAI voices, answer 400 on a missing voice

Calls Gradium's documented /api/speech/tts path, passes ulaw_8000, alaw_8000 and the pcm_* rates through with audio content types, maps ash, ballad, coral, sage, verse, marin and cedar, prices gradium/gradium-tts-beta, and types the tests

* fix(gradium): map OpenAI voices to English voices, forward json_config, accept speed 1.0

Missing api_key now answers 401 and a missing api_base answers 500 without a traceback

* fix(gradium): ignore a non-object extra_body and keep a top-level json_config

A non-object extra_body no longer answers 500, and a null json_config in
extra_body no longer erases the top-level value. The cost map drops the advice
to override input_cost_per_character, which speech cost ignores today, and adds
gradium/gradium-tts-202602, Gradium's previous model, at the same rate. The
async speech test now checks the request body sent on both the streamed and
buffered paths.

* fix(gradium): read json_config from any mapping extra_body

A read-only mapping such as MappingProxyType passed as extra_body is now
read like a dict, as it was before the non-object check. The non-object
test also sends a top-level json_config so it fails if that check drops
every caller field

* fix(gradium): answer 502 for a 200 response that is not audio

Only a missing content type or application/octet-stream, which Gradium
sends for pcm, ulaw and alaw, is relabeled as audio. Any other 200, such
as JSON or HTML, now raises a 502 instead of reaching the caller labeled
audio/pcm and being billed. Tests also pin case-insensitive voice names,
trimmed voices and extra_body's json_config winning over the top level

* fix(gradium): release the upstream response when rejecting a non-audio reply

A streamed 200 that is not audio was raised as a 502 without closing the
response, so the sync and async speech paths could keep the connection.
Both paths now close it before raising

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-21 23:51:27 +00:00
..
auto-close-duplicates.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
check-schema-sync.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
codeql.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
codspeed.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
compat-matrix-image.yml feat(docker)!: one shipped image and one entrypoint beside the Dockerfile (#43332) 2026-11-10 18:32:16 -08:00
conventional-commits.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
cost-map-guard.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
cost-map-pins-recheck.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
create-rc-branch.yml ci: cut the weekly rc branch on Monday 3am PT instead of Friday (#49472) 2026-10-31 12:32:23 -07:00
create-release-branch.yml ci(release): create stable/X.Y.x line branch on X.Y.0 tags (#29457) 2026-06-01 15:56:34 -07:00
duplicate_issue_check.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
e2e_record_replay.yml ci(e2e): record the e2e suite weekly and replay it on weekdays with zero egress (#38163) 2026-08-24 23:49:03 -04:00
guard-fork-dependencies.yml chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
image-scan.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
interactions-spec-canary.yml feat(interactions): forward continuation_token and type requires_continuation so callers can resume a long decode (#50151) 2026-11-05 15:38:44 -08:00
issue-keyword-labeler.yml chore: fixes 2026-04-05 01:30:57 -07:00
issue_classifier.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
issue_fixed_comment.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
issue_label_claude_code.yml ci(issue-classifier): name every workflow, script and job after the issue it works on 2026-09-18 11:37:55 -07:00
issue_label_sync.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
linear-release.yml ci: sync the weekly release cycle with Linear releases (#43636) 2026-09-28 17:00:56 -07:00
mutation-test.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
osv-scan.yml chore: move ui and vscode-extension under litellm and delete docs (#50992) 2026-11-12 04:19:57 +00:00
publish-lint-base-counts.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
root-entry-limit.yml ci(lint): run the fast lint checks on pull requests again without compiling Rust (#53421) 2026-11-21 14:17:30 -08:00
scorecard.yml chore: fixes 2026-04-05 01:30:57 -07:00
spend-logs-guard.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
stale.yml chore: fixes 2026-04-05 01:30:57 -07:00
sync-schema.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test-e2e-redis-chaos.yml test(e2e): rename load to perf and consolidate the opt-in into E2E_PERF_TESTS (#46077) 2026-10-12 13:54:03 -07:00
test-integration.yml ci(integration): point the rust gateway install step at litellm/packaging (#51743) 2026-11-14 13:36:57 +09:00
test-linting.yml ci(lint): run the fast lint checks on pull requests again without compiling Rust (#53421) 2026-11-21 14:17:30 -08:00
test-mcp-dependency-resolution.yml ci(mcp-deps): build unoptimized in the MCP dependency resolution workflow (#51684) 2026-11-13 19:17:44 +00:00
test-merge-smoke.yml ci(lint): clear the two code-quality failures behind the stale provider file (#52921) 2026-11-19 19:59:23 +00:00
test-rust-db.yml ci(rust): run LiteLLM Rust DB on pushes to main only and cover release-line PRs (#52609) 2026-11-18 17:44:13 -08:00
test-rust.yml feat(proxy): send gateway model calls to Lens as traces when the Lens store is connected (#53042) 2026-11-20 10:12:08 -08:00
test-terraform-modules.yml chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test-terraform-provider.yml feat(proxy): send gateway model calls to Lens as traces when the Lens store is connected (#53042) 2026-11-20 10:12:08 -08:00
test-unit.yml feat(gradium): add text-to-speech support for /v1/audio/speech (#46427) 2026-11-21 23:51:27 +00:00
test-vscode-extension.yml chore: move ui and vscode-extension under litellm and delete docs (#50992) 2026-11-12 04:19:57 +00:00
zizmor.yml ci: run zizmor with --no-ignores and move the spend logs and cost map guards to pull_request (#48947) 2026-10-28 17:44:48 -07:00