From 75b39aa606c85b909f0b4584cdf7d752dbc41923 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 3 Dec 2026 20:31:47 +0000 Subject: [PATCH] ## Typescript SDK Changes: * `openrouter.tts.createSpeech()`: * `request.speechRequest.timestampGranularities` **Added** * `error.status[504]` **Added** * `openrouter.tts.listModels()`: `response.data[].endpoints[].outputModalities[].supportedParameters.timestampGranularities` **Added** * `openrouter.tts.getModel()`: `response.endpoints[].outputModalities[].supportedParameters.timestampGranularities` **Added** --- .speakeasy/gen.lock | 17 +- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 152 +++++++++++++++++- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/models/keybudget.mdx | 22 +-- docs/models/outputdelivery.mdx | 2 +- docs/models/scimgrouppolicyassignment.mdx | 2 +- .../scimgrouppolicyassignmentresponse.mdx | 6 +- docs/models/speechoutputmodality.mdx | 10 +- docs/models/speechrequest.mdx | 29 ++-- docs/models/speechsupportedparameters.mdx | 1 + docs/models/timestampgranularity.mdx | 19 +++ docs/sdks/tts/README.mdx | 1 + jsr.json | 2 +- package.json | 10 +- src/funcs/ttsCreateSpeech.ts | 4 + src/lib/config.ts | 4 +- src/models/keybudget.ts | 2 +- src/models/scimgrouppolicyassignment.ts | 2 +- .../scimgrouppolicyassignmentresponse.ts | 2 +- src/models/speechrequest.ts | 26 ++- src/models/speechsupportedparameters.ts | 3 + 23 files changed, 270 insertions(+), 70 deletions(-) create mode 100644 docs/models/timestampgranularity.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f1a401502..8db4fce9b 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: "" id: "" management: - docChecksum: e082caf3723ab1e222f73325c2ef3e49 + docChecksum: 2c831a797619337ab7c5a3c81a0a5f84 docVersion: 1.0.0 speakeasyVersion: 1.808.1 generationVersion: 2.960.8 - releaseVersion: 1.5.170 - configChecksum: 42293044358dde5d13b2f633f5b58c5d + releaseVersion: 1.5.171 + configChecksum: 208880cb93f8e9dc086876a1045e3dbb repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true @@ -13061,6 +13061,7 @@ trackedFiles: docs/models/thinkingenabled.mdx: id: 03cfcb6908ac pristine_git_object: 42ab67d0f0d7fcdfe02685b1b706fd0517adc513 + docs/models/timestampgranularity.mdx: {} docs/models/timings.md: id: eb749976982c last_write_checksum: sha1:43ecebedd106bbffffaaa1d7d7656a4ec6a58b95 @@ -19792,6 +19793,8 @@ examples: application/json: {"error": {"code": 413, "message": "Request payload too large"}} "403": application/json: {"error": {"code": 403, "message": "Only management keys can perform this operation"}} + "504": + application/json: {"error": {"code": 504, "message": "The operation was aborted due to timeout"}} createAudioTranscriptions: speakeasy-default-create-audio-transcriptions: requestBody: @@ -24208,10 +24211,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 -releaseNotes: | - ## Typescript SDK Changes: - * `openrouter.embeddings.listModels()`: `response.data[].isOpenWeight` **Added** - * `openrouter.models.get()`: `response.data.isOpenWeight` **Added** - * `openrouter.models.list()`: `response.data[].isOpenWeight` **Added** - * `openrouter.models.listForUser()`: `response.data[].isOpenWeight` **Added** - * `openrouter.rerank.listModels()`: `response.data[].isOpenWeight` **Added** +releaseNotes: "## Typescript SDK Changes:\n* `openrouter.tts.createSpeech()`: \n * `request.speechRequest.timestampGranularities` **Added**\n * `error.status[504]` **Added**\n* `openrouter.tts.listModels()`: `response.data[].endpoints[].outputModalities[].supportedParameters.timestampGranularities` **Added**\n* `openrouter.tts.getModel()`: `response.endpoints[].outputModalities[].supportedParameters.timestampGranularities` **Added**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 81fbde521..22ce406fc 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -38,7 +38,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.5.170 + version: 1.5.171 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 1402af9dd..1b066be08 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -24,6 +24,19 @@ components: type: string description: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + responses: + SpeechTimedAudio: + content: + application/json: + schema: + $ref: '#/components/schemas/SpeechTimedAudioResponse' + description: 'Speech request with `timestamp_granularities`: base64 audio plus the requested timings.' + SpeechTimedUrl: + content: + application/json: + schema: + $ref: '#/components/schemas/SpeechTimedUrlResponse' + description: 'Speech request with `timestamp_granularities` and `output_delivery: url`: the signed download URL plus the requested timings.' schemas: AABenchmarkEntry: description: 'Benchmark index scores published by Artificial Analysis (artificialanalysis.ai), one field per index. Each score is the model''s best on that index across the configurations Artificial Analysis evaluated (for example reasoning levels), so two indexes of one model can come from different configurations. The deprecated Coding Index and Agentic Index fields are null for every model: Artificial Analysis has retired those indexes. Attribute Artificial Analysis when you republish them. Omitted when Artificial Analysis has scored the model on none of them.' @@ -19350,7 +19363,7 @@ components: - 'string' - 'null' guardrail_id: - description: 'ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes.' + description: 'ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list.' example: '0df9e665-d932-5740-b2c7-b52af166bc11' type: - 'string' @@ -35420,7 +35433,7 @@ components: - 'policy_type' type: 'object' ScimGroupPolicyAssignment: - description: 'Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).' + description: 'Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan).' example: budget: '6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f' model_availability: null @@ -36835,7 +36848,7 @@ components: example: 'mistralai/voxtral-mini-tts-2603' type: 'string' output_delivery: - description: '`stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace.' + description: '`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`.' enum: - 'stream' - 'url' @@ -36927,6 +36940,17 @@ components: example: 1 format: 'double' type: 'number' + timestamp_granularities: + description: 'Timings to return with the audio. When nonempty, the response is JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity (`supported_parameters.timestamp_granularities` on the speech models list). A timed response is sent once the whole audio is generated, not streamed, and is capped at 10 MiB of decoded audio for both inline and `url` delivery (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input or a smaller audio format. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse the JSON response when using `timestamp_granularities`. An empty array is treated as no timings.' + example: + - 'word' + items: + enum: + - 'word' + - 'character' + type: 'string' + x-speakeasy-unknown-values: allow + type: 'array' trace: $ref: '#/components/schemas/TraceConfig' user: @@ -36943,6 +36967,30 @@ components: - 'model' - 'input' type: 'object' + SpeechSignedUrlResponse: + description: 'JSON response containing a signed download URL for generated speech audio.' + example: + expires_at: 1748458800 + media_type: 'audio/mpeg' + url: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + properties: + expires_at: + description: 'Unix timestamp (seconds) when the signed download URL expires.' + example: 1748458800 + type: 'integer' + media_type: + description: 'MIME type of the generated audio (for example `audio/mpeg` for mp3 or `audio/pcm;rate=24000;channels=1` for pcm).' + example: 'audio/mpeg' + type: 'string' + url: + description: 'Signed download URL for the generated audio, valid until `expires_at` (up to 24 hours).' + example: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + type: 'string' + required: + - 'url' + - 'expires_at' + - 'media_type' + type: 'object' SpeechSupportedParameters: example: instructions: @@ -36956,6 +37004,11 @@ components: max: 4 min: 0.25 type: 'range' + timestamp_granularities: + type: 'enum' + values: + - 'word' + - 'character' voice: type: 'enum' values: @@ -36968,9 +37021,90 @@ components: $ref: '#/components/schemas/SpeechEnumParameter' speed: $ref: '#/components/schemas/SpeechRangeParameter' + timestamp_granularities: + allOf: + - $ref: '#/components/schemas/SpeechEnumParameter' + - description: 'The `timestamp_granularities` values the endpoint can return (`word`, `character`). Absent: timings are not supported.' voice: $ref: '#/components/schemas/SpeechVoiceParameter' type: 'object' + SpeechTimedAudioResponse: + description: 'JSON response for a request with `timestamp_granularities`: the audio as base64 plus the requested timings.' + example: + audio: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + media_type: 'audio/mpeg' + words: + - end: 0.42 + start: 0 + text: 'Hello' + properties: + audio: + description: 'Base64-encoded audio in the format named by `media_type`.' + example: 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYw' + type: 'string' + characters: + description: 'Character timings, present when `timestamp_granularities` includes `character`.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + media_type: + description: 'MIME type of the generated audio (for example `audio/mpeg` for mp3 or `audio/pcm;rate=24000;channels=1` for pcm).' + example: 'audio/mpeg' + type: 'string' + words: + description: 'Word timings, present when `timestamp_granularities` includes `word`. Grouped from character timings by splitting on whitespace, so unspaced scripts (such as Japanese or Chinese) may return one span per unspaced run.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + required: + - 'audio' + - 'media_type' + type: 'object' + SpeechTimedUrlResponse: + allOf: + - $ref: '#/components/schemas/SpeechSignedUrlResponse' + - properties: + characters: + description: 'Character timings, present when `timestamp_granularities` includes `character`.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + words: + description: 'Word timings, present when `timestamp_granularities` includes `word`. Grouped from character timings by splitting on whitespace, so unspaced scripts (such as Japanese or Chinese) may return one span per unspaced run.' + items: + $ref: '#/components/schemas/SpeechTimestamp' + type: 'array' + type: 'object' + description: 'Signed download URL response for a request with `timestamp_granularities`, plus the requested timings.' + example: + characters: + - end: 0.064 + start: 0 + text: 'H' + expires_at: 1748458800 + media_type: 'audio/mpeg' + url: 'https://openrouter.ai/api/v1/audio/speech/media/abcdefghijklmnopqrstuvwxyz0123456789abcdefg' + SpeechTimestamp: + properties: + end: + description: 'End time in seconds from the beginning of the audio' + example: 0.42 + format: 'double' + type: 'number' + start: + description: 'Start time in seconds from the beginning of the audio' + example: 0 + format: 'double' + type: 'number' + text: + description: 'The aligned input word or character (follows the input text, not normalized spoken text)' + example: 'Hello' + type: 'string' + required: + - 'text' + - 'start' + - 'end' + type: 'object' SpeechTurn: properties: instructions: @@ -43888,7 +44022,7 @@ paths: example: '' format: 'binary' type: 'string' - description: 'Raw audio bytes stream (`audio/*`) by default. When `output_delivery` is `"url"`, returns `application/json` with `{ url, expires_at, media_type }` (a 24-hour signed download URL) unless zero-data-retention or missing workspace causes fallback to raw audio streaming.' + description: 'Raw audio bytes stream (`audio/*`) by default. When `output_delivery` is `"url"`, returns `application/json` with `{ url, expires_at, media_type }` (a 24-hour signed download URL) unless zero-data-retention or missing workspace causes fallback to raw audio streaming. When `timestamp_granularities` is nonempty, always returns `application/json`: `{ audio, media_type }` with base64 audio (`SpeechTimedAudioResponse`), or `{ url, expires_at, media_type }` with URL delivery (`SpeechTimedUrlResponse`), each with the requested `words` and/or `characters` timings. A timed `url` request that cannot get a signed URL (zero-data-retention, missing workspace, or storage failure) returns the inline `{ audio, media_type }` envelope with no `url`.' '400': content: application/json: @@ -43989,6 +44123,16 @@ paths: schema: $ref: '#/components/schemas/ServiceUnavailableResponse' description: 'Service Unavailable - Service temporarily unavailable' + '504': + content: + application/json: + example: + error: + code: 504 + message: 'The operation was aborted due to timeout' + schema: + $ref: '#/components/schemas/GatewayTimeoutResponse' + description: 'Gateway Timeout - Provider did not respond before the upstream deadline' '524': content: application/json: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 05a4d2e1a..8e36ccc53 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:8d8dc2c91d068c4499b71b16c8c1260eb9282641f1af9613d09162d5b128f7d1 - sourceBlobDigest: sha256:29576fe252c6bbfd1d5ca446e664bfcca4f8169c9ad32fee59b25e45cb1775de + sourceRevisionDigest: sha256:f451fed3ca9ab29c36729d99441e2a0a9c3b0df59377a2f90c1bdeac8ddb9682 + sourceBlobDigest: sha256:ec51fa6a1b780f14bfa1d8b9224ef6eb2553dc373aa19b42496d4359d84d408a tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:8d8dc2c91d068c4499b71b16c8c1260eb9282641f1af9613d09162d5b128f7d1 - sourceBlobDigest: sha256:29576fe252c6bbfd1d5ca446e664bfcca4f8169c9ad32fee59b25e45cb1775de + sourceRevisionDigest: sha256:f451fed3ca9ab29c36729d99441e2a0a9c3b0df59377a2f90c1bdeac8ddb9682 + sourceBlobDigest: sha256:ec51fa6a1b780f14bfa1d8b9224ef6eb2553dc373aa19b42496d4359d84d408a codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:1660272311a578fc58453e85a3470650274df8133559783956c1eee298bac5fb + codeSamplesRevisionDigest: sha256:e948c8939afb92e767837f3bf198919096d78b3039ecde8dc5970c371fd3c21a workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.808.1 diff --git a/RELEASES.md b/RELEASES.md index 84e6a9e0e..09fa8de70 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6076,4 +6076,14 @@ Based on: ### Generated - [typescript v1.5.170] . ### Releases -- [NPM v1.5.170] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.170 - . \ No newline at end of file +- [NPM v1.5.170] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.170 - . + +## 2026-12-03 20:29:44 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.808.1 (2.960.8) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.5.171] . +### Releases +- [NPM v1.5.171] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.171 - . \ No newline at end of file diff --git a/docs/models/keybudget.mdx b/docs/models/keybudget.mdx index e071464f3..c856ede42 100644 --- a/docs/models/keybudget.mdx +++ b/docs/models/keybudget.mdx @@ -24,14 +24,14 @@ let value: KeyBudget = { ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `budgetId` | *string* | ✔️ | ID of the workspace budget for the `workspace` scope; null for other scopes. | null | -| `guardrailId` | *string* | ✔️ | ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes. | 0df9e665-d932-5740-b2c7-b52af166bc11 | -| `includeByok` | *boolean* | ✔️ | Whether external BYOK inference spend counts toward this budget. | false | -| `limitUsd` | *number* | ✔️ | Budget limit in USD for the current window. | 50 | -| `remainingUsd` | *number* | ✔️ | `limit_usd - spend_usd`. Zero or negative means this layer rejects requests with a 403 until it resets. | 17.5 | -| `resetInterval` | [models.KeyBudgetResetInterval](../models/keybudgetresetinterval.mdx) | ✔️ | UTC window the spend is counted over (weeks start Monday); null for a lifetime budget that never resets. | weekly | -| `resetsAt` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | ✔️ | ISO 8601 UTC instant at which the window rolls over and spend returns to zero; null for a lifetime budget. | 2026-10-12T00:00:00.000Z | -| `scope` | [models.KeyBudgetScope](../models/keybudgetscope.mdx) | ✔️ | Which budget layer this is, in the order enforcement checks them: the workspace default guardrail against the member aggregate (`workspace_default_member`) and against this key (`workspace_default_key`), the member guardrail (`member`), the API key guardrail (`api_key`), a workspace budget (`workspace`), or the key's own limit (`key_limit`). | member | -| `spendUsd` | *number* | ✔️ | Spend in USD that enforcement counts against this limit in the current window: the member aggregate for member-scoped layers, otherwise this key or workspace. | 32.5 | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `budgetId` | *string* | ✔️ | ID of the workspace budget for the `workspace` scope; null for other scopes. | null | +| `guardrailId` | *string* | ✔️ | ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list. | 0df9e665-d932-5740-b2c7-b52af166bc11 | +| `includeByok` | *boolean* | ✔️ | Whether external BYOK inference spend counts toward this budget. | false | +| `limitUsd` | *number* | ✔️ | Budget limit in USD for the current window. | 50 | +| `remainingUsd` | *number* | ✔️ | `limit_usd - spend_usd`. Zero or negative means this layer rejects requests with a 403 until it resets. | 17.5 | +| `resetInterval` | [models.KeyBudgetResetInterval](../models/keybudgetresetinterval.mdx) | ✔️ | UTC window the spend is counted over (weeks start Monday); null for a lifetime budget that never resets. | weekly | +| `resetsAt` | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | ✔️ | ISO 8601 UTC instant at which the window rolls over and spend returns to zero; null for a lifetime budget. | 2026-10-12T00:00:00.000Z | +| `scope` | [models.KeyBudgetScope](../models/keybudgetscope.mdx) | ✔️ | Which budget layer this is, in the order enforcement checks them: the workspace default guardrail against the member aggregate (`workspace_default_member`) and against this key (`workspace_default_key`), the member guardrail (`member`), the API key guardrail (`api_key`), a workspace budget (`workspace`), or the key's own limit (`key_limit`). | member | +| `spendUsd` | *number* | ✔️ | Spend in USD that enforcement counts against this limit in the current window: the member aggregate for member-scoped layers, otherwise this key or workspace. | 32.5 | \ No newline at end of file diff --git a/docs/models/outputdelivery.mdx b/docs/models/outputdelivery.mdx index 0ad81b3e9..fbbe8297d 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. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. +`stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. ## Example Usage diff --git a/docs/models/scimgrouppolicyassignment.mdx b/docs/models/scimgrouppolicyassignment.mdx index faf8cc614..0d0bab556 100644 --- a/docs/models/scimgrouppolicyassignment.mdx +++ b/docs/models/scimgrouppolicyassignment.mdx @@ -2,7 +2,7 @@ title: "ScimGroupPolicyAssignment" --- -Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). +Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). ## Example Usage diff --git a/docs/models/scimgrouppolicyassignmentresponse.mdx b/docs/models/scimgrouppolicyassignmentresponse.mdx index 3aaf9aeab..fe38a8284 100644 --- a/docs/models/scimgrouppolicyassignmentresponse.mdx +++ b/docs/models/scimgrouppolicyassignmentresponse.mdx @@ -22,6 +22,6 @@ let value: ScimGroupPolicyAssignmentResponse = { ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `data` | [models.ScimGroupPolicyAssignment](../models/scimgrouppolicyassignment.mdx) | ✔️ | Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). | \{
"budget": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
"model_availability": null,
"moderation": null,
"rate_limit": null,
"scim_group_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
"scim_group_mapping_id": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"workspace_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `data` | [models.ScimGroupPolicyAssignment](../models/scimgrouppolicyassignment.mdx) | ✔️ | Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). | \{
"budget": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
"model_availability": null,
"moderation": null,
"rate_limit": null,
"scim_group_id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
"scim_group_mapping_id": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
"workspace_id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
} | \ No newline at end of file diff --git a/docs/models/speechoutputmodality.mdx b/docs/models/speechoutputmodality.mdx index fc1211b74..95eecaa21 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"
},
"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"
},
"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 9a4721352..61b3cdd52 100644 --- a/docs/models/speechrequest.mdx +++ b/docs/models/speechrequest.mdx @@ -17,17 +17,18 @@ 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. 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. 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` | *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. `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` | [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 | 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 | -| `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. 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. 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` | *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 | 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`. 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 diff --git a/docs/models/speechsupportedparameters.mdx b/docs/models/speechsupportedparameters.mdx index 6fe245448..2d993fde5 100644 --- a/docs/models/speechsupportedparameters.mdx +++ b/docs/models/speechsupportedparameters.mdx @@ -17,4 +17,5 @@ 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"
} | +| `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/timestampgranularity.mdx b/docs/models/timestampgranularity.mdx new file mode 100644 index 000000000..622b0bf6f --- /dev/null +++ b/docs/models/timestampgranularity.mdx @@ -0,0 +1,19 @@ +--- +title: "TimestampGranularity" +--- + +## Example Usage + +```typescript +import { TimestampGranularity } from "@openrouter/sdk/models"; + +let value: TimestampGranularity = "word"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"word" | "character" | Unrecognized +``` \ No newline at end of file diff --git a/docs/sdks/tts/README.mdx b/docs/sdks/tts/README.mdx index 20c740c68..0b863a6c8 100644 --- a/docs/sdks/tts/README.mdx +++ b/docs/sdks/tts/README.mdx @@ -109,6 +109,7 @@ run(); | errors.InternalServerResponseError | 500 | application/json | | errors.BadGatewayResponseError | 502 | application/json | | errors.ServiceUnavailableResponseError | 503 | application/json | +| errors.GatewayTimeoutResponseError | 504 | application/json | | errors.EdgeNetworkTimeoutResponseError | 524 | application/json | | errors.ProviderOverloadedResponseError | 529 | application/json | | errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | diff --git a/jsr.json b/jsr.json index 35f6c8edf..ad7898906 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.5.170", + "version": "1.5.171", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 9e229a75d..93a194fb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.5.170", + "version": "1.5.171", "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": [ @@ -73,15 +73,15 @@ "lint": "eslint --cache --max-warnings=0 src", "build": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", "prepublishOnly": "npm run build", - "typecheck:transit": "exit 0", "postinstall": "node scripts/check-types.js || true", - "test": "vitest --run --project unit", + "test:e2e": "vitest --run --project e2e", "test:transit": "exit 0", + "test:watch": "vitest --watch --project unit", "typecheck": "tsc --noEmit", "compile": "node --max-old-space-size=8192 ./node_modules/typescript/bin/tsc && node scripts/unbarrel-imports.js", "prepare": "npm run build", - "test:e2e": "vitest --run --project e2e", - "test:watch": "vitest --watch --project unit" + "test": "vitest --run --project unit", + "typecheck:transit": "exit 0" }, "peerDependencies": { diff --git a/src/funcs/ttsCreateSpeech.ts b/src/funcs/ttsCreateSpeech.ts index 0135f7f12..de62aae75 100644 --- a/src/funcs/ttsCreateSpeech.ts +++ b/src/funcs/ttsCreateSpeech.ts @@ -50,6 +50,7 @@ export function ttsCreateSpeech( | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError + | errors.GatewayTimeoutResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError @@ -87,6 +88,7 @@ async function $do( | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError + | errors.GatewayTimeoutResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError @@ -206,6 +208,7 @@ async function $do( | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError + | errors.GatewayTimeoutResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError @@ -232,6 +235,7 @@ async function $do( M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.jsonErr(502, errors.BadGatewayResponseError$inboundSchema), M.jsonErr(503, errors.ServiceUnavailableResponseError$inboundSchema), + M.jsonErr(504, errors.GatewayTimeoutResponseError$inboundSchema), M.jsonErr(524, errors.EdgeNetworkTimeoutResponseError$inboundSchema), M.jsonErr(529, errors.ProviderOverloadedResponseError$inboundSchema), M.fail("4XX"), diff --git a/src/lib/config.ts b/src/lib/config.ts index 644b31495..68b1d72d5 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.170", + sdkVersion: "1.5.171", genVersion: "2.960.8", - userAgent: "speakeasy-sdk/typescript 1.5.170 2.960.8 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.5.171 2.960.8 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/keybudget.ts b/src/models/keybudget.ts index 8da8df6d0..3238c23ca 100644 --- a/src/models/keybudget.ts +++ b/src/models/keybudget.ts @@ -48,7 +48,7 @@ export type KeyBudget = { */ budgetId: string | null; /** - * ID of the budget that applies at this layer: a guardrail policy ID (look it up with `GET /api/v1/guardrails/policies`) or, for accounts still on v1 guardrails, a guardrail ID. Null for the `workspace` and `key_limit` scopes. + * ID of the guardrail policy whose budget applies at this layer. A budget still managed through v1 guardrails reports its synced policy ID, not its guardrail ID. Null for the `workspace` and `key_limit` scopes. Look up a policy ID with a management key that has guardrail read access (for a Custom key, select the `guardrails:read` grant): `GET /api/v1/guardrails/policies/budget/{id}` (an organization-wide key must add `?workspace_id=`, for example the `workspace_id` this endpoint returns), or find an account-level policy in `GET /api/v1/guardrails/policies/account` (organization-wide key only). A workspace-scoped key can read only policies its workspace owns, so it gets 404 for an account-level policy, such as an inherited account default or a policy synced from a v1 guardrail assigned only to members or API keys; look those up with an organization-wide key and `?workspace_id=`. Policies synced from v1 guardrails assigned only to members or API keys can be missing from the account-level list. */ guardrailId: string | null; /** diff --git a/src/models/scimgrouppolicyassignment.ts b/src/models/scimgrouppolicyassignment.ts index c4a4fb5d1..739b8ca50 100644 --- a/src/models/scimgrouppolicyassignment.ts +++ b/src/models/scimgrouppolicyassignment.ts @@ -9,7 +9,7 @@ import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; /** - * Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). + * Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). */ export type ScimGroupPolicyAssignment = { budget: string | null; diff --git a/src/models/scimgrouppolicyassignmentresponse.ts b/src/models/scimgrouppolicyassignmentresponse.ts index 8b8dd3f31..3bd0bce68 100644 --- a/src/models/scimgrouppolicyassignmentresponse.ts +++ b/src/models/scimgrouppolicyassignmentresponse.ts @@ -13,7 +13,7 @@ import { export type ScimGroupPolicyAssignmentResponse = { /** - * Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the least restrictive policy of each type applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). + * Guardrail policy attached to a SCIM group mapping for each policy type, or `null` when none. Members receive the group policy unless they have a manual assignment or opted out; when a member is in several mapped groups, the most restrictive policy of each type applies, and when policies cannot be ranked against each other (for example, a daily and a monthly budget), the policy from the newest mapping applies. `rate_limit` is `null` unless capacity policies are enabled for the account (Enterprise-only feature with a custom plan). */ data: ScimGroupPolicyAssignment; }; diff --git a/src/models/speechrequest.ts b/src/models/speechrequest.ts index 0a405ebef..bce50a5d7 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. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. + * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. */ export const OutputDelivery = { Stream: "stream", Url: "url", } as const; /** - * `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. + * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. */ export type OutputDelivery = OpenEnum; @@ -128,6 +128,12 @@ export type SpeechRequestResponseFormat = OpenEnum< typeof SpeechRequestResponseFormat >; +export const TimestampGranularity = { + Word: "word", + Character: "character", +} as const; +export type TimestampGranularity = OpenEnum; + /** * Text-to-speech request input */ @@ -149,7 +155,7 @@ export type SpeechRequest = { */ model: string; /** - * `stream` (default) streams the audio bytes directly in the response body. `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type`. The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. Falls back to streaming raw audio bytes when a URL cannot be issued because zero-data-retention applies (account settings, guardrails, `provider.zdr`, or a ZDR endpoint) or the request has no workspace. + * `stream` (default) streams the audio bytes directly in the response body (or returns inline base64 JSON when `timestamp_granularities` is nonempty). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. */ outputDelivery?: OutputDelivery | undefined; /** @@ -168,6 +174,10 @@ export type SpeechRequest = { * 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. */ 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`. 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. + */ + timestampGranularities?: Array | undefined; /** * 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. */ @@ -292,6 +302,12 @@ export const SpeechRequestResponseFormat$outboundSchema: z.ZodType< SpeechRequestResponseFormat > = openEnums.outboundSchema(SpeechRequestResponseFormat); +/** @internal */ +export const TimestampGranularity$outboundSchema: z.ZodType< + string, + TimestampGranularity +> = openEnums.outboundSchema(TimestampGranularity); + /** @internal */ export type SpeechRequest$Outbound = { input: SpeechInput$Outbound; @@ -303,6 +319,7 @@ export type SpeechRequest$Outbound = { response_format: string; session_id?: string | undefined; speed?: number | undefined; + timestamp_granularities?: Array | undefined; trace?: TraceConfig$Outbound | undefined; user?: string | undefined; voice?: string | undefined; @@ -322,6 +339,8 @@ export const SpeechRequest$outboundSchema: z.ZodType< responseFormat: SpeechRequestResponseFormat$outboundSchema.default("pcm"), sessionId: z.string().optional(), speed: z.number().optional(), + timestampGranularities: z.array(TimestampGranularity$outboundSchema) + .optional(), trace: TraceConfig$outboundSchema.optional(), user: z.string().optional(), voice: z.string().optional(), @@ -331,6 +350,7 @@ export const SpeechRequest$outboundSchema: z.ZodType< outputDelivery: "output_delivery", responseFormat: "response_format", sessionId: "session_id", + timestampGranularities: "timestamp_granularities", }); }); diff --git a/src/models/speechsupportedparameters.ts b/src/models/speechsupportedparameters.ts index e9610de93..466a67531 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; + 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. */ @@ -45,10 +46,12 @@ export const SpeechSupportedParameters$inboundSchema: z.ZodType< instructions: SpeechUnknownParameter$inboundSchema.optional(), response_format: SpeechEnumParameter$inboundSchema.optional(), speed: SpeechRangeParameter$inboundSchema.optional(), + timestamp_granularities: SpeechEnumParameter$inboundSchema.optional(), voice: SpeechVoiceParameter$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "response_format": "responseFormat", + "timestamp_granularities": "timestampGranularities", }); });