From 30f6ca50a2bfca7db6f0ec49dd2137a76faf2e9d Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Thu, 3 Dec 2026 21:27:55 +0000 Subject: [PATCH] =?UTF-8?q?##=20Typescript=20SDK=20Changes:=20*=20`openrou?= =?UTF-8?q?ter.batch.createBatches()`:=20=20`response.results[].response.b?= =?UTF-8?q?ody`=20**Changed**=20(Breaking=20=E2=9A=A0=EF=B8=8F)=20*=20`ope?= =?UTF-8?q?nrouter.batch.getBatches()`:=20=20`response.results[].response.?= =?UTF-8?q?body`=20**Changed**=20(Breaking=20=E2=9A=A0=EF=B8=8F)=20*=20`op?= =?UTF-8?q?enrouter.batch.cancel()`:=20=20`response.results[].response.bod?= =?UTF-8?q?y`=20**Changed**=20(Breaking=20=E2=9A=A0=EF=B8=8F)=20*=20`openr?= =?UTF-8?q?outer.batch.getResults()`:=20=20`response.data[].response.body`?= =?UTF-8?q?=20**Changed**=20(Breaking=20=E2=9A=A0=EF=B8=8F)=20*=20`openrou?= =?UTF-8?q?ter.tts.createSpeech()`:=20=20=20*=20=20`request.speechRequest.?= =?UTF-8?q?inputReferences[].union(video=5Furl)`=20**Added**=20*=20`openro?= =?UTF-8?q?uter.tts.listModels()`:=20=20`response.data[].endpoints[].input?= =?UTF-8?q?Modalities[].union(video)`=20**Added**=20*=20`openrouter.tts.ge?= =?UTF-8?q?tModel()`:=20=20`response.endpoints[].inputModalities[].union(v?= =?UTF-8?q?ideo)`=20**Added**=20*=20`openrouter.presets.createPresetsMessa?= =?UTF-8?q?ges()`:=20=20=20*=20=20`request.messagesRequest.messages[].cont?= =?UTF-8?q?ent.union(Array<>)[]`=20**Changed**?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .speakeasy/gen.lock | 44 +-- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 253 ++++++++++++++++-- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/models/anthropicsafeguardresult.mdx | 26 ++ .../models/anthropicsafeguardresultstatus.mdx | 20 ++ docs/models/anthropicservertoolusage.mdx | 21 -- docs/models/anthropicservicetier.mdx | 19 -- docs/models/appliededit.mdx | 20 ++ .../batchimagegenerationmissingimage.mdx | 23 ++ docs/models/batchimagegenerationresponse.mdx | 15 +- docs/models/batchresultcontextmanagement.mdx | 19 ++ .../batchresultdeferredtoolsdetails.mdx | 25 ++ docs/models/batchresultusage2.mdx | 56 ++-- docs/models/body.mdx | 26 +- docs/models/bodymessage.mdx | 56 ++-- docs/models/messagesmcptoolresultblock.mdx | 26 ++ .../messagesmcptoolresultblockcontent.mdx | 23 ++ docs/models/messagesmcptooluseblock.mdx | 29 ++ .../messagesmessageparamcontentunion4.mdx | 20 ++ docs/models/messagesrequest.mdx | 2 +- ...x => messagesrequestcontextmanagement.mdx} | 6 +- docs/models/oranthropicservertoolusage.mdx | 23 ++ docs/models/speechinputmodality.mdx | 16 +- .../speechinputmodalitysupportedinputs3.mdx | 24 ++ docs/models/speechinputmodalityvideo.mdx | 26 ++ docs/models/speechinputreference.mdx | 11 + docs/models/speechinputreferencevideo.mdx | 25 ++ .../models/speechinputreferencevideoinput.mdx | 21 ++ docs/models/speechrequest.mdx | 2 +- jsr.json | 2 +- package.json | 8 +- src/lib/config.ts | 4 +- src/models/anthropicsafeguardresult.ts | 70 +++++ src/models/anthropicservicetier.ts | 20 -- .../batchimagegenerationmissingimage.ts | 41 +++ src/models/batchimagegenerationresponse.ts | 11 + src/models/batchresult.ts | 154 ++++++++++- src/models/index.ts | 9 +- src/models/messagesmcptoolresultblock.ts | 93 +++++++ src/models/messagesmcptooluseblock.ts | 62 +++++ src/models/messagesmessageparam.ts | 32 ++- src/models/messagesrequest.ts | 30 ++- ...usage.ts => oranthropicservertoolusage.ts} | 20 +- src/models/speechinputmodality.ts | 63 ++++- src/models/speechinputreference.ts | 12 +- src/models/speechinputreferencevideo.ts | 49 ++++ src/models/speechinputreferencevideoinput.ts | 38 +++ src/models/speechrequest.ts | 2 +- 50 files changed, 1402 insertions(+), 219 deletions(-) create mode 100644 docs/models/anthropicsafeguardresult.mdx create mode 100644 docs/models/anthropicsafeguardresultstatus.mdx delete mode 100644 docs/models/anthropicservertoolusage.mdx delete mode 100644 docs/models/anthropicservicetier.mdx create mode 100644 docs/models/appliededit.mdx create mode 100644 docs/models/batchimagegenerationmissingimage.mdx create mode 100644 docs/models/batchresultcontextmanagement.mdx create mode 100644 docs/models/batchresultdeferredtoolsdetails.mdx create mode 100644 docs/models/messagesmcptoolresultblock.mdx create mode 100644 docs/models/messagesmcptoolresultblockcontent.mdx create mode 100644 docs/models/messagesmcptooluseblock.mdx rename docs/models/{contextmanagement.mdx => messagesrequestcontextmanagement.mdx} (64%) create mode 100644 docs/models/oranthropicservertoolusage.mdx create mode 100644 docs/models/speechinputmodalitysupportedinputs3.mdx create mode 100644 docs/models/speechinputmodalityvideo.mdx create mode 100644 docs/models/speechinputreferencevideo.mdx create mode 100644 docs/models/speechinputreferencevideoinput.mdx create mode 100644 src/models/anthropicsafeguardresult.ts delete mode 100644 src/models/anthropicservicetier.ts create mode 100644 src/models/batchimagegenerationmissingimage.ts create mode 100644 src/models/messagesmcptoolresultblock.ts create mode 100644 src/models/messagesmcptooluseblock.ts rename src/models/{anthropicservertoolusage.ts => oranthropicservertoolusage.ts} (51%) create mode 100644 src/models/speechinputreferencevideo.ts create mode 100644 src/models/speechinputreferencevideoinput.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 74e3a036f..cad0ff0c2 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: "" id: "" management: - docChecksum: abba447baf75e1b380e7ddbd8d38d743 + docChecksum: e26c66479d55a5a19e09be187f7d9204 docVersion: 1.0.0 speakeasyVersion: 1.808.1 generationVersion: 2.960.8 - releaseVersion: 1.5.172 - configChecksum: de5f13cd327926c693b86bf74a3eb383 + releaseVersion: 1.5.173 + configChecksum: 15231fa597f3732aab1703bacac3f13c repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true @@ -740,6 +740,8 @@ trackedFiles: docs/models/anthropicsafeguard.mdx: id: dcadd086658f pristine_git_object: ec79cebd11d834da605ea4104f47ae8e65867ded + docs/models/anthropicsafeguardresult.mdx: {} + docs/models/anthropicsafeguardresultstatus.mdx: {} docs/models/anthropicsearchresultblockparam.md: id: a92917e679e6 last_write_checksum: sha1:57d97bb2f0e982633c75abb54a0ecb7026f3bdd9 @@ -759,12 +761,6 @@ trackedFiles: docs/models/anthropicservertoolerrorcode.mdx: id: bcc937766e1c pristine_git_object: acf46df623ca3563ccc489e95e935cc08c47b1c9 - docs/models/anthropicservertoolusage.mdx: - id: 9c710dc37072 - pristine_git_object: 4a6e65e4732f67bd01f3d8dbebda99abd38c46cf - docs/models/anthropicservicetier.mdx: - id: 8fef0965080c - pristine_git_object: 6a3e1664add5de188ee4b03599bf29f609c4b61b docs/models/anthropicspeed.md: id: 017b6766d56b last_write_checksum: sha1:2622bacc9bd808f2bdf3d918bbd66795f833617c @@ -1071,6 +1067,7 @@ trackedFiles: docs/models/app.mdx: id: a6f931f688d3 pristine_git_object: a26eb5f93532c4fdb17748e4eefde4d978a4e819 + docs/models/appliededit.mdx: {} docs/models/applypatchcallitem.md: id: 2a6981624708 last_write_checksum: sha1:6bc50333036438f2aa9d413cb012648d85b5e5a1 @@ -1625,6 +1622,7 @@ trackedFiles: id: 2a1312a38f2a pristine_git_object: 52a0d7ef7034b3b4b077b4d91aaf33af18a53117 docs/models/batchimagegenerationimage.mdx: {} + docs/models/batchimagegenerationmissingimage.mdx: {} docs/models/batchimagegenerationresponse.mdx: {} docs/models/batchinputreference.mdx: id: c3be424a4ad9 @@ -1735,8 +1733,10 @@ trackedFiles: docs/models/batchresult.mdx: {} docs/models/batchresultcompletiontokensdetails.mdx: {} docs/models/batchresultcontent.mdx: {} + docs/models/batchresultcontextmanagement.mdx: {} docs/models/batchresultdata.mdx: {} docs/models/batchresultdebug.mdx: {} + docs/models/batchresultdeferredtoolsdetails.mdx: {} docs/models/batchresulterror.mdx: {} docs/models/batchresultevent.mdx: {} docs/models/batchresultformat1.mdx: {} @@ -3472,9 +3472,6 @@ trackedFiles: last_write_checksum: sha1:c3abb433ff5aa232abf246e95042af3f4dfc3621 pristine_git_object: 9efd4bba306cab4b000c979e756c44fb51142964 deleted: true - docs/models/contextmanagement.mdx: - id: 27503f058aca - pristine_git_object: 0469e96c41afeba1cc86014f88ee137632aa7f11 docs/models/contradiction.md: id: "486232227559" last_write_checksum: sha1:027f5016c331b0648a37e0d35c272a32ed699150 @@ -6547,6 +6544,9 @@ trackedFiles: docs/models/messagesfallbackparam.mdx: id: 2d2424e617b4 pristine_git_object: cd366aaebeff06f2859e104b97956c027b6e33ba + docs/models/messagesmcptoolresultblock.mdx: {} + docs/models/messagesmcptoolresultblockcontent.mdx: {} + docs/models/messagesmcptooluseblock.mdx: {} docs/models/messagesmessageparam.md: id: 21340f0c144a last_write_checksum: sha1:6d8d049dc1daa4fd15fc1e84deed88ee7a072ae6 @@ -6649,6 +6649,7 @@ trackedFiles: docs/models/messagesrequest.mdx: id: d4992135326b pristine_git_object: 74004521ba7555219477922a75af2d8e51f393da + docs/models/messagesrequestcontextmanagement.mdx: {} docs/models/messagesrequestinputschema.mdx: id: 876e9267c984 pristine_git_object: 3379198ee0bd155671183125963ca005927de016 @@ -10217,6 +10218,7 @@ trackedFiles: docs/models/oranthropicnullablecaller.mdx: id: f2253c04c59b pristine_git_object: baa587da661a8fda6a1591ed29a2b98528e8a83d + docs/models/oranthropicservertoolusage.mdx: {} docs/models/oranthropicservertooluseblock.mdx: id: 852dea9c6933 pristine_git_object: d51d208efa88635bb893eea264fd0f89ccc597f0 @@ -12487,7 +12489,9 @@ trackedFiles: docs/models/speechinputmodalityimage.mdx: {} docs/models/speechinputmodalitysupportedinputs1.mdx: {} docs/models/speechinputmodalitysupportedinputs2.mdx: {} + docs/models/speechinputmodalitysupportedinputs3.mdx: {} docs/models/speechinputmodalitytext.mdx: {} + docs/models/speechinputmodalityvideo.mdx: {} docs/models/speechinputreference.mdx: id: 185904811fc6 pristine_git_object: a03f5f3401eba71192d69dc880a7c376240b2725 @@ -12506,6 +12510,8 @@ trackedFiles: docs/models/speechinputreferencetext.mdx: id: a8fcc50d87e3 pristine_git_object: 256d90a6ce469dcf1f5627b29b78aca8afcd5a76 + docs/models/speechinputreferencevideo.mdx: {} + docs/models/speechinputreferencevideoinput.mdx: {} docs/models/speechmodelendpoint.mdx: {} docs/models/speechmodelresponse.mdx: {} docs/models/speechmodelslistresponse.mdx: {} @@ -15258,18 +15264,13 @@ trackedFiles: src/models/anthropicsafeguard.ts: id: "607549785460" pristine_git_object: 2af0853379e5267846e031a92447f6d42eefa95c + src/models/anthropicsafeguardresult.ts: {} src/models/anthropicsearchresultblockparam.ts: id: db204b792de1 pristine_git_object: 1d40e36058c0c921469c19ae047d6ccf057833eb src/models/anthropicservertoolerrorcode.ts: id: 822c5d079562 pristine_git_object: d00ed9ffc537aa244467307ef498b41e8d93c516 - src/models/anthropicservertoolusage.ts: - id: 71a8b24aad61 - pristine_git_object: a31b99473ab175d03d4e62bbaab8b2e1bc271c2b - src/models/anthropicservicetier.ts: - id: 414847377bd6 - pristine_git_object: f3d2f0c4f2ea7ad78fa556e8475528c6ac2f38ee src/models/anthropicspeed.ts: id: 8c545705b9ae pristine_git_object: 59606eec154e5ef8c56070a0de101237e710dd95 @@ -15496,6 +15497,7 @@ trackedFiles: id: 61c415402d74 pristine_git_object: 1b8bf7795089ff1d8333b03619792739db4bbce5 src/models/batchimagegenerationimage.ts: {} + src/models/batchimagegenerationmissingimage.ts: {} src/models/batchimagegenerationresponse.ts: {} src/models/batchinputreference.ts: id: 28a8897d1937 @@ -16760,6 +16762,8 @@ trackedFiles: src/models/messagesfallbackparam.ts: id: 990ce0f7bc03 pristine_git_object: 73a70df30602cf12003bc64edfd5ff146c12a030 + src/models/messagesmcptoolresultblock.ts: {} + src/models/messagesmcptooluseblock.ts: {} src/models/messagesmessageparam.ts: id: 0a3ea5a7e049 pristine_git_object: 899edb8c7ef1f2669ac9cbfb8bbe29805a728032 @@ -17565,6 +17569,7 @@ trackedFiles: src/models/oranthropicnullablecaller.ts: id: ecf0849a25c1 pristine_git_object: 8a6fc4654f5198cc427bb9546bca2143ece6b153 + src/models/oranthropicservertoolusage.ts: {} src/models/oranthropicservertooluseblock.ts: id: 6dab967e4db6 pristine_git_object: 9234a171c4fb12b62e6fee7cd460acc1e38edf74 @@ -18151,6 +18156,8 @@ trackedFiles: src/models/speechinputreferencetext.ts: id: 88f12d1ebfa6 pristine_git_object: 9736271f1eca14fc2be3d7281472b25fc79fec3e + src/models/speechinputreferencevideo.ts: {} + src/models/speechinputreferencevideoinput.ts: {} src/models/speechmodelendpoint.ts: {} src/models/speechmodelresponse.ts: {} src/models/speechmodelslistresponse.ts: {} @@ -24211,3 +24218,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 +releaseNotes: "## Typescript SDK Changes:\n* `openrouter.batch.createBatches()`: `response.results[].response.body` **Changed** (Breaking ⚠️)\n* `openrouter.batch.getBatches()`: `response.results[].response.body` **Changed** (Breaking ⚠️)\n* `openrouter.batch.cancel()`: `response.results[].response.body` **Changed** (Breaking ⚠️)\n* `openrouter.batch.getResults()`: `response.data[].response.body` **Changed** (Breaking ⚠️)\n* `openrouter.tts.createSpeech()`: \n * `request.speechRequest.inputReferences[].union(video_url)` **Added**\n* `openrouter.tts.listModels()`: `response.data[].endpoints[].inputModalities[].union(video)` **Added**\n* `openrouter.tts.getModel()`: `response.endpoints[].inputModalities[].union(video)` **Added**\n* `openrouter.presets.createPresetsMessages()`: \n * `request.messagesRequest.messages[].content.union(Array<>)[]` **Changed**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 3d41d5564..20c766492 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -38,7 +38,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.5.172 + version: 1.5.173 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 0e3d2ebca..0dd5d5a0a 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -5420,6 +5420,21 @@ components: required: - 'url' type: 'object' + BatchImageGenerationMissingImage: + description: 'An image the provider returned that OpenRouter could not store. It is not billed.' + properties: + index: + description: 'Position of the image among the images returned for this request, from 0' + example: 1 + type: 'integer' + message: + description: 'Why the image is missing' + example: 'The provider returned this image without readable image data.' + type: 'string' + required: + - 'index' + - 'message' + type: 'object' BatchImageGenerationResponse: description: 'Image generation result of a batch request: image links and when they expire' properties: @@ -5439,6 +5454,11 @@ components: description: 'Generation ID of this request. Look up its cost and details with `GET /api/v1/generation?id=`.' example: 'gen-batch-1748372400-3f1c9b2e7a5d4c8e0b61' type: 'string' + missing_images: + description: 'Images the provider returned without usable image data. Present only when some images of the request are missing; `data` lists the rest.' + items: + $ref: '#/components/schemas/BatchImageGenerationMissingImage' + type: 'array' usage: $ref: '#/components/schemas/ImageGenerationUsage' required: @@ -6579,6 +6599,23 @@ components: items: $ref: '#/components/schemas/ORAnthropicContentBlock' type: 'array' + context_management: + properties: + applied_edits: + items: + additionalProperties: {} + properties: + type: + type: 'string' + required: + - 'type' + type: 'object' + type: 'array' + required: + - 'applied_edits' + type: + - 'object' + - 'null' id: type: 'string' input_transformations: @@ -6589,10 +6626,20 @@ components: - 'null' model: type: 'string' + openrouter_metadata: + $ref: '#/components/schemas/OpenRouterMetadata' + provider: + type: 'string' role: enum: - 'assistant' type: 'string' + safeguard_results: + items: + $ref: '#/components/schemas/AnthropicSafeguardResult' + type: + - 'array' + - 'null' stop_details: $ref: '#/components/schemas/AnthropicRefusalStopDetails' stop_reason: @@ -6606,26 +6653,81 @@ components: - 'message' type: 'string' usage: - allOf: - - $ref: '#/components/schemas/AnthropicUsage' - - properties: - iterations: - items: - $ref: '#/components/schemas/AnthropicUsageIteration' - type: 'array' - speed: - $ref: '#/components/schemas/AnthropicSpeed' + properties: + cache_creation: + $ref: '#/components/schemas/AnthropicCacheCreation' + cache_creation_input_tokens: + type: + - 'integer' + - 'null' + cache_read_input_tokens: + type: + - 'integer' + - 'null' + cost: + format: 'double' + type: + - 'number' + - 'null' + cost_details: + $ref: '#/components/schemas/CostDetails' + deferred_tools_details: + properties: + completion_tokens: + description: 'Completion tokens summed over every upstream call' + type: 'integer' + prompt_tokens: + description: 'Prompt tokens summed over every upstream call' + type: 'integer' + total_tokens: + description: 'Sum of the above two fields' + type: 'integer' + turns: + description: 'Upstream model calls the run made' + exclusiveMinimum: true + minimum: 0 + type: 'integer' + required: + - 'turns' + - 'prompt_tokens' + - 'completion_tokens' + - 'total_tokens' type: 'object' - example: - cache_creation: null - cache_creation_input_tokens: null - cache_read_input_tokens: null - inference_geo: null - input_tokens: 100 - output_tokens: 50 - output_tokens_details: null - server_tool_use: null - service_tier: 'standard' + inference_geo: + type: + - 'string' + - 'null' + input_tokens: + type: 'integer' + is_byok: + type: 'boolean' + iterations: + items: + $ref: '#/components/schemas/AnthropicUsageIteration' + type: 'array' + output_tokens: + type: 'integer' + output_tokens_details: + $ref: '#/components/schemas/AnthropicOutputTokensDetails' + server_tool_use: + $ref: '#/components/schemas/ORAnthropicServerToolUsage' + service_tier: + type: + - 'string' + - 'null' + speed: + $ref: '#/components/schemas/AnthropicSpeed' + required: + - 'input_tokens' + - 'output_tokens' + - 'output_tokens_details' + - 'cache_creation_input_tokens' + - 'cache_read_input_tokens' + - 'cache_creation' + - 'inference_geo' + - 'server_tool_use' + - 'service_tier' + type: 'object' required: - 'id' - 'type' @@ -21259,6 +21361,63 @@ components: required: - 'model' type: 'object' + MessagesMcpToolResultBlock: + description: 'MCP tool result block paired with a prior `mcp_tool_use` block for replay.' + example: + content: 'Sunny, 21C' + is_error: false + tool_use_id: 'mcptoolu_01abc' + type: 'mcp_tool_result' + properties: + cache_control: + $ref: '#/components/schemas/AnthropicCacheControlDirective' + content: + anyOf: + - type: 'string' + - items: + $ref: '#/components/schemas/AnthropicTextBlockParam' + type: 'array' + is_error: + type: 'boolean' + tool_use_id: + type: 'string' + type: + enum: + - 'mcp_tool_result' + type: 'string' + required: + - 'type' + - 'tool_use_id' + type: 'object' + MessagesMcpToolUseBlock: + description: 'MCP tool call emitted by an upstream Anthropic assistant turn for replay.' + example: + id: 'mcptoolu_01abc' + input: + city: 'Paris' + name: 'get_forecast' + server_name: 'weather' + type: 'mcp_tool_use' + properties: + cache_control: + $ref: '#/components/schemas/AnthropicCacheControlDirective' + id: + type: 'string' + input: {} + name: + type: 'string' + server_name: + type: 'string' + type: + enum: + - 'mcp_tool_use' + type: 'string' + required: + - 'type' + - 'id' + - 'name' + - 'server_name' + type: 'object' MessagesMessageParam: description: 'Anthropic message with OpenRouter extensions' example: @@ -21435,6 +21594,8 @@ components: - $ref: '#/components/schemas/MessagesBashToolResultBlock' - $ref: '#/components/schemas/ORAnthropicToolSearchResultParam' - $ref: '#/components/schemas/MessagesToolSearchToolResultBlock' + - $ref: '#/components/schemas/MessagesMcpToolUseBlock' + - $ref: '#/components/schemas/MessagesMcpToolResultBlock' type: 'array' output_config: $ref: '#/components/schemas/AnthropicMessageOutputConfig' @@ -36386,7 +36547,7 @@ components: description: 'Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models.' example: 'Hello world' SpeechInputModality: - description: 'An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design.' + description: 'An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for.' example: type: 'text' oneOf: @@ -36446,6 +36607,23 @@ components: - 'type' - 'supported_inputs' type: 'object' + - properties: + supported_inputs: + description: '`references` is how many `video_url` parts a request may send. A video reference is the only part of its request and bills at the endpoint''s video rate.' + properties: + references: + $ref: '#/components/schemas/SpeechReferenceCount' + required: + - 'references' + type: 'object' + type: + enum: + - 'video' + type: 'string' + required: + - 'type' + - 'supported_inputs' + type: 'object' SpeechInputReference: description: 'Reference content part for stateless voice cloning or voice design' discriminator: @@ -36453,6 +36631,7 @@ components: image_url: '#/components/schemas/SpeechInputReferenceImage' input_audio: '#/components/schemas/SpeechInputReferenceAudio' text: '#/components/schemas/SpeechInputReferenceText' + video_url: '#/components/schemas/SpeechInputReferenceVideo' propertyName: 'type' example: input_audio: @@ -36462,6 +36641,7 @@ components: - $ref: '#/components/schemas/SpeechInputReferenceAudio' - $ref: '#/components/schemas/SpeechInputReferenceText' - $ref: '#/components/schemas/SpeechInputReferenceImage' + - $ref: '#/components/schemas/SpeechInputReferenceVideo' SpeechInputReferenceAudio: description: 'Reference audio input for stateless voice cloning. Up to three parts per request; the Nth audio part is addressable from `input` as `@AudioN` on providers that support multiple references.' example: @@ -36551,6 +36731,37 @@ components: - 'type' - 'text' type: 'object' + SpeechInputReferenceVideo: + description: 'Reference video the generated audio is made for (sound and voice matched to the footage, same length as the clip). Must be the only part in `input_references`. Only routed to endpoints that support video references, which bill at their video rate.' + example: + type: 'video_url' + video_url: + url: 'https://example.com/clip.mp4' + properties: + type: + enum: + - 'video_url' + type: 'string' + video_url: + $ref: '#/components/schemas/SpeechInputReferenceVideoInput' + required: + - 'type' + - 'video_url' + type: 'object' + SpeechInputReferenceVideoInput: + description: 'Reference video input object' + example: + url: 'https://example.com/clip.mp4' + properties: + url: + description: 'Public http(s) URL of the reference video. The provider downloads it; OpenRouter does not fetch it, and data URIs are rejected.' + example: 'https://example.com/clip.mp4' + maxLength: 2048 + minLength: 1 + type: 'string' + required: + - 'url' + type: 'object' SpeechModelEndpoint: description: 'One endpoint serving a speech model, with the inputs and parameters it accepts.' example: @@ -36829,7 +37040,7 @@ components: input: $ref: '#/components/schemas/SpeechInput' input_references: - description: '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.' + description: '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 and no other parts; only routed to endpoints that support video references. An empty array is treated as no reference.' example: - input_audio: data: 'data:audio/wav;base64,UklGRuQXDABXQVZF...' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 3d4e94fbe..c4606df1c 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:7ce7da0d309ec852935e976093ba4adb604932ff65e116d300fa73752cb3e339 - sourceBlobDigest: sha256:92caa9d5fa65ee27f937bdf6e98700e1caa690be88fd65d9cea188c230124002 + sourceRevisionDigest: sha256:51d6baca9f630b996fae26738ca95f2b9f08963b42560dfb6652c654b30f946d + sourceBlobDigest: sha256:f5e064e616f561b6afcbd54b62a3377b810732e2752028eab2097a2598082ae1 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:7ce7da0d309ec852935e976093ba4adb604932ff65e116d300fa73752cb3e339 - sourceBlobDigest: sha256:92caa9d5fa65ee27f937bdf6e98700e1caa690be88fd65d9cea188c230124002 + sourceRevisionDigest: sha256:51d6baca9f630b996fae26738ca95f2b9f08963b42560dfb6652c654b30f946d + sourceBlobDigest: sha256:f5e064e616f561b6afcbd54b62a3377b810732e2752028eab2097a2598082ae1 codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:ac9ea22a985d12d42ff9eeba43e4a59d0609cf9e0990c6f77dedc1024994336e + codeSamplesRevisionDigest: sha256:39592ed9563e621c58a72193bc735eee03614ce5ffbce1f3558e71e90ff47847 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.808.1 diff --git a/RELEASES.md b/RELEASES.md index df16bed67..70f0abc4e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6096,4 +6096,14 @@ Based on: ### Generated - [typescript v1.5.172] . ### Releases -- [NPM v1.5.172] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.172 - . \ No newline at end of file +- [NPM v1.5.172] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.172 - . + +## 2026-12-03 21:24:48 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.808.1 (2.960.8) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.5.173] . +### Releases +- [NPM v1.5.173] https://www.npmjs.com/package/@openrouter/sdk/v/1.5.173 - . \ No newline at end of file diff --git a/docs/models/anthropicsafeguardresult.mdx b/docs/models/anthropicsafeguardresult.mdx new file mode 100644 index 000000000..7fb81ab41 --- /dev/null +++ b/docs/models/anthropicsafeguardresult.mdx @@ -0,0 +1,26 @@ +--- +title: "AnthropicSafeguardResult" +--- + +The outcome of a server-side safeguard, keyed by tool-use id where applicable + +## Example Usage + +```typescript +import { AnthropicSafeguardResult } from "@openrouter/sdk/models"; + +let value: AnthropicSafeguardResult = { + status: { + type: "available", + }, + type: "dangerous_tool_use", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `status` | [models.AnthropicSafeguardResultStatus](../models/anthropicsafeguardresultstatus.mdx) | ✔️ | N/A | | +| `type` | *string* | ✔️ | N/A | | +| `additionalProperties` | Record\ | ➖ | N/A | \{
"status": \{
"tool_uses": \{
"toolu_01ABC": \{
"outcome": "not_flagged",
"type": "evaluated"
}
},
"type": "available"
},
"type": "dangerous_tool_use"
} | \ No newline at end of file diff --git a/docs/models/anthropicsafeguardresultstatus.mdx b/docs/models/anthropicsafeguardresultstatus.mdx new file mode 100644 index 000000000..ad7a8c615 --- /dev/null +++ b/docs/models/anthropicsafeguardresultstatus.mdx @@ -0,0 +1,20 @@ +--- +title: "AnthropicSafeguardResultStatus" +--- + +## Example Usage + +```typescript +import { AnthropicSafeguardResultStatus } from "@openrouter/sdk/models"; + +let value: AnthropicSafeguardResultStatus = { + type: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------- | ---------------------- | ---------------------- | ---------------------- | +| `type` | *string* | ✔️ | N/A | +| `additionalProperties` | Record\ | ➖ | N/A | \ No newline at end of file diff --git a/docs/models/anthropicservertoolusage.mdx b/docs/models/anthropicservertoolusage.mdx deleted file mode 100644 index 4a6e65e47..000000000 --- a/docs/models/anthropicservertoolusage.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: "AnthropicServerToolUsage" ---- - -## Example Usage - -```typescript -import { AnthropicServerToolUsage } from "@openrouter/sdk/models"; - -let value: AnthropicServerToolUsage = { - webFetchRequests: 0, - webSearchRequests: 1, -}; -``` - -## Fields - -| Field | Type | Required | Description | -| ------------------- | ------------------- | ------------------- | ------------------- | -| `webFetchRequests` | *number* | ✔️ | N/A | -| `webSearchRequests` | *number* | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/anthropicservicetier.mdx b/docs/models/anthropicservicetier.mdx deleted file mode 100644 index 6a3e1664a..000000000 --- a/docs/models/anthropicservicetier.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: "AnthropicServiceTier" ---- - -## Example Usage - -```typescript -import { AnthropicServiceTier } from "@openrouter/sdk/models"; - -let value: AnthropicServiceTier = "standard"; - -// Open enum: unrecognized values are captured as Unrecognized -``` - -## Values - -```typescript -"standard" | "priority" | "batch" | Unrecognized -``` \ No newline at end of file diff --git a/docs/models/appliededit.mdx b/docs/models/appliededit.mdx new file mode 100644 index 000000000..a8981048e --- /dev/null +++ b/docs/models/appliededit.mdx @@ -0,0 +1,20 @@ +--- +title: "AppliedEdit" +--- + +## Example Usage + +```typescript +import { AppliedEdit } from "@openrouter/sdk/models"; + +let value: AppliedEdit = { + type: "", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------- | ---------------------- | ---------------------- | ---------------------- | +| `type` | *string* | ✔️ | N/A | +| `additionalProperties` | Record\ | ➖ | N/A | \ No newline at end of file diff --git a/docs/models/batchimagegenerationmissingimage.mdx b/docs/models/batchimagegenerationmissingimage.mdx new file mode 100644 index 000000000..3b2cee722 --- /dev/null +++ b/docs/models/batchimagegenerationmissingimage.mdx @@ -0,0 +1,23 @@ +--- +title: "BatchImageGenerationMissingImage" +--- + +An image the provider returned that OpenRouter could not store. It is not billed. + +## Example Usage + +```typescript +import { BatchImageGenerationMissingImage } from "@openrouter/sdk/models"; + +let value: BatchImageGenerationMissingImage = { + index: 1, + message: "The provider returned this image without readable image data.", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `index` | *number* | ✔️ | Position of the image among the images returned for this request, from 0 | 1 | +| `message` | *string* | ✔️ | Why the image is missing | The provider returned this image without readable image data. | \ No newline at end of file diff --git a/docs/models/batchimagegenerationresponse.mdx b/docs/models/batchimagegenerationresponse.mdx index 60f78f863..c20348908 100644 --- a/docs/models/batchimagegenerationresponse.mdx +++ b/docs/models/batchimagegenerationresponse.mdx @@ -18,10 +18,11 @@ let value: BatchImageGenerationResponse = { ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `created` | *number* | ✔️ | Unix timestamp (seconds) when the image was generated | 1748372400 | -| `data` | [models.BatchImageGenerationImage](../models/batchimagegenerationimage.mdx)[] | ✔️ | N/A | | -| `expiresAt` | *number* | ✔️ | Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then. | 1748458800 | -| `id` | *string* | ➖ | Generation ID of this request. Look up its cost and details with `GET /api/v1/generation?id=`. | gen-batch-1748372400-3f1c9b2e7a5d4c8e0b61 | -| `usage` | [models.ImageGenerationUsage](../models/imagegenerationusage.mdx) | ➖ | Token and cost usage for the image generation request, when available | \{
"completion_tokens": 4175,
"cost": 0.04,
"prompt_tokens": 0,
"total_tokens": 4175
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| `created` | *number* | ✔️ | Unix timestamp (seconds) when the image was generated | 1748372400 | +| `data` | [models.BatchImageGenerationImage](../models/batchimagegenerationimage.mdx)[] | ✔️ | N/A | | +| `expiresAt` | *number* | ✔️ | Unix timestamp (seconds) when the image URLs in `data` stop working. Download the images before then. | 1748458800 | +| `id` | *string* | ➖ | Generation ID of this request. Look up its cost and details with `GET /api/v1/generation?id=`. | gen-batch-1748372400-3f1c9b2e7a5d4c8e0b61 | +| `missingImages` | [models.BatchImageGenerationMissingImage](../models/batchimagegenerationmissingimage.mdx)[] | ➖ | Images the provider returned without usable image data. Present only when some images of the request are missing; `data` lists the rest. | | +| `usage` | [models.ImageGenerationUsage](../models/imagegenerationusage.mdx) | ➖ | Token and cost usage for the image generation request, when available | \{
"completion_tokens": 4175,
"cost": 0.04,
"prompt_tokens": 0,
"total_tokens": 4175
} | \ No newline at end of file diff --git a/docs/models/batchresultcontextmanagement.mdx b/docs/models/batchresultcontextmanagement.mdx new file mode 100644 index 000000000..7cf0fd632 --- /dev/null +++ b/docs/models/batchresultcontextmanagement.mdx @@ -0,0 +1,19 @@ +--- +title: "BatchResultContextManagement" +--- + +## Example Usage + +```typescript +import { BatchResultContextManagement } from "@openrouter/sdk/models"; + +let value: BatchResultContextManagement = { + appliedEdits: [], +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | +| `appliedEdits` | [models.AppliedEdit](../models/appliededit.mdx)[] | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/batchresultdeferredtoolsdetails.mdx b/docs/models/batchresultdeferredtoolsdetails.mdx new file mode 100644 index 000000000..3ad13ed1f --- /dev/null +++ b/docs/models/batchresultdeferredtoolsdetails.mdx @@ -0,0 +1,25 @@ +--- +title: "BatchResultDeferredToolsDetails" +--- + +## Example Usage + +```typescript +import { BatchResultDeferredToolsDetails } from "@openrouter/sdk/models"; + +let value: BatchResultDeferredToolsDetails = { + completionTokens: 273070, + promptTokens: 254912, + totalTokens: 493855, + turns: 34338, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | +| `completionTokens` | *number* | ✔️ | Completion tokens summed over every upstream call | +| `promptTokens` | *number* | ✔️ | Prompt tokens summed over every upstream call | +| `totalTokens` | *number* | ✔️ | Sum of the above two fields | +| `turns` | *number* | ✔️ | Upstream model calls the run made | \ No newline at end of file diff --git a/docs/models/batchresultusage2.mdx b/docs/models/batchresultusage2.mdx index c51f23392..463b75130 100644 --- a/docs/models/batchresultusage2.mdx +++ b/docs/models/batchresultusage2.mdx @@ -8,30 +8,42 @@ title: "BatchResultUsage2" import { BatchResultUsage2 } from "@openrouter/sdk/models"; let value: BatchResultUsage2 = { - cacheCreation: null, - cacheCreationInputTokens: null, - cacheReadInputTokens: null, - inferenceGeo: null, - inputTokens: 100, - outputTokens: 50, - outputTokensDetails: null, - serverToolUse: null, - serviceTier: "standard", + cacheCreation: { + ephemeral1hInputTokens: 0, + ephemeral5mInputTokens: 100, + }, + cacheCreationInputTokens: 606661, + cacheReadInputTokens: 577088, + inferenceGeo: "", + inputTokens: 493793, + outputTokens: 919217, + outputTokensDetails: { + thinkingTokens: 0, + }, + serverToolUse: { + webFetchRequests: 0, + webSearchRequests: 0, + }, + serviceTier: "", }; ``` ## Fields -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -| `cacheCreation` | [models.AnthropicCacheCreation](../models/anthropiccachecreation.mdx) | ✔️ | N/A | \{
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 100
} | -| `cacheCreationInputTokens` | *number* | ✔️ | N/A | | -| `cacheReadInputTokens` | *number* | ✔️ | N/A | | -| `inferenceGeo` | *string* | ✔️ | N/A | | -| `inputTokens` | *number* | ✔️ | N/A | | -| `outputTokens` | *number* | ✔️ | N/A | | -| `outputTokensDetails` | [models.AnthropicOutputTokensDetails](../models/anthropicoutputtokensdetails.mdx) | ✔️ | N/A | \{
"thinking_tokens": 0
} | -| `serverToolUse` | [models.AnthropicServerToolUsage](../models/anthropicservertoolusage.mdx) | ✔️ | N/A | \{
"web_fetch_requests": 0,
"web_search_requests": 1
} | -| `serviceTier` | [models.AnthropicServiceTier](../models/anthropicservicetier.mdx) | ✔️ | N/A | standard | -| `iterations` | *models.AnthropicUsageIteration*[] | ➖ | N/A | | -| `speed` | [models.AnthropicSpeed](../models/anthropicspeed.mdx) | ➖ | N/A | standard | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| `cacheCreation` | [models.AnthropicCacheCreation](../models/anthropiccachecreation.mdx) | ✔️ | N/A | \{
"ephemeral_1h_input_tokens": 0,
"ephemeral_5m_input_tokens": 100
} | +| `cacheCreationInputTokens` | *number* | ✔️ | N/A | | +| `cacheReadInputTokens` | *number* | ✔️ | N/A | | +| `cost` | *number* | ➖ | N/A | | +| `costDetails` | [models.CostDetails](../models/costdetails.mdx) | ➖ | Breakdown of upstream inference costs | \{
"upstream_inference_completions_cost": 0.0004,
"upstream_inference_cost": null,
"upstream_inference_prompt_cost": 0.0008
} | +| `deferredToolsDetails` | [models.BatchResultDeferredToolsDetails](../models/batchresultdeferredtoolsdetails.mdx) | ➖ | N/A | | +| `inferenceGeo` | *string* | ✔️ | N/A | | +| `inputTokens` | *number* | ✔️ | N/A | | +| `isByok` | *boolean* | ➖ | N/A | | +| `iterations` | *models.AnthropicUsageIteration*[] | ➖ | N/A | | +| `outputTokens` | *number* | ✔️ | N/A | | +| `outputTokensDetails` | [models.AnthropicOutputTokensDetails](../models/anthropicoutputtokensdetails.mdx) | ✔️ | N/A | \{
"thinking_tokens": 0
} | +| `serverToolUse` | [models.ORAnthropicServerToolUsage](../models/oranthropicservertoolusage.mdx) | ✔️ | N/A | \{
"tool_calls_executed": 1,
"tool_calls_requested": 1,
"web_fetch_requests": 0,
"web_search_requests": 0
} | +| `serviceTier` | *string* | ✔️ | N/A | | +| `speed` | [models.AnthropicSpeed](../models/anthropicspeed.mdx) | ➖ | N/A | standard | \ No newline at end of file diff --git a/docs/models/body.mdx b/docs/models/body.mdx index 15525ac0b..825237de3 100644 --- a/docs/models/body.mdx +++ b/docs/models/body.mdx @@ -101,15 +101,23 @@ const value: models.BodyMessage = { stopSequence: "", type: "message", usage: { - cacheCreation: null, - cacheCreationInputTokens: null, - cacheReadInputTokens: null, - inferenceGeo: null, - inputTokens: 100, - outputTokens: 50, - outputTokensDetails: null, - serverToolUse: null, - serviceTier: "standard", + cacheCreation: { + ephemeral1hInputTokens: 0, + ephemeral5mInputTokens: 100, + }, + cacheCreationInputTokens: 754297, + cacheReadInputTokens: 208650, + inferenceGeo: "", + inputTokens: 58012, + outputTokens: 327115, + outputTokensDetails: { + thinkingTokens: 0, + }, + serverToolUse: { + webFetchRequests: 0, + webSearchRequests: 0, + }, + serviceTier: "", }, }; ``` diff --git a/docs/models/bodymessage.mdx b/docs/models/bodymessage.mdx index c8cf6b7b3..82313229c 100644 --- a/docs/models/bodymessage.mdx +++ b/docs/models/bodymessage.mdx @@ -31,31 +31,43 @@ let value: BodyMessage = { stopSequence: "", type: "message", usage: { - cacheCreation: null, - cacheCreationInputTokens: null, - cacheReadInputTokens: null, - inferenceGeo: null, - inputTokens: 100, - outputTokens: 50, - outputTokensDetails: null, - serverToolUse: null, - serviceTier: "standard", + cacheCreation: { + ephemeral1hInputTokens: 0, + ephemeral5mInputTokens: 100, + }, + cacheCreationInputTokens: 754297, + cacheReadInputTokens: 208650, + inferenceGeo: "", + inputTokens: 58012, + outputTokens: 327115, + outputTokensDetails: { + thinkingTokens: 0, + }, + serverToolUse: { + webFetchRequests: 0, + webSearchRequests: 0, + }, + serviceTier: "", }, }; ``` ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `container` | [models.AnthropicContainer](../models/anthropiccontainer.mdx) | ✔️ | N/A | \{
"expires_at": "2026-04-08T00:00:00Z",
"id": "ctr_01abc",
"skills": null
} | -| `content` | *models.ORAnthropicContentBlock*[] | ✔️ | N/A | | -| `id` | *string* | ✔️ | N/A | | -| `inputTransformations` | [models.AnthropicInputTransformation](../models/anthropicinputtransformation.mdx)[] | ➖ | N/A | | -| `model` | *string* | ✔️ | N/A | | -| `role` | [models.BatchResultRole](../models/batchresultrole.mdx) | ✔️ | N/A | | -| `stopDetails` | [models.AnthropicRefusalStopDetails](../models/anthropicrefusalstopdetails.mdx) | ✔️ | Structured information about a refusal | \{
"category": "cyber",
"explanation": "The request was refused due to policy.",
"type": "refusal"
} | -| `stopReason` | [models.ORAnthropicStopReason](../models/oranthropicstopreason.mdx) | ✔️ | N/A | end_turn | -| `stopSequence` | *string* | ✔️ | N/A | | -| `type` | [models.BatchResultTypeMessage](../models/batchresulttypemessage.mdx) | ✔️ | N/A | | -| `usage` | [models.BatchResultUsage2](../models/batchresultusage2.mdx) | ✔️ | N/A | \{
"cache_creation": null,
"cache_creation_input_tokens": null,
"cache_read_input_tokens": null,
"inference_geo": null,
"input_tokens": 100,
"output_tokens": 50,
"output_tokens_details": null,
"server_tool_use": null,
"service_tier": "standard"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `container` | [models.AnthropicContainer](../models/anthropiccontainer.mdx) | ✔️ | N/A | \{
"expires_at": "2026-04-08T00:00:00Z",
"id": "ctr_01abc",
"skills": null
} | +| `content` | *models.ORAnthropicContentBlock*[] | ✔️ | N/A | | +| `contextManagement` | [models.BatchResultContextManagement](../models/batchresultcontextmanagement.mdx) | ➖ | N/A | | +| `id` | *string* | ✔️ | N/A | | +| `inputTransformations` | [models.AnthropicInputTransformation](../models/anthropicinputtransformation.mdx)[] | ➖ | N/A | | +| `model` | *string* | ✔️ | N/A | | +| `openrouterMetadata` | [models.OpenRouterMetadata](../models/openroutermetadata.mdx) | ➖ | N/A | \{
"attempt": 1,
"endpoints": \{
"available": [
\{
"model": "openai/gpt-4o",
"provider": "OpenAI",
"selected": true
}
],
"total": 1
},
"generation_time": 2016,
"is_byok": false,
"region": "iad",
"requested": "openai/gpt-4o",
"strategy": "direct",
"summary": "available=1, selected=OpenAI"
} | +| `provider` | *string* | ➖ | N/A | | +| `role` | [models.BatchResultRole](../models/batchresultrole.mdx) | ✔️ | N/A | | +| `safeguardResults` | [models.AnthropicSafeguardResult](../models/anthropicsafeguardresult.mdx)[] | ➖ | N/A | | +| `stopDetails` | [models.AnthropicRefusalStopDetails](../models/anthropicrefusalstopdetails.mdx) | ✔️ | Structured information about a refusal | \{
"category": "cyber",
"explanation": "The request was refused due to policy.",
"type": "refusal"
} | +| `stopReason` | [models.ORAnthropicStopReason](../models/oranthropicstopreason.mdx) | ✔️ | N/A | end_turn | +| `stopSequence` | *string* | ✔️ | N/A | | +| `type` | [models.BatchResultTypeMessage](../models/batchresulttypemessage.mdx) | ✔️ | N/A | | +| `usage` | [models.BatchResultUsage2](../models/batchresultusage2.mdx) | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/messagesmcptoolresultblock.mdx b/docs/models/messagesmcptoolresultblock.mdx new file mode 100644 index 000000000..fb787a7f1 --- /dev/null +++ b/docs/models/messagesmcptoolresultblock.mdx @@ -0,0 +1,26 @@ +--- +title: "MessagesMcpToolResultBlock" +--- + +MCP tool result block paired with a prior `mcp_tool_use` block for replay. + +## Example Usage + +```typescript +import { MessagesMcpToolResultBlock } from "@openrouter/sdk/models"; + +let value: MessagesMcpToolResultBlock = { + toolUseId: "mcptoolu_01abc", + type: "mcp_tool_result", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `cacheControl` | [models.AnthropicCacheControlDirective](../models/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `content` | *models.MessagesMcpToolResultBlockContent* | ➖ | N/A | | +| `isError` | *boolean* | ➖ | N/A | | +| `toolUseId` | *string* | ✔️ | N/A | | +| `type` | *"mcp_tool_result"* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/messagesmcptoolresultblockcontent.mdx b/docs/models/messagesmcptoolresultblockcontent.mdx new file mode 100644 index 000000000..6e4031241 --- /dev/null +++ b/docs/models/messagesmcptoolresultblockcontent.mdx @@ -0,0 +1,23 @@ +--- +title: "MessagesMcpToolResultBlockContent" +--- + +## Supported Types + +### `string` + +```typescript +const value: string = ""; +``` + +### `models.AnthropicTextBlockParam[]` + +```typescript +const value: models.AnthropicTextBlockParam[] = [ + { + text: "Hello, world!", + type: "text", + }, +]; +``` + diff --git a/docs/models/messagesmcptooluseblock.mdx b/docs/models/messagesmcptooluseblock.mdx new file mode 100644 index 000000000..97649b9fd --- /dev/null +++ b/docs/models/messagesmcptooluseblock.mdx @@ -0,0 +1,29 @@ +--- +title: "MessagesMcpToolUseBlock" +--- + +MCP tool call emitted by an upstream Anthropic assistant turn for replay. + +## Example Usage + +```typescript +import { MessagesMcpToolUseBlock } from "@openrouter/sdk/models"; + +let value: MessagesMcpToolUseBlock = { + id: "mcptoolu_01abc", + name: "get_forecast", + serverName: "weather", + type: "mcp_tool_use", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `cacheControl` | [models.AnthropicCacheControlDirective](../models/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | +| `id` | *string* | ✔️ | N/A | | +| `input` | *any* | ➖ | N/A | | +| `name` | *string* | ✔️ | N/A | | +| `serverName` | *string* | ✔️ | N/A | | +| `type` | *"mcp_tool_use"* | ✔️ | N/A | | \ No newline at end of file diff --git a/docs/models/messagesmessageparamcontentunion4.mdx b/docs/models/messagesmessageparamcontentunion4.mdx index 64632fca1..57944f02c 100644 --- a/docs/models/messagesmessageparamcontentunion4.mdx +++ b/docs/models/messagesmessageparamcontentunion4.mdx @@ -232,3 +232,23 @@ const value: models.MessagesToolSearchToolResultBlock = { }; ``` +### `models.MessagesMcpToolUseBlock` + +```typescript +const value: models.MessagesMcpToolUseBlock = { + id: "mcptoolu_01abc", + name: "get_forecast", + serverName: "weather", + type: "mcp_tool_use", +}; +``` + +### `models.MessagesMcpToolResultBlock` + +```typescript +const value: models.MessagesMcpToolResultBlock = { + toolUseId: "mcptoolu_01abc", + type: "mcp_tool_result", +}; +``` + diff --git a/docs/models/messagesrequest.mdx b/docs/models/messagesrequest.mdx index 74004521b..9a24d8b9d 100644 --- a/docs/models/messagesrequest.mdx +++ b/docs/models/messagesrequest.mdx @@ -25,7 +25,7 @@ let value: MessagesRequest = { | Field | Type | Required | Description | Example | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `cacheControl` | [models.AnthropicCacheControlDirective](../models/anthropiccachecontroldirective.mdx) | ➖ | Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. | \{
"type": "ephemeral"
} | -| `contextManagement` | [models.ContextManagement](../models/contextmanagement.mdx) | ➖ | N/A | | +| `contextManagement` | [models.MessagesRequestContextManagement](../models/messagesrequestcontextmanagement.mdx) | ➖ | N/A | | | `deferredTools` | [models.DeferredToolsControl](../models/deferredtoolscontrol.mdx) | ➖ | Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. | \{
"profile": "portable",
"protocol": "v1",
"search": \{
"max_results": 5,
"type": "bm25"
},
"validation": "runtime"
} | | `fallbacks` | [models.MessagesFallbackParam](../models/messagesfallbackparam.mdx)[] | ➖ | Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with `models`. Each entry accepts only `model`. Maximum of 3 entries. | [
\{
"model": "claude-opus-4-8"
}
] | | `maxTokens` | *number* | ➖ | N/A | | diff --git a/docs/models/contextmanagement.mdx b/docs/models/messagesrequestcontextmanagement.mdx similarity index 64% rename from docs/models/contextmanagement.mdx rename to docs/models/messagesrequestcontextmanagement.mdx index 0469e96c4..c0f169266 100644 --- a/docs/models/contextmanagement.mdx +++ b/docs/models/messagesrequestcontextmanagement.mdx @@ -1,13 +1,13 @@ --- -title: "ContextManagement" +title: "MessagesRequestContextManagement" --- ## Example Usage ```typescript -import { ContextManagement } from "@openrouter/sdk/models"; +import { MessagesRequestContextManagement } from "@openrouter/sdk/models"; -let value: ContextManagement = {}; +let value: MessagesRequestContextManagement = {}; ``` ## Fields diff --git a/docs/models/oranthropicservertoolusage.mdx b/docs/models/oranthropicservertoolusage.mdx new file mode 100644 index 000000000..b6848558a --- /dev/null +++ b/docs/models/oranthropicservertoolusage.mdx @@ -0,0 +1,23 @@ +--- +title: "ORAnthropicServerToolUsage" +--- + +## Example Usage + +```typescript +import { ORAnthropicServerToolUsage } from "@openrouter/sdk/models"; + +let value: ORAnthropicServerToolUsage = { + webFetchRequests: 0, + webSearchRequests: 0, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------- | -------------------- | -------------------- | -------------------- | +| `toolCallsExecuted` | *number* | ➖ | N/A | +| `toolCallsRequested` | *number* | ➖ | N/A | +| `webFetchRequests` | *number* | ✔️ | N/A | +| `webSearchRequests` | *number* | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/speechinputmodality.mdx b/docs/models/speechinputmodality.mdx index 963070fc5..06c83a837 100644 --- a/docs/models/speechinputmodality.mdx +++ b/docs/models/speechinputmodality.mdx @@ -2,7 +2,7 @@ title: "SpeechInputModality" --- -An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design. +An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for. ## Supported Types @@ -43,3 +43,17 @@ const value: models.SpeechInputModalityImage = { }; ``` +### `models.SpeechInputModalityVideo` + +```typescript +const value: models.SpeechInputModalityVideo = { + supportedInputs: { + references: { + min: 1, + type: "integer", + }, + }, + type: "video", +}; +``` + diff --git a/docs/models/speechinputmodalitysupportedinputs3.mdx b/docs/models/speechinputmodalitysupportedinputs3.mdx new file mode 100644 index 000000000..f7c3b8641 --- /dev/null +++ b/docs/models/speechinputmodalitysupportedinputs3.mdx @@ -0,0 +1,24 @@ +--- +title: "SpeechInputModalitySupportedInputs3" +--- + +`references` is how many `video_url` parts a request may send. A video reference is the only part of its request and bills at the endpoint's video rate. + +## Example Usage + +```typescript +import { SpeechInputModalitySupportedInputs3 } from "@openrouter/sdk/models"; + +let value: SpeechInputModalitySupportedInputs3 = { + references: { + min: 1, + type: "integer", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `references` | [models.SpeechReferenceCount](../models/speechreferencecount.mdx) | ✔️ | N/A | \{
"max": 1,
"min": 1,
"type": "integer"
} | \ No newline at end of file diff --git a/docs/models/speechinputmodalityvideo.mdx b/docs/models/speechinputmodalityvideo.mdx new file mode 100644 index 000000000..3b7b8897a --- /dev/null +++ b/docs/models/speechinputmodalityvideo.mdx @@ -0,0 +1,26 @@ +--- +title: "SpeechInputModalityVideo" +--- + +## Example Usage + +```typescript +import { SpeechInputModalityVideo } from "@openrouter/sdk/models"; + +let value: SpeechInputModalityVideo = { + supportedInputs: { + references: { + min: 1, + type: "integer", + }, + }, + type: "video", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `supportedInputs` | [models.SpeechInputModalitySupportedInputs3](../models/speechinputmodalitysupportedinputs3.mdx) | ✔️ | `references` is how many `video_url` parts a request may send. A video reference is the only part of its request and bills at the endpoint's video rate. | +| `type` | *"video"* | ✔️ | N/A | \ No newline at end of file diff --git a/docs/models/speechinputreference.mdx b/docs/models/speechinputreference.mdx index a03f5f340..54f7c6199 100644 --- a/docs/models/speechinputreference.mdx +++ b/docs/models/speechinputreference.mdx @@ -36,3 +36,14 @@ const value: models.SpeechInputReferenceText = { }; ``` +### `models.SpeechInputReferenceVideo` + +```typescript +const value: models.SpeechInputReferenceVideo = { + type: "video_url", + videoUrl: { + url: "https://example.com/clip.mp4", + }, +}; +``` + diff --git a/docs/models/speechinputreferencevideo.mdx b/docs/models/speechinputreferencevideo.mdx new file mode 100644 index 000000000..28d8cbb91 --- /dev/null +++ b/docs/models/speechinputreferencevideo.mdx @@ -0,0 +1,25 @@ +--- +title: "SpeechInputReferenceVideo" +--- + +Reference video the generated audio is made for (sound and voice matched to the footage, same length as the clip). Must be the only part in `input_references`. Only routed to endpoints that support video references, which bill at their video rate. + +## Example Usage + +```typescript +import { SpeechInputReferenceVideo } from "@openrouter/sdk/models"; + +let value: SpeechInputReferenceVideo = { + type: "video_url", + videoUrl: { + url: "https://example.com/clip.mp4", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `type` | *"video_url"* | ✔️ | N/A | | +| `videoUrl` | [models.SpeechInputReferenceVideoInput](../models/speechinputreferencevideoinput.mdx) | ✔️ | Reference video input object | \{
"url": "https://example.com/clip.mp4"
} | \ No newline at end of file diff --git a/docs/models/speechinputreferencevideoinput.mdx b/docs/models/speechinputreferencevideoinput.mdx new file mode 100644 index 000000000..1f124bccc --- /dev/null +++ b/docs/models/speechinputreferencevideoinput.mdx @@ -0,0 +1,21 @@ +--- +title: "SpeechInputReferenceVideoInput" +--- + +Reference video input object + +## Example Usage + +```typescript +import { SpeechInputReferenceVideoInput } from "@openrouter/sdk/models"; + +let value: SpeechInputReferenceVideoInput = { + url: "https://example.com/clip.mp4", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| `url` | *string* | ✔️ | Public http(s) URL of the reference video. The provider downloads it; OpenRouter does not fetch it, and data URIs are rejected. | https://example.com/clip.mp4 | \ No newline at end of file diff --git a/docs/models/speechrequest.mdx b/docs/models/speechrequest.mdx index 61b3cdd52..7537a0ce4 100644 --- a/docs/models/speechrequest.mdx +++ b/docs/models/speechrequest.mdx @@ -20,7 +20,7 @@ let value: SpeechRequest = { | 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"
}
] | +| `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 and no other parts; only routed to endpoints that support video 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 | diff --git a/jsr.json b/jsr.json index 9073574e8..f99f29689 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.5.172", + "version": "1.5.173", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 692b9a32f..551657d0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.5.172", + "version": "1.5.173", "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": [ @@ -21,8 +21,8 @@ "license": "Apache-2.0", "packageManager": "pnpm@10.22.0", "publishConfig": { - "provenance": true, - "access": "public" + "access": "public", + "provenance": true }, "type": "module", "main": "./esm/index.js", @@ -74,13 +74,13 @@ "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", + "postinstall": "node scripts/check-types.js || true", "prepare": "npm run build", "test": "vitest --run --project unit", "test:e2e": "vitest --run --project e2e", "test:transit": "exit 0", "test:watch": "vitest --watch --project unit", "typecheck": "tsc --noEmit", - "postinstall": "node scripts/check-types.js || true", "typecheck:transit": "exit 0" }, "peerDependencies": { diff --git a/src/lib/config.ts b/src/lib/config.ts index 42704ca0e..4b7fc374b 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.172", + sdkVersion: "1.5.173", genVersion: "2.960.8", - userAgent: "speakeasy-sdk/typescript 1.5.172 2.960.8 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.5.173 2.960.8 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/anthropicsafeguardresult.ts b/src/models/anthropicsafeguardresult.ts new file mode 100644 index 000000000..a2b1af2b1 --- /dev/null +++ b/src/models/anthropicsafeguardresult.ts @@ -0,0 +1,70 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { + collectExtraKeys as collectExtraKeys$, + safeParse, +} from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +export type AnthropicSafeguardResultStatus = { + type: string; + additionalProperties?: { [k: string]: any } | undefined; +}; + +/** + * The outcome of a server-side safeguard, keyed by tool-use id where applicable + */ +export type AnthropicSafeguardResult = { + status: AnthropicSafeguardResultStatus; + type: string; + additionalProperties?: { [k: string]: any } | undefined; +}; + +/** @internal */ +export const AnthropicSafeguardResultStatus$inboundSchema: z.ZodType< + AnthropicSafeguardResultStatus, + unknown +> = collectExtraKeys$( + z.object({ + type: z.string(), + }).catchall(z.any()), + "additionalProperties", + true, +); + +export function anthropicSafeguardResultStatusFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AnthropicSafeguardResultStatus$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AnthropicSafeguardResultStatus' from JSON`, + ); +} + +/** @internal */ +export const AnthropicSafeguardResult$inboundSchema: z.ZodType< + AnthropicSafeguardResult, + unknown +> = collectExtraKeys$( + z.object({ + status: z.lazy(() => AnthropicSafeguardResultStatus$inboundSchema), + type: z.string(), + }).catchall(z.any()), + "additionalProperties", + true, +); + +export function anthropicSafeguardResultFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AnthropicSafeguardResult$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AnthropicSafeguardResult' from JSON`, + ); +} diff --git a/src/models/anthropicservicetier.ts b/src/models/anthropicservicetier.ts deleted file mode 100644 index e882738f9..000000000 --- a/src/models/anthropicservicetier.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ - -import * as z from "zod/v4"; -import * as openEnums from "../types/enums.js"; -import { OpenEnum } from "../types/enums.js"; - -export const AnthropicServiceTier = { - Standard: "standard", - Priority: "priority", - Batch: "batch", -} as const; -export type AnthropicServiceTier = OpenEnum; - -/** @internal */ -export const AnthropicServiceTier$inboundSchema: z.ZodType< - AnthropicServiceTier, - unknown -> = openEnums.inboundSchema(AnthropicServiceTier); diff --git a/src/models/batchimagegenerationmissingimage.ts b/src/models/batchimagegenerationmissingimage.ts new file mode 100644 index 000000000..b55597c9e --- /dev/null +++ b/src/models/batchimagegenerationmissingimage.ts @@ -0,0 +1,41 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { safeParse } from "../lib/schemas.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +/** + * An image the provider returned that OpenRouter could not store. It is not billed. + */ +export type BatchImageGenerationMissingImage = { + /** + * Position of the image among the images returned for this request, from 0 + */ + index: number; + /** + * Why the image is missing + */ + message: string; +}; + +/** @internal */ +export const BatchImageGenerationMissingImage$inboundSchema: z.ZodType< + BatchImageGenerationMissingImage, + unknown +> = z.object({ + index: z.int(), + message: z.string(), +}); + +export function batchImageGenerationMissingImageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchImageGenerationMissingImage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchImageGenerationMissingImage' from JSON`, + ); +} diff --git a/src/models/batchimagegenerationresponse.ts b/src/models/batchimagegenerationresponse.ts index 4d1e02cf6..80f18adc7 100644 --- a/src/models/batchimagegenerationresponse.ts +++ b/src/models/batchimagegenerationresponse.ts @@ -10,6 +10,10 @@ import { BatchImageGenerationImage, BatchImageGenerationImage$inboundSchema, } from "./batchimagegenerationimage.js"; +import { + BatchImageGenerationMissingImage, + BatchImageGenerationMissingImage$inboundSchema, +} from "./batchimagegenerationmissingimage.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; import { ImageGenerationUsage, @@ -33,6 +37,10 @@ export type BatchImageGenerationResponse = { * Generation ID of this request. Look up its cost and details with `GET /api/v1/generation?id=`. */ id?: string | undefined; + /** + * Images the provider returned without usable image data. Present only when some images of the request are missing; `data` lists the rest. + */ + missingImages?: Array | undefined; /** * Token and cost usage for the image generation request, when available */ @@ -48,10 +56,13 @@ export const BatchImageGenerationResponse$inboundSchema: z.ZodType< data: z.array(BatchImageGenerationImage$inboundSchema), expires_at: z.int(), id: z.string().optional(), + missing_images: z.array(BatchImageGenerationMissingImage$inboundSchema) + .optional(), usage: ImageGenerationUsage$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "expires_at": "expiresAt", + "missing_images": "missingImages", }); }); diff --git a/src/models/batchresult.ts b/src/models/batchresult.ts index e57abe132..c0c9327f3 100644 --- a/src/models/batchresult.ts +++ b/src/models/batchresult.ts @@ -35,13 +35,9 @@ import { AnthropicRefusalStopDetails$inboundSchema, } from "./anthropicrefusalstopdetails.js"; import { - AnthropicServerToolUsage, - AnthropicServerToolUsage$inboundSchema, -} from "./anthropicservertoolusage.js"; -import { - AnthropicServiceTier, - AnthropicServiceTier$inboundSchema, -} from "./anthropicservicetier.js"; + AnthropicSafeguardResult, + AnthropicSafeguardResult$inboundSchema, +} from "./anthropicsafeguardresult.js"; import { AnthropicSpeed, AnthropicSpeed$inboundSchema, @@ -78,6 +74,10 @@ import { ORAnthropicContentBlock, ORAnthropicContentBlock$inboundSchema, } from "./oranthropiccontentblock.js"; +import { + ORAnthropicServerToolUsage, + ORAnthropicServerToolUsage$inboundSchema, +} from "./oranthropicservertoolusage.js"; import { ORAnthropicStopReason, ORAnthropicStopReason$inboundSchema, @@ -272,6 +272,15 @@ export type BodyList = { usage?: BatchResultUsage3 | undefined; }; +export type AppliedEdit = { + type: string; + additionalProperties?: { [k: string]: any } | undefined; +}; + +export type BatchResultContextManagement = { + appliedEdits: Array; +}; + export const BatchResultRole = { Assistant: "assistant", } as const; @@ -282,27 +291,57 @@ export const BatchResultTypeMessage = { } as const; export type BatchResultTypeMessage = ClosedEnum; +export type BatchResultDeferredToolsDetails = { + /** + * Completion tokens summed over every upstream call + */ + completionTokens: number; + /** + * Prompt tokens summed over every upstream call + */ + promptTokens: number; + /** + * Sum of the above two fields + */ + totalTokens: number; + /** + * Upstream model calls the run made + */ + turns: number; +}; + export type BatchResultUsage2 = { cacheCreation: AnthropicCacheCreation | null; cacheCreationInputTokens: number | null; cacheReadInputTokens: number | null; + cost?: number | null | undefined; + /** + * Breakdown of upstream inference costs + */ + costDetails?: CostDetails | null | undefined; + deferredToolsDetails?: BatchResultDeferredToolsDetails | undefined; inferenceGeo: string | null; inputTokens: number; + isByok?: boolean | undefined; + iterations?: Array | undefined; outputTokens: number; outputTokensDetails: AnthropicOutputTokensDetails | null; - serverToolUse: AnthropicServerToolUsage | null; - serviceTier: AnthropicServiceTier | null; - iterations?: Array | undefined; + serverToolUse: ORAnthropicServerToolUsage | null; + serviceTier: string | null; speed?: AnthropicSpeed | null | undefined; }; export type BodyMessage = { container: AnthropicContainer | null; content: Array; + contextManagement?: BatchResultContextManagement | null | undefined; id: string; inputTransformations?: Array | null | undefined; model: string; + openrouterMetadata?: OpenRouterMetadata | undefined; + provider?: string | undefined; role: BatchResultRole; + safeguardResults?: Array | null | undefined; /** * Structured information about a refusal */ @@ -888,6 +927,48 @@ export function bodyListFromJSON( ); } +/** @internal */ +export const AppliedEdit$inboundSchema: z.ZodType = + collectExtraKeys$( + z.object({ + type: z.string(), + }).catchall(z.any()), + "additionalProperties", + true, + ); + +export function appliedEditFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AppliedEdit$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AppliedEdit' from JSON`, + ); +} + +/** @internal */ +export const BatchResultContextManagement$inboundSchema: z.ZodType< + BatchResultContextManagement, + unknown +> = z.object({ + applied_edits: z.array(z.lazy(() => AppliedEdit$inboundSchema)), +}).transform((v) => { + return remap$(v, { + "applied_edits": "appliedEdits", + }); +}); + +export function batchResultContextManagementFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchResultContextManagement$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchResultContextManagement' from JSON`, + ); +} + /** @internal */ export const BatchResultRole$inboundSchema: z.ZodEnum = z.enum(BatchResultRole); @@ -897,6 +978,33 @@ export const BatchResultTypeMessage$inboundSchema: z.ZodEnum< typeof BatchResultTypeMessage > = z.enum(BatchResultTypeMessage); +/** @internal */ +export const BatchResultDeferredToolsDetails$inboundSchema: z.ZodType< + BatchResultDeferredToolsDetails, + unknown +> = z.object({ + completion_tokens: z.int(), + prompt_tokens: z.int(), + total_tokens: z.int(), + turns: z.int(), +}).transform((v) => { + return remap$(v, { + "completion_tokens": "completionTokens", + "prompt_tokens": "promptTokens", + "total_tokens": "totalTokens", + }); +}); + +export function batchResultDeferredToolsDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchResultDeferredToolsDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchResultDeferredToolsDetails' from JSON`, + ); +} + /** @internal */ export const BatchResultUsage2$inboundSchema: z.ZodType< BatchResultUsage2, @@ -905,21 +1013,30 @@ export const BatchResultUsage2$inboundSchema: z.ZodType< cache_creation: z.nullable(AnthropicCacheCreation$inboundSchema), cache_creation_input_tokens: z.nullable(z.int()), cache_read_input_tokens: z.nullable(z.int()), + cost: z.nullable(z.number()).optional(), + cost_details: z.nullable(CostDetails$inboundSchema).optional(), + deferred_tools_details: z.lazy(() => + BatchResultDeferredToolsDetails$inboundSchema + ).optional(), inference_geo: z.nullable(z.string()), input_tokens: z.int(), + is_byok: z.boolean().optional(), + iterations: z.array(AnthropicUsageIteration$inboundSchema).optional(), output_tokens: z.int(), output_tokens_details: z.nullable(AnthropicOutputTokensDetails$inboundSchema), - server_tool_use: z.nullable(AnthropicServerToolUsage$inboundSchema), - service_tier: z.nullable(AnthropicServiceTier$inboundSchema), - iterations: z.array(AnthropicUsageIteration$inboundSchema).optional(), + server_tool_use: z.nullable(ORAnthropicServerToolUsage$inboundSchema), + service_tier: z.nullable(z.string()), speed: z.nullable(AnthropicSpeed$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "cache_creation": "cacheCreation", "cache_creation_input_tokens": "cacheCreationInputTokens", "cache_read_input_tokens": "cacheReadInputTokens", + "cost_details": "costDetails", + "deferred_tools_details": "deferredToolsDetails", "inference_geo": "inferenceGeo", "input_tokens": "inputTokens", + "is_byok": "isByok", "output_tokens": "outputTokens", "output_tokens_details": "outputTokensDetails", "server_tool_use": "serverToolUse", @@ -942,12 +1059,20 @@ export const BodyMessage$inboundSchema: z.ZodType = z .object({ container: z.nullable(AnthropicContainer$inboundSchema), content: z.array(ORAnthropicContentBlock$inboundSchema), + context_management: z.nullable( + z.lazy(() => BatchResultContextManagement$inboundSchema), + ).optional(), id: z.string(), input_transformations: z.nullable( z.array(AnthropicInputTransformation$inboundSchema), ).optional(), model: z.string(), + openrouter_metadata: OpenRouterMetadata$inboundSchema.optional(), + provider: z.string().optional(), role: BatchResultRole$inboundSchema, + safeguard_results: z.nullable( + z.array(AnthropicSafeguardResult$inboundSchema), + ).optional(), stop_details: z.nullable(AnthropicRefusalStopDetails$inboundSchema), stop_reason: z.nullable(ORAnthropicStopReason$inboundSchema), stop_sequence: z.nullable(z.string()), @@ -955,7 +1080,10 @@ export const BodyMessage$inboundSchema: z.ZodType = z usage: z.lazy(() => BatchResultUsage2$inboundSchema), }).transform((v) => { return remap$(v, { + "context_management": "contextManagement", "input_transformations": "inputTransformations", + "openrouter_metadata": "openrouterMetadata", + "safeguard_results": "safeguardResults", "stop_details": "stopDetails", "stop_reason": "stopReason", "stop_sequence": "stopSequence", diff --git a/src/models/index.ts b/src/models/index.ts index c3b0a612b..ae7fe15c1 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -87,10 +87,9 @@ export * from "./anthropicplaintextsource.js"; export * from "./anthropicredactedthinkingblock.js"; export * from "./anthropicrefusalstopdetails.js"; export * from "./anthropicsafeguard.js"; +export * from "./anthropicsafeguardresult.js"; export * from "./anthropicsearchresultblockparam.js"; export * from "./anthropicservertoolerrorcode.js"; -export * from "./anthropicservertoolusage.js"; -export * from "./anthropicservicetier.js"; export * from "./anthropicspeed.js"; export * from "./anthropicsystemclearat.js"; export * from "./anthropictextblock.js"; @@ -167,6 +166,7 @@ export * from "./batchdeletionoutcome.js"; export * from "./batchdeletiontargets.js"; export * from "./batcherrorresponse.js"; export * from "./batchimagegenerationimage.js"; +export * from "./batchimagegenerationmissingimage.js"; export * from "./batchimagegenerationresponse.js"; export * from "./batchinputreference.js"; export * from "./batchlistitem.js"; @@ -574,6 +574,8 @@ export * from "./memberassignment.js"; export * from "./messagesadvisortoolresultblock.js"; export * from "./messagesbashtoolresultblock.js"; export * from "./messagesfallbackparam.js"; +export * from "./messagesmcptoolresultblock.js"; +export * from "./messagesmcptooluseblock.js"; export * from "./messagesmessageparam.js"; export * from "./messagesoutputconfig.js"; export * from "./messagesrequest.js"; @@ -672,6 +674,7 @@ export * from "./operator.js"; export * from "./oranthropicbashtoolresult.js"; export * from "./oranthropiccontentblock.js"; export * from "./oranthropicnullablecaller.js"; +export * from "./oranthropicservertoolusage.js"; export * from "./oranthropicservertooluseblock.js"; export * from "./oranthropicshelltoolresult.js"; export * from "./oranthropicstopreason.js"; @@ -876,6 +879,8 @@ export * from "./speechinputreferenceaudioinput.js"; export * from "./speechinputreferenceimage.js"; export * from "./speechinputreferenceimageinput.js"; export * from "./speechinputreferencetext.js"; +export * from "./speechinputreferencevideo.js"; +export * from "./speechinputreferencevideoinput.js"; export * from "./speechmodelendpoint.js"; export * from "./speechmodelresponse.js"; export * from "./speechmodelslistresponse.js"; diff --git a/src/models/messagesmcptoolresultblock.ts b/src/models/messagesmcptoolresultblock.ts new file mode 100644 index 000000000..e067294ff --- /dev/null +++ b/src/models/messagesmcptoolresultblock.ts @@ -0,0 +1,93 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { + AnthropicCacheControlDirective, + AnthropicCacheControlDirective$Outbound, + AnthropicCacheControlDirective$outboundSchema, +} from "./anthropiccachecontroldirective.js"; +import { + AnthropicTextBlockParam, + AnthropicTextBlockParam$Outbound, + AnthropicTextBlockParam$outboundSchema, +} from "./anthropictextblockparam.js"; + +export type MessagesMcpToolResultBlockContent = + | string + | Array; + +/** + * MCP tool result block paired with a prior `mcp_tool_use` block for replay. + */ +export type MessagesMcpToolResultBlock = { + /** + * Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + */ + cacheControl?: AnthropicCacheControlDirective | undefined; + content?: string | Array | undefined; + isError?: boolean | undefined; + toolUseId: string; + type: "mcp_tool_result"; +}; + +/** @internal */ +export type MessagesMcpToolResultBlockContent$Outbound = + | string + | Array; + +/** @internal */ +export const MessagesMcpToolResultBlockContent$outboundSchema: z.ZodType< + MessagesMcpToolResultBlockContent$Outbound, + MessagesMcpToolResultBlockContent +> = z.union([z.string(), z.array(AnthropicTextBlockParam$outboundSchema)]); + +export function messagesMcpToolResultBlockContentToJSON( + messagesMcpToolResultBlockContent: MessagesMcpToolResultBlockContent, +): string { + return JSON.stringify( + MessagesMcpToolResultBlockContent$outboundSchema.parse( + messagesMcpToolResultBlockContent, + ), + ); +} + +/** @internal */ +export type MessagesMcpToolResultBlock$Outbound = { + cache_control?: AnthropicCacheControlDirective$Outbound | undefined; + content?: string | Array | undefined; + is_error?: boolean | undefined; + tool_use_id: string; + type: "mcp_tool_result"; +}; + +/** @internal */ +export const MessagesMcpToolResultBlock$outboundSchema: z.ZodType< + MessagesMcpToolResultBlock$Outbound, + MessagesMcpToolResultBlock +> = z.object({ + cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(), + content: z.union([ + z.string(), + z.array(AnthropicTextBlockParam$outboundSchema), + ]).optional(), + isError: z.boolean().optional(), + toolUseId: z.string(), + type: z.literal("mcp_tool_result"), +}).transform((v) => { + return remap$(v, { + cacheControl: "cache_control", + isError: "is_error", + toolUseId: "tool_use_id", + }); +}); + +export function messagesMcpToolResultBlockToJSON( + messagesMcpToolResultBlock: MessagesMcpToolResultBlock, +): string { + return JSON.stringify( + MessagesMcpToolResultBlock$outboundSchema.parse(messagesMcpToolResultBlock), + ); +} diff --git a/src/models/messagesmcptooluseblock.ts b/src/models/messagesmcptooluseblock.ts new file mode 100644 index 000000000..83faa78b6 --- /dev/null +++ b/src/models/messagesmcptooluseblock.ts @@ -0,0 +1,62 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { + AnthropicCacheControlDirective, + AnthropicCacheControlDirective$Outbound, + AnthropicCacheControlDirective$outboundSchema, +} from "./anthropiccachecontroldirective.js"; + +/** + * MCP tool call emitted by an upstream Anthropic assistant turn for replay. + */ +export type MessagesMcpToolUseBlock = { + /** + * Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. + */ + cacheControl?: AnthropicCacheControlDirective | undefined; + id: string; + input?: any | undefined; + name: string; + serverName: string; + type: "mcp_tool_use"; +}; + +/** @internal */ +export type MessagesMcpToolUseBlock$Outbound = { + cache_control?: AnthropicCacheControlDirective$Outbound | undefined; + id: string; + input?: any | undefined; + name: string; + server_name: string; + type: "mcp_tool_use"; +}; + +/** @internal */ +export const MessagesMcpToolUseBlock$outboundSchema: z.ZodType< + MessagesMcpToolUseBlock$Outbound, + MessagesMcpToolUseBlock +> = z.object({ + cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(), + id: z.string(), + input: z.any().optional(), + name: z.string(), + serverName: z.string(), + type: z.literal("mcp_tool_use"), +}).transform((v) => { + return remap$(v, { + cacheControl: "cache_control", + serverName: "server_name", + }); +}); + +export function messagesMcpToolUseBlockToJSON( + messagesMcpToolUseBlock: MessagesMcpToolUseBlock, +): string { + return JSON.stringify( + MessagesMcpToolUseBlock$outboundSchema.parse(messagesMcpToolUseBlock), + ); +} diff --git a/src/models/messagesmessageparam.ts b/src/models/messagesmessageparam.ts index 18c9c4d0f..384856271 100644 --- a/src/models/messagesmessageparam.ts +++ b/src/models/messagesmessageparam.ts @@ -55,6 +55,16 @@ import { MessagesBashToolResultBlock$Outbound, MessagesBashToolResultBlock$outboundSchema, } from "./messagesbashtoolresultblock.js"; +import { + MessagesMcpToolResultBlock, + MessagesMcpToolResultBlock$Outbound, + MessagesMcpToolResultBlock$outboundSchema, +} from "./messagesmcptoolresultblock.js"; +import { + MessagesMcpToolUseBlock, + MessagesMcpToolUseBlock$Outbound, + MessagesMcpToolUseBlock$outboundSchema, +} from "./messagesmcptooluseblock.js"; import { MessagesShellToolResultBlock, MessagesShellToolResultBlock$Outbound, @@ -224,7 +234,9 @@ export type MessagesMessageParamContentUnion4 = | MessagesShellToolResultBlock | MessagesBashToolResultBlock | ORAnthropicToolSearchResultParam - | MessagesToolSearchToolResultBlock; + | MessagesToolSearchToolResultBlock + | MessagesMcpToolUseBlock + | MessagesMcpToolResultBlock; export type MessagesMessageParamContentUnion5 = | string @@ -247,6 +259,8 @@ export type MessagesMessageParamContentUnion5 = | MessagesBashToolResultBlock | ORAnthropicToolSearchResultParam | MessagesToolSearchToolResultBlock + | MessagesMcpToolUseBlock + | MessagesMcpToolResultBlock >; export const MessagesMessageParamRole = { @@ -284,6 +298,8 @@ export type MessagesMessageParam = { | MessagesBashToolResultBlock | ORAnthropicToolSearchResultParam | MessagesToolSearchToolResultBlock + | MessagesMcpToolUseBlock + | MessagesMcpToolResultBlock >; outputConfig?: AnthropicMessageOutputConfig | null | undefined; role: MessagesMessageParamRole; @@ -700,7 +716,9 @@ export type MessagesMessageParamContentUnion4$Outbound = | MessagesShellToolResultBlock$Outbound | MessagesBashToolResultBlock$Outbound | ORAnthropicToolSearchResultParam$Outbound - | MessagesToolSearchToolResultBlock$Outbound; + | MessagesToolSearchToolResultBlock$Outbound + | MessagesMcpToolUseBlock$Outbound + | MessagesMcpToolResultBlock$Outbound; /** @internal */ export const MessagesMessageParamContentUnion4$outboundSchema: z.ZodType< @@ -725,6 +743,8 @@ export const MessagesMessageParamContentUnion4$outboundSchema: z.ZodType< MessagesBashToolResultBlock$outboundSchema, ORAnthropicToolSearchResultParam$outboundSchema, MessagesToolSearchToolResultBlock$outboundSchema, + MessagesMcpToolUseBlock$outboundSchema, + MessagesMcpToolResultBlock$outboundSchema, ]); export function messagesMessageParamContentUnion4ToJSON( @@ -759,6 +779,8 @@ export type MessagesMessageParamContentUnion5$Outbound = | MessagesBashToolResultBlock$Outbound | ORAnthropicToolSearchResultParam$Outbound | MessagesToolSearchToolResultBlock$Outbound + | MessagesMcpToolUseBlock$Outbound + | MessagesMcpToolResultBlock$Outbound >; /** @internal */ @@ -787,6 +809,8 @@ export const MessagesMessageParamContentUnion5$outboundSchema: z.ZodType< MessagesBashToolResultBlock$outboundSchema, ORAnthropicToolSearchResultParam$outboundSchema, MessagesToolSearchToolResultBlock$outboundSchema, + MessagesMcpToolUseBlock$outboundSchema, + MessagesMcpToolResultBlock$outboundSchema, ]), ), ]); @@ -831,6 +855,8 @@ export type MessagesMessageParam$Outbound = { | MessagesBashToolResultBlock$Outbound | ORAnthropicToolSearchResultParam$Outbound | MessagesToolSearchToolResultBlock$Outbound + | MessagesMcpToolUseBlock$Outbound + | MessagesMcpToolResultBlock$Outbound >; output_config?: AnthropicMessageOutputConfig$Outbound | null | undefined; role: string; @@ -864,6 +890,8 @@ export const MessagesMessageParam$outboundSchema: z.ZodType< MessagesBashToolResultBlock$outboundSchema, ORAnthropicToolSearchResultParam$outboundSchema, MessagesToolSearchToolResultBlock$outboundSchema, + MessagesMcpToolUseBlock$outboundSchema, + MessagesMcpToolResultBlock$outboundSchema, ]), ), ]), diff --git a/src/models/messagesrequest.ts b/src/models/messagesrequest.ts index dbcd33cb4..9722bca5f 100644 --- a/src/models/messagesrequest.ts +++ b/src/models/messagesrequest.ts @@ -276,7 +276,7 @@ export type Edit = | EditClearThinking20251015 | EditCompact20260112; -export type ContextManagement = { +export type MessagesRequestContextManagement = { edits?: | Array< | EditClearToolUses20250919 @@ -553,7 +553,7 @@ export type MessagesRequest = { * Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format. */ cacheControl?: AnthropicCacheControlDirective | undefined; - contextManagement?: ContextManagement | null | undefined; + contextManagement?: MessagesRequestContextManagement | null | undefined; /** * Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with `announce_catalog_changes`, tells the model about it. */ @@ -883,7 +883,7 @@ export function editToJSON(edit: Edit): string { } /** @internal */ -export type ContextManagement$Outbound = { +export type MessagesRequestContextManagement$Outbound = { edits?: | Array< | EditClearToolUses20250919$Outbound @@ -894,9 +894,9 @@ export type ContextManagement$Outbound = { }; /** @internal */ -export const ContextManagement$outboundSchema: z.ZodType< - ContextManagement$Outbound, - ContextManagement +export const MessagesRequestContextManagement$outboundSchema: z.ZodType< + MessagesRequestContextManagement$Outbound, + MessagesRequestContextManagement > = z.object({ edits: z.array( z.union([ @@ -907,11 +907,13 @@ export const ContextManagement$outboundSchema: z.ZodType< ).optional(), }); -export function contextManagementToJSON( - contextManagement: ContextManagement, +export function messagesRequestContextManagementToJSON( + messagesRequestContextManagement: MessagesRequestContextManagement, ): string { return JSON.stringify( - ContextManagement$outboundSchema.parse(contextManagement), + MessagesRequestContextManagement$outboundSchema.parse( + messagesRequestContextManagement, + ), ); } @@ -1635,7 +1637,10 @@ export function messagesRequestToolUnionToJSON( /** @internal */ export type MessagesRequest$Outbound = { cache_control?: AnthropicCacheControlDirective$Outbound | undefined; - context_management?: ContextManagement$Outbound | null | undefined; + context_management?: + | MessagesRequestContextManagement$Outbound + | null + | undefined; deferred_tools?: DeferredToolsControl$Outbound | undefined; fallbacks?: Array | null | undefined; max_tokens?: number | undefined; @@ -1719,8 +1724,9 @@ export const MessagesRequest$outboundSchema: z.ZodType< MessagesRequest > = z.object({ cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(), - contextManagement: z.nullable(z.lazy(() => ContextManagement$outboundSchema)) - .optional(), + contextManagement: z.nullable( + z.lazy(() => MessagesRequestContextManagement$outboundSchema), + ).optional(), deferredTools: DeferredToolsControl$outboundSchema.optional(), fallbacks: z.nullable(z.array(MessagesFallbackParam$outboundSchema)) .optional(), diff --git a/src/models/anthropicservertoolusage.ts b/src/models/oranthropicservertoolusage.ts similarity index 51% rename from src/models/anthropicservertoolusage.ts rename to src/models/oranthropicservertoolusage.ts index d60aa023f..e9c4be55a 100644 --- a/src/models/anthropicservertoolusage.ts +++ b/src/models/oranthropicservertoolusage.ts @@ -8,31 +8,37 @@ import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; -export type AnthropicServerToolUsage = { +export type ORAnthropicServerToolUsage = { + toolCallsExecuted?: number | undefined; + toolCallsRequested?: number | undefined; webFetchRequests: number; webSearchRequests: number; }; /** @internal */ -export const AnthropicServerToolUsage$inboundSchema: z.ZodType< - AnthropicServerToolUsage, +export const ORAnthropicServerToolUsage$inboundSchema: z.ZodType< + ORAnthropicServerToolUsage, unknown > = z.object({ + tool_calls_executed: z.int().optional(), + tool_calls_requested: z.int().optional(), web_fetch_requests: z.int(), web_search_requests: z.int(), }).transform((v) => { return remap$(v, { + "tool_calls_executed": "toolCallsExecuted", + "tool_calls_requested": "toolCallsRequested", "web_fetch_requests": "webFetchRequests", "web_search_requests": "webSearchRequests", }); }); -export function anthropicServerToolUsageFromJSON( +export function orAnthropicServerToolUsageFromJSON( jsonString: string, -): SafeParseResult { +): SafeParseResult { return safeParse( jsonString, - (x) => AnthropicServerToolUsage$inboundSchema.parse(JSON.parse(x)), - `Failed to parse 'AnthropicServerToolUsage' from JSON`, + (x) => ORAnthropicServerToolUsage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ORAnthropicServerToolUsage' from JSON`, ); } diff --git a/src/models/speechinputmodality.ts b/src/models/speechinputmodality.ts index 78087f6b9..1919be9ad 100644 --- a/src/models/speechinputmodality.ts +++ b/src/models/speechinputmodality.ts @@ -16,6 +16,21 @@ import { SpeechReferenceCount$inboundSchema, } from "./speechreferencecount.js"; +/** + * `references` is how many `video_url` parts a request may send. A video reference is the only part of its request and bills at the endpoint's video rate. + */ +export type SpeechInputModalitySupportedInputs3 = { + references: SpeechReferenceCount; +}; + +export type SpeechInputModalityVideo = { + /** + * `references` is how many `video_url` parts a request may send. A video reference is the only part of its request and bills at the endpoint's video rate. + */ + supportedInputs: SpeechInputModalitySupportedInputs3; + type: "video"; +}; + /** * `required`: an image reference is accepted only together with an audio reference. `excluded`: only without one. Absent: either. */ @@ -80,14 +95,59 @@ export type SpeechInputModalityText = { }; /** - * An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design. + * An input the model accepts. `audio` and `image` are `input_references` for voice cloning and voice design; `video` is a reference video the generated audio is made for. */ export type SpeechInputModality = | SpeechInputModalityText | SpeechInputModalityAudio | SpeechInputModalityImage + | SpeechInputModalityVideo | discriminatedUnionTypes.Unknown<"type">; +/** @internal */ +export const SpeechInputModalitySupportedInputs3$inboundSchema: z.ZodType< + SpeechInputModalitySupportedInputs3, + unknown +> = z.object({ + references: SpeechReferenceCount$inboundSchema, +}); + +export function speechInputModalitySupportedInputs3FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + SpeechInputModalitySupportedInputs3$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SpeechInputModalitySupportedInputs3' from JSON`, + ); +} + +/** @internal */ +export const SpeechInputModalityVideo$inboundSchema: z.ZodType< + SpeechInputModalityVideo, + unknown +> = z.object({ + supported_inputs: z.lazy(() => + SpeechInputModalitySupportedInputs3$inboundSchema + ), + type: z.literal("video"), +}).transform((v) => { + return remap$(v, { + "supported_inputs": "supportedInputs", + }); +}); + +export function speechInputModalityVideoFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SpeechInputModalityVideo$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SpeechInputModalityVideo' from JSON`, + ); +} + /** @internal */ export const AudioEnum$inboundSchema: z.ZodType = openEnums .inboundSchema(AudioEnum); @@ -212,6 +272,7 @@ export const SpeechInputModality$inboundSchema: z.ZodType< text: z.lazy(() => SpeechInputModalityText$inboundSchema), audio: z.lazy(() => SpeechInputModalityAudio$inboundSchema), image: z.lazy(() => SpeechInputModalityImage$inboundSchema), + video: z.lazy(() => SpeechInputModalityVideo$inboundSchema), }); export function speechInputModalityFromJSON( diff --git a/src/models/speechinputreference.ts b/src/models/speechinputreference.ts index fadd2bae7..c6f9c7ea4 100644 --- a/src/models/speechinputreference.ts +++ b/src/models/speechinputreference.ts @@ -18,6 +18,11 @@ import { SpeechInputReferenceText$Outbound, SpeechInputReferenceText$outboundSchema, } from "./speechinputreferencetext.js"; +import { + SpeechInputReferenceVideo, + SpeechInputReferenceVideo$Outbound, + SpeechInputReferenceVideo$outboundSchema, +} from "./speechinputreferencevideo.js"; /** * Reference content part for stateless voice cloning or voice design @@ -25,13 +30,15 @@ import { export type SpeechInputReference = | SpeechInputReferenceImage | SpeechInputReferenceAudio - | SpeechInputReferenceText; + | SpeechInputReferenceText + | SpeechInputReferenceVideo; /** @internal */ export type SpeechInputReference$Outbound = | SpeechInputReferenceImage$Outbound | SpeechInputReferenceAudio$Outbound - | SpeechInputReferenceText$Outbound; + | SpeechInputReferenceText$Outbound + | SpeechInputReferenceVideo$Outbound; /** @internal */ export const SpeechInputReference$outboundSchema: z.ZodType< @@ -41,6 +48,7 @@ export const SpeechInputReference$outboundSchema: z.ZodType< SpeechInputReferenceImage$outboundSchema, SpeechInputReferenceAudio$outboundSchema, SpeechInputReferenceText$outboundSchema, + SpeechInputReferenceVideo$outboundSchema, ]); export function speechInputReferenceToJSON( diff --git a/src/models/speechinputreferencevideo.ts b/src/models/speechinputreferencevideo.ts new file mode 100644 index 000000000..780c3a67f --- /dev/null +++ b/src/models/speechinputreferencevideo.ts @@ -0,0 +1,49 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; +import { + SpeechInputReferenceVideoInput, + SpeechInputReferenceVideoInput$Outbound, + SpeechInputReferenceVideoInput$outboundSchema, +} from "./speechinputreferencevideoinput.js"; + +/** + * Reference video the generated audio is made for (sound and voice matched to the footage, same length as the clip). Must be the only part in `input_references`. Only routed to endpoints that support video references, which bill at their video rate. + */ +export type SpeechInputReferenceVideo = { + type: "video_url"; + /** + * Reference video input object + */ + videoUrl: SpeechInputReferenceVideoInput; +}; + +/** @internal */ +export type SpeechInputReferenceVideo$Outbound = { + type: "video_url"; + video_url: SpeechInputReferenceVideoInput$Outbound; +}; + +/** @internal */ +export const SpeechInputReferenceVideo$outboundSchema: z.ZodType< + SpeechInputReferenceVideo$Outbound, + SpeechInputReferenceVideo +> = z.object({ + type: z.literal("video_url"), + videoUrl: SpeechInputReferenceVideoInput$outboundSchema, +}).transform((v) => { + return remap$(v, { + videoUrl: "video_url", + }); +}); + +export function speechInputReferenceVideoToJSON( + speechInputReferenceVideo: SpeechInputReferenceVideo, +): string { + return JSON.stringify( + SpeechInputReferenceVideo$outboundSchema.parse(speechInputReferenceVideo), + ); +} diff --git a/src/models/speechinputreferencevideoinput.ts b/src/models/speechinputreferencevideoinput.ts new file mode 100644 index 000000000..e9abb31c3 --- /dev/null +++ b/src/models/speechinputreferencevideoinput.ts @@ -0,0 +1,38 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod/v4"; + +/** + * Reference video input object + */ +export type SpeechInputReferenceVideoInput = { + /** + * Public http(s) URL of the reference video. The provider downloads it; OpenRouter does not fetch it, and data URIs are rejected. + */ + url: string; +}; + +/** @internal */ +export type SpeechInputReferenceVideoInput$Outbound = { + url: string; +}; + +/** @internal */ +export const SpeechInputReferenceVideoInput$outboundSchema: z.ZodType< + SpeechInputReferenceVideoInput$Outbound, + SpeechInputReferenceVideoInput +> = z.object({ + url: z.string(), +}); + +export function speechInputReferenceVideoInputToJSON( + speechInputReferenceVideoInput: SpeechInputReferenceVideoInput, +): string { + return JSON.stringify( + SpeechInputReferenceVideoInput$outboundSchema.parse( + speechInputReferenceVideoInput, + ), + ); +} diff --git a/src/models/speechrequest.ts b/src/models/speechrequest.ts index bce50a5d7..7533e8850 100644 --- a/src/models/speechrequest.ts +++ b/src/models/speechrequest.ts @@ -143,7 +143,7 @@ export type SpeechRequest = { */ input: SpeechInput; /** - * 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. + * 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 and no other parts; only routed to endpoints that support video references. An empty array is treated as no reference. */ inputReferences?: Array | undefined; /**