diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index ec4a3856..b11d6e83 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: c48cf606-fb42-4a45-9c23-8f0555307828 management: - docChecksum: 4ec24ba93b3a397ecc159ac306a6bd8a + docChecksum: a1823e398ef1b0d3f2314d16c5fd9b22 docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.3.29 - configChecksum: 82c5f834c7b9d556fb73ec8117d817a6 + releaseVersion: 1.3.30 + configChecksum: 6c32822b074d7404007cd6410371ad92 repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: b928df92-9cae-47af-9454-7d30c8053b5a - pristine_commit_hash: 09a11fd1f5dcfe408a96bb057ed8339698eddf31 - pristine_tree_hash: f9147190ea5e3cf564da92a88c2f35aa14314adc + generation_id: a58a3b0f-3113-4cbb-b0f9-e0d218f1de4e + pristine_commit_hash: e5712c504d02689c881c73522c62e866301ad5b6 + pristine_tree_hash: 82f92d658696b808589f8a8936e23dffe0dffd6b features: python: acceptHeaders: 3.0.0 @@ -3832,8 +3832,8 @@ trackedFiles: pristine_git_object: 33aee92c61bf7ab9beded4e193f50a2c08462378 docs/components/inputsunion1.mdx: id: c216609d21ce - last_write_checksum: sha1:9227d47c24ee5edc23887ac20f218cffd067b528 - pristine_git_object: e76c31df752f42afe7df4285608f21e6c8392a59 + last_write_checksum: sha1:c2f6569bdb331bd9076a61467e61cfcec65668b0 + pristine_git_object: 3d16d55938f8b22bfe43608d45682aaaf48db285 docs/components/inputtext.mdx: id: c8a97322a50a last_write_checksum: sha1:6f92abbb193a5d21cc129df4c5804b3f9161322d @@ -7238,6 +7238,50 @@ trackedFiles: id: b3ea2dbc7af5 last_write_checksum: sha1:3659a42c9b930d77f5aecb8be29aef877d1502de pristine_git_object: a4ed39817c997d4e25266c25d12498e648d77190 + docs/components/toolsearchcallitem.mdx: + id: eb95e04d3021 + last_write_checksum: sha1:b502fea9779b201737d5049de618e4f1b2595cfa + pristine_git_object: 470d130f0b59df99c9f8e47452430b4c0da7f3cb + docs/components/toolsearchcallitemexecution.mdx: + id: 628641b6d80a + last_write_checksum: sha1:33610fdc12f4cfa46c060bb2bbd6a63fe8b729e1 + pristine_git_object: 56b48f217eef573ca74be339639c8129df0ae103 + docs/components/toolsearchcallitemstatus.mdx: + id: 0d40be817e4a + last_write_checksum: sha1:f64191f8dfb19d64b4a7a9df1cc34dd0486238f4 + pristine_git_object: b71fd2da8d19f1da71c4a89748ad15ac3158830e + docs/components/toolsearchcallitemtype.mdx: + id: 502218d84dbc + last_write_checksum: sha1:b57a84430502209aa46ffdaeb631fb57397657a8 + pristine_git_object: d35aaf3b280c6e6e985c8fa5f0511dc1134bcbf7 + docs/components/toolsearchoutputitem.mdx: + id: 5924dbd67404 + last_write_checksum: sha1:f574f21dec820190b84e772145c1e526f3e37274 + pristine_git_object: a5d1dd6c7ec279c4d543100ae08c7b33dea533bd + docs/components/toolsearchoutputitemexecution.mdx: + id: df33a1ae9565 + last_write_checksum: sha1:afc5ebeb2567d89c34df76cb86f7ffd96262fe1d + pristine_git_object: 905132c843ae1fd8276335423aaa6ac27e2a934c + docs/components/toolsearchoutputitemstatus.mdx: + id: 96304f797292 + last_write_checksum: sha1:659d2756fb349c20c267c9afbeabe6739ecc5e52 + pristine_git_object: cbd5ff21806a56f4e3f0c3668b67321044f9b1e5 + docs/components/toolsearchoutputitemtool.mdx: + id: 5d0008399326 + last_write_checksum: sha1:60b3c1e3522ea241fe02159dbaeb1248e3c286dd + pristine_git_object: da5087fa634826e4a4146df98697a83f822b12f6 + docs/components/toolsearchoutputitemtoolfunction.mdx: + id: 0e5b37ad1d40 + last_write_checksum: sha1:a528e2bc54f1b25638647ea150beb9e563575a23 + pristine_git_object: 1c5758db00e2e5a3fa589d1b8babd6d0ade6b744 + docs/components/toolsearchoutputitemtoolunion.mdx: + id: b0ea571f5d27 + last_write_checksum: sha1:d6add493f38d0fdce75a3c2ad33f390881358ce9 + pristine_git_object: fc1479a10a0f3c164384ee353388bb85bb3bc615 + docs/components/toolsearchoutputitemtypefunction.mdx: + id: 6a6efebc029a + last_write_checksum: sha1:059e58a497256a4cb22de1ab332b6961a85192da + pristine_git_object: a31e6e8f950bce5060542d1814340ec8080798b5 docs/components/toolsearchservertool.mdx: id: 827c342fe25b last_write_checksum: sha1:62eee3897b26cfc2097be04aeb24dc578da877ec @@ -7414,6 +7458,10 @@ trackedFiles: id: 07ae3f30e4a2 last_write_checksum: sha1:aa2931bc195ddc15bd18d9fac6948f8f24bfbe08 pristine_git_object: e7702ba4121c757b4f57d552a4f608bd4636e7b5 + docs/components/typetoolsearchoutput.mdx: + id: 16b1e85474e0 + last_write_checksum: sha1:a747849f24b7447aa71129a9857e6b48c2496775 + pristine_git_object: c59f9693a1160d7d2d54d10756eb4df0c579a818 docs/components/typewebsearch20250305.mdx: id: c5cd64905a32 last_write_checksum: sha1:70d29a41edfb246a4e50bf98bfca9df61809d075 @@ -9976,8 +10024,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:a0a0e377dad68cf07ff46b62dc13b119f3d1f334 - pristine_git_object: c90d15d83489495c8e51cd6c4ab79e70d0348b0c + last_write_checksum: sha1:191e980556ab005b582724fda8862fa7e9dd2a7f + pristine_git_object: 00261de997c35f0431250332a436fc423f3fdab7 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -10004,8 +10052,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:2fac6475fda86b96345a2f0011083661ee2a9c9b - pristine_git_object: 3400c5d8b99dc456d96a8d06265bf6814af68eaa + last_write_checksum: sha1:85c2e2691703e999424c2d82d6a4f6460da0e37f + pristine_git_object: 1681aded2d66dca4cbdca580fe23d25a9329128b src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:30f55a360f41376ab194b9ea725fe4e001a5ae1a @@ -10052,8 +10100,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:5929f0aad1def97fb47d220701cd8ad626c32cdf - pristine_git_object: 92a29ef91468729ce876f26d46881cdbbf845c0d + last_write_checksum: sha1:cb293302abf5e8150c7354edf5d8e577ac5ef748 + pristine_git_object: 531cae292be19fde0a57120c2dcd106c4c11fad5 src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:fab4d9a24d2cea937bb749d46c5f83941e99d65c @@ -11672,8 +11720,8 @@ trackedFiles: pristine_git_object: f499cbbb546232f5cfbfe2c44fb41aefb306c87f src/openrouter/components/inputs_union.py: id: 17d6239cb6a7 - last_write_checksum: sha1:b1fef5d0b2d02dbee579e83bb43ac8c183a58dc4 - pristine_git_object: fb8db7b12531efc2b6fa21c999b3a9c3c5b83b46 + last_write_checksum: sha1:4adb06234008383b60c330b57a3fdaeafc2c8c9f + pristine_git_object: 9b9312c027551f43e32403cd6c1e84e659030534 src/openrouter/components/inputtext.py: id: a995ae96be99 last_write_checksum: sha1:2da9ff645acc96772701908830151c5a707ed021 @@ -13126,6 +13174,14 @@ trackedFiles: id: a46dc874f6c8 last_write_checksum: sha1:b7d04d0b4d2ed2c052007e4d00e7857a9f70f5c7 pristine_git_object: 0042e076baa780911493aad1ed66975fc321045b + src/openrouter/components/toolsearchcallitem.py: + id: 2acbd13aef5c + last_write_checksum: sha1:943ca77ad2372ce7e72b4b3476bff4d6f7c3c8c7 + pristine_git_object: 61f716e4713759aff37d73562aa55ab335b3a178 + src/openrouter/components/toolsearchoutputitem.py: + id: 8d1db20e5746 + last_write_checksum: sha1:c88f83ef9fb91d76f8a587a2b0446eabc04e4fbf + pristine_git_object: 46d8b40969209860f4f387c45dc75ff14118b052 src/openrouter/components/toolsearchservertool.py: id: 3aa6de41ca07 last_write_checksum: sha1:21dc898a1519400cbfbda4aa35eda60a9dcbf668 @@ -18280,3 +18336,4 @@ examples: "500": application/json: {"error": {"code": 500, "message": "Internal Server Error"}} examplesVersion: 1.0.2 +releaseNotes: "## Python SDK Changes:\n* `open_router.presets.create_presets_responses()`: \n * `request.input.union(Array<>)[]` **Changed**\n* `open_router.responses.send()`: \n * `request.input.union(Array<>)[]` **Changed**\n* `open_router.beta.responses.send()`: \n * `request.input.union(Array<>)[]` **Changed**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 7c57f6e1..35081ed1 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.3.29 + version: 1.3.30 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 989547af..2dfbbb7a 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -14489,6 +14489,8 @@ components: - $ref: '#/components/schemas/AdditionalToolsItem' - $ref: '#/components/schemas/AgentMessageItem' - $ref: '#/components/schemas/ConfigurationUpdateItem' + - $ref: '#/components/schemas/ToolSearchCallItem' + - $ref: '#/components/schemas/ToolSearchOutputItem' type: 'array' description: 'Input for a response request - can be a string or array of items' example: @@ -17667,7 +17669,7 @@ components: openrouter_metadata: $ref: '#/components/schemas/OpenRouterMetadata' provider: - $ref: '#/components/schemas/ProviderName' + type: 'string' safeguard_results: items: $ref: '#/components/schemas/AnthropicSafeguardResult' @@ -17996,7 +17998,7 @@ components: - 'Z.AI' - 'FakeProvider' type: 'string' - x-speakeasy-unknown-values: allow + x-speakeasy-unknown-values: 'allow' role: enum: - 'assistant' @@ -26438,7 +26440,7 @@ components: - 'FakeProvider' example: 'OpenAI' type: 'string' - x-speakeasy-unknown-values: allow + x-speakeasy-unknown-values: 'allow' routed_service_tier: description: 'The service tier this request was routed to (e.g. flex, priority). The tier actually applied and billed is determined by the provider response and may differ.' enum: @@ -30491,6 +30493,165 @@ components: - 'required' - 'function' type: 'object' + ToolSearchCallItem: + description: 'A tool search call the client executed' + example: + arguments: + query: 'weather' + call_id: 'call_search_1' + execution: 'client' + status: 'completed' + type: 'tool_search_call' + properties: + arguments: {} + call_id: + type: 'string' + execution: + enum: + - 'server' + - 'client' + type: 'string' + x-speakeasy-unknown-values: allow + id: + type: + - 'string' + - 'null' + status: + enum: + - 'in_progress' + - 'completed' + - 'incomplete' + - null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow + type: + enum: + - 'tool_search_call' + type: 'string' + required: + - 'type' + - 'call_id' + - 'execution' + type: 'object' + ToolSearchOutputItem: + description: 'The tools a client-executed tool search loaded' + example: + call_id: 'call_search_1' + execution: 'client' + status: 'completed' + tools: + - name: 'get_weather' + parameters: + properties: + location: + type: 'string' + type: 'object' + type: 'function' + type: 'tool_search_output' + properties: + call_id: + type: 'string' + execution: + enum: + - 'server' + - 'client' + type: 'string' + x-speakeasy-unknown-values: allow + id: + type: + - 'string' + - 'null' + status: + enum: + - 'in_progress' + - 'completed' + - 'incomplete' + - null + type: + - 'string' + - 'null' + x-speakeasy-unknown-values: allow + tools: + items: + anyOf: + - allOf: + - $ref: '#/components/schemas/FunctionTool' + - properties: + async: + description: 'Lets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.' + example: true + type: 'boolean' + defer_loading: + description: 'Withhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.' + example: true + type: 'boolean' + type: 'object' + description: 'Function tool definition' + example: + description: 'Get the current weather in a location' + name: 'get_weather' + parameters: + properties: + location: + description: 'The city and state' + type: 'string' + unit: + enum: + - 'celsius' + - 'fahrenheit' + type: 'string' + x-speakeasy-unknown-values: allow + required: + - 'location' + type: 'object' + type: 'function' + - $ref: '#/components/schemas/Preview_WebSearchServerTool' + - $ref: '#/components/schemas/Preview_20250311_WebSearchServerTool' + - $ref: '#/components/schemas/Legacy_WebSearchServerTool' + - $ref: '#/components/schemas/WebSearchServerTool' + - $ref: '#/components/schemas/FileSearchServerTool' + - $ref: '#/components/schemas/ComputerUseServerTool' + - $ref: '#/components/schemas/CodeInterpreterServerTool' + - $ref: '#/components/schemas/McpServerTool' + - $ref: '#/components/schemas/ImageGenerationServerTool' + - $ref: '#/components/schemas/CodexLocalShellTool' + - $ref: '#/components/schemas/ShellServerTool' + - $ref: '#/components/schemas/ApplyPatchServerTool' + - $ref: '#/components/schemas/CustomTool' + - $ref: '#/components/schemas/NamespaceTool' + - $ref: '#/components/schemas/AdvisorServerTool_OpenRouter' + - $ref: '#/components/schemas/SubagentServerTool_OpenRouter' + - $ref: '#/components/schemas/DatetimeServerTool' + - $ref: '#/components/schemas/FilesServerTool' + - $ref: '#/components/schemas/FusionServerTool_OpenRouter' + - $ref: '#/components/schemas/ImageGenerationServerTool_OpenRouter' + - $ref: '#/components/schemas/SearchModelsServerTool_OpenRouter' + - $ref: '#/components/schemas/WebFetchServerTool' + - $ref: '#/components/schemas/WebSearchServerTool_OpenRouter' + - $ref: '#/components/schemas/ApplyPatchServerTool_OpenRouter' + - $ref: '#/components/schemas/BashServerTool' + - $ref: '#/components/schemas/ShellServerTool_OpenRouter' + - $ref: '#/components/schemas/ToolSearchServerTool' + - additionalProperties: {} + properties: + type: + type: 'string' + required: + - 'type' + type: 'object' + type: 'array' + type: + enum: + - 'tool_search_output' + type: 'string' + required: + - 'type' + - 'call_id' + - 'execution' + - 'tools' + type: 'object' ToolSearchServerTool: description: 'OpenRouter built-in server tool: finds tools marked `defer_loading` and makes them callable' example: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 94b1a860..9ecbb9a9 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:bf7fda8c98a42027444954119bd5f58646b93dd9d55cc5f21378e37a95a4ce2f - sourceBlobDigest: sha256:4d40bc4e642a7f455fd9de4ca42f0af6bfb9e4ebc4b2cf2d489b7037f436b689 + sourceRevisionDigest: sha256:4f7d856e5b6cc802e2402204573da0cf25747750110b71d92b4f6cc6d9a0f1b2 + sourceBlobDigest: sha256:32d1edb3551b9e15b5e46f7a205f92e832f2ed613979eb3475e8d1a35d3c0c9a tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:bf7fda8c98a42027444954119bd5f58646b93dd9d55cc5f21378e37a95a4ce2f - sourceBlobDigest: sha256:4d40bc4e642a7f455fd9de4ca42f0af6bfb9e4ebc4b2cf2d489b7037f436b689 + sourceRevisionDigest: sha256:4f7d856e5b6cc802e2402204573da0cf25747750110b71d92b4f6cc6d9a0f1b2 + sourceBlobDigest: sha256:32d1edb3551b9e15b5e46f7a205f92e832f2ed613979eb3475e8d1a35d3c0c9a codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:a975166c914e7c2619de53cdb36eee13a913db00816de0f2c62fe993a339d118 + codeSamplesRevisionDigest: sha256:5f4f4e8d4e0cf27a769328aa97641bf05eda5ee1098329f37a77e4fffd07a8d7 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index b189d0cb..978b1aca 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3059,4 +3059,14 @@ Based on: ### Generated - [python v1.3.29] . ### Releases -- [PyPI v1.3.29] https://pypi.org/project/openrouter/1.3.29 - . \ No newline at end of file +- [PyPI v1.3.29] https://pypi.org/project/openrouter/1.3.29 - . + +## 2026-10-07 12:25:20 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.30] . +### Releases +- [PyPI v1.3.30] https://pypi.org/project/openrouter/1.3.30 - . \ No newline at end of file diff --git a/docs/components/inputsunion1.mdx b/docs/components/inputsunion1.mdx index e76c31df..3d16d559 100644 --- a/docs/components/inputsunion1.mdx +++ b/docs/components/inputsunion1.mdx @@ -298,3 +298,15 @@ value: components.AgentMessageItem = /* values here */ value: components.ConfigurationUpdateItem = /* values here */ ``` +### `components.ToolSearchCallItem` + +```python +value: components.ToolSearchCallItem = /* values here */ +``` + +### `components.ToolSearchOutputItem` + +```python +value: components.ToolSearchOutputItem = /* values here */ +``` + diff --git a/docs/components/toolsearchcallitem.mdx b/docs/components/toolsearchcallitem.mdx new file mode 100644 index 00000000..b72b5f6c --- /dev/null +++ b/docs/components/toolsearchcallitem.mdx @@ -0,0 +1,17 @@ +--- +title: "ToolSearchCallItem" +--- + +A tool search call the client executed + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `arguments` | *Optional[Any]* | ➖ | N/A | +| `call_id` | *str* | ✅ | N/A | +| `execution` | [components.ToolSearchCallItemExecution](../components/toolsearchcallitemexecution.mdx) | ✅ | N/A | +| `id` | *OptionalNullable[str]* | ➖ | N/A | +| `status` | [OptionalNullable[components.ToolSearchCallItemStatus]](../components/toolsearchcallitemstatus.mdx) | ➖ | N/A | +| `type` | [components.ToolSearchCallItemType](../components/toolsearchcallitemtype.mdx) | ✅ | N/A | \ No newline at end of file diff --git a/docs/components/toolsearchcallitemexecution.mdx b/docs/components/toolsearchcallitemexecution.mdx new file mode 100644 index 00000000..56b48f21 --- /dev/null +++ b/docs/components/toolsearchcallitemexecution.mdx @@ -0,0 +1,20 @@ +--- +title: "ToolSearchCallItemExecution" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchCallItemExecution + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: ToolSearchCallItemExecution = "server" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"server"` +- `"client"` diff --git a/docs/components/toolsearchcallitemstatus.mdx b/docs/components/toolsearchcallitemstatus.mdx new file mode 100644 index 00000000..b71fd2da --- /dev/null +++ b/docs/components/toolsearchcallitemstatus.mdx @@ -0,0 +1,21 @@ +--- +title: "ToolSearchCallItemStatus" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchCallItemStatus + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: ToolSearchCallItemStatus = "in_progress" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"in_progress"` +- `"completed"` +- `"incomplete"` diff --git a/docs/components/toolsearchcallitemtype.mdx b/docs/components/toolsearchcallitemtype.mdx new file mode 100644 index 00000000..d35aaf3b --- /dev/null +++ b/docs/components/toolsearchcallitemtype.mdx @@ -0,0 +1,15 @@ +--- +title: "ToolSearchCallItemType" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchCallItemType +value: ToolSearchCallItemType = "tool_search_call" +``` + + +## Values + +- `"tool_search_call"` diff --git a/docs/components/toolsearchoutputitem.mdx b/docs/components/toolsearchoutputitem.mdx new file mode 100644 index 00000000..1c1e5aa8 --- /dev/null +++ b/docs/components/toolsearchoutputitem.mdx @@ -0,0 +1,17 @@ +--- +title: "ToolSearchOutputItem" +--- + +The tools a client-executed tool search loaded + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `call_id` | *str* | ✅ | N/A | +| `execution` | [components.ToolSearchOutputItemExecution](../components/toolsearchoutputitemexecution.mdx) | ✅ | N/A | +| `id` | *OptionalNullable[str]* | ➖ | N/A | +| `status` | [OptionalNullable[components.ToolSearchOutputItemStatus]](../components/toolsearchoutputitemstatus.mdx) | ➖ | N/A | +| `tools` | List[[components.ToolSearchOutputItemToolUnion](../components/toolsearchoutputitemtoolunion.mdx)] | ✅ | N/A | +| `type` | [components.TypeToolSearchOutput](../components/typetoolsearchoutput.mdx) | ✅ | N/A | \ No newline at end of file diff --git a/docs/components/toolsearchoutputitemexecution.mdx b/docs/components/toolsearchoutputitemexecution.mdx new file mode 100644 index 00000000..905132c8 --- /dev/null +++ b/docs/components/toolsearchoutputitemexecution.mdx @@ -0,0 +1,20 @@ +--- +title: "ToolSearchOutputItemExecution" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchOutputItemExecution + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: ToolSearchOutputItemExecution = "server" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"server"` +- `"client"` diff --git a/docs/components/toolsearchoutputitemstatus.mdx b/docs/components/toolsearchoutputitemstatus.mdx new file mode 100644 index 00000000..cbd5ff21 --- /dev/null +++ b/docs/components/toolsearchoutputitemstatus.mdx @@ -0,0 +1,21 @@ +--- +title: "ToolSearchOutputItemStatus" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchOutputItemStatus + +# Open enum: unrecognized values are captured as UnrecognizedStr +value: ToolSearchOutputItemStatus = "in_progress" +``` + + +## Values + +This is an open enum. Unrecognized values will not fail type checks. + +- `"in_progress"` +- `"completed"` +- `"incomplete"` diff --git a/docs/components/toolsearchoutputitemtool.mdx b/docs/components/toolsearchoutputitemtool.mdx new file mode 100644 index 00000000..4af6be7b --- /dev/null +++ b/docs/components/toolsearchoutputitemtool.mdx @@ -0,0 +1,10 @@ +--- +title: "ToolSearchOutputItemTool" +--- + +## Fields + +| Field | Type | Required | Description | +| -------------------- | -------------------- | -------------------- | -------------------- | +| `type` | *str* | ✅ | N/A | +| `__pydantic_extra__` | Dict[str, *Any*] | ➖ | N/A | \ No newline at end of file diff --git a/docs/components/toolsearchoutputitemtoolfunction.mdx b/docs/components/toolsearchoutputitemtoolfunction.mdx new file mode 100644 index 00000000..b74a71d1 --- /dev/null +++ b/docs/components/toolsearchoutputitemtoolfunction.mdx @@ -0,0 +1,18 @@ +--- +title: "ToolSearchOutputItemToolFunction" +--- + +Function tool definition + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `description` | *OptionalNullable[str]* | ➖ | N/A | | +| `name` | *str* | ✅ | N/A | | +| `parameters` | Dict[str, *Any*] | ✅ | N/A | | +| `strict` | *OptionalNullable[bool]* | ➖ | N/A | | +| `type` | [components.ToolSearchOutputItemTypeFunction](../components/toolsearchoutputitemtypefunction.mdx) | ✅ | N/A | | +| `async_` | *Optional[bool]* | ➖ | Lets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere. | true | +| `defer_loading` | *Optional[bool]* | ➖ | Withhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred. | true | \ No newline at end of file diff --git a/docs/components/toolsearchoutputitemtoolunion.mdx b/docs/components/toolsearchoutputitemtoolunion.mdx new file mode 100644 index 00000000..fc1479a1 --- /dev/null +++ b/docs/components/toolsearchoutputitemtoolunion.mdx @@ -0,0 +1,180 @@ +--- +title: "ToolSearchOutputItemToolUnion" +--- + +## Supported Types + +### `components.ToolSearchOutputItemToolFunction` + +```python +value: components.ToolSearchOutputItemToolFunction = /* values here */ +``` + +### `components.PreviewWebSearchServerTool` + +```python +value: components.PreviewWebSearchServerTool = /* values here */ +``` + +### `components.Preview20250311WebSearchServerTool` + +```python +value: components.Preview20250311WebSearchServerTool = /* values here */ +``` + +### `components.LegacyWebSearchServerTool` + +```python +value: components.LegacyWebSearchServerTool = /* values here */ +``` + +### `components.WebSearchServerTool` + +```python +value: components.WebSearchServerTool = /* values here */ +``` + +### `components.FileSearchServerTool` + +```python +value: components.FileSearchServerTool = /* values here */ +``` + +### `components.ComputerUseServerTool` + +```python +value: components.ComputerUseServerTool = /* values here */ +``` + +### `components.CodeInterpreterServerTool` + +```python +value: components.CodeInterpreterServerTool = /* values here */ +``` + +### `components.McpServerTool` + +```python +value: components.McpServerTool = /* values here */ +``` + +### `components.ImageGenerationServerTool` + +```python +value: components.ImageGenerationServerTool = /* values here */ +``` + +### `components.CodexLocalShellTool` + +```python +value: components.CodexLocalShellTool = /* values here */ +``` + +### `components.ShellServerTool` + +```python +value: components.ShellServerTool = /* values here */ +``` + +### `components.ApplyPatchServerTool` + +```python +value: components.ApplyPatchServerTool = /* values here */ +``` + +### `components.CustomTool` + +```python +value: components.CustomTool = /* values here */ +``` + +### `components.NamespaceTool` + +```python +value: components.NamespaceTool = /* values here */ +``` + +### `components.AdvisorServerToolOpenRouter` + +```python +value: components.AdvisorServerToolOpenRouter = /* values here */ +``` + +### `components.SubagentServerToolOpenRouter` + +```python +value: components.SubagentServerToolOpenRouter = /* values here */ +``` + +### `components.DatetimeServerTool` + +```python +value: components.DatetimeServerTool = /* values here */ +``` + +### `components.FilesServerTool` + +```python +value: components.FilesServerTool = /* values here */ +``` + +### `components.FusionServerToolOpenRouter` + +```python +value: components.FusionServerToolOpenRouter = /* values here */ +``` + +### `components.ImageGenerationServerToolOpenRouter` + +```python +value: components.ImageGenerationServerToolOpenRouter = /* values here */ +``` + +### `components.SearchModelsServerToolOpenRouter` + +```python +value: components.SearchModelsServerToolOpenRouter = /* values here */ +``` + +### `components.WebFetchServerTool` + +```python +value: components.WebFetchServerTool = /* values here */ +``` + +### `components.WebSearchServerToolOpenRouter` + +```python +value: components.WebSearchServerToolOpenRouter = /* values here */ +``` + +### `components.ApplyPatchServerToolOpenRouter` + +```python +value: components.ApplyPatchServerToolOpenRouter = /* values here */ +``` + +### `components.BashServerTool` + +```python +value: components.BashServerTool = /* values here */ +``` + +### `components.ShellServerToolOpenRouter` + +```python +value: components.ShellServerToolOpenRouter = /* values here */ +``` + +### `components.ToolSearchServerTool` + +```python +value: components.ToolSearchServerTool = /* values here */ +``` + +### `components.ToolSearchOutputItemTool` + +```python +value: components.ToolSearchOutputItemTool = /* values here */ +``` + diff --git a/docs/components/toolsearchoutputitemtypefunction.mdx b/docs/components/toolsearchoutputitemtypefunction.mdx new file mode 100644 index 00000000..a31e6e8f --- /dev/null +++ b/docs/components/toolsearchoutputitemtypefunction.mdx @@ -0,0 +1,15 @@ +--- +title: "ToolSearchOutputItemTypeFunction" +--- + +## Example Usage + +```python +from openrouter.components import ToolSearchOutputItemTypeFunction +value: ToolSearchOutputItemTypeFunction = "function" +``` + + +## Values + +- `"function"` diff --git a/docs/components/typetoolsearchoutput.mdx b/docs/components/typetoolsearchoutput.mdx new file mode 100644 index 00000000..c59f9693 --- /dev/null +++ b/docs/components/typetoolsearchoutput.mdx @@ -0,0 +1,15 @@ +--- +title: "TypeToolSearchOutput" +--- + +## Example Usage + +```python +from openrouter.components import TypeToolSearchOutput +value: TypeToolSearchOutput = "tool_search_output" +``` + + +## Values + +- `"tool_search_output"` diff --git a/pyproject.toml b/pyproject.toml index c90d15d8..00261de9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.3.29" +version = "1.3.30" description = "Official Python Client SDK for OpenRouter." authors = [{ name = "OpenRouter" },] readme = "README-PYPI.md" diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 3400c5d8..1681aded 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.3.29" +__version__: str = "1.3.30" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.3.29 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.3.30 2.914.0 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/components/__init__.py b/src/openrouter/components/__init__.py index 92a29ef9..531cae29 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -4037,6 +4037,27 @@ ToolChoiceAllowedTypedDict, ) from .toolchoicesupport import ToolChoiceSupport, ToolChoiceSupportTypedDict + from .toolsearchcallitem import ( + ToolSearchCallItem, + ToolSearchCallItemExecution, + ToolSearchCallItemStatus, + ToolSearchCallItemType, + ToolSearchCallItemTypedDict, + ) + from .toolsearchoutputitem import ( + ToolSearchOutputItem, + ToolSearchOutputItemExecution, + ToolSearchOutputItemStatus, + ToolSearchOutputItemTool, + ToolSearchOutputItemToolFunction, + ToolSearchOutputItemToolFunctionTypedDict, + ToolSearchOutputItemToolTypedDict, + ToolSearchOutputItemToolUnion, + ToolSearchOutputItemToolUnionTypedDict, + ToolSearchOutputItemTypeFunction, + ToolSearchOutputItemTypedDict, + TypeToolSearchOutput, + ) from .toolsearchservertool import ( ToolSearchServerTool, ToolSearchServerToolType, @@ -7191,6 +7212,22 @@ "ToolChoiceTypedDict", "ToolCustom", "ToolCustomTypedDict", + "ToolSearchCallItem", + "ToolSearchCallItemExecution", + "ToolSearchCallItemStatus", + "ToolSearchCallItemType", + "ToolSearchCallItemTypedDict", + "ToolSearchOutputItem", + "ToolSearchOutputItemExecution", + "ToolSearchOutputItemStatus", + "ToolSearchOutputItemTool", + "ToolSearchOutputItemToolFunction", + "ToolSearchOutputItemToolFunctionTypedDict", + "ToolSearchOutputItemToolTypedDict", + "ToolSearchOutputItemToolUnion", + "ToolSearchOutputItemToolUnionTypedDict", + "ToolSearchOutputItemTypeFunction", + "ToolSearchOutputItemTypedDict", "ToolSearchServerTool", "ToolSearchServerToolConfig", "ToolSearchServerToolConfigTypedDict", @@ -7244,6 +7281,7 @@ "TypeToolAddition", "TypeToolRemoval", "TypeToolResult", + "TypeToolSearchOutput", "TypeTypedDict", "TypeWebSearch20250305", "TypeWebSearch20260209", @@ -10450,6 +10488,23 @@ "ToolChoiceAllowedTypedDict": ".toolchoiceallowed", "ToolChoiceSupport": ".toolchoicesupport", "ToolChoiceSupportTypedDict": ".toolchoicesupport", + "ToolSearchCallItem": ".toolsearchcallitem", + "ToolSearchCallItemExecution": ".toolsearchcallitem", + "ToolSearchCallItemStatus": ".toolsearchcallitem", + "ToolSearchCallItemType": ".toolsearchcallitem", + "ToolSearchCallItemTypedDict": ".toolsearchcallitem", + "ToolSearchOutputItem": ".toolsearchoutputitem", + "ToolSearchOutputItemExecution": ".toolsearchoutputitem", + "ToolSearchOutputItemStatus": ".toolsearchoutputitem", + "ToolSearchOutputItemTool": ".toolsearchoutputitem", + "ToolSearchOutputItemToolFunction": ".toolsearchoutputitem", + "ToolSearchOutputItemToolFunctionTypedDict": ".toolsearchoutputitem", + "ToolSearchOutputItemToolTypedDict": ".toolsearchoutputitem", + "ToolSearchOutputItemToolUnion": ".toolsearchoutputitem", + "ToolSearchOutputItemToolUnionTypedDict": ".toolsearchoutputitem", + "ToolSearchOutputItemTypeFunction": ".toolsearchoutputitem", + "ToolSearchOutputItemTypedDict": ".toolsearchoutputitem", + "TypeToolSearchOutput": ".toolsearchoutputitem", "ToolSearchServerTool": ".toolsearchservertool", "ToolSearchServerToolType": ".toolsearchservertool", "ToolSearchServerToolTypedDict": ".toolsearchservertool", diff --git a/src/openrouter/components/inputs_union.py b/src/openrouter/components/inputs_union.py index fb8db7b1..9b9312c0 100644 --- a/src/openrouter/components/inputs_union.py +++ b/src/openrouter/components/inputs_union.py @@ -146,6 +146,8 @@ from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict from .shellcallitem import ShellCallItem, ShellCallItemTypedDict from .shellcalloutputitem import ShellCallOutputItem, ShellCallOutputItemTypedDict +from .toolsearchcallitem import ToolSearchCallItem, ToolSearchCallItemTypedDict +from .toolsearchoutputitem import ToolSearchOutputItem, ToolSearchOutputItemTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -377,45 +379,47 @@ def serialize_model(self, handler): Union[ ItemReferenceItemTypedDict, ConfigurationUpdateItemTypedDict, - CompactionItemTypedDict, - OutputFileSearchCallItemTypedDict, - CustomToolCallOutputItemTypedDict, - OutputFileSearchServerToolItemTypedDict, ContextCompactionItemTypedDict, EasyInputMessageTypedDict, - AdditionalToolsItemTypedDict, InputMessageItemTypedDict, LocalShellCallOutputItemTypedDict, - FunctionCallOutputItemTypedDict, - McpApprovalResponseItemTypedDict, - LocalShellCallItemTypedDict, + OutputFileSearchServerToolItemTypedDict, + CustomToolCallOutputItemTypedDict, + AdditionalToolsItemTypedDict, + CompactionItemTypedDict, + OutputFileSearchCallItemTypedDict, + ApplyPatchCallOutputItemTypedDict, + McpApprovalRequestItemTypedDict, OutputWebSearchCallItemTypedDict, + OutputMcpServerToolItemTypedDict, OutputWebSearchServerToolItemTypedDict, + McpApprovalResponseItemTypedDict, + ApplyPatchCallItemTypedDict, OutputImageGenerationCallItemTypedDict, OutputBrowserUseServerToolItemTypedDict, - OutputMcpServerToolItemTypedDict, McpListToolsItemTypedDict, - ApplyPatchCallItemTypedDict, OutputTextEditorServerToolItemTypedDict, - McpApprovalRequestItemTypedDict, - ApplyPatchCallOutputItemTypedDict, + FunctionCallOutputItemTypedDict, + LocalShellCallItemTypedDict, OutputToolSearchServerToolItemTypedDict, - InputsMessageTypedDict, OutputMemoryServerToolItemTypedDict, - OutputSearchModelsServerToolItemTypedDict, OutputApplyPatchServerToolItemTypedDict, + OutputSearchModelsServerToolItemTypedDict, + ToolSearchOutputItemTypedDict, OutputDatetimeItemTypedDict, + ToolSearchCallItemTypedDict, OutputComputerCallItemTypedDict, - OutputCodeInterpreterCallItemTypedDict, - ShellCallItemTypedDict, + InputsMessageTypedDict, AgentMessageItemTypedDict, + ShellCallItemTypedDict, + OutputCodeInterpreterCallItemTypedDict, McpCallItemTypedDict, - OutputCodeInterpreterServerToolItemTypedDict, - ReasoningItemTypedDict, - OutputAdvisorServerToolItemTypedDict, - InputsReasoningTypedDict, OutputWebFetchServerToolItemTypedDict, + InputsReasoningTypedDict, + ReasoningItemTypedDict, + OutputCodeInterpreterServerToolItemTypedDict, CustomToolCallItemTypedDict, + OutputAdvisorServerToolItemTypedDict, OutputImageGenerationServerToolItemTypedDict, ShellCallOutputItemTypedDict, OutputFusionServerToolItemTypedDict, @@ -433,45 +437,47 @@ def serialize_model(self, handler): Union[ ItemReferenceItem, ConfigurationUpdateItem, - CompactionItem, - OutputFileSearchCallItem, - CustomToolCallOutputItem, - OutputFileSearchServerToolItem, ContextCompactionItem, EasyInputMessage, - AdditionalToolsItem, InputMessageItem, LocalShellCallOutputItem, - FunctionCallOutputItem, - McpApprovalResponseItem, - LocalShellCallItem, + OutputFileSearchServerToolItem, + CustomToolCallOutputItem, + AdditionalToolsItem, + CompactionItem, + OutputFileSearchCallItem, + ApplyPatchCallOutputItem, + McpApprovalRequestItem, OutputWebSearchCallItem, + OutputMcpServerToolItem, OutputWebSearchServerToolItem, + McpApprovalResponseItem, + ApplyPatchCallItem, OutputImageGenerationCallItem, OutputBrowserUseServerToolItem, - OutputMcpServerToolItem, McpListToolsItem, - ApplyPatchCallItem, OutputTextEditorServerToolItem, - McpApprovalRequestItem, - ApplyPatchCallOutputItem, + FunctionCallOutputItem, + LocalShellCallItem, OutputToolSearchServerToolItem, - InputsMessage, OutputMemoryServerToolItem, - OutputSearchModelsServerToolItem, OutputApplyPatchServerToolItem, + OutputSearchModelsServerToolItem, + ToolSearchOutputItem, OutputDatetimeItem, + ToolSearchCallItem, OutputComputerCallItem, - OutputCodeInterpreterCallItem, - ShellCallItem, + InputsMessage, AgentMessageItem, + ShellCallItem, + OutputCodeInterpreterCallItem, McpCallItem, - OutputCodeInterpreterServerToolItem, - ReasoningItem, - OutputAdvisorServerToolItem, - InputsReasoning, OutputWebFetchServerToolItem, + InputsReasoning, + ReasoningItem, + OutputCodeInterpreterServerToolItem, CustomToolCallItem, + OutputAdvisorServerToolItem, OutputImageGenerationServerToolItem, ShellCallOutputItem, OutputFusionServerToolItem, diff --git a/src/openrouter/components/toolsearchcallitem.py b/src/openrouter/components/toolsearchcallitem.py new file mode 100644 index 00000000..61f716e4 --- /dev/null +++ b/src/openrouter/components/toolsearchcallitem.py @@ -0,0 +1,88 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, + UnrecognizedStr, +) +from pydantic import model_serializer +from typing import Any, Literal, Optional, Union +from typing_extensions import NotRequired, TypedDict + + +ToolSearchCallItemExecution = Union[ + Literal[ + "server", + "client", + ], + UnrecognizedStr, +] + + +ToolSearchCallItemStatus = Union[ + Literal[ + "in_progress", + "completed", + "incomplete", + ], + UnrecognizedStr, +] + + +ToolSearchCallItemType = Literal["tool_search_call",] + + +class ToolSearchCallItemTypedDict(TypedDict): + r"""A tool search call the client executed""" + + call_id: str + execution: ToolSearchCallItemExecution + type: ToolSearchCallItemType + arguments: NotRequired[Any] + id: NotRequired[Nullable[str]] + status: NotRequired[Nullable[ToolSearchCallItemStatus]] + + +class ToolSearchCallItem(BaseModel): + r"""A tool search call the client executed""" + + call_id: str + + execution: ToolSearchCallItemExecution + + type: ToolSearchCallItemType + + arguments: Optional[Any] = None + + id: OptionalNullable[str] = UNSET + + status: OptionalNullable[ToolSearchCallItemStatus] = UNSET + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["arguments", "id", "status"]) + nullable_fields = set(["id", "status"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + + return m diff --git a/src/openrouter/components/toolsearchoutputitem.py b/src/openrouter/components/toolsearchoutputitem.py new file mode 100644 index 00000000..46d8b409 --- /dev/null +++ b/src/openrouter/components/toolsearchoutputitem.py @@ -0,0 +1,316 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .advisorservertool_openrouter import ( + AdvisorServerToolOpenRouter, + AdvisorServerToolOpenRouterTypedDict, +) +from .applypatchservertool import ApplyPatchServerTool, ApplyPatchServerToolTypedDict +from .applypatchservertool_openrouter import ( + ApplyPatchServerToolOpenRouter, + ApplyPatchServerToolOpenRouterTypedDict, +) +from .bashservertool import BashServerTool, BashServerToolTypedDict +from .codeinterpreterservertool import ( + CodeInterpreterServerTool, + CodeInterpreterServerToolTypedDict, +) +from .codexlocalshelltool import CodexLocalShellTool, CodexLocalShellToolTypedDict +from .computeruseservertool import ComputerUseServerTool, ComputerUseServerToolTypedDict +from .customtool import CustomTool, CustomToolTypedDict +from .datetimeservertool import DatetimeServerTool, DatetimeServerToolTypedDict +from .filesearchservertool import FileSearchServerTool, FileSearchServerToolTypedDict +from .filesservertool import FilesServerTool, FilesServerToolTypedDict +from .fusionservertool_openrouter import ( + FusionServerToolOpenRouter, + FusionServerToolOpenRouterTypedDict, +) +from .imagegenerationservertool import ( + ImageGenerationServerTool, + ImageGenerationServerToolTypedDict, +) +from .imagegenerationservertool_openrouter import ( + ImageGenerationServerToolOpenRouter, + ImageGenerationServerToolOpenRouterTypedDict, +) +from .legacy_websearchservertool import ( + LegacyWebSearchServerTool, + LegacyWebSearchServerToolTypedDict, +) +from .mcpservertool import McpServerTool, McpServerToolTypedDict +from .namespacetool import NamespaceTool, NamespaceToolTypedDict +from .preview_20250311_websearchservertool import ( + Preview20250311WebSearchServerTool, + Preview20250311WebSearchServerToolTypedDict, +) +from .preview_websearchservertool import ( + PreviewWebSearchServerTool, + PreviewWebSearchServerToolTypedDict, +) +from .searchmodelsservertool_openrouter import ( + SearchModelsServerToolOpenRouter, + SearchModelsServerToolOpenRouterTypedDict, +) +from .shellservertool import ShellServerTool, ShellServerToolTypedDict +from .shellservertool_openrouter import ( + ShellServerToolOpenRouter, + ShellServerToolOpenRouterTypedDict, +) +from .subagentservertool_openrouter import ( + SubagentServerToolOpenRouter, + SubagentServerToolOpenRouterTypedDict, +) +from .toolsearchservertool import ToolSearchServerTool, ToolSearchServerToolTypedDict +from .webfetchservertool import WebFetchServerTool, WebFetchServerToolTypedDict +from .websearchservertool import WebSearchServerTool, WebSearchServerToolTypedDict +from .websearchservertool_openrouter import ( + WebSearchServerToolOpenRouter, + WebSearchServerToolOpenRouterTypedDict, +) +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, + UnrecognizedStr, +) +import pydantic +from pydantic import ConfigDict, model_serializer +from typing import Any, Dict, List, Literal, Optional, Union +from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict + + +ToolSearchOutputItemExecution = Union[ + Literal[ + "server", + "client", + ], + UnrecognizedStr, +] + + +ToolSearchOutputItemStatus = Union[ + Literal[ + "in_progress", + "completed", + "incomplete", + ], + UnrecognizedStr, +] + + +class ToolSearchOutputItemToolTypedDict(TypedDict): + type: str + + +class ToolSearchOutputItemTool(BaseModel): + model_config = ConfigDict( + populate_by_name=True, arbitrary_types_allowed=True, extra="allow" + ) + __pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False) + + type: str + + @property + def additional_properties(self): + return self.__pydantic_extra__ + + @additional_properties.setter + def additional_properties(self, value): + self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride] + + +ToolSearchOutputItemTypeFunction = Literal["function",] + + +class ToolSearchOutputItemToolFunctionTypedDict(TypedDict): + r"""Function tool definition""" + + name: str + parameters: Nullable[Dict[str, Any]] + type: ToolSearchOutputItemTypeFunction + description: NotRequired[Nullable[str]] + strict: NotRequired[Nullable[bool]] + async_: NotRequired[bool] + r"""Lets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.""" + defer_loading: NotRequired[bool] + r"""Withhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.""" + + +class ToolSearchOutputItemToolFunction(BaseModel): + r"""Function tool definition""" + + name: str + + parameters: Nullable[Dict[str, Any]] + + type: ToolSearchOutputItemTypeFunction + + description: OptionalNullable[str] = UNSET + + strict: OptionalNullable[bool] = UNSET + + async_: Annotated[Optional[bool], pydantic.Field(alias="async")] = None + r"""Lets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.""" + + defer_loading: Optional[bool] = None + r"""Withhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["description", "strict", "async", "defer_loading"]) + nullable_fields = set(["description", "parameters", "strict"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + + return m + + +ToolSearchOutputItemToolUnionTypedDict = TypeAliasType( + "ToolSearchOutputItemToolUnionTypedDict", + Union[ + CodexLocalShellToolTypedDict, + ApplyPatchServerToolTypedDict, + ShellServerToolTypedDict, + SearchModelsServerToolOpenRouterTypedDict, + WebFetchServerToolTypedDict, + ToolSearchOutputItemToolTypedDict, + ToolSearchServerToolTypedDict, + CodeInterpreterServerToolTypedDict, + ShellServerToolOpenRouterTypedDict, + BashServerToolTypedDict, + ApplyPatchServerToolOpenRouterTypedDict, + WebSearchServerToolOpenRouterTypedDict, + ImageGenerationServerToolOpenRouterTypedDict, + FusionServerToolOpenRouterTypedDict, + FilesServerToolTypedDict, + AdvisorServerToolOpenRouterTypedDict, + SubagentServerToolOpenRouterTypedDict, + DatetimeServerToolTypedDict, + NamespaceToolTypedDict, + ComputerUseServerToolTypedDict, + CustomToolTypedDict, + FileSearchServerToolTypedDict, + ToolSearchOutputItemToolFunctionTypedDict, + PreviewWebSearchServerToolTypedDict, + WebSearchServerToolTypedDict, + Preview20250311WebSearchServerToolTypedDict, + LegacyWebSearchServerToolTypedDict, + McpServerToolTypedDict, + ImageGenerationServerToolTypedDict, + ], +) + + +ToolSearchOutputItemToolUnion = TypeAliasType( + "ToolSearchOutputItemToolUnion", + Union[ + CodexLocalShellTool, + ApplyPatchServerTool, + ShellServerTool, + SearchModelsServerToolOpenRouter, + WebFetchServerTool, + ToolSearchOutputItemTool, + ToolSearchServerTool, + CodeInterpreterServerTool, + ShellServerToolOpenRouter, + BashServerTool, + ApplyPatchServerToolOpenRouter, + WebSearchServerToolOpenRouter, + ImageGenerationServerToolOpenRouter, + FusionServerToolOpenRouter, + FilesServerTool, + AdvisorServerToolOpenRouter, + SubagentServerToolOpenRouter, + DatetimeServerTool, + NamespaceTool, + ComputerUseServerTool, + CustomTool, + FileSearchServerTool, + ToolSearchOutputItemToolFunction, + PreviewWebSearchServerTool, + WebSearchServerTool, + Preview20250311WebSearchServerTool, + LegacyWebSearchServerTool, + McpServerTool, + ImageGenerationServerTool, + ], +) + + +TypeToolSearchOutput = Literal["tool_search_output",] + + +class ToolSearchOutputItemTypedDict(TypedDict): + r"""The tools a client-executed tool search loaded""" + + call_id: str + execution: ToolSearchOutputItemExecution + tools: List[ToolSearchOutputItemToolUnionTypedDict] + type: TypeToolSearchOutput + id: NotRequired[Nullable[str]] + status: NotRequired[Nullable[ToolSearchOutputItemStatus]] + + +class ToolSearchOutputItem(BaseModel): + r"""The tools a client-executed tool search loaded""" + + call_id: str + + execution: ToolSearchOutputItemExecution + + tools: List[ToolSearchOutputItemToolUnion] + + type: TypeToolSearchOutput + + id: OptionalNullable[str] = UNSET + + status: OptionalNullable[ToolSearchOutputItemStatus] = UNSET + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set(["id", "status"]) + nullable_fields = set(["id", "status"]) + serialized = handler(self) + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k, serialized.get(n)) + is_nullable_and_explicitly_set = ( + k in nullable_fields + and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member + ) + + if val != UNSET_SENTINEL: + if ( + val is not None + or k not in optional_fields + or is_nullable_and_explicitly_set + ): + m[k] = val + + return m + + +try: + ToolSearchOutputItemToolFunction.model_rebuild() +except NameError: + pass diff --git a/uv.lock b/uv.lock index df099717..0a12b503 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.3.29" +version = "1.3.30" source = { editable = "." } dependencies = [ { name = "httpcore" },