diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 0ed2ed03..1ade19bc 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: 5523a99aeba8d22ec99fe29fde3081cc + docChecksum: 4d82e0bb28f8a6282dc30c8a4d83fca8 docVersion: 1.0.0 speakeasyVersion: 1.803.2 generationVersion: 2.950.13 - releaseVersion: 1.3.209 - configChecksum: 594ea931660cc5a95f0b833ceef0dfe7 + releaseVersion: 1.3.210 + configChecksum: f42f0088c32d2e902f3ea5cb772c09b3 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 23b0b72b-48f1-477e-ab26-c3d14487b550 - pristine_commit_hash: 5e57e5c447618ca19068a8c4f83afdc92acfadba - pristine_tree_hash: 579b0a5ed8b74495b33dd8793b3ccdc68a9e4aaa + generation_id: 743616bd-d6bf-4c14-b9f8-7cfb67a1565e + pristine_commit_hash: 95e89e40d286461c627183111cc68fac71ced02b + pristine_tree_hash: 928468581347d154ebedc08fa47d5c1f558e0ec5 features: python: acceptHeaders: 3.0.0 @@ -6574,6 +6574,10 @@ trackedFiles: id: a8219ea3cbbe last_write_checksum: sha1:7eb09027b473e745dee4f4fb533c6e3cc2ed7321 pristine_git_object: 62bc0076806110e866d63bf477349fe9753bdf3e + docs/components/outputdelivery.mdx: + id: 0cb4c1fb2927 + last_write_checksum: sha1:33312586a0033b3b3be4ccb3c4960bc6d5faa144 + pristine_git_object: 24b71c95e4186e89dca3be8782c15d96be1211ed docs/components/outputfilesearchcallitem.mdx: id: 16f4409e4148 last_write_checksum: sha1:2ca9cc034ab3d2acb7456475d90ed65b7c65c8fd @@ -8260,8 +8264,8 @@ trackedFiles: pristine_git_object: 38be122fce694e660cd56d82182dd3d15098479d docs/components/speechrequest.mdx: id: 06e81b0433f6 - last_write_checksum: sha1:474e3a8e5258c76ba6a915d86da615951fc5d572 - pristine_git_object: 6245248da9c4fcffcb9a2bf03453d42a4526c959 + last_write_checksum: sha1:824fc72c47b3af6a703d2c0a8a28ba6e027d2a55 + pristine_git_object: 723545ac721a518156cc6105bdb88e82224a28ce docs/components/speechrequestdatacollection.mdx: id: 6c5938568888 last_write_checksum: sha1:89a08b4c4de66c1ef7676792a38747e030ed6729 @@ -11848,8 +11852,8 @@ trackedFiles: pristine_git_object: bcbe30fccceb97caa3a0e170038245dcc7f1e540 docs/sdks/tts/README.mdx: id: cd1132543884 - last_write_checksum: sha1:d153a25bafea3b9ec7a083ad0a352bc3682b4b16 - pristine_git_object: 0addd5d2acf64d1e0b7aed00f445f930affea1f8 + last_write_checksum: sha1:e55f965157aa2e981370cab85a8be963e75638ef + pristine_git_object: 229c11658d3014036753eeadc1e4cf0bb87f9188 docs/sdks/vault/README.mdx: id: 3738c6722acd last_write_checksum: sha1:290b439ff730b9eabf4a6ef93737d1c61006b0fa @@ -11868,8 +11872,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:e214a515a04c4f88bc4a0f08e53c5d4a612c6e34 - pristine_git_object: a649c156d0e05683d3018647b3d85c5fddb057b0 + last_write_checksum: sha1:8758f7b0b8afbdd36cd73c11a5c7752584fdad5b + pristine_git_object: 486641f0f09463a0e8ea06a1cb3fee6c03aa5030 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -11896,8 +11900,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:8d5c0cb3469fb60dd52dcb492cbfb3a50bef23a8 - pristine_git_object: f1438eace800a2d3e09d3ff6a7dfdd84723e7ab0 + last_write_checksum: sha1:853450c8ee202d21c299b5ddd7206f94e063856f + pristine_git_object: ebb29394c03857ec869024de232aa6c03feeaff4 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:80cc0f39649445431cc2247ed0e0765438467766 @@ -11944,8 +11948,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:41219c5d71a12394e152fabb5b9624aeaed824c9 - pristine_git_object: ae3c6652a2517664982455cb0f6f4e87bda918fc + last_write_checksum: sha1:375acc709be3b3cb9d9f08464f9c5d2470e1ad9a + pristine_git_object: ac86ae50aade2f12c070b0f42bfaa13d4bd2fdcc src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:08125e1d60df82793e11e8aed6e3c9fdb7512ebb @@ -15324,8 +15328,8 @@ trackedFiles: pristine_git_object: 69c0355e7d575e6b7c52183d3cd5696611e4e8bf src/openrouter/components/speechrequest.py: id: 2a9400167112 - last_write_checksum: sha1:cf22dbaca7ef549f6f5baf48b5e9f95cbfdceeb0 - pristine_git_object: 9ba3e70a09cd8bbae8b8fc995237e60566549a88 + last_write_checksum: sha1:ad68e3edee8bada9d7a7cf487be8c0e00ee634b7 + pristine_git_object: bf95c5745e517b78184ce04f1e0c523fac0998f7 src/openrouter/components/speechsupportedparameters.py: id: 618f33cc9229 last_write_checksum: sha1:9c152515a0cedad80d796c8981df706c08746d45 @@ -16800,8 +16804,8 @@ trackedFiles: pristine_git_object: 701fa8597ff85f41a60736ade55fcb32f9ec7125 src/openrouter/tts.py: id: 5055d4b95f1d - last_write_checksum: sha1:6dc3d10fc7e927122eb139d65c9fea7cf534a9a4 - pristine_git_object: b9ee475523057e41efd726e86150e9e88a83b073 + last_write_checksum: sha1:a479cee30f00e53289d308dff60334bb3add298d + pristine_git_object: bced8dbca5e5254efbfe2787e172c25ce4704bbf src/openrouter/types/__init__.py: id: 5eab536205b7 last_write_checksum: sha1:f9ad14217f832e74f594285960125add50324be9 @@ -22023,3 +22027,6 @@ examples: "503": application/json: {"error": {"code": 503, "message": "Service temporarily unavailable"}} examplesVersion: 1.0.2 +releaseNotes: | + ## Python SDK Changes: + * `open_router.tts.create_speech()`: `request.output_delivery` **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 7475f8d9..e25b8688 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.209 + version: 1.3.210 additionalDependencies: dev: pytest: '>=8.3' diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 5b80d568..e948906b 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -34907,6 +34907,14 @@ components: description: 'TTS model identifier' 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.' + enum: + - 'stream' + - 'url' + example: 'stream' + type: 'string' + x-speakeasy-unknown-values: allow provider: description: 'Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options' properties: @@ -41617,7 +41625,7 @@ paths: - $ref: "#/components/parameters/AppCategories" /audio/speech: post: - description: 'Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm, wav).' + description: 'Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm) by default, or a JSON response with a 24-hour signed download URL when `output_delivery` is set to `"url"`.' operationId: 'createAudioSpeech' requestBody: content: @@ -41640,7 +41648,7 @@ paths: example: '' format: 'binary' type: 'string' - description: 'Audio bytes stream' + 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.' '400': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index aa16974c..a99dff4c 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:5cfe611ddea7f6069ebd8b3139264a5280c4b6f7c6ecc65fdb05781527c8ad64 - sourceBlobDigest: sha256:ec5ebbdb43d4f02a741127d8620537cf6a11eb0945e50d17c7c62664d81d76ce + sourceRevisionDigest: sha256:ba90c495baff410bced3e769d29fd3956b00bd839027405dcad0628e383b7784 + sourceBlobDigest: sha256:b9088d65dab80454ae36699aeaa1191ee708097b84fc930fe5bb01da5f17b468 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:5cfe611ddea7f6069ebd8b3139264a5280c4b6f7c6ecc65fdb05781527c8ad64 - sourceBlobDigest: sha256:ec5ebbdb43d4f02a741127d8620537cf6a11eb0945e50d17c7c62664d81d76ce + sourceRevisionDigest: sha256:ba90c495baff410bced3e769d29fd3956b00bd839027405dcad0628e383b7784 + sourceBlobDigest: sha256:b9088d65dab80454ae36699aeaa1191ee708097b84fc930fe5bb01da5f17b468 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:8df3e92960ebf42ee39c7a092490a8d1789b77cb40669c4840a97e943fd1e80e + codeSamplesRevisionDigest: sha256:a9ebf8b0ee0a7ae394735eed466c3ff5e30ee12f3123c59a5ed5375dfab2f09b workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.803.2 diff --git a/RELEASES.md b/RELEASES.md index c826c75d..8d275cff 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4859,4 +4859,14 @@ Based on: ### Generated - [python v1.3.209] . ### Releases -- [PyPI v1.3.209] https://pypi.org/project/openrouter/1.3.209 - . \ No newline at end of file +- [PyPI v1.3.209] https://pypi.org/project/openrouter/1.3.209 - . + +## 2026-11-24 10:57:26 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.803.2 (2.950.13) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.210] . +### Releases +- [PyPI v1.3.210] https://pypi.org/project/openrouter/1.3.210 - . \ No newline at end of file diff --git a/docs/components/outputdelivery.mdx b/docs/components/outputdelivery.mdx new file mode 100644 index 00000000..24b71c95 --- /dev/null +++ b/docs/components/outputdelivery.mdx @@ -0,0 +1,22 @@ +--- +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. + +## Example Usage + +```python +from openrouter.components import OutputDelivery + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: OutputDelivery = "stream" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"stream"` +- `"url"` diff --git a/docs/components/speechrequest.mdx b/docs/components/speechrequest.mdx index 6245248d..723545ac 100644 --- a/docs/components/speechrequest.mdx +++ b/docs/components/speechrequest.mdx @@ -13,6 +13,7 @@ Text-to-speech request input | `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 | diff --git a/docs/sdks/tts/README.mdx b/docs/sdks/tts/README.mdx index 0addd5d2..229c1165 100644 --- a/docs/sdks/tts/README.mdx +++ b/docs/sdks/tts/README.mdx @@ -15,7 +15,7 @@ Text-to-speech endpoints ## create_speech -Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm, wav). +Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm) by default, or a JSON response with a 24-hour signed download URL when `output_delivery` is set to `"url"`. ### Example Usage @@ -49,6 +49,7 @@ with OpenRouter( | `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 | diff --git a/pyproject.toml b/pyproject.toml index a649c156..486641f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.209" +version = "1.3.210" 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 f1438eac..ebb29394 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.209" +__version__: str = "1.3.210" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.950.13" -__user_agent__: str = "speakeasy-sdk/python 1.3.209 2.950.13 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.210 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 ae3c6652..ac86ae50 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -4606,6 +4606,7 @@ SpeechReferenceCountTypedDict, ) from .speechrequest import ( + OutputDelivery, SpeechRequest, SpeechRequestDataCollection, SpeechRequestIgnore, @@ -7812,6 +7813,7 @@ "OutputDatetimeItem", "OutputDatetimeItemType", "OutputDatetimeItemTypedDict", + "OutputDelivery", "OutputFileSearchCallItem", "OutputFileSearchCallItemType", "OutputFileSearchCallItemTypedDict", @@ -12409,6 +12411,7 @@ "SpeechReferenceCount": ".speechreferencecount", "SpeechReferenceCountType": ".speechreferencecount", "SpeechReferenceCountTypedDict": ".speechreferencecount", + "OutputDelivery": ".speechrequest", "SpeechRequest": ".speechrequest", "SpeechRequestDataCollection": ".speechrequest", "SpeechRequestIgnore": ".speechrequest", diff --git a/src/openrouter/components/speechrequest.py b/src/openrouter/components/speechrequest.py index 9ba3e70a..bf95c574 100644 --- a/src/openrouter/components/speechrequest.py +++ b/src/openrouter/components/speechrequest.py @@ -19,6 +19,16 @@ from typing_extensions import NotRequired, TypeAliasType, TypedDict +OutputDelivery = Union[ + Literal[ + "stream", + "url", + ], + 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.""" + + SpeechRequestDataCollection = Union[ Literal[ "deny", @@ -175,6 +185,8 @@ class SpeechRequestTypedDict(TypedDict): r"""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.""" 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.""" 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] @@ -206,6 +218,9 @@ class SpeechRequest(BaseModel): instructions: Optional[str] = None 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.""" + 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""" @@ -233,6 +248,7 @@ def serialize_model(self, handler): [ "input_references", "instructions", + "output_delivery", "provider", "response_format", "session_id", diff --git a/src/openrouter/tts.py b/src/openrouter/tts.py index b9ee4755..bced8dbc 100644 --- a/src/openrouter/tts.py +++ b/src/openrouter/tts.py @@ -28,6 +28,7 @@ def create_speech( ] ] = None, instructions: Optional[str] = None, + output_delivery: Optional[components.OutputDelivery] = None, provider: Optional[ Union[ components.SpeechRequestProvider, @@ -49,7 +50,7 @@ def create_speech( ) -> httpx.Response: r"""Create speech - Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm, wav). + Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm) by default, or a JSON response with a 24-hour signed download URL when `output_delivery` is set to `\"url\"`. :param input: 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. :param model: TTS model identifier @@ -62,6 +63,7 @@ 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 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. @@ -95,6 +97,7 @@ def create_speech( ), instructions=instructions, model=model, + output_delivery=output_delivery, provider=utils.get_pydantic_model( provider, Optional[components.SpeechRequestProvider] ), @@ -284,6 +287,7 @@ async def create_speech_async( ] ] = None, instructions: Optional[str] = None, + output_delivery: Optional[components.OutputDelivery] = None, provider: Optional[ Union[ components.SpeechRequestProvider, @@ -305,7 +309,7 @@ async def create_speech_async( ) -> httpx.Response: r"""Create speech - Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm, wav). + Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm) by default, or a JSON response with a 24-hour signed download URL when `output_delivery` is set to `\"url\"`. :param input: 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. :param model: TTS model identifier @@ -318,6 +322,7 @@ 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 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. @@ -351,6 +356,7 @@ async def create_speech_async( ), instructions=instructions, model=model, + output_delivery=output_delivery, provider=utils.get_pydantic_model( provider, Optional[components.SpeechRequestProvider] ), diff --git a/uv.lock b/uv.lock index e341f20c..f038ecbf 100644 --- a/uv.lock +++ b/uv.lock @@ -231,7 +231,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.209" +version = "1.3.210" source = { editable = "." } dependencies = [ { name = "httpcore" },