From f8fe835406a6958183e3daa11ca1964ffc7787fe Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 3 Dec 2026 20:38:02 +0000 Subject: [PATCH] ## Python SDK Changes: * `open_router.tts.create_speech()`: * `request.timestamp_granularities` **Added** * `error.status[504]` **Added** * `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.timestamp_granularities` **Added** * `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.timestamp_granularities` **Added** --- .speakeasy/gen.lock | 94 +++++------ .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 152 +++++++++++++++++- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/components/keybudget.mdx | 22 +-- docs/components/outputdelivery.mdx | 2 +- docs/components/scimgrouppolicyassignment.mdx | 2 +- .../scimgrouppolicyassignmentresponse.mdx | 6 +- docs/components/speechoutputmodality.mdx | 10 +- docs/components/speechrequest.mdx | 29 ++-- docs/components/speechsupportedparameters.mdx | 1 + docs/components/timestampgranularity.mdx | 20 +++ docs/sdks/tts/README.mdx | 38 ++--- pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/components/__init__.py | 3 + src/openrouter/components/keybudget.py | 4 +- .../components/scimgrouppolicyassignment.py | 4 +- .../scimgrouppolicyassignmentresponse.py | 4 +- src/openrouter/components/speechrequest.py | 21 ++- .../components/speechsupportedparameters.py | 13 +- src/openrouter/tts.py | 36 ++++- uv.lock | 2 +- 24 files changed, 366 insertions(+), 127 deletions(-) create mode 100644 docs/components/timestampgranularity.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index d1e6cbdb..9c3d6f29 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: c48cf606-fb42-4a45-9c23-8f0555307828 management: - docChecksum: 75525ddbb8083684b49e018ec9091b0c + docChecksum: e73937be9d67b7086d2b9189ed94394d docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.237 - configChecksum: 8949f17114764f95ad7986de38daf254 + releaseVersion: 1.3.238 + configChecksum: 8991cb8f69d8ff8283ec2e934c1e5522 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: d4012637-9117-45d5-8f98-ab34865f64b7 - pristine_commit_hash: 047a999d1f0d837b27b8c553977df61e42f7661f - pristine_tree_hash: 97d3569821136689d68bd07f5b101701fe080f31 + generation_id: 300f0c45-578b-49e8-96b5-2ade8973b2ac + pristine_commit_hash: 3cf68c2d50264d9463028e0bbddaf57bf148386a + pristine_tree_hash: 5d8644aa57cf4fbae073d20e23e9cf9cc1c966cf features: python: acceptHeaders: 3.0.0 @@ -4988,8 +4988,8 @@ trackedFiles: pristine_git_object: cb06254f868dcd6382020a51f98e9dbed083ee0f docs/components/keybudget.mdx: id: 97c09b7c00bb - last_write_checksum: sha1:1fa72462ba13f2c1af4238df7a973165fd062571 - pristine_git_object: 3e7f8d5d8f75a3cc94b43d023fda07eeb414001b + last_write_checksum: sha1:e3066dc6807d5478f5362dc5bcbc66fa0e6c4357 + pristine_git_object: 7395e7501125159a5e714d6868c1d1cb6c8d92fb docs/components/keybudgetresetinterval.mdx: id: 04c5a5d5c2de last_write_checksum: sha1:6461a5c207b783acbaf11733a89c2091bba302cb @@ -6956,8 +6956,8 @@ trackedFiles: pristine_git_object: 62bc0076806110e866d63bf477349fe9753bdf3e docs/components/outputdelivery.mdx: id: 0cb4c1fb2927 - last_write_checksum: sha1:33312586a0033b3b3be4ccb3c4960bc6d5faa144 - pristine_git_object: 24b71c95e4186e89dca3be8782c15d96be1211ed + last_write_checksum: sha1:02ea6a68e8275fbdc527358512bba85e9fedd347 + pristine_git_object: 5604179c01583b203a9da51ce5229af8313ce25a docs/components/outputfilesearchcallitem.mdx: id: 16f4409e4148 last_write_checksum: sha1:2ca9cc034ab3d2acb7456475d90ed65b7c65c8fd @@ -8340,12 +8340,12 @@ trackedFiles: pristine_git_object: 7bdd0f21288890b966d2dddd7c914af17344f686 docs/components/scimgrouppolicyassignment.mdx: id: 32b8adc5b2a7 - last_write_checksum: sha1:3f2818f5509ff6cfa41f3f0f1d7d09c30b82a39c - pristine_git_object: 23cd1b15d9a9efe31fada6f4254a776f4cab106f + last_write_checksum: sha1:c92ae6822241ff41861a2d57644f32c1080cbacf + pristine_git_object: 085b6dd7f2c278ed1696609d6e44304626238353 docs/components/scimgrouppolicyassignmentresponse.mdx: id: e1f15352b10e - last_write_checksum: sha1:d802b34e570573c5574e8e8d1bb167728911420a - pristine_git_object: 7e5b5a216654bf5c6db8975b9d80739bff6e5519 + last_write_checksum: sha1:e7452851e07301481da2578eb16475bfed4e0d31 + pristine_git_object: d970421d75d2679994e4ef7fdec71e2e6e5e539d docs/components/scimorganizationrolemapping.mdx: id: a75fc1832d1c last_write_checksum: sha1:a0dec5843ccfd9cf9de34e764283b4bb5edc4c25 @@ -8708,8 +8708,8 @@ trackedFiles: pristine_git_object: f1efb6365d56d846e102d1b665590f58a6899211 docs/components/speechoutputmodality.mdx: id: a3a222faacda - last_write_checksum: sha1:50b09597521fe00a0cee30215f067afceb147db1 - pristine_git_object: 9f3cff040a0c6508592bf542e3b73877506abf06 + last_write_checksum: sha1:ea913bbcc3d82aec213fa2c9e0af21222a3dd8b2 + pristine_git_object: 729223131c899c3ef139480ddffe22e1ccffa305 docs/components/speechoutputmodalitytype.mdx: id: bc216dcb8091 last_write_checksum: sha1:201cce4f72878e6efd47edf139626c1e02eab816 @@ -8732,8 +8732,8 @@ trackedFiles: pristine_git_object: 38be122fce694e660cd56d82182dd3d15098479d docs/components/speechrequest.mdx: id: 06e81b0433f6 - last_write_checksum: sha1:824fc72c47b3af6a703d2c0a8a28ba6e027d2a55 - pristine_git_object: 723545ac721a518156cc6105bdb88e82224a28ce + last_write_checksum: sha1:3318701c05a03d405b7488bf15ac6eae85be102c + pristine_git_object: 94c1dd82bdafa8a76b5c2d6ebb0be79e5187c7b5 docs/components/speechrequestdatacollection.mdx: id: 6c5938568888 last_write_checksum: sha1:89a08b4c4de66c1ef7676792a38747e030ed6729 @@ -8760,8 +8760,8 @@ trackedFiles: pristine_git_object: 9e08b7ba425de5f336923a69054fc4a238f504b6 docs/components/speechsupportedparameters.mdx: id: e40d7c8fb1e4 - last_write_checksum: sha1:4d1613b404212e0367e88c6166140da61acb2364 - pristine_git_object: cb48009012c716967e1132856e59f54f95bb07c5 + last_write_checksum: sha1:aa79177157900a8673a1e31311462e645d933e29 + pristine_git_object: 39378df792773716c59e56ca2bc1ec7c9131c93c docs/components/speechturn.mdx: id: ca90a4443e6e last_write_checksum: sha1:68b0e3750740ff2ff4a34a5dd0a0f5a191e514f1 @@ -9146,6 +9146,10 @@ trackedFiles: id: 9f8561d6342c last_write_checksum: sha1:6226a4ff5f99a852e34cd5053851a507cb3a9e7c pristine_git_object: 834297f4c2167ee22b57bd3cfb126b37662cd1ae + docs/components/timestampgranularity.mdx: + id: 4c7650ea049a + last_write_checksum: sha1:379d1ee88b87b7c901effdfad9b4823ad61db39b + pristine_git_object: ab2dac73c22ee310e1c0219174df71eab4aff761 docs/components/token.mdx: id: f22f9a37dc7e last_write_checksum: sha1:97ec547ce1db50eecd30b5a03fe51d6365f93d3d @@ -12568,8 +12572,8 @@ trackedFiles: pristine_git_object: bcbe30fccceb97caa3a0e170038245dcc7f1e540 docs/sdks/tts/README.mdx: id: cd1132543884 - last_write_checksum: sha1:e55f965157aa2e981370cab85a8be963e75638ef - pristine_git_object: 229c11658d3014036753eeadc1e4cf0bb87f9188 + last_write_checksum: sha1:4193af781eec14688c999d2d2328ab4b9064270a + pristine_git_object: 35394e656c4a66fcd643ee3c5a307571ca8d1c6a docs/sdks/vault/README.mdx: id: 3738c6722acd last_write_checksum: sha1:290b439ff730b9eabf4a6ef93737d1c61006b0fa @@ -12588,8 +12592,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:b292486c9c1df8cc72cb9bfb1a28a52e3b13aa35 - pristine_git_object: bae8999081da34eee3f75d5876ec6b2e797141f6 + last_write_checksum: sha1:dd631604d1edc41757fbcade6b0ba2be184798a4 + pristine_git_object: c201d60002c95d6689e82e205c4d0c8b55d185a4 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -12616,8 +12620,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:3e6e3db31888fa1ab9637c21bbd6ac2c71ab2fdb - pristine_git_object: 3a0b147cdcbe60ffb5774863963d274f4ce72c97 + last_write_checksum: sha1:7ff720fedf47043e7ad91352c0edee00db354fba + pristine_git_object: 210f6dad6923c2c78853e7e75a6a7c4d96d14537 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -12664,8 +12668,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:8313207d019fd05d24d8790f1e4c02e8f1d586b6 - pristine_git_object: aeaac2e6c721f888bef2c44ae2b986519ed82b3a + last_write_checksum: sha1:ac349924212648f74fc5a503e8c8339876ba9e8b + pristine_git_object: 1ed0a646dab56572c7c3f300426c1d31122797bd src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:08125e1d60df82793e11e8aed6e3c9fdb7512ebb @@ -14736,8 +14740,8 @@ trackedFiles: pristine_git_object: d334197ca0822a32f5f98a7548b254a37ee7d110 src/openrouter/components/keybudget.py: id: 02da5af09bac - last_write_checksum: sha1:632ab020f155709442e00a7236a1922344c272ac - pristine_git_object: fa6d2afb6c63b3a2dd468f765083f9d8a27c56b7 + last_write_checksum: sha1:27ee42520937b15c5ecc2ce85bd6889bc94de969 + pristine_git_object: 3d1f74875d37f53739a552539e0597e3316dcdf5 src/openrouter/components/legacy_chatcontentvideo.py: id: b06bf8b4b644 last_write_checksum: sha1:59cab32b6634299755ba92b46c90ee4495e6e86a @@ -15992,12 +15996,12 @@ trackedFiles: pristine_git_object: 7666d4d046ada750789c03958961e07b07259d03 src/openrouter/components/scimgrouppolicyassignment.py: id: "126971218647" - last_write_checksum: sha1:72de607c526c5d672db0626924c58d37a29bb4b2 - pristine_git_object: d50a94705ac9a731a192ce270b5c94d3e80f2890 + last_write_checksum: sha1:dd0128543aeb383ed4cf39391b7148bea96df79b + pristine_git_object: bfca210d3659a0018da721e33f169c82f98bf28e src/openrouter/components/scimgrouppolicyassignmentresponse.py: id: c167cfb4eaab - last_write_checksum: sha1:313a2a11ad40add90e61317744eea8b2137489d9 - pristine_git_object: 9bf8bfc53cc05466e2a0dc3c667280bfda3cbcec + last_write_checksum: sha1:ed1f184be79c3976fa6e26fd10fcfac49605c9e6 + pristine_git_object: 622f17c8fc53758a8ece6134ddc18d2d3405a5c8 src/openrouter/components/scimorganizationrolemapping.py: id: 81f2e9224676 last_write_checksum: sha1:5d34c36872358cff24c87fddc6c4d7e2bdb429a2 @@ -16188,12 +16192,12 @@ trackedFiles: pristine_git_object: 69c0355e7d575e6b7c52183d3cd5696611e4e8bf src/openrouter/components/speechrequest.py: id: 2a9400167112 - last_write_checksum: sha1:50224010ebfabc4c63dca096b29f3a8825c9cb00 - pristine_git_object: b31d52439e6ecb7f04d6377b8d90923516b0bb94 + last_write_checksum: sha1:0239848690cabcee8600c4f35acd3da2f0aa3dae + pristine_git_object: ca55f7a057606a4ed8aa84eb9ca91852fc9a1156 src/openrouter/components/speechsupportedparameters.py: id: 618f33cc9229 - last_write_checksum: sha1:9c152515a0cedad80d796c8981df706c08746d45 - pristine_git_object: cbb22d167e87004e1ab1b6e625ce3a2700d3d77c + last_write_checksum: sha1:6f3fe1b11d56407227306a93fb6d232066158913 + pristine_git_object: bea7e35329cb9b1b4f4ac2e7bb03306abd277d07 src/openrouter/components/speechturn.py: id: 121e0a940f91 last_write_checksum: sha1:31bdba00e027b81de8a3872d48e694475cf02e7a @@ -17756,8 +17760,8 @@ trackedFiles: pristine_git_object: 701fa8597ff85f41a60736ade55fcb32f9ec7125 src/openrouter/tts.py: id: 5055d4b95f1d - last_write_checksum: sha1:a479cee30f00e53289d308dff60334bb3add298d - pristine_git_object: bced8dbca5e5254efbfe2787e172c25ce4704bbf + last_write_checksum: sha1:28bc4742c2525631d1faceed945bd9a84e44be0a + pristine_git_object: 5474834977880d605b7f9d408d9558059fadafb1 src/openrouter/types/__init__.py: id: 5eab536205b7 last_write_checksum: sha1:f9ad14217f832e74f594285960125add50324be9 @@ -18763,6 +18767,8 @@ examples: application/json: {"error": {"code": 413, "message": "Request payload too large"}} "403": application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "504": + application/json: {"error": {"code": 504, "message": "The operation was aborted due to timeout"}} createAudioTranscriptions: speakeasy-default-create-audio-transcriptions: requestBody: @@ -23305,10 +23311,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: | - ## Python SDK Changes: - * `open_router.embeddings.list_models()`: `response.data[].is_open_weight` **Added** - * `open_router.models.get()`: `response.data.is_open_weight` **Added** - * `open_router.models.list()`: `response.data[].is_open_weight` **Added** - * `open_router.models.list_for_user()`: `response.data[].is_open_weight` **Added** - * `open_router.rerank.list_models()`: `response.data[].is_open_weight` **Added** +releaseNotes: "## Python SDK Changes:\n* `open_router.tts.create_speech()`: \n * `request.timestamp_granularities` **Added**\n * `error.status[504]` **Added**\n* `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.timestamp_granularities` **Added**\n* `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.timestamp_granularities` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index e1577ddf..f0ec9eae 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.237 + version: 1.3.238 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index b9a655a4..2c927170 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -22,6 +22,19 @@ components: type: string description: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + responses: + SpeechTimedAudio: + content: + application/json: + schema: + $ref: '#/components/schemas/SpeechTimedAudioResponse' + description: 'Speech request with `timestamp_granularities`: base64 audio plus the requested timings.' + SpeechTimedUrl: + content: + application/json: + schema: + $ref: '#/components/schemas/SpeechTimedUrlResponse' + description: 'Speech request with `timestamp_granularities` and `output_delivery: url`: the signed download URL plus the requested timings.' schemas: AABenchmarkEntry: description: 'Benchmark index scores published by Artificial Analysis (artificialanalysis.ai), one field per index. Each score is the model''s best on that index across the configurations Artificial Analysis evaluated (for example reasoning levels), so two indexes of one model can come from different configurations. The deprecated Coding Index and Agentic Index fields are null for every model: Artificial Analysis has retired those indexes. Attribute Artificial Analysis when you republish them. Omitted when Artificial Analysis has scored the model on none of them.' @@ -19334,7 +19347,7 @@ components: - 'string' - 'null' guardrail_id: - description: 'ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes.' + description: 'ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' type: - 'string' @@ -35404,7 +35417,7 @@ components: - 'policy_type' type: 'object' ScimGroupPolicyAssignment: - description: 'Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).' + description: 'Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).' example: budget: '6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f' model_availability: null @@ -36819,7 +36832,7 @@ components: example: 'mistralai/voxtral-mini-tts-2603' type: 'string' output_delivery: - description: '`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace.' + description: '`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.' enum: - 'stream' - 'url' @@ -36911,6 +36924,17 @@ components: example: 1 format: 'double' type: 'number' + timestamp_granularities: + description: 'Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings.' + example: + - 'word' + items: + enum: + - 'word' + - 'character' + type: 'string' + x-speakeasy-unknown-values: allow + type: 'array' trace: $ref: '#/components/schemas/TraceConfig' user: @@ -36927,6 +36951,30 @@ components: - 'model' - 'input' type: 'object' + SpeechSignedUrlResponse: + description: 'JSON response containing a signed download URL for generated speech audio.' + example: + expires_at: 1748458800 + media_type: 'audio/mpeg' + url: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + properties: + expires_at: + description: 'Unix timestamp (seconds) when the signed download URL expires.' + example: 1748458800 + type: 'integer' + media_type: + description: 'MIME type of the generated audio (for example `audio/mpeg` for mp3 or `audio/pcm;rate=24000;channels=1` for pcm).' + example: 'audio/mpeg' + type: 'string' + url: + description: 'Signed download URL for the generated audio, valid until `expires_at` (up to 24 hours).' + example: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + type: 'string' + required: + - 'url' + - 'expires_at' + - 'media_type' + type: 'object' SpeechSupportedParameters: example: instructions: @@ -36940,6 +36988,11 @@ components: max: 4 min: 0.25 type: 'range' + timestamp_granularities: + type: 'enum' + values: + - 'word' + - 'character' voice: type: 'enum' values: @@ -36952,9 +37005,90 @@ components: $ref: '#/components/schemas/SpeechEnumParameter' speed: $ref: '#/components/schemas/SpeechRangeParameter' + timestamp_granularities: + allOf: + - $ref: '#/components/schemas/SpeechEnumParameter' + - description: 'The `timestamp_granularities` values the endpoint can return (`word`, `character`). Absent: timings are not supported.' voice: $ref: '#/components/schemas/SpeechVoiceParameter' type: 'object' + SpeechTimedAudioResponse: + description: 'JSON response for a request with `timestamp_granularities`: the audio as base64 plus the requested timings.' + example: + audio: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + media_type: 'audio/mpeg' + words: + - end: 0.42 + start: 0 + text: 'Hello' + properties: + audio: + description: 'Base64-encoded audio in the format named by `media_type`.' + example: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + type: 'string' + characters: + description: 'Character timings, present when `timestamp_granularities` includes `character`.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + media_type: + description: 'MIME type of the generated audio (for example `audio/mpeg` for mp3 or `audio/pcm;rate=24000;channels=1` for pcm).' + example: 'audio/mpeg' + type: 'string' + words: + description: 'Word timings, present when `timestamp_granularities` includes `word`. Grouped from character timings by splitting on whitespace, so unspaced scripts (such as Japanese or Chinese) may return one span per unspaced run.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + required: + - 'audio' + - 'media_type' + type: 'object' + SpeechTimedUrlResponse: + allOf: + - $ref: '#/components/schemas/SpeechSignedUrlResponse' + - properties: + characters: + description: 'Character timings, present when `timestamp_granularities` includes `character`.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + words: + description: 'Word timings, present when `timestamp_granularities` includes `word`. Grouped from character timings by splitting on whitespace, so unspaced scripts (such as Japanese or Chinese) may return one span per unspaced run.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + type: 'object' + description: 'Signed download URL response for a request with `timestamp_granularities`, plus the requested timings.' + example: + characters: + - end: 0.064 + start: 0 + text: 'H' + expires_at: 1748458800 + media_type: 'audio/mpeg' + url: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + SpeechTimestamp: + properties: + end: + description: 'End time in seconds from the beginning of the audio' + example: 0.42 + format: 'double' + type: 'number' + start: + description: 'Start time in seconds from the beginning of the audio' + example: 0 + format: 'double' + type: 'number' + text: + description: 'The aligned input word or character (follows the input text, not normalized spoken text)' + example: 'Hello' + type: 'string' + required: + - 'text' + - 'start' + - 'end' + type: 'object' SpeechTurn: properties: instructions: @@ -43870,7 +44004,7 @@ paths: example: '' format: 'binary' type: 'string' - description: 'Raw audio bytes stream (`audio/*`) by default. When `output_delivery` is `"url"`, returns `application/json` with `{ url, expires_at, media_type }` (a 24-hour signed download URL) unless zero-data-retention or missing workspace causes fallback to raw audio streaming.' + description: 'Raw audio bytes stream (`audio/*`) by default. When `output_delivery` is `"url"`, returns `application/json` with `{ url, expires_at, media_type }` (a 24-hour signed download URL) unless zero-data-retention or missing workspace causes fallback to raw audio streaming. When `timestamp_granularities` is nonempty, always returns `application/json`: `{ audio, media_type }` with base64 audio (`SpeechTimedAudioResponse`), or `{ url, expires_at, media_type }` with URL delivery (`SpeechTimedUrlResponse`), each with the requested `words` and/or `characters` timings. A timed `url` request that cannot get a signed URL (zero-data-retention, missing workspace, or storage failure) returns the inline `{ audio, media_type }` envelope with no `url`.' '400': content: application/json: @@ -43971,6 +44105,16 @@ paths: schema: $ref: '#/components/schemas/ServiceUnavailableResponse' description: 'Service Unavailable - Service temporarily unavailable' + '504': + content: + application/json: + example: + error: + code: 504 + message: 'The operation was aborted due to timeout' + schema: + $ref: '#/components/schemas/GatewayTimeoutResponse' + description: 'Gateway Timeout - Provider did not respond before the upstream deadline' '524': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 0ecac60d..2df224b9 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.803.2 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:736b5be01c3df35d0f24e2fb73e0ce9b4cabdabbe8a3207840a8423caac35924 - sourceBlobDigest: sha256:77af25e4f39f912e3b224314ce4bbc5dae5c8ec1d146adcc1669e518d64bdc51 + sourceRevisionDigest: sha256:856cf59619c47e9e8203ddcb9f2f4a5a228f5be9bdbd067a50e882e6d5cd868f + sourceBlobDigest: sha256:e1a5665e5f4d5bb0b440759e3787a270c901a6c3fa1f14a1f5a98dd83f7980a5 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:736b5be01c3df35d0f24e2fb73e0ce9b4cabdabbe8a3207840a8423caac35924 - sourceBlobDigest: sha256:77af25e4f39f912e3b224314ce4bbc5dae5c8ec1d146adcc1669e518d64bdc51 + sourceRevisionDigest: sha256:856cf59619c47e9e8203ddcb9f2f4a5a228f5be9bdbd067a50e882e6d5cd868f + sourceBlobDigest: sha256:e1a5665e5f4d5bb0b440759e3787a270c901a6c3fa1f14a1f5a98dd83f7980a5 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:bcd1350abbadaf3393abf9d4caee6d09f3ee2f3126a21ef5498899ae03cae4df + codeSamplesRevisionDigest: sha256:460c2d5b51d2944f3d5d6f3e246919b8d1ec5030720512b77c26b0cfbdf1ddd3 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index ac1ea64a..6a89e32f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5139,4 +5139,14 @@ Based on: ### Generated - [python v1.3.237] . ### Releases -- [PyPI v1.3.237] https://pypi.org/project/openrouter/1.3.237 - . \ No newline at end of file +- [PyPI v1.3.237] https://pypi.org/project/openrouter/1.3.237 - . + +## 2026-12-03 20:34:36 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.238] . +### Releases +- [PyPI v1.3.238] https://pypi.org/project/openrouter/1.3.238 - . \ No newline at end of file diff --git a/docs/components/keybudget.mdx b/docs/components/keybudget.mdx index 3e7f8d5d..7395e750 100644 --- a/docs/components/keybudget.mdx +++ b/docs/components/keybudget.mdx @@ -7,14 +7,14 @@ One budget layer that applies to requests made with this key, with the spend enf ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `budget_id` | *Nullable[str]* | ✔️ | ID of the workspace budget for the `workspace` scope; null for other scopes. | null | -| `guardrail_id` | *Nullable[str]* | ✔️ | ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes. | 0df9e665-d932-5740-b2c7-b52af166bc11 | -| `include_byok` | *bool* | ✔️ | Whether external BYOK inference spend counts toward this budget. | false | -| `limit_usd` | *float* | ✔️ | Budget limit in USD for the current window. | 50 | -| `remaining_usd` | *float* | ✔️ | `limit_usd - spend_usd`. Zero or negative means this layer rejects requests with a 403 until it resets. | 17.5 | -| `reset_interval` | [Nullable[components.KeyBudgetResetInterval]](../components/keybudgetresetinterval.mdx) | ✔️ | UTC window the spend is counted over (weeks start Monday); null for a lifetime budget that never resets. | weekly | -| `resets_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ✔️ | ISO 8601 UTC instant at which the window rolls over and spend returns to zero; null for a lifetime budget. | 2026-10-12T00:00:00.000Z | -| `scope` | [components.KeyBudgetScope](../components/keybudgetscope.mdx) | ✔️ | Which budget layer this is, in the order enforcement checks them: the workspace default guardrail against the member aggregate (`workspace_default_member`) and against this key (`workspace_default_key`), the member guardrail (`member`), the API key guardrail (`api_key`), a workspace budget (`workspace`), or the key's own limit (`key_limit`). | member | -| `spend_usd` | *float* | ✔️ | Spend in USD that enforcement counts against this limit in the current window: the member aggregate for member-scoped layers, otherwise this key or workspace. | 32.5 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `budget_id` | *Nullable[str]* | ✔️ | ID of the workspace budget for the `workspace` scope; null for other scopes. | null | +| `guardrail_id` | *Nullable[str]* | ✔️ | ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `include_byok` | *bool* | ✔️ | Whether external BYOK inference spend counts toward this budget. | false | +| `limit_usd` | *float* | ✔️ | Budget limit in USD for the current window. | 50 | +| `remaining_usd` | *float* | ✔️ | `limit_usd - spend_usd`. Zero or negative means this layer rejects requests with a 403 until it resets. | 17.5 | +| `reset_interval` | [Nullable[components.KeyBudgetResetInterval]](../components/keybudgetresetinterval.mdx) | ✔️ | UTC window the spend is counted over (weeks start Monday); null for a lifetime budget that never resets. | weekly | +| `resets_at` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | ✔️ | ISO 8601 UTC instant at which the window rolls over and spend returns to zero; null for a lifetime budget. | 2026-10-12T00:00:00.000Z | +| `scope` | [components.KeyBudgetScope](../components/keybudgetscope.mdx) | ✔️ | Which budget layer this is, in the order enforcement checks them: the workspace default guardrail against the member aggregate (`workspace_default_member`) and against this key (`workspace_default_key`), the member guardrail (`member`), the API key guardrail (`api_key`), a workspace budget (`workspace`), or the key's own limit (`key_limit`). | member | +| `spend_usd` | *float* | ✔️ | Spend in USD that enforcement counts against this limit in the current window: the member aggregate for member-scoped layers, otherwise this key or workspace. | 32.5 | \ No newline at end of file diff --git a/docs/components/outputdelivery.mdx b/docs/components/outputdelivery.mdx index 24b71c95..5604179c 100644 --- a/docs/components/outputdelivery.mdx +++ b/docs/components/outputdelivery.mdx @@ -2,7 +2,7 @@ title: "OutputDelivery" --- -`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. +`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. ## Example Usage diff --git a/docs/components/scimgrouppolicyassignment.mdx b/docs/components/scimgrouppolicyassignment.mdx index 23cd1b15..085b6dd7 100644 --- a/docs/components/scimgrouppolicyassignment.mdx +++ b/docs/components/scimgrouppolicyassignment.mdx @@ -2,7 +2,7 @@ title: "ScimGroupPolicyAssignment" --- -Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). +Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). ## Fields diff --git a/docs/components/scimgrouppolicyassignmentresponse.mdx b/docs/components/scimgrouppolicyassignmentresponse.mdx index 7e5b5a21..d970421d 100644 --- a/docs/components/scimgrouppolicyassignmentresponse.mdx +++ b/docs/components/scimgrouppolicyassignmentresponse.mdx @@ -4,6 +4,6 @@ title: "ScimGroupPolicyAssignmentResponse" ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | [components.ScimGroupPolicyAssignment](../components/scimgrouppolicyassignment.mdx) | ✔️ | Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). | \{
"budget": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
"model_availability": null,
"moderation": null,
"rate_limit": null,
"scim_group_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
"scim_group_mapping_id": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"workspace_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `data` | [components.ScimGroupPolicyAssignment](../components/scimgrouppolicyassignment.mdx) | ✔️ | Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). | \{
"budget": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
"model_availability": null,
"moderation": null,
"rate_limit": null,
"scim_group_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
"scim_group_mapping_id": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"workspace_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
} | \ No newline at end of file diff --git a/docs/components/speechoutputmodality.mdx b/docs/components/speechoutputmodality.mdx index 9f3cff04..72922313 100644 --- a/docs/components/speechoutputmodality.mdx +++ b/docs/components/speechoutputmodality.mdx @@ -4,8 +4,8 @@ title: "SpeechOutputModality" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `languages` | List[*str*] | ➖ | BCP 47 tags of the languages the provider documents for this output, for example `en`, `hi` or `pt-BR`. How the language is chosen (from the text, the voice, or a provider option) varies by provider. Absent: not described. | [
"en",
"fr",
"hi"
] | -| `supported_parameters` | [components.SpeechSupportedParameters](../components/speechsupportedparameters.mdx) | ✔️ | N/A | \{
"instructions": \{
"type": "unknown"
},
"response_format": \{
"type": "enum",
"values": [
"mp3",
"pcm"
]
},
"speed": \{
"max": 4,
"min": 0.25,
"type": "range"
},
"voice": \{
"type": "enum",
"values": [
"alloy",
"coral"
]
}
} | -| `type` | [components.SpeechOutputModalityType](../components/speechoutputmodalitytype.mdx) | ✔️ | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `languages` | List[*str*] | ➖ | BCP 47 tags of the languages the provider documents for this output, for example `en`, `hi` or `pt-BR`. How the language is chosen (from the text, the voice, or a provider option) varies by provider. Absent: not described. | [
"en",
"fr",
"hi"
] | +| `supported_parameters` | [components.SpeechSupportedParameters](../components/speechsupportedparameters.mdx) | ✔️ | N/A | \{
"instructions": \{
"type": "unknown"
},
"response_format": \{
"type": "enum",
"values": [
"mp3",
"pcm"
]
},
"speed": \{
"max": 4,
"min": 0.25,
"type": "range"
},
"timestamp_granularities": \{
"type": "enum",
"values": [
"word",
"character"
]
},
"voice": \{
"type": "enum",
"values": [
"alloy",
"coral"
]
}
} | +| `type` | [components.SpeechOutputModalityType](../components/speechoutputmodalitytype.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/components/speechrequest.mdx b/docs/components/speechrequest.mdx index 723545ac..94c1dd82 100644 --- a/docs/components/speechrequest.mdx +++ b/docs/components/speechrequest.mdx @@ -7,17 +7,18 @@ Text-to-speech request input ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `input` | [components.SpeechInput](../components/speechinput.mdx) | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | -| `input_references` | List[[components.SpeechInputReference](../components/speechinputreference.mdx)] | ➖ | Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. | [
\{
"input_audio": \{
"data": "data:audio/wav;base64,UklGRuQXDABXQVZF..."
},
"type": "input_audio"
},
\{
"text": "I used to rule the world.",
"type": "text"
}
] | -| `instructions` | *Optional[str]* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. | Speak in a warm and friendly tone. | -| `model` | *str* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | -| `output_delivery` | [Optional[components.OutputDelivery]](../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. | stream | -| `provider` | [Optional[components.SpeechRequestProvider]](../components/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | -| `response_format` | [Optional[components.SpeechRequestResponseFormat]](../components/speechrequestresponseformat.mdx) | ➖ | Audio output format | pcm | -| `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | -| `speed` | *Optional[float]* | ➖ | Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. | 1 | -| `trace` | [Optional[components.TraceConfig]](../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | -| `user` | *Optional[str]* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | -| `voice` | *Optional[str]* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `input` | [components.SpeechInput](../components/speechinput.mdx) | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | +| `input_references` | List[[components.SpeechInputReference](../components/speechinputreference.mdx)] | ➖ | Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. | [
\{
"input_audio": \{
"data": "data:audio/wav;base64,UklGRuQXDABXQVZF..."
},
"type": "input_audio"
},
\{
"text": "I used to rule the world.",
"type": "text"
}
] | +| `instructions` | *Optional[str]* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. | Speak in a warm and friendly tone. | +| `model` | *str* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | +| `output_delivery` | [Optional[components.OutputDelivery]](../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. | stream | +| `provider` | [Optional[components.SpeechRequestProvider]](../components/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | +| `response_format` | [Optional[components.SpeechRequestResponseFormat]](../components/speechrequestresponseformat.mdx) | ➖ | Audio output format | pcm | +| `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | +| `speed` | *Optional[float]* | ➖ | Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. | 1 | +| `timestamp_granularities` | List[[components.TimestampGranularity](../components/timestampgranularity.mdx)] | ➖ | Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. | [
"word"
] | +| `trace` | [Optional[components.TraceConfig]](../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | +| `user` | *Optional[str]* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | +| `voice` | *Optional[str]* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | \ No newline at end of file diff --git a/docs/components/speechsupportedparameters.mdx b/docs/components/speechsupportedparameters.mdx index cb480090..39378df7 100644 --- a/docs/components/speechsupportedparameters.mdx +++ b/docs/components/speechsupportedparameters.mdx @@ -9,4 +9,5 @@ title: "SpeechSupportedParameters" | `instructions` | [Optional[components.SpeechUnknownParameter]](../components/speechunknownparameter.mdx) | ➖ | N/A | \{
"type": "unknown"
} | | `response_format` | [Optional[components.SpeechEnumParameter]](../components/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `speed` | [Optional[components.SpeechRangeParameter]](../components/speechrangeparameter.mdx) | ➖ | The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`. | \{
"max": 4,
"min": 0.25,
"type": "range"
} | +| `timestamp_granularities` | [Optional[components.SpeechEnumParameter]](../components/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `voice` | [Optional[components.SpeechVoiceParameter]](../components/speechvoiceparameter.mdx) | ➖ | `enum` lists the documented voices in `values`; some providers also accept voice IDs not listed there (custom or cloned voices). `unknown` means the field is accepted but no voices are listed. | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | \ No newline at end of file diff --git a/docs/components/timestampgranularity.mdx b/docs/components/timestampgranularity.mdx new file mode 100644 index 00000000..ab2dac73 --- /dev/null +++ b/docs/components/timestampgranularity.mdx @@ -0,0 +1,20 @@ +--- +title: "TimestampGranularity" +--- + +## Example Usage + +```python +from openrouter.components import TimestampGranularity + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: TimestampGranularity = "word" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"word"` +- `"character"` diff --git a/docs/sdks/tts/README.mdx b/docs/sdks/tts/README.mdx index 229c1165..35394e65 100644 --- a/docs/sdks/tts/README.mdx +++ b/docs/sdks/tts/README.mdx @@ -40,24 +40,25 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `input` | [components.SpeechInput](../../components/speechinput.mdx) | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | -| `model` | *str* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | -| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | -| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | -| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | -| `input_references` | List[[components.SpeechInputReference](../../components/speechinputreference.mdx)] | ➖ | Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. | [
\{
"input_audio": \{
"data": "data:audio/wav;base64,UklGRuQXDABXQVZF..."
},
"type": "input_audio"
},
\{
"text": "I used to rule the world.",
"type": "text"
}
] | -| `instructions` | *Optional[str]* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. | Speak in a warm and friendly tone. | -| `output_delivery` | [Optional[components.OutputDelivery]](../../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. | stream | -| `provider` | [Optional[components.SpeechRequestProvider]](../../components/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | -| `response_format` | [Optional[components.SpeechRequestResponseFormat]](../../components/speechrequestresponseformat.mdx) | ➖ | Audio output format | pcm | -| `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | -| `speed` | *Optional[float]* | ➖ | Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. | 1 | -| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | -| `user` | *Optional[str]* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | -| `voice` | *Optional[str]* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `input` | [components.SpeechInput](../../components/speechinput.mdx) | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | +| `model` | *str* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | +| `http_referer` | *Optional[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `x_open_router_title` | *Optional[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `x_open_router_categories` | *Optional[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `input_references` | List[[components.SpeechInputReference](../../components/speechinputreference.mdx)] | ➖ | Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. | [
\{
"input_audio": \{
"data": "data:audio/wav;base64,UklGRuQXDABXQVZF..."
},
"type": "input_audio"
},
\{
"text": "I used to rule the world.",
"type": "text"
}
] | +| `instructions` | *Optional[str]* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. | Speak in a warm and friendly tone. | +| `output_delivery` | [Optional[components.OutputDelivery]](../../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. | stream | +| `provider` | [Optional[components.SpeechRequestProvider]](../../components/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | +| `response_format` | [Optional[components.SpeechRequestResponseFormat]](../../components/speechrequestresponseformat.mdx) | ➖ | Audio output format | pcm | +| `session_id` | *Optional[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 | +| `speed` | *Optional[float]* | ➖ | Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. | 1 | +| `timestamp_granularities` | List[[components.TimestampGranularity](../../components/timestampgranularity.mdx)] | ➖ | Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. | [
"word"
] | +| `trace` | [Optional[components.TraceConfig]](../../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | +| `user` | *Optional[str]* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | +| `voice` | *Optional[str]* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | | ### Response @@ -77,6 +78,7 @@ with OpenRouter( | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | +| errors.GatewayTimeoutResponseError | 504 | application/json | | errors.EdgeNetworkTimeoutResponseError | 524 | application/json | | errors.ProviderOverloadedResponseError | 529 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | diff --git a/pyproject.toml b/pyproject.toml index bae89990..c201d600 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.237" +version = "1.3.238" description = "Official Python Client SDK for OpenRouter." authors = [{ name = "OpenRouter" },] readme = "README-PYPI.md" diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 3a0b147c..210f6dad 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.3.237" +__version__: str = "1.3.238" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.237 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.238 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index aeaac2e6..1ed0a646 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -4900,6 +4900,7 @@ SpeechRequestProviderTypedDict, SpeechRequestResponseFormat, SpeechRequestTypedDict, + TimestampGranularity, ) from .speechsupportedparameters import ( SpeechSupportedParameters, @@ -9129,6 +9130,7 @@ "ThinkingEnabledTypedDict", "ThinkingTypeDisabled", "ThinkingTypedDict", + "TimestampGranularity", "Token", "TokenExchangeRequest", "TokenExchangeRequestScope", @@ -13158,6 +13160,7 @@ "SpeechRequestProviderTypedDict": ".speechrequest", "SpeechRequestResponseFormat": ".speechrequest", "SpeechRequestTypedDict": ".speechrequest", + "TimestampGranularity": ".speechrequest", "SpeechSupportedParameters": ".speechsupportedparameters", "SpeechSupportedParametersTypedDict": ".speechsupportedparameters", "SpeechTurn": ".speechturn", diff --git a/src/openrouter/components/keybudget.py b/src/openrouter/components/keybudget.py index fa6d2afb..3d1f7487 100644 --- a/src/openrouter/components/keybudget.py +++ b/src/openrouter/components/keybudget.py @@ -39,7 +39,7 @@ class KeyBudgetTypedDict(TypedDict): budget_id: Nullable[str] r"""ID of the workspace budget for the `workspace` scope; null for other scopes.""" guardrail_id: Nullable[str] - r"""ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes.""" + r"""ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list.""" include_byok: bool r"""Whether external BYOK inference spend counts toward this budget.""" limit_usd: float @@ -63,7 +63,7 @@ class KeyBudget(BaseModel): r"""ID of the workspace budget for the `workspace` scope; null for other scopes.""" guardrail_id: Nullable[str] - r"""ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes.""" + r"""ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list.""" include_byok: bool r"""Whether external BYOK inference spend counts toward this budget.""" diff --git a/src/openrouter/components/scimgrouppolicyassignment.py b/src/openrouter/components/scimgrouppolicyassignment.py index d50a9470..bfca210d 100644 --- a/src/openrouter/components/scimgrouppolicyassignment.py +++ b/src/openrouter/components/scimgrouppolicyassignment.py @@ -7,7 +7,7 @@ class ScimGroupPolicyAssignmentTypedDict(TypedDict): - r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" + r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" budget: Nullable[str] model_availability: Nullable[str] @@ -19,7 +19,7 @@ class ScimGroupPolicyAssignmentTypedDict(TypedDict): class ScimGroupPolicyAssignment(BaseModel): - r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" + r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" budget: Nullable[str] diff --git a/src/openrouter/components/scimgrouppolicyassignmentresponse.py b/src/openrouter/components/scimgrouppolicyassignmentresponse.py index 9bf8bfc5..622f17c8 100644 --- a/src/openrouter/components/scimgrouppolicyassignmentresponse.py +++ b/src/openrouter/components/scimgrouppolicyassignmentresponse.py @@ -11,9 +11,9 @@ class ScimGroupPolicyAssignmentResponseTypedDict(TypedDict): data: ScimGroupPolicyAssignmentTypedDict - r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" + r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" class ScimGroupPolicyAssignmentResponse(BaseModel): data: ScimGroupPolicyAssignment - r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" + r"""Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).""" diff --git a/src/openrouter/components/speechrequest.py b/src/openrouter/components/speechrequest.py index b31d5243..ca55f7a0 100644 --- a/src/openrouter/components/speechrequest.py +++ b/src/openrouter/components/speechrequest.py @@ -26,7 +26,7 @@ ], UnrecognizedStr, ] -r"""`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace.""" +r"""`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.""" SpeechRequestDataCollection = Union[ @@ -175,6 +175,15 @@ def serialize_model(self, handler): r"""Audio output format""" +TimestampGranularity = Union[ + Literal[ + "word", + "character", + ], + UnrecognizedStr, +] + + class SpeechRequestTypedDict(TypedDict): r"""Text-to-speech request input""" @@ -187,7 +196,7 @@ class SpeechRequestTypedDict(TypedDict): instructions: NotRequired[str] r"""Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers.""" output_delivery: NotRequired[OutputDelivery] - r"""`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace.""" + r"""`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.""" provider: NotRequired[SpeechRequestProviderTypedDict] r"""Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options""" response_format: NotRequired[SpeechRequestResponseFormat] @@ -196,6 +205,8 @@ class SpeechRequestTypedDict(TypedDict): r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.""" speed: NotRequired[float] r"""Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control.""" + timestamp_granularities: NotRequired[List[TimestampGranularity]] + r"""Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings.""" trace: NotRequired[TraceConfigTypedDict] r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.""" user: NotRequired[str] @@ -220,7 +231,7 @@ class SpeechRequest(BaseModel): r"""Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers.""" output_delivery: Optional[OutputDelivery] = None - r"""`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace.""" + r"""`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.""" provider: Optional[SpeechRequestProvider] = None r"""Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options""" @@ -234,6 +245,9 @@ class SpeechRequest(BaseModel): speed: Optional[float] = None r"""Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control.""" + timestamp_granularities: Optional[List[TimestampGranularity]] = None + r"""Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings.""" + trace: Optional[TraceConfig] = None r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.""" @@ -254,6 +268,7 @@ def serialize_model(self, handler): "response_format", "session_id", "speed", + "timestamp_granularities", "trace", "user", "voice", diff --git a/src/openrouter/components/speechsupportedparameters.py b/src/openrouter/components/speechsupportedparameters.py index cbb22d16..bea7e353 100644 --- a/src/openrouter/components/speechsupportedparameters.py +++ b/src/openrouter/components/speechsupportedparameters.py @@ -19,6 +19,7 @@ class SpeechSupportedParametersTypedDict(TypedDict): response_format: NotRequired[SpeechEnumParameterTypedDict] speed: NotRequired[SpeechRangeParameterTypedDict] r"""The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`.""" + timestamp_granularities: NotRequired[SpeechEnumParameterTypedDict] voice: NotRequired[SpeechVoiceParameterTypedDict] r"""`enum` lists the documented voices in `values`; some providers also accept voice IDs not listed there (custom or cloned voices). `unknown` means the field is accepted but no voices are listed.""" @@ -31,12 +32,22 @@ class SpeechSupportedParameters(BaseModel): speed: Optional[SpeechRangeParameter] = None r"""The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`.""" + timestamp_granularities: Optional[SpeechEnumParameter] = None + voice: Optional[SpeechVoiceParameter] = None r"""`enum` lists the documented voices in `values`; some providers also accept voice IDs not listed there (custom or cloned voices). `unknown` means the field is accepted but no voices are listed.""" @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = set(["instructions", "response_format", "speed", "voice"]) + optional_fields = set( + [ + "instructions", + "response_format", + "speed", + "timestamp_granularities", + "voice", + ] + ) serialized = handler(self) m = {} diff --git a/src/openrouter/tts.py b/src/openrouter/tts.py index bced8dbc..54748349 100644 --- a/src/openrouter/tts.py +++ b/src/openrouter/tts.py @@ -38,6 +38,9 @@ def create_speech( response_format: Optional[components.SpeechRequestResponseFormat] = "pcm", session_id: Optional[str] = None, speed: Optional[float] = None, + timestamp_granularities: Optional[ + Iterable[components.TimestampGranularity] + ] = None, trace: Optional[ Union[components.TraceConfig, components.TraceConfigTypedDict] ] = None, @@ -63,11 +66,12 @@ def create_speech( :param input_references: Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. :param instructions: Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. - :param output_delivery: `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. + :param output_delivery: `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. :param provider: Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options :param response_format: Audio output format :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. :param speed: Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. + :param timestamp_granularities: Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. :param user: A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. :param voice: Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. @@ -104,6 +108,10 @@ def create_speech( response_format=response_format, session_id=session_id, speed=speed, + timestamp_granularities=utils.unmarshal( + timestamp_granularities, + Optional[List[components.TimestampGranularity]], + ), trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), user=user, voice=voice, @@ -240,6 +248,14 @@ def create_speech( raise errors.ServiceUnavailableResponseError( response_data, http_res, http_res_text ) + if utils.match_response(http_res, "504", "application/json"): + http_res_text = utils.stream_to_text(http_res) + response_data = unmarshal_json_response( + errors.GatewayTimeoutResponseErrorData, http_res, http_res_text + ) + raise errors.GatewayTimeoutResponseError( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "524", "application/json"): http_res_text = utils.stream_to_text(http_res) response_data = unmarshal_json_response( @@ -297,6 +313,9 @@ async def create_speech_async( response_format: Optional[components.SpeechRequestResponseFormat] = "pcm", session_id: Optional[str] = None, speed: Optional[float] = None, + timestamp_granularities: Optional[ + Iterable[components.TimestampGranularity] + ] = None, trace: Optional[ Union[components.TraceConfig, components.TraceConfigTypedDict] ] = None, @@ -322,11 +341,12 @@ async def create_speech_async( :param input_references: Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. An empty array is treated as no reference. :param instructions: Delivery instructions for the whole request, such as tone, pacing, or emotion. Supported by OpenAI gpt-4o-mini-tts, Gemini TTS, and Fish Audio models. Ignored by other providers. - :param output_delivery: `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. + :param output_delivery: `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. :param provider: Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options :param response_format: Audio output format :param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. :param speed: Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. + :param timestamp_granularities: Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. :param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. :param user: A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. :param voice: Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. @@ -363,6 +383,10 @@ async def create_speech_async( response_format=response_format, session_id=session_id, speed=speed, + timestamp_granularities=utils.unmarshal( + timestamp_granularities, + Optional[List[components.TimestampGranularity]], + ), trace=utils.get_pydantic_model(trace, Optional[components.TraceConfig]), user=user, voice=voice, @@ -499,6 +523,14 @@ async def create_speech_async( raise errors.ServiceUnavailableResponseError( response_data, http_res, http_res_text ) + if utils.match_response(http_res, "504", "application/json"): + http_res_text = await utils.stream_to_text_async(http_res) + response_data = unmarshal_json_response( + errors.GatewayTimeoutResponseErrorData, http_res, http_res_text + ) + raise errors.GatewayTimeoutResponseError( + response_data, http_res, http_res_text + ) if utils.match_response(http_res, "524", "application/json"): http_res_text = await utils.stream_to_text_async(http_res) response_data = unmarshal_json_response( diff --git a/uv.lock b/uv.lock index 5b7c07da..2847adf1 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.237" +version = "1.3.238" source = { editable = "." } dependencies = [ { name = "httpcore" },