From 9b0102f35ac03dba3615e102ef43a7f3dca8e5fe Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 4 Dec 2026 21:05:22 +0000 Subject: [PATCH] ## Python SDK Changes: * `open_router.tts.create_speech()`: `request.separate_tracks` **Added** * `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** * `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** * `open_router.images.list_models()`: `response.data[].supported_parameters.Map.union(range)` **Changed** * `open_router.images.list_model_endpoints()`: `response.endpoints[].supported_parameters.Map.union(range)` **Changed** --- .speakeasy/gen.lock | 76 +++++------ .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 121 +++++++++++++++++- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/components/rangecapability.mdx | 12 +- docs/components/speechinputmodality.mdx | 2 +- docs/components/speechinputmodalityaudio.mdx | 8 +- .../speechinputmodalitysupportedinputs1.mdx | 2 +- docs/components/speechrequest.mdx | 1 + docs/components/speechsupportedparameters.mdx | 1 + docs/sdks/tts/README.mdx | 1 + pyproject.toml | 2 +- src/openrouter/_version.py | 4 +- src/openrouter/components/rangecapability.py | 33 ++++- .../components/speechinputmodality.py | 12 +- src/openrouter/components/speechrequest.py | 6 + .../components/speechsupportedparameters.py | 4 + src/openrouter/tts.py | 6 + uv.lock | 2 +- 20 files changed, 246 insertions(+), 71 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 333ea6d2e..afa69f6fc 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: 825bfff76c73da0325731e2ba8da4202 + docChecksum: 67ee7f2bb1ab5067b2102f459b8f23b2 docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.246 - configChecksum: 733089b0d7ea60f53efbf118c34405af + releaseVersion: 1.3.247 + configChecksum: d770a14449806169f3e4493a91092c77 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 0ccec9dc-cb52-400c-834d-2dbaff752f32 - pristine_commit_hash: 33ca665870b0d7595b2c3d5bc7cddfe9a36b1d25 - pristine_tree_hash: 3d9d8d6d663094042cf4dbae0617d1bba8b25599 + generation_id: 88b22f06-3368-4ad9-b495-b74c52e23c98 + pristine_commit_hash: d98558be9ca98e0a0ac811c12dc980692157877f + pristine_tree_hash: 94180302778ea7be1e1ff1513378c1df4ddb3921 features: python: acceptHeaders: 3.0.0 @@ -8000,8 +8000,8 @@ trackedFiles: pristine_git_object: f6c2d80b0e12882e559031e0244b3c348814bc12 docs/components/rangecapability.mdx: id: 8c2d6524bd62 - last_write_checksum: sha1:659e69a57534c2c02d6039d3f940a41249df3e61 - pristine_git_object: 3135af749578216f47af5611b8393c25e5a03d92 + last_write_checksum: sha1:8df3f542c81952ec72f1765269988d1c72024c67 + pristine_git_object: 82c50868404eb75f10328e6a49460d66d76c89d6 docs/components/rangecapabilitytype.mdx: id: ed9a27bb5417 last_write_checksum: sha1:357127ec16001090e00bfc05c17573fa9f271783 @@ -8668,20 +8668,20 @@ trackedFiles: pristine_git_object: 5d2f88829becfc0307674fce87660e96744b7a2e docs/components/speechinputmodality.mdx: id: 74665b26b41d - last_write_checksum: sha1:c2ffb3a2b363fdec40c36a8a3a5c81e9b7d2eb93 - pristine_git_object: 00aa5bea806fd6f364659761c90ba2d892e246d3 + last_write_checksum: sha1:ccb97019bab57e6e4420c75ce3cb1eb6a9f26f69 + pristine_git_object: fb5ae24bf8ef8186390eff169f5a71406b22b500 docs/components/speechinputmodalityaudio.mdx: id: 67f693a9a81e - last_write_checksum: sha1:d51c21c9a10941aef4c1eee27e61658814be4e7d - pristine_git_object: a6ad3370b8e40d37e83d05fbf604c9fb577a1fec + last_write_checksum: sha1:fb54772539579922aaea450a9f840d0732c7f3b5 + pristine_git_object: 484e385e38a4bf5094ff2c2e178cc3170bcb47e3 docs/components/speechinputmodalityimage.mdx: id: 3b669f1d4e68 last_write_checksum: sha1:635c466e7791734723d3692ef523c38184fd2bff pristine_git_object: 2b5b9d917962daa2b44ebde2db225620ab2be5af docs/components/speechinputmodalitysupportedinputs1.mdx: id: df6463935e58 - last_write_checksum: sha1:43756406dadada57c56a3de17611d0e04da6cbde - pristine_git_object: 06b49bea897f8ea672ea46ed67517bd722a52dab + last_write_checksum: sha1:c5229cd6569855105406b0e9bfacda00fd89158a + pristine_git_object: 4c0063b4a67a7ec5748bb9a75bded9132aa104dc docs/components/speechinputmodalitysupportedinputs2.mdx: id: acc111e79186 last_write_checksum: sha1:9a4eb1759b618b88f7531c84215e6a1edc2c8270 @@ -8800,8 +8800,8 @@ trackedFiles: pristine_git_object: 38be122fce694e660cd56d82182dd3d15098479d docs/components/speechrequest.mdx: id: 06e81b0433f6 - last_write_checksum: sha1:e268d103d91677943e9f60afb8a0ca24737b9abd - pristine_git_object: 78a1e3b014fde528de3fe4c9142656d772d756ce + last_write_checksum: sha1:82eae727c9e7d1189ac5cf5efca97114c02e3649 + pristine_git_object: d07dd901afe276b811a9f2648b40fb9f4ef700b8 docs/components/speechrequestdatacollection.mdx: id: 6c5938568888 last_write_checksum: sha1:89a08b4c4de66c1ef7676792a38747e030ed6729 @@ -8828,8 +8828,8 @@ trackedFiles: pristine_git_object: 28816d7a32f629289c2a932e9c16a17183c25e69 docs/components/speechsupportedparameters.mdx: id: e40d7c8fb1e4 - last_write_checksum: sha1:85a86a6a38fc75f87623b39af760eb7797c0a7f8 - pristine_git_object: 0a99447929147a9acfcaf9820c75174b1a9a37b9 + last_write_checksum: sha1:b07fba817a21affa67e8e1d5d73101ce0fc09c17 + pristine_git_object: b2ada4a5e0f3e891eca3a17e0f02f1f0b9ef94f7 docs/components/speechturn.mdx: id: ca90a4443e6e last_write_checksum: sha1:68b0e3750740ff2ff4a34a5dd0a0f5a191e514f1 @@ -12644,8 +12644,8 @@ trackedFiles: pristine_git_object: bcbe30fccceb97caa3a0e170038245dcc7f1e540 docs/sdks/tts/README.mdx: id: cd1132543884 - last_write_checksum: sha1:36bb84fe391df95e0bf15450e67603f3db106aef - pristine_git_object: fd28773bdc6c7e80c1cfb30dbf92605b8f7f9d96 + last_write_checksum: sha1:fa739f311347932107ad60169b4a28c3e5de8e0b + pristine_git_object: 971ee254c7e6da06f920750b5d2f071ae3eadd11 docs/sdks/vault/README.mdx: id: 3738c6722acd last_write_checksum: sha1:290b439ff730b9eabf4a6ef93737d1c61006b0fa @@ -12664,8 +12664,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:d133963a921ce2f638c14f9f3438cb1e6f491544 - pristine_git_object: 6014e72ed8695b2464a75b7dd709d76399234208 + last_write_checksum: sha1:2c94c3e454f7cf9ff020b6df516dd716f76d50a2 + pristine_git_object: 5525dafe27561ec980a1fbf7846a1918a52edf17 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -12692,8 +12692,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:6744ebf097cf9083395a410975c292993d61123a - pristine_git_object: afee1974f38b07507e67e3b8627fb3e745dad8db + last_write_checksum: sha1:a2028804657a6d0e3137fe5b25e867782cb630db + pristine_git_object: f68041cee1dd76aaf390da6d91be436023914369 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -15904,8 +15904,8 @@ trackedFiles: pristine_git_object: 2357bc53054b91764777e23dde3ea7d67693a17d src/openrouter/components/rangecapability.py: id: ac3aad570488 - last_write_checksum: sha1:9eaed841f5e178925a070ebcbe6f18b4178dbaab - pristine_git_object: 76fabc08d96646862e7a1618d39d84934a25b5e4 + last_write_checksum: sha1:c580010fa9e08ac0b9dc8cd27938c9e6851c7908 + pristine_git_object: c13fbf23ec4c4dce969462eea64d6c32a4be1ebf src/openrouter/components/rankingsdailyitem.py: id: 9aab72b1d643 last_write_checksum: sha1:356cb98c9d721ada4faab5a6e6e8e80088f81f2d @@ -16224,8 +16224,8 @@ trackedFiles: pristine_git_object: cc45b6da88350cd9ab4b9c6456b5dd81c0b4c8e9 src/openrouter/components/speechinputmodality.py: id: d475c5a1288b - last_write_checksum: sha1:e5a37779aea96d97c8c41b128117d814ebd50375 - pristine_git_object: beba53e284182e3e3793b26ba3e4a9c1f46c356a + last_write_checksum: sha1:a56ced95179ecf07d665c6fc96ff909d7e27fb14 + pristine_git_object: 27df4497735a0bdeb1b43d0348e925bb557d0665 src/openrouter/components/speechinputreference.py: id: 8e2b63f83354 last_write_checksum: sha1:ca75ac4bf88336c0a6c00d0d9fce34fd4b34af87 @@ -16284,12 +16284,12 @@ trackedFiles: pristine_git_object: 69c0355e7d575e6b7c52183d3cd5696611e4e8bf src/openrouter/components/speechrequest.py: id: 2a9400167112 - last_write_checksum: sha1:e85707cc35ca5d629cd61e5814482297a3c2665d - pristine_git_object: b88af6a262e303cf6fc995d29b9cae87d9e4b907 + last_write_checksum: sha1:6622a68e3903c2cb50fc097050cd14e4a23f2273 + pristine_git_object: e543683e67c044aa20ead0ca84ab1a9e919757e8 src/openrouter/components/speechsupportedparameters.py: id: 618f33cc9229 - last_write_checksum: sha1:e05046fb9df89bd1c7ac118dec1c51f00de91007 - pristine_git_object: c99fcc565b29c9053bb50a18561a4b38449998c3 + last_write_checksum: sha1:575dd67904f45d7474d1531adcbdaafdf2896a4d + pristine_git_object: ec3d39c42fb239625bbfa9464afbfe6dcd7714c2 src/openrouter/components/speechturn.py: id: 121e0a940f91 last_write_checksum: sha1:31bdba00e027b81de8a3872d48e694475cf02e7a @@ -17852,8 +17852,8 @@ trackedFiles: pristine_git_object: 701fa8597ff85f41a60736ade55fcb32f9ec7125 src/openrouter/tts.py: id: 5055d4b95f1d - last_write_checksum: sha1:3a0b902e83a6987d94dffb1a752582704b471643 - pristine_git_object: 3fc05547bb566ec91045c6576eca6397ff9c3a9b + last_write_checksum: sha1:31cc0406d9d47c2d82dab2003468e8ba0ba15368 + pristine_git_object: 20158653c8943debbd12f4c9b6c76c605517b82a src/openrouter/types/__init__.py: id: 5eab536205b7 last_write_checksum: sha1:f9ad14217f832e74f594285960125add50324be9 @@ -23405,6 +23405,8 @@ examples: examplesVersion: 1.0.2 releaseNotes: | ## Python SDK Changes: - * `open_router.tts.create_speech()`: `request.stream_format` **Added** - * `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.stream_format` **Added** - * `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.stream_format` **Added** + * `open_router.tts.create_speech()`: `request.separate_tracks` **Added** + * `open_router.tts.list_models()`: `response.data[].endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** + * `open_router.tts.get_model()`: `response.endpoints[].output_modalities[].supported_parameters.separate_tracks` **Added** + * `open_router.images.list_models()`: `response.data[].supported_parameters.Map.union(range)` **Changed** + * `open_router.images.list_model_endpoints()`: `response.endpoints[].supported_parameters.Map.union(range)` **Changed** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 38f9c2d60..397d706da 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.246 + version: 1.3.247 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index de8126e83..d767fccef 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -23,6 +23,12 @@ components: description: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. responses: + SpeechSeparatedTracks: + content: + application/json: + schema: + $ref: '#/components/schemas/SpeechSeparatedTracksResponse' + description: 'Speech request with `separate_tracks`: one entry per separated track, each with base64 audio or a signed download URL.' SpeechTimedAudio: content: application/json: @@ -34195,9 +34201,15 @@ components: max: format: 'double' type: 'number' + max_pixels: + description: '`input_references` only: largest accepted pixel count (width x height) of each reference image. Absent when none is declared.' + type: 'integer' min: format: 'double' type: 'number' + min_edge: + description: '`input_references` only: smallest accepted shorter side of each reference image, in pixels. Absent when none is declared.' + type: 'integer' type: enum: - 'range' @@ -36509,6 +36521,82 @@ components: oneOf: - $ref: '#/components/schemas/ContainerAutoEnvironment' - $ref: '#/components/schemas/ContainerReferenceEnvironment' + SpeechAudioTrack: + description: 'One separated track with its audio as base64.' + example: + audio: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + description: 'all speech' + media_type: 'audio/mpeg' + type: 'speaker' + properties: + audio: + description: 'Base64-encoded audio in the format named by `media_type`.' + example: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + type: 'string' + description: + description: 'The provider''s short description of the track.' + example: 'all speech' + type: 'string' + 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' + type: + description: 'What the track holds: `speaker` (speech), `sfx` (sound effects), `bgm` (background music), or `composite` (several categories merged because the prompt asked for it).' + enum: + - 'speaker' + - 'sfx' + - 'bgm' + - 'composite' + example: 'speaker' + type: 'string' + x-speakeasy-unknown-values: allow + required: + - 'type' + - 'media_type' + - 'audio' + type: 'object' + SpeechAudioTrackUrl: + description: 'One separated track as a signed download URL.' + example: + description: 'background music' + expires_at: 1748458800 + media_type: 'audio/mpeg' + type: 'bgm' + url: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + properties: + description: + description: 'The provider''s short description of the track.' + example: 'all speech' + type: 'string' + 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' + type: + description: 'What the track holds: `speaker` (speech), `sfx` (sound effects), `bgm` (background music), or `composite` (several categories merged because the prompt asked for it).' + enum: + - 'speaker' + - 'sfx' + - 'bgm' + - 'composite' + example: 'speaker' + type: 'string' + x-speakeasy-unknown-values: allow + 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: + - 'type' + - 'media_type' + - 'url' + - 'expires_at' + type: 'object' SpeechEnumParameter: example: type: 'enum' @@ -36538,7 +36626,7 @@ components: description: '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.' example: 'Hello world' SpeechInputModality: - description: 'An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for.' + description: 'An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design, and `audio` is also the clip `separate_tracks` splits; `video` is a reference video the generated audio is made for.' example: type: 'text' oneOf: @@ -36560,7 +36648,7 @@ components: type: 'object' - properties: supported_inputs: - description: '`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder.' + description: '`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice.' properties: references: $ref: '#/components/schemas/SpeechReferenceCount' @@ -37131,6 +37219,10 @@ components: example: 'pcm' type: 'string' x-speakeasy-unknown-values: allow + separate_tracks: + description: 'Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example "all speech in one track, background music in one track, all sound effects in one track"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: "url"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON.' + example: true + type: 'boolean' session_id: description: '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.' example: 'session-1234' @@ -37176,6 +37268,25 @@ components: - 'model' - 'input' type: 'object' + SpeechSeparatedTracksResponse: + description: 'JSON response for a request with `separate_tracks`: one entry per separated track.' + example: + tracks: + - audio: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + description: 'all speech' + media_type: 'audio/mpeg' + type: 'speaker' + properties: + tracks: + description: 'The separated tracks in provider order (up to six). Each carries base64 `audio`, or `url` and `expires_at` when `output_delivery` is `url` and a signed URL could be issued.' + items: + anyOf: + - $ref: '#/components/schemas/SpeechAudioTrack' + - $ref: '#/components/schemas/SpeechAudioTrackUrl' + type: 'array' + required: + - 'tracks' + type: 'object' SpeechSignedUrlResponse: description: 'JSON response containing a signed download URL for generated speech audio.' example: @@ -37233,6 +37344,10 @@ components: $ref: '#/components/schemas/SpeechUnknownParameter' response_format: $ref: '#/components/schemas/SpeechEnumParameter' + separate_tracks: + allOf: + - $ref: '#/components/schemas/SpeechUnknownParameter' + - description: 'Present when the endpoint accepts `separate_tracks` (split one audio clip into speech, sound effect and music tracks). Absent: track separation is not supported.' speed: $ref: '#/components/schemas/SpeechRangeParameter' stream_format: @@ -44238,7 +44353,7 @@ paths: example: '' format: 'binary' type: 'string' - description: 'Raw audio bytes stream (`audio/*`) by default. When `stream_format` is `"sse"`, returns `text/event-stream` with `X-Audio-Media-Type` set to the effective audio media type (exposed via `Access-Control-Expose-Headers`) and default SSE `data:` frames (no named `event:` field) carrying one JSON object per event discriminated by `type`: `{"type":"speech.audio.delta","audio":""}` (base64-encoded audio chunk; decode each delta separately before concatenating bytes), `{"type":"speech.timestamps.delta","words"?:[{"text","start","end"}],"characters"?:[{"text","start","end"}]}` (when `timestamp_granularities` is nonempty; times in float seconds from start of output), `{"type":"speech.audio.done","media_type":"","usage"?:{"input_characters"?:number}}`, and `{"type":"error","error":{"message":""}}` on mid-stream failure. 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 and `stream_format` is `"audio"` (default), 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`.' + description: 'Raw audio bytes stream (`audio/*`) by default. When `stream_format` is `"sse"`, returns `text/event-stream` with `X-Audio-Media-Type` set to the effective audio media type (exposed via `Access-Control-Expose-Headers`) and default SSE `data:` frames (no named `event:` field) carrying one JSON object per event discriminated by `type`: `{"type":"speech.audio.delta","audio":""}` (base64-encoded audio chunk; decode each delta separately before concatenating bytes), `{"type":"speech.timestamps.delta","words"?:[{"text","start","end"}],"characters"?:[{"text","start","end"}]}` (when `timestamp_granularities` is nonempty; times in float seconds from start of output), `{"type":"speech.audio.done","media_type":"","usage"?:{"input_characters"?:number}}`, and `{"type":"error","error":{"message":""}}` on mid-stream failure. 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 and `stream_format` is `"audio"` (default), 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`. When `separate_tracks` is true, always returns `application/json` `{ tracks }` (`SpeechSeparatedTracksResponse`), one entry per separated track with base64 `audio`, or `url` and `expires_at` with URL delivery. A separated-tracks `url` request that cannot get signed URLs (zero-data-retention, missing workspace, or storage failure) returns inline base64 `audio` per track under the inline size cap.' '400': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 7e8988181..7f751d4d9 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:8c4964898b84905744a337e016fd8360c795a9912330a03eeb6e6e2fde165a6b - sourceBlobDigest: sha256:b22c4c6acec0aa7b3978027ab90e094597af08bff4f7c6ae8c68c7dfaf13ca27 + sourceRevisionDigest: sha256:f39f4f0a46eaa08d7c1a289caab83ba05e55fbdca9fc5753048d6e651a0834e6 + sourceBlobDigest: sha256:7a247bcaba4521169bc8525cc5dc877135c852bf9abac69c56b54d926d3ed200 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:8c4964898b84905744a337e016fd8360c795a9912330a03eeb6e6e2fde165a6b - sourceBlobDigest: sha256:b22c4c6acec0aa7b3978027ab90e094597af08bff4f7c6ae8c68c7dfaf13ca27 + sourceRevisionDigest: sha256:f39f4f0a46eaa08d7c1a289caab83ba05e55fbdca9fc5753048d6e651a0834e6 + sourceBlobDigest: sha256:7a247bcaba4521169bc8525cc5dc877135c852bf9abac69c56b54d926d3ed200 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:09f29cdebc9b5e7a06992913784bee13d0d4c8d33921d1e9a9a4d5c664d9e647 + codeSamplesRevisionDigest: sha256:d8e5ce41b1cf9732455afc2cd2358680bd51960f4491aff83fcf1b02b68866a3 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index d5576cd16..aa21307ab 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5229,4 +5229,14 @@ Based on: ### Generated - [python v1.3.246] . ### Releases -- [PyPI v1.3.246] https://pypi.org/project/openrouter/1.3.246 - . \ No newline at end of file +- [PyPI v1.3.246] https://pypi.org/project/openrouter/1.3.246 - . + +## 2026-12-04 21:03:06 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.247] . +### Releases +- [PyPI v1.3.247] https://pypi.org/project/openrouter/1.3.247 - . \ No newline at end of file diff --git a/docs/components/rangecapability.mdx b/docs/components/rangecapability.mdx index 3135af749..82c508684 100644 --- a/docs/components/rangecapability.mdx +++ b/docs/components/rangecapability.mdx @@ -7,8 +7,10 @@ A parameter that accepts any value within an inclusive numeric range. ## Fields -| Field | Type | Required | Description | -| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | -| `max` | *float* | ✔️ | N/A | -| `min` | *float* | ✔️ | N/A | -| `type` | [components.RangeCapabilityType](../components/rangecapabilitytype.mdx) | ✔️ | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| `max` | *float* | ✔️ | N/A | +| `max_pixels` | *Optional[int]* | ➖ | `input_references` only: largest accepted pixel count (width x height) of each reference image. Absent when none is declared. | +| `min` | *float* | ✔️ | N/A | +| `min_edge` | *Optional[int]* | ➖ | `input_references` only: smallest accepted shorter side of each reference image, in pixels. Absent when none is declared. | +| `type` | [components.RangeCapabilityType](../components/rangecapabilitytype.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/components/speechinputmodality.mdx b/docs/components/speechinputmodality.mdx index 00aa5bea8..fb5ae24bf 100644 --- a/docs/components/speechinputmodality.mdx +++ b/docs/components/speechinputmodality.mdx @@ -2,7 +2,7 @@ title: "SpeechInputModality" --- -An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for. +An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design, and `audio` is also the clip `separate_tracks` splits; `video` is a reference video the generated audio is made for. ## Supported Types diff --git a/docs/components/speechinputmodalityaudio.mdx b/docs/components/speechinputmodalityaudio.mdx index a6ad3370b..484e385e3 100644 --- a/docs/components/speechinputmodalityaudio.mdx +++ b/docs/components/speechinputmodalityaudio.mdx @@ -4,7 +4,7 @@ title: "SpeechInputModalityAudio" ## Fields -| Field | Type | Required | Description | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `supported_inputs` | [components.SpeechInputModalitySupportedInputs1](../components/speechinputmodalitysupportedinputs1.mdx) | ✔️ | `references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. | -| `type` | [components.SpeechInputModalityTypeAudio](../components/speechinputmodalitytypeaudio.mdx) | ✔️ | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `supported_inputs` | [components.SpeechInputModalitySupportedInputs1](../components/speechinputmodalitysupportedinputs1.mdx) | ✔️ | `references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice. | +| `type` | [components.SpeechInputModalityTypeAudio](../components/speechinputmodalitytypeaudio.mdx) | ✔️ | N/A | \ No newline at end of file diff --git a/docs/components/speechinputmodalitysupportedinputs1.mdx b/docs/components/speechinputmodalitysupportedinputs1.mdx index 06b49bea8..4c0063b4a 100644 --- a/docs/components/speechinputmodalitysupportedinputs1.mdx +++ b/docs/components/speechinputmodalitysupportedinputs1.mdx @@ -2,7 +2,7 @@ title: "SpeechInputModalitySupportedInputs1" --- -`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. +`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice. ## Fields diff --git a/docs/components/speechrequest.mdx b/docs/components/speechrequest.mdx index 78a1e3b01..d07dd901a 100644 --- a/docs/components/speechrequest.mdx +++ b/docs/components/speechrequest.mdx @@ -16,6 +16,7 @@ Text-to-speech request input | `output_delivery` | [Optional[components.OutputDelivery]](../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (returns inline base64 JSON when `timestamp_granularities` is nonempty and `stream_format` is `"audio"`, or `text/event-stream` events when `stream_format` is `"sse"`). `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. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. | pcm | +| `separate_tracks` | *Optional[bool]* | ➖ | Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example "all speech in one track, background music in one track, all sound effects in one track"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: "url"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON. | true | | `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 | | `stream_format` | [Optional[components.StreamFormat]](../components/streamformat.mdx) | ➖ | Wire framing for inline responses. `audio` (default) returns raw audio bytes (or a buffered JSON envelope when `timestamp_granularities` is nonempty). `sse` streams `text/event-stream` events (`speech.audio.delta`, `speech.timestamps.delta` when `timestamp_granularities` is nonempty, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type`. Cannot be combined with `output_delivery: "url"`. Only routed to endpoints that advertise `sse` in `supported_parameters.stream_format` (and every requested granularity when `timestamp_granularities` is nonempty). Generated SDKs still type the 200 response as binary audio for compatibility; when using `stream_format: "sse"`, call the HTTP endpoint directly and parse `text/event-stream`. | audio | diff --git a/docs/components/speechsupportedparameters.mdx b/docs/components/speechsupportedparameters.mdx index 0a9944792..b2ada4a5e 100644 --- a/docs/components/speechsupportedparameters.mdx +++ b/docs/components/speechsupportedparameters.mdx @@ -8,6 +8,7 @@ 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"
]
} | +| `separate_tracks` | [Optional[components.SpeechUnknownParameter]](../components/speechunknownparameter.mdx) | ➖ | N/A | \{
"type": "unknown"
} | | `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"
} | | `stream_format` | [Optional[components.SpeechEnumParameter]](../components/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `timestamp_granularities` | [Optional[components.SpeechEnumParameter]](../components/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | diff --git a/docs/sdks/tts/README.mdx b/docs/sdks/tts/README.mdx index fd28773bd..971ee254c 100644 --- a/docs/sdks/tts/README.mdx +++ b/docs/sdks/tts/README.mdx @@ -52,6 +52,7 @@ with OpenRouter( | `output_delivery` | [Optional[components.OutputDelivery]](../../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (returns inline base64 JSON when `timestamp_granularities` is nonempty and `stream_format` is `"audio"`, or `text/event-stream` events when `stream_format` is `"sse"`). `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. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. | pcm | +| `separate_tracks` | *Optional[bool]* | ➖ | Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example "all speech in one track, background music in one track, all sound effects in one track"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: "url"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON. | true | | `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 | | `stream_format` | [Optional[components.StreamFormat]](../../components/streamformat.mdx) | ➖ | Wire framing for inline responses. `audio` (default) returns raw audio bytes (or a buffered JSON envelope when `timestamp_granularities` is nonempty). `sse` streams `text/event-stream` events (`speech.audio.delta`, `speech.timestamps.delta` when `timestamp_granularities` is nonempty, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type`. Cannot be combined with `output_delivery: "url"`. Only routed to endpoints that advertise `sse` in `supported_parameters.stream_format` (and every requested granularity when `timestamp_granularities` is nonempty). Generated SDKs still type the 200 response as binary audio for compatibility; when using `stream_format: "sse"`, call the HTTP endpoint directly and parse `text/event-stream`. | audio | diff --git a/pyproject.toml b/pyproject.toml index 6014e72ed..5525dafe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.246" +version = "1.3.247" 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 afee1974f..f68041cee 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.246" +__version__: str = "1.3.247" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.246 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.247 2.950.13 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/rangecapability.py b/src/openrouter/components/rangecapability.py index 76fabc08d..c13fbf23e 100644 --- a/src/openrouter/components/rangecapability.py +++ b/src/openrouter/components/rangecapability.py @@ -1,9 +1,10 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from openrouter.types import BaseModel -from typing import Literal -from typing_extensions import TypedDict +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import Literal, Optional +from typing_extensions import NotRequired, TypedDict RangeCapabilityType = Literal["range",] @@ -15,6 +16,10 @@ class RangeCapabilityTypedDict(TypedDict): max: float min: float type: RangeCapabilityType + max_pixels: NotRequired[int] + r"""`input_references` only: largest accepted pixel count (width x height) of each reference image. Absent when none is declared.""" + min_edge: NotRequired[int] + r"""`input_references` only: smallest accepted shorter side of each reference image, in pixels. Absent when none is declared.""" class RangeCapability(BaseModel): @@ -25,3 +30,25 @@ class RangeCapability(BaseModel): min: float type: RangeCapabilityType + + max_pixels: Optional[int] = None + r"""`input_references` only: largest accepted pixel count (width x height) of each reference image. Absent when none is declared.""" + + min_edge: Optional[int] = None + r"""`input_references` only: smallest accepted shorter side of each reference image, in pixels. Absent when none is declared.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["max_pixels", "min_edge"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/src/openrouter/components/speechinputmodality.py b/src/openrouter/components/speechinputmodality.py index beba53e28..27df44977 100644 --- a/src/openrouter/components/speechinputmodality.py +++ b/src/openrouter/components/speechinputmodality.py @@ -93,13 +93,13 @@ class SpeechInputModalityImage(BaseModel): class SpeechInputModalitySupportedInputs1TypedDict(TypedDict): - r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder.""" + r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice.""" references: SpeechReferenceCountTypedDict class SpeechInputModalitySupportedInputs1(BaseModel): - r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder.""" + r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice.""" references: SpeechReferenceCount @@ -109,13 +109,13 @@ class SpeechInputModalitySupportedInputs1(BaseModel): class SpeechInputModalityAudioTypedDict(TypedDict): supported_inputs: SpeechInputModalitySupportedInputs1TypedDict - r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder.""" + r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice.""" type: SpeechInputModalityTypeAudio class SpeechInputModalityAudio(BaseModel): supported_inputs: SpeechInputModalitySupportedInputs1 - r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder.""" + r"""`references` is how many audio clips a request may send. With more than one, some providers require the text to address every clip with an `@AudioN` placeholder. An endpoint may accept a clip only for voice cloning, only for `separate_tracks`, or both: check `supported_parameters` for `separate_tracks` and `voice` before cloning a voice.""" type: SpeechInputModalityTypeAudio @@ -175,7 +175,7 @@ def serialize_model(self, handler): SpeechInputModalityVideoTypedDict, ], ) -r"""An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for.""" +r"""An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design, and `audio` is also the clip `separate_tracks` splits; `video` is a reference video the generated audio is made for.""" class UnknownSpeechInputModality(BaseModel): @@ -214,4 +214,4 @@ class UnknownSpeechInputModality(BaseModel): ) ), ] -r"""An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for.""" +r"""An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design, and `audio` is also the clip `separate_tracks` splits; `video` is a reference video the generated audio is made for.""" diff --git a/src/openrouter/components/speechrequest.py b/src/openrouter/components/speechrequest.py index b88af6a26..e543683e6 100644 --- a/src/openrouter/components/speechrequest.py +++ b/src/openrouter/components/speechrequest.py @@ -211,6 +211,8 @@ class SpeechRequestTypedDict(TypedDict): 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] r"""Audio output format. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty.""" + separate_tracks: NotRequired[bool] + r"""Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example \"all speech in one track, background music in one track, all sound effects in one track\"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: \"url\"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON.""" session_id: NotRequired[str] 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] @@ -251,6 +253,9 @@ class SpeechRequest(BaseModel): response_format: Optional[SpeechRequestResponseFormat] = None r"""Audio output format. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty.""" + separate_tracks: Optional[bool] = None + r"""Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example \"all speech in one track, background music in one track, all sound effects in one track\"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: \"url\"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON.""" + session_id: Optional[str] = None 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.""" @@ -281,6 +286,7 @@ def serialize_model(self, handler): "output_delivery", "provider", "response_format", + "separate_tracks", "session_id", "speed", "stream_format", diff --git a/src/openrouter/components/speechsupportedparameters.py b/src/openrouter/components/speechsupportedparameters.py index c99fcc565..ec3d39c42 100644 --- a/src/openrouter/components/speechsupportedparameters.py +++ b/src/openrouter/components/speechsupportedparameters.py @@ -17,6 +17,7 @@ class SpeechSupportedParametersTypedDict(TypedDict): instructions: NotRequired[SpeechUnknownParameterTypedDict] response_format: NotRequired[SpeechEnumParameterTypedDict] + separate_tracks: NotRequired[SpeechUnknownParameterTypedDict] speed: NotRequired[SpeechRangeParameterTypedDict] r"""The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`.""" stream_format: NotRequired[SpeechEnumParameterTypedDict] @@ -30,6 +31,8 @@ class SpeechSupportedParameters(BaseModel): response_format: Optional[SpeechEnumParameter] = None + separate_tracks: Optional[SpeechUnknownParameter] = None + speed: Optional[SpeechRangeParameter] = None r"""The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`.""" @@ -46,6 +49,7 @@ def serialize_model(self, handler): [ "instructions", "response_format", + "separate_tracks", "speed", "stream_format", "timestamp_granularities", diff --git a/src/openrouter/tts.py b/src/openrouter/tts.py index 3fc05547b..20158653c 100644 --- a/src/openrouter/tts.py +++ b/src/openrouter/tts.py @@ -36,6 +36,7 @@ def create_speech( ] ] = None, response_format: Optional[components.SpeechRequestResponseFormat] = None, + separate_tracks: Optional[bool] = None, session_id: Optional[str] = None, speed: Optional[float] = None, stream_format: Optional[components.StreamFormat] = None, @@ -70,6 +71,7 @@ def create_speech( :param output_delivery: `stream` (default) streams the audio bytes directly in the response body (returns inline base64 JSON when `timestamp_granularities` is nonempty and `stream_format` is `\"audio\"`, or `text/event-stream` events when `stream_format` is `\"sse\"`). `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. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. + :param separate_tracks: Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example \"all speech in one track, background music in one track, all sound effects in one track\"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: \"url\"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON. :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 stream_format: Wire framing for inline responses. `audio` (default) returns raw audio bytes (or a buffered JSON envelope when `timestamp_granularities` is nonempty). `sse` streams `text/event-stream` events (`speech.audio.delta`, `speech.timestamps.delta` when `timestamp_granularities` is nonempty, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type`. Cannot be combined with `output_delivery: \"url\"`. Only routed to endpoints that advertise `sse` in `supported_parameters.stream_format` (and every requested granularity when `timestamp_granularities` is nonempty). Generated SDKs still type the 200 response as binary audio for compatibility; when using `stream_format: \"sse\"`, call the HTTP endpoint directly and parse `text/event-stream`. @@ -108,6 +110,7 @@ def create_speech( provider, Optional[components.SpeechRequestProvider] ), response_format=response_format, + separate_tracks=separate_tracks, session_id=session_id, speed=speed, stream_format=stream_format, @@ -314,6 +317,7 @@ async def create_speech_async( ] ] = None, response_format: Optional[components.SpeechRequestResponseFormat] = None, + separate_tracks: Optional[bool] = None, session_id: Optional[str] = None, speed: Optional[float] = None, stream_format: Optional[components.StreamFormat] = None, @@ -348,6 +352,7 @@ async def create_speech_async( :param output_delivery: `stream` (default) streams the audio bytes directly in the response body (returns inline base64 JSON when `timestamp_granularities` is nonempty and `stream_format` is `\"audio\"`, or `text/event-stream` events when `stream_format` is `\"sse\"`). `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. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. + :param separate_tracks: Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example \"all speech in one track, background music in one track, all sound effects in one track\"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: \"url\"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON. :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 stream_format: Wire framing for inline responses. `audio` (default) returns raw audio bytes (or a buffered JSON envelope when `timestamp_granularities` is nonempty). `sse` streams `text/event-stream` events (`speech.audio.delta`, `speech.timestamps.delta` when `timestamp_granularities` is nonempty, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type`. Cannot be combined with `output_delivery: \"url\"`. Only routed to endpoints that advertise `sse` in `supported_parameters.stream_format` (and every requested granularity when `timestamp_granularities` is nonempty). Generated SDKs still type the 200 response as binary audio for compatibility; when using `stream_format: \"sse\"`, call the HTTP endpoint directly and parse `text/event-stream`. @@ -386,6 +391,7 @@ async def create_speech_async( provider, Optional[components.SpeechRequestProvider] ), response_format=response_format, + separate_tracks=separate_tracks, session_id=session_id, speed=speed, stream_format=stream_format, diff --git a/uv.lock b/uv.lock index 6794d03ab..09fc2f96d 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.246" +version = "1.3.247" source = { editable = "." } dependencies = [ { name = "httpcore" },