From 6e8a30f4241134ba732abd2d5b9ce3ca7e603b03 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 4 Dec 2026 19:23:48 +0000 Subject: [PATCH] ## Typescript SDK Changes: * `openrouter.tts.createSpeech()`: * `request.speechRequest.streamFormat` **Added** * `openrouter.tts.listModels()`: `response.data[].endpoints[].outputModalities[].supportedParameters.streamFormat` **Added** * `openrouter.tts.getModel()`: `response.endpoints[].outputModalities[].supportedParameters.streamFormat` **Added** --- .speakeasy/gen.lock | 9 ++++--- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 23 ++++++++++++++--- .speakeasy/workflow.lock | 10 ++++---- RELEASES.md | 12 ++++++++- docs/models/outputdelivery.mdx | 2 +- docs/models/speechoutputmodality.mdx | 10 ++++---- docs/models/speechrequest.mdx | 31 ++++++++++++----------- docs/models/speechsupportedparameters.mdx | 1 + docs/models/streamformat.mdx | 21 +++++++++++++++ jsr.json | 2 +- package.json | 12 ++++----- src/lib/config.ts | 4 +-- src/models/speechrequest.ts | 31 ++++++++++++++++++++--- src/models/speechsupportedparameters.ts | 3 +++ 15 files changed, 125 insertions(+), 48 deletions(-) create mode 100644 docs/models/streamformat.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 54debb19d..9e85ddb83 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: "" id: "" management: - docChecksum: 93dc429cea259bac51d2deba56b57427 + docChecksum: ee22093311cc0f37ed22037cfb77fcf3 docVersion: 1.0.0 speakeasyVersion: 1.808.1 generationVersion: 2.960.8 - releaseVersion: 1.5.178 - configChecksum: 3832af9ac11724251b9ec645a5d768de + releaseVersion: 1.5.179 + configChecksum: 1b7d457d4b504d3af05b2ade3c4b4e4b repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true @@ -12705,6 +12705,7 @@ trackedFiles: docs/models/streameventsresponseoutputitemdone.mdx: id: f78b880ee8be pristine_git_object: e7adea7b505b7dfb6b6ca580fc1762d74bb21e72 + docs/models/streamformat.mdx: {} docs/models/streamlogprob.md: id: 98efa527982e last_write_checksum: sha1:3e845d902c0aa78dc24bbc84ae88f26d00ac7e19 @@ -24219,4 +24220,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: "## Typescript SDK Changes:\n* `openrouter.tts.createSpeech()`: \n * `request.speechRequest.responseFormat` **Changed**\n" +releaseNotes: "## Typescript SDK Changes:\n* `openrouter.tts.createSpeech()`: \n * `request.speechRequest.streamFormat` **Added**\n* `openrouter.tts.listModels()`: `response.data[].endpoints[].outputModalities[].supportedParameters.streamFormat` **Added**\n* `openrouter.tts.getModel()`: `response.endpoints[].outputModalities[].supportedParameters.streamFormat` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index bd6e40240..a2a8462c5 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -38,7 +38,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.5.178 + version: 1.5.179 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index ea4b08f36..2a4231f61 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -37066,7 +37066,7 @@ components: example: 'mistralai/voxtral-mini-tts-2603' type: 'string' output_delivery: - description: '`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.' + description: '`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`.' enum: - 'stream' - 'url' @@ -37157,8 +37157,16 @@ components: example: 1 format: 'double' type: 'number' + stream_format: + description: '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`.' + enum: + - 'audio' + - 'sse' + example: 'audio' + type: 'string' + x-speakeasy-unknown-values: allow timestamp_granularities: - description: 'Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings.' + description: 'Timings to return with the audio. With the default `stream_format: "audio"`, the response is buffered JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Buffered timed responses are sent once the whole audio is generated and are capped at 10 MiB of decoded audio (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input, a smaller audio format, or `stream_format: "sse"`. With `stream_format: "sse"`, the response is `text/event-stream` (`speech.audio.delta`, `speech.timestamps.delta`, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type` and no 10 MiB cap. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity for the requested `stream_format`. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse JSON (for `stream_format: "audio"`) or `text/event-stream` (for `stream_format: "sse"`). An empty array is treated as no timings.' example: - 'word' items: @@ -37221,6 +37229,11 @@ components: max: 4 min: 0.25 type: 'range' + stream_format: + type: 'enum' + values: + - 'audio' + - 'sse' timestamp_granularities: type: 'enum' values: @@ -37238,6 +37251,10 @@ components: $ref: '#/components/schemas/SpeechEnumParameter' speed: $ref: '#/components/schemas/SpeechRangeParameter' + stream_format: + allOf: + - $ref: '#/components/schemas/SpeechEnumParameter' + - description: 'The `stream_format` values the endpoint supports (`audio`, `sse`).' timestamp_granularities: allOf: - $ref: '#/components/schemas/SpeechEnumParameter' @@ -44239,7 +44256,7 @@ paths: example: '' format: 'binary' type: 'string' - description: 'Raw audio bytes stream (`audio/*`) by default. When `output_delivery` is `"url"`, returns `application/json` with `{ url, expires_at, media_type }` (a 24-hour signed download URL) unless zero-data-retention or missing workspace causes fallback to raw audio streaming. When `timestamp_granularities` is nonempty, always returns `application/json`: `{ audio, media_type }` with base64 audio (`SpeechTimedAudioResponse`), or `{ url, expires_at, media_type }` with URL delivery (`SpeechTimedUrlResponse`), each with the requested `words` and/or `characters` timings. A timed `url` request that cannot get a signed URL (zero-data-retention, missing workspace, or storage failure) returns the inline `{ audio, media_type }` envelope with no `url`.' + 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`.' '400': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 42e8fc35e..bd1afa1ee 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.808.1 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:b7a1d4a19b2b9ef84a7b299486f1c011d67d74bee59ec7547c8c81b98629aff4 - sourceBlobDigest: sha256:a74a543b711cbfb66a3c769a31b57bbb23b3332baf16e43fe250a42073fd59a1 + sourceRevisionDigest: sha256:6305b1e258dadea08c306870d09be1979085a71760e3530a97d4f1bfa55a101d + sourceBlobDigest: sha256:4d2b5ecedb5c99dd9a244f73a9eeaf9c66a570b6567f30f1847a772f28bafff5 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:b7a1d4a19b2b9ef84a7b299486f1c011d67d74bee59ec7547c8c81b98629aff4 - sourceBlobDigest: sha256:a74a543b711cbfb66a3c769a31b57bbb23b3332baf16e43fe250a42073fd59a1 + sourceRevisionDigest: sha256:6305b1e258dadea08c306870d09be1979085a71760e3530a97d4f1bfa55a101d + sourceBlobDigest: sha256:4d2b5ecedb5c99dd9a244f73a9eeaf9c66a570b6567f30f1847a772f28bafff5 codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:776e617aeb06d731f4e6a55a4df3ab44da6735b275ef238fadb98c3abb1669f8 + codeSamplesRevisionDigest: sha256:e2af5a57a798f82aa0a975d32be7653157771d6f7729d4dc58fc2a9fd0b2c0c0 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.808.1 diff --git a/RELEASES.md b/RELEASES.md index 3a935806a..25becf988 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6156,4 +6156,14 @@ Based on: ### Generated - [typescript v1.5.178] . ### Releases -- [NPM v1.5.178] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.178 - . \ No newline at end of file +- [NPM v1.5.178] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.178 - . + +## 2026-12-04 19:21:02 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.808.1 (2.960.8) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.5.179] . +### Releases +- [NPM v1.5.179] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.179 - . \ No newline at end of file diff --git a/docs/models/outputdelivery.mdx b/docs/models/outputdelivery.mdx index fbbe8297d..08f64917f 100644 --- a/docs/models/outputdelivery.mdx +++ b/docs/models/outputdelivery.mdx @@ -2,7 +2,7 @@ title: "OutputDelivery" --- -`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. +`stream` (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`. ## Example Usage diff --git a/docs/models/speechoutputmodality.mdx b/docs/models/speechoutputmodality.mdx index 95eecaa21..6a9b0554e 100644 --- a/docs/models/speechoutputmodality.mdx +++ b/docs/models/speechoutputmodality.mdx @@ -15,8 +15,8 @@ let value: SpeechOutputModality = { ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `languages` | *string*[] | ➖ | BCP 47 tags of the languages the provider documents for this output, for example `en`, `hi` or `pt-BR`. How the language is chosen (from the text, the voice, or a provider option) varies by provider. Absent: not described. | [
"en",
"fr",
"hi"
] | -| `supportedParameters` | [models.SpeechSupportedParameters](../models/speechsupportedparameters.mdx) | ✔️ | N/A | \{
"instructions": \{
"type": "unknown"
},
"response_format": \{
"type": "enum",
"values": [
"mp3",
"pcm"
]
},
"speed": \{
"max": 4,
"min": 0.25,
"type": "range"
},
"timestamp_granularities": \{
"type": "enum",
"values": [
"word",
"character"
]
},
"voice": \{
"type": "enum",
"values": [
"alloy",
"coral"
]
}
} | -| `type` | [models.SpeechOutputModalityType](../models/speechoutputmodalitytype.mdx) | ✔️ | N/A | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `languages` | *string*[] | ➖ | BCP 47 tags of the languages the provider documents for this output, for example `en`, `hi` or `pt-BR`. How the language is chosen (from the text, the voice, or a provider option) varies by provider. Absent: not described. | [
"en",
"fr",
"hi"
] | +| `supportedParameters` | [models.SpeechSupportedParameters](../models/speechsupportedparameters.mdx) | ✔️ | N/A | \{
"instructions": \{
"type": "unknown"
},
"response_format": \{
"type": "enum",
"values": [
"mp3",
"pcm"
]
},
"speed": \{
"max": 4,
"min": 0.25,
"type": "range"
},
"stream_format": \{
"type": "enum",
"values": [
"audio",
"sse"
]
},
"timestamp_granularities": \{
"type": "enum",
"values": [
"word",
"character"
]
},
"voice": \{
"type": "enum",
"values": [
"alloy",
"coral"
]
}
} | +| `type` | [models.SpeechOutputModalityType](../models/speechoutputmodalitytype.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/speechrequest.mdx b/docs/models/speechrequest.mdx index 4c04baf6b..5eb3ac3dc 100644 --- a/docs/models/speechrequest.mdx +++ b/docs/models/speechrequest.mdx @@ -17,18 +17,19 @@ let value: SpeechRequest = { ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `input` | *models.SpeechInput* | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | -| `inputReferences` | *models.SpeechInputReference*[] | ➖ | 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. Video mode: exactly one `video_url` part with a public http(s) URL, optionally with one to three `input_audio` parts (and their `text` transcripts) grouped as in audio mode, and no `image_url` part; Seed Audio 1.5 ignores those transcripts, so the words the voices speak go in `input`; only routed to endpoints that support video references (and voice cloning when clips are sent, plus multiple references for two or three clips). 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` | *string* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. For the selected endpoint in the [Speech Models API](https://openrouter.ai/docs/guides/overview/multimodal/tts#via-the-speech-models-api), look for `supported_parameters.instructions` in the `output_modalities` entry with `type: speech`. | Speak in a warm and friendly tone. | -| `model` | *string* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | -| `outputDelivery` | [models.OutputDelivery](../models/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. | stream | -| `provider` | [models.SpeechRequestProvider](../models/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | -| `responseFormat` | [models.SpeechRequestResponseFormat](../models/speechrequestresponseformat.mdx) | ➖ | Audio output format. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. | pcm | -| `sessionId` | *string* | ➖ | 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` | *number* | ➖ | 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 | -| `timestampGranularities` | [models.TimestampGranularity](../models/timestampgranularity.mdx)[] | ➖ | Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. | [
"word"
] | -| `trace` | [models.TraceConfig](../models/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | -| `user` | *string* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | -| `voice` | *string* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `input` | *models.SpeechInput* | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world | +| `inputReferences` | *models.SpeechInputReference*[] | ➖ | 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. Video mode: exactly one `video_url` part with a public http(s) URL, optionally with one to three `input_audio` parts (and their `text` transcripts) grouped as in audio mode, and no `image_url` part; Seed Audio 1.5 ignores those transcripts, so the words the voices speak go in `input`; only routed to endpoints that support video references (and voice cloning when clips are sent, plus multiple references for two or three clips). 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` | *string* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. For the selected endpoint in the [Speech Models API](https://openrouter.ai/docs/guides/overview/multimodal/tts#via-the-speech-models-api), look for `supported_parameters.instructions` in the `output_modalities` entry with `type: speech`. | Speak in a warm and friendly tone. | +| `model` | *string* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 | +| `outputDelivery` | [models.OutputDelivery](../models/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` | [models.SpeechRequestProvider](../models/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | | +| `responseFormat` | [models.SpeechRequestResponseFormat](../models/speechrequestresponseformat.mdx) | ➖ | Audio output format. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. | pcm | +| `sessionId` | *string* | ➖ | 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` | *number* | ➖ | 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 | +| `streamFormat` | [models.StreamFormat](../models/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 | +| `timestampGranularities` | [models.TimestampGranularity](../models/timestampgranularity.mdx)[] | ➖ | Timings to return with the audio. With the default `stream_format: "audio"`, the response is buffered JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Buffered timed responses are sent once the whole audio is generated and are capped at 10 MiB of decoded audio (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input, a smaller audio format, or `stream_format: "sse"`. With `stream_format: "sse"`, the response is `text/event-stream` (`speech.audio.delta`, `speech.timestamps.delta`, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type` and no 10 MiB cap. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity for the requested `stream_format`. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse JSON (for `stream_format: "audio"`) or `text/event-stream` (for `stream_format: "sse"`). An empty array is treated as no timings. | [
"word"
] | +| `trace` | [models.TraceConfig](../models/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{
"trace_id": "trace-abc123",
"trace_name": "my-app-trace"
} | +| `user` | *string* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 | +| `voice` | *string* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en_paul_neutral | \ No newline at end of file diff --git a/docs/models/speechsupportedparameters.mdx b/docs/models/speechsupportedparameters.mdx index 2d993fde5..a1bcd0050 100644 --- a/docs/models/speechsupportedparameters.mdx +++ b/docs/models/speechsupportedparameters.mdx @@ -17,5 +17,6 @@ let value: SpeechSupportedParameters = {}; | `instructions` | [models.SpeechUnknownParameter](../models/speechunknownparameter.mdx) | ➖ | N/A | \{
"type": "unknown"
} | | `responseFormat` | [models.SpeechEnumParameter](../models/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `speed` | [models.SpeechRangeParameter](../models/speechrangeparameter.mdx) | ➖ | The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`. | \{
"max": 4,
"min": 0.25,
"type": "range"
} | +| `streamFormat` | [models.SpeechEnumParameter](../models/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `timestampGranularities` | [models.SpeechEnumParameter](../models/speechenumparameter.mdx) | ➖ | N/A | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | | `voice` | [models.SpeechVoiceParameter](../models/speechvoiceparameter.mdx) | ➖ | `enum` lists the documented voices in `values`; some providers also accept voice IDs not listed there (custom or cloned voices). `unknown` means the field is accepted but no voices are listed. | \{
"type": "enum",
"values": [
"alloy",
"coral"
]
} | \ No newline at end of file diff --git a/docs/models/streamformat.mdx b/docs/models/streamformat.mdx new file mode 100644 index 000000000..e879ff867 --- /dev/null +++ b/docs/models/streamformat.mdx @@ -0,0 +1,21 @@ +--- +title: "StreamFormat" +--- + +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`. + +## Example Usage + +```typescript +import { StreamFormat } from "@openrouter/sdk/models"; + +let value: StreamFormat = "audio"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"audio" | "sse" | Unrecognized +``` \ No newline at end of file diff --git a/jsr.json b/jsr.json index 2bb6a6dc1..1a1fa439b 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.5.178", + "version": "1.5.179", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index efd3ab032..33b532533 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.5.178", + "version": "1.5.179", "author": "OpenRouter", "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.", "keywords": [ @@ -74,14 +74,14 @@ "build": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", "prepublishOnly": "npm run build", "compile": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", - "test:transit": "exit 0", - "test:watch": "vitest --watch --project unit", - "typecheck": "tsc --noEmit", - "typecheck:transit": "exit 0", "postinstall": "node scripts/check-types.js || true", "prepare": "npm run build", "test": "vitest --run --project unit", - "test:e2e": "vitest --run --project e2e" + "test:watch": "vitest --watch --project unit", + "typecheck": "tsc --noEmit", + "test:e2e": "vitest --run --project e2e", + "test:transit": "exit 0", + "typecheck:transit": "exit 0" }, "peerDependencies": { diff --git a/src/lib/config.ts b/src/lib/config.ts index 98687633a..c9c26e960 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -74,7 +74,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "1.5.178", + sdkVersion: "1.5.179", genVersion: "2.960.8", - userAgent: "speakeasy-sdk/typescript 1.5.178 2.960.8 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.5.179 2.960.8 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/speechrequest.ts b/src/models/speechrequest.ts index 108290ba2..c113643ae 100644 --- a/src/models/speechrequest.ts +++ b/src/models/speechrequest.ts @@ -29,14 +29,14 @@ import { } from "./traceconfig.js"; /** - * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. + * `stream` (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`. */ export const OutputDelivery = { Stream: "stream", Url: "url", } as const; /** - * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. + * `stream` (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`. */ export type OutputDelivery = OpenEnum; @@ -128,6 +128,18 @@ export type SpeechRequestResponseFormat = OpenEnum< typeof SpeechRequestResponseFormat >; +/** + * 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`. + */ +export const StreamFormat = { + Audio: "audio", + Sse: "sse", +} as const; +/** + * 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`. + */ +export type StreamFormat = OpenEnum; + export const TimestampGranularity = { Word: "word", Character: "character", @@ -155,7 +167,7 @@ export type SpeechRequest = { */ model: string; /** - * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. + * `stream` (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`. */ outputDelivery?: OutputDelivery | undefined; /** @@ -175,7 +187,11 @@ export type SpeechRequest = { */ speed?: number | undefined; /** - * Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings. + * 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`. + */ + streamFormat?: StreamFormat | undefined; + /** + * Timings to return with the audio. With the default `stream_format: "audio"`, the response is buffered JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Buffered timed responses are sent once the whole audio is generated and are capped at 10 MiB of decoded audio (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input, a smaller audio format, or `stream_format: "sse"`. With `stream_format: "sse"`, the response is `text/event-stream` (`speech.audio.delta`, `speech.timestamps.delta`, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type` and no 10 MiB cap. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity for the requested `stream_format`. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse JSON (for `stream_format: "audio"`) or `text/event-stream` (for `stream_format: "sse"`). An empty array is treated as no timings. */ timestampGranularities?: Array | undefined; /** @@ -302,6 +318,10 @@ export const SpeechRequestResponseFormat$outboundSchema: z.ZodType< SpeechRequestResponseFormat > = openEnums.outboundSchema(SpeechRequestResponseFormat); +/** @internal */ +export const StreamFormat$outboundSchema: z.ZodType = + openEnums.outboundSchema(StreamFormat); + /** @internal */ export const TimestampGranularity$outboundSchema: z.ZodType< string, @@ -319,6 +339,7 @@ export type SpeechRequest$Outbound = { response_format?: string | undefined; session_id?: string | undefined; speed?: number | undefined; + stream_format?: string | undefined; timestamp_granularities?: Array | undefined; trace?: TraceConfig$Outbound | undefined; user?: string | undefined; @@ -339,6 +360,7 @@ export const SpeechRequest$outboundSchema: z.ZodType< responseFormat: SpeechRequestResponseFormat$outboundSchema.optional(), sessionId: z.string().optional(), speed: z.number().optional(), + streamFormat: StreamFormat$outboundSchema.optional(), timestampGranularities: z.array(TimestampGranularity$outboundSchema) .optional(), trace: TraceConfig$outboundSchema.optional(), @@ -350,6 +372,7 @@ export const SpeechRequest$outboundSchema: z.ZodType< outputDelivery: "output_delivery", responseFormat: "response_format", sessionId: "session_id", + streamFormat: "stream_format", timestampGranularities: "timestamp_granularities", }); }); diff --git a/src/models/speechsupportedparameters.ts b/src/models/speechsupportedparameters.ts index 466a67531..8dbe8b82d 100644 --- a/src/models/speechsupportedparameters.ts +++ b/src/models/speechsupportedparameters.ts @@ -31,6 +31,7 @@ export type SpeechSupportedParameters = { * The accepted `speed` range. Absent: the provider documents no range; some providers still forward `speed`. */ speed?: SpeechRangeParameter | undefined; + streamFormat?: SpeechEnumParameter | undefined; timestampGranularities?: SpeechEnumParameter | undefined; /** * `enum` lists the documented voices in `values`; some providers also accept voice IDs not listed there (custom or cloned voices). `unknown` means the field is accepted but no voices are listed. @@ -46,11 +47,13 @@ export const SpeechSupportedParameters$inboundSchema: z.ZodType< instructions: SpeechUnknownParameter$inboundSchema.optional(), response_format: SpeechEnumParameter$inboundSchema.optional(), speed: SpeechRangeParameter$inboundSchema.optional(), + stream_format: SpeechEnumParameter$inboundSchema.optional(), timestamp_granularities: SpeechEnumParameter$inboundSchema.optional(), voice: SpeechVoiceParameter$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "response_format": "responseFormat", + "stream_format": "streamFormat", "timestamp_granularities": "timestampGranularities", }); });