diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 9c565853..fc469655 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: ca5490549e0512d5b60a5fe396a2b9dc + docChecksum: 7bc4e2b7ddaf5ff60ed1f4fdf4e6014b docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.2.10 - configChecksum: f8e731e3a98cab5c9313b188a3e39457 + releaseVersion: 1.2.11 + configChecksum: 18db98838c528641464154ac5df7e0aa repoURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git published: true persistentEdits: - generation_id: 83c751b1-10e5-4624-aa07-71fc29aa98e3 - pristine_commit_hash: 8b25e0a23a882a124af18740258d70a895fd346f - pristine_tree_hash: 29327f64e8fea01394bdc25e0cf2c450dc04797e + generation_id: 6ba811c3-4b2b-4301-b318-3a4cd0c8895d + pristine_commit_hash: 138cf1bb159aef251699270741f4b7489b8c232b + pristine_tree_hash: 20a96672f32eeacc5d9710f928293f0f8b693627 features: python: acceptHeaders: 3.0.0 @@ -1255,8 +1255,8 @@ trackedFiles: pristine_git_object: 11d6c22059efcf4e3b0d6b15b39a67678adc7a4b docs/components/chatwebsearchshorthand.mdx: id: 40f0c0a47ef4 - last_write_checksum: sha1:5b95f0e1a5bae43dee10b8357022286ec847c807 - pristine_git_object: 5833ac229f8f39e4e9d2f5f3d58e3fde74bdc1ac + last_write_checksum: sha1:6b74306ebbac1a2ad02a01eb9120a06072d2a6f9 + pristine_git_object: ae3a6874304ddf295979e5a837eb2205baf074c8 docs/components/chatwebsearchshorthandtype.mdx: id: ce16c0139963 last_write_checksum: sha1:1637ce5dac9fc9c87df3793d46a4eff33282e0a3 @@ -3159,8 +3159,8 @@ trackedFiles: pristine_git_object: 63991d9ba8aedd15e34bdc73c8f99fbdcda2d037 docs/components/legacywebsearchservertool.mdx: id: 0b47ff5dd0c4 - last_write_checksum: sha1:a0547b5ec5cb8d9bbe0d046c4f06279cf44ab7d2 - pristine_git_object: df8142b8197d1e0b112f4a0580f6bb3b1cdcb19c + last_write_checksum: sha1:c8eb76bc0b835d635234302a1539bcc954205f2f + pristine_git_object: fc8f8785bb9c293d8c2fcda2ab9ca869644d7627 docs/components/legacywebsearchservertooltype.mdx: id: 192fa7358f3b last_write_checksum: sha1:c82facbab1f9b4f53e06a6e3986b886f2a9b9b00 @@ -4767,16 +4767,16 @@ trackedFiles: pristine_git_object: 56d189d99021af45f7fa6fb143af33d7d08cedcb docs/components/preview20250311websearchservertool.mdx: id: aeecb65a50e0 - last_write_checksum: sha1:217f26de38fcee5dff7383bcc951209f7953128e - pristine_git_object: 1bf764e9509ec226be514b35df3611b4ed77d8a0 + last_write_checksum: sha1:131cb53d5ac143bd2f639054ecfab44370892a12 + pristine_git_object: 750580a391ce99294d15f204d7fd1a98673f24ee docs/components/preview20250311websearchservertooltype.mdx: id: cedcfeda38d6 last_write_checksum: sha1:f7ac2913cc8c24d851c06d02c06742f9fe435084 pristine_git_object: 3669d05ce38327fa9b3d9a8c66c1de208a5f30e2 docs/components/previewwebsearchservertool.mdx: id: 2695e6e2fdfb - last_write_checksum: sha1:05b9f2d0cd253d8b41efc9a5e0636d27b001fe17 - pristine_git_object: 019ecc2ee18b8514a8158df1994fd1d010f26e6c + last_write_checksum: sha1:0476d35ca00842429b2e6764128f8bc3a316298d + pristine_git_object: ccbdb6a61a7f2243404a8d9d0aa63a744633ef09 docs/components/previewwebsearchservertooltype.mdx: id: 4b6373295164 last_write_checksum: sha1:b28bae247d5a91d62f9be9877cd6f437628be49e @@ -6299,8 +6299,8 @@ trackedFiles: pristine_git_object: 6453f10f1843521ab57609e00cea4459984d565b docs/components/websearchconfig.mdx: id: 6d343d63543d - last_write_checksum: sha1:427af5f821a51df4a0a25afba483c53f50f82643 - pristine_git_object: eaef734fea7a2343f4f57fa6014fc88b5461a2fe + last_write_checksum: sha1:bf33fc169d688cb8b561706bb96199447d5ea76d + pristine_git_object: b7671cf8a275a28b932c76cef86abe4264aa5b32 docs/components/websearchdomainfilter.mdx: id: e6aef0d8853a last_write_checksum: sha1:3f5103c40e44f2a6d9d11052e6f5dc88284c4fca @@ -6319,8 +6319,8 @@ trackedFiles: pristine_git_object: c674cdb6a897e6c96734175d20e3a68efd5f60b5 docs/components/websearchplugin.mdx: id: 5cb313bf543c - last_write_checksum: sha1:de63c0f452dd8aeb7f461898b29a5d0db07661d0 - pristine_git_object: c9c9b637782a5380c7ec96519fe16363a8ce066b + last_write_checksum: sha1:4bb3c3a050b07b4dc2b0fe69a1b4c9f4d299ff19 + pristine_git_object: 6cd0c9a7768160928145bc1310d1c1ec72a4c7e6 docs/components/websearchpluginid.mdx: id: d033d5ea2573 last_write_checksum: sha1:11622d868a103d09aa6a02ad5253f8fae2e90004 @@ -6331,12 +6331,12 @@ trackedFiles: pristine_git_object: 35edaa6c73e1f7c3731d7d5005897f72ca4ed496 docs/components/websearchservertool.mdx: id: cf9994f5aba9 - last_write_checksum: sha1:30b6b3afbe1112343da4befa5cc94b56c97d334f - pristine_git_object: 86c6d642762f247b61755692bba9fd1e88cfb99f + last_write_checksum: sha1:f9d90ebe9df3978f4df638efd92ac7810f406538 + pristine_git_object: 4a66fcbb55a265d7544f0c879f8900a19aa6f011 docs/components/websearchservertoolconfig.mdx: id: bb335e5d49e5 - last_write_checksum: sha1:292e26300cd55d0740170e5824ec37fdcde440f3 - pristine_git_object: a39dc8893a1e8bdca79c876b6d650e1a54ac7bda + last_write_checksum: sha1:ef25882b2f06c2e4c7390c8df42e9f4dc2840d01 + pristine_git_object: 206799c778e9ada28cbeebbb43f746c126b69b27 docs/components/websearchservertoolopenrouter.mdx: id: d1e3cf613d26 last_write_checksum: sha1:014a351e3ba7d11d72eeb622e088215abdf7d4eb @@ -6397,6 +6397,10 @@ trackedFiles: id: 61bd9cfaba50 last_write_checksum: sha1:53d06ae2c195423e5c8e87e73ed33664c20ab65a pristine_git_object: aa60a54ac2096800d7ac3d9b1130beeb9507428b + docs/components/xsearchoptions.mdx: + id: ac41486c3c1f + last_write_checksum: sha1:2c98029247dc9be031bf9967db47f660ac7e2158 + pristine_git_object: d742b5c2b96dbc33bdb8c3f9e7cd09681772e8d2 docs/errors/badgatewayresponseerror.mdx: id: d60591f67794 last_write_checksum: sha1:fa8405fadd704b16b0f6bbd71e923f76a3c8fc41 @@ -8183,8 +8187,8 @@ trackedFiles: pristine_git_object: 3e38f1a929f7d6b1d6de74604aa87e3d8f010544 pyproject.toml: id: 5d07e7d72637 - last_write_checksum: sha1:a54c5bd748cd8c54f4261e7d9ba92514990573fa - pristine_git_object: ae1cadfe9123feeb16101bbea7105b9c16a3ac6c + last_write_checksum: sha1:cf86197fe77b35a04bc2bfb53ac21533998114b6 + pristine_git_object: 4f3dc63192bcc162b105326871f5f5fb18aaa360 scripts/prepare_readme.py: id: e0c5957a6035 last_write_checksum: sha1:77f44b60b98bc126557ec27391f91dfba764bb54 @@ -8211,8 +8215,8 @@ trackedFiles: pristine_git_object: 86713cfea633e09d33b3d4e65281071fe20e6137 src/openrouter/_version.py: id: d8d15ad6c586 - last_write_checksum: sha1:b13fc71a96d03fcf84aeb50b95e3881e502e7c01 - pristine_git_object: 6fbdc32f94d3f42665f78b154bdae13c090f2198 + last_write_checksum: sha1:73e68e10ce3f843ddc8a90298772d8ac15eca3a2 + pristine_git_object: 4a594e6072be0f35dafcda7f40fc6e72c97ab192 src/openrouter/alpha.py: id: 306c4d93308d last_write_checksum: sha1:0c25a52ed5fb688ec1e923e4e82bcfc9cae49465 @@ -8255,8 +8259,8 @@ trackedFiles: pristine_git_object: ad3d247954547814054c01989a2dff3d12b3e4e1 src/openrouter/components/__init__.py: id: 81754e97b3f4 - last_write_checksum: sha1:363e12b7b42a054a22088edd196351bfa728455e - pristine_git_object: 331cc51584bf4ae089e18d26629538b9260a3102 + last_write_checksum: sha1:e94914ac35c3a452f21a0ea52e9a137bf5ee7674 + pristine_git_object: 32e9db7534eae3fa697da87935cae18fbf391c27 src/openrouter/components/aabenchmarkentry.py: id: e2e0f0b48c82 last_write_checksum: sha1:fab4d9a24d2cea937bb749d46c5f83941e99d65c @@ -8811,8 +8815,8 @@ trackedFiles: pristine_git_object: d5ebd465c8d843f4bc1f0763d136d31960ab2efa src/openrouter/components/chatwebsearchshorthand.py: id: 13091b97a3f6 - last_write_checksum: sha1:9d13fe621764f1fb81617b0c6c323331c05991c3 - pristine_git_object: 5a4b645f94ad99647a7cf7b8ef1317def0baa61c + last_write_checksum: sha1:149b879e2e79043d782f17ca32616fd83a3ea754 + pristine_git_object: c69f9972dde727de925fd5d8f538f12606608eb9 src/openrouter/components/codeinterpretercallcodedeltaevent.py: id: 57cd88fa2bbd last_write_checksum: sha1:494b5f489144b2b2e30203bd4cdf43df102508f6 @@ -9651,8 +9655,8 @@ trackedFiles: pristine_git_object: 0e7afcaa9c47ce1a6b15a90b9419aaa406c51079 src/openrouter/components/legacy_websearchservertool.py: id: 8b28b05b8756 - last_write_checksum: sha1:236eb9aa2e35646d64c0b6beb172dbf0a8cade6d - pristine_git_object: 25e499f0595dbe1eb9059600e7aee8216a100778 + last_write_checksum: sha1:499a758eb277bd29393957e734d920ac27db717e + pristine_git_object: a06a05fe24b1f1ca60b504ebb5dc97afe6726395 src/openrouter/components/listbyokkeysresponse.py: id: d5f63cba5dd9 last_write_checksum: sha1:97cd54e94ba4996ebb43252ac31aa70511e0328c @@ -10019,8 +10023,8 @@ trackedFiles: pristine_git_object: 08d990d8cc07b7928158fc55784cd9d613f4c58b src/openrouter/components/openresponsesresult.py: id: 78f7e33b19e6 - last_write_checksum: sha1:81f65446952f01519266a09ac78ad9325f0ccf7c - pristine_git_object: 9301d127a339d0f3d7e632c575d29c69113c9b77 + last_write_checksum: sha1:9101cb7e089917c4f50c707e69821ffaf97e3e79 + pristine_git_object: bff0a6fe583dc21887ed28942bb0b669d5ef3419 src/openrouter/components/openrouterfile.py: id: df1961bcb130 last_write_checksum: sha1:1a9a1b1e640f4d0ef78ce0caa160b5ab342f02cc @@ -10267,12 +10271,12 @@ trackedFiles: pristine_git_object: 6828e9dd037e51ac1409380429e4aa86f8446211 src/openrouter/components/preview_20250311_websearchservertool.py: id: ecfe1a37c34f - last_write_checksum: sha1:aff10889646ab6286f3a9e65686c61dc2ca52be7 - pristine_git_object: 3df7c01df5cac12b079105627fceb8722e7fac87 + last_write_checksum: sha1:afd6827e77a214d5099980b9ef29b6dc6d002b8a + pristine_git_object: 3faa27e34b7a91488950ba25bdcf2fdd5070ef0a src/openrouter/components/preview_websearchservertool.py: id: 9c02777285ce - last_write_checksum: sha1:44a3481201bca0948161bbb382d3170395ab9b0e - pristine_git_object: a6cf3bc0a8d6401f07ddc2e8880c150afed9f578 + last_write_checksum: sha1:9f40d07eefd60a14db954f7fecbc0dddd383c9ef + pristine_git_object: 8a0d46368d7000e9651c49ed41938537c364376d src/openrouter/components/preview_websearchuserlocation.py: id: 40414eada27a last_write_checksum: sha1:0e241830bf9014e8ea814465c573711d8a7caa2c @@ -10943,8 +10947,8 @@ trackedFiles: pristine_git_object: adceee794cf8135f5db3b2d741dc6e4de9c4e968 src/openrouter/components/websearchconfig.py: id: 3884d9509e8c - last_write_checksum: sha1:b13ad1f3b3b6d84cf315ed6c09720d5cebc0d604 - pristine_git_object: 3c4da59fc4d11f9f381aae7edddc1d1c46588dc3 + last_write_checksum: sha1:8e0ca52d34f8c3f0512071e610d5dd161502dec7 + pristine_git_object: 764e1c3a67b6037c62f9b8c3565205d037b72d6d src/openrouter/components/websearchdomainfilter.py: id: 4a7307ed2ba6 last_write_checksum: sha1:15246ac9135fd303e0522b8b570f27254b90495d @@ -10963,20 +10967,20 @@ trackedFiles: pristine_git_object: 61fb20e57526288d2b768165dff3524400b573ed src/openrouter/components/websearchplugin.py: id: 1d872d1792a7 - last_write_checksum: sha1:2a196cb9883166d6a5317afc1503a249f9a0e479 - pristine_git_object: 338d13aa60d5325a3fa369282f9c0589be602620 + last_write_checksum: sha1:e8c2cbe6428ba80465edb200c4d9e1dafd511027 + pristine_git_object: 77f977d01226c9aa4e8e85beab85ce675455cf9a src/openrouter/components/websearchservertool.py: id: 32c7333e3c21 - last_write_checksum: sha1:20427239c9bfce56e5d3c0f5fa51f22d6cd07021 - pristine_git_object: 2c4460d1ccda88300babac0af631da8a0c1bf4cd + last_write_checksum: sha1:9ea9fb4647a0cdd436647780c1fb512afb4443e6 + pristine_git_object: ca027ac43156c9dcc7c5c6ba6ff1e2d87b5a53f6 src/openrouter/components/websearchservertool_openrouter.py: id: 3fcedc999f5b last_write_checksum: sha1:d5c34450670513a4fed73afc86670fc77f19a247 pristine_git_object: cac816de64f204cda6c706eee57f0d72b8b860eb src/openrouter/components/websearchservertoolconfig.py: id: ebdaa99d47da - last_write_checksum: sha1:59741826392b77c989b4c233f251d39615cb6804 - pristine_git_object: 8a7ecce351027a4b71fa3e4198c85932b38f09f0 + last_write_checksum: sha1:d6c33cb4bad43b67de11e783a4548c9eded9f2b8 + pristine_git_object: b8c30a3db8f98b1b9afff33efc2818cb35b481d8 src/openrouter/components/websearchsource.py: id: a1fe81b68a7b last_write_checksum: sha1:fa30e5813682231d742fb6861f0fe92f655c8e81 @@ -11009,6 +11013,10 @@ trackedFiles: id: b510f727fe9c last_write_checksum: sha1:cc6c8880763f294494616a3daa84c8822d4e3f08 pristine_git_object: ad78361d147d2edb7b5772c14501d9c25a2000b0 + src/openrouter/components/xsearchoptions.py: + id: bbd8095c8936 + last_write_checksum: sha1:ba8490b96373d6283f0c0784f1bbacc51a4fe2f2 + pristine_git_object: 72db9c53af7eca4225e47c854d94f686df920af9 src/openrouter/containers.py: id: 5edae5db57e9 last_write_checksum: sha1:f85e2c6690147ccae53d67d70951b60b9a040e36 @@ -15022,4 +15030,4 @@ examples: "529": application/json: {"error": {"code": 529, "message": "Provider returned error"}} examplesVersion: 1.0.2 -releaseNotes: "## Python SDK Changes:\n* `open_router.video_generation.generate()`: \n * `request.resolution.enum(360p)` **Added**\n* `open_router.video_generation.list_videos_models()`: `response.data[]` **Changed**\n" +releaseNotes: "## Python SDK Changes:\n* `open_router.chat.send()`: `request` **Changed**\n* `open_router.presets.create_presets_chat_completions()`: `request` **Changed**\n* `open_router.presets.create_presets_messages()`: `request` **Changed**\n* `open_router.presets.create_presets_responses()`: `request` **Changed**\n* `open_router.responses.send()`: \n * `request` **Changed**\n * `response` **Changed**\n* `open_router.beta.responses.send()`: \n * `request` **Changed**\n * `response` **Changed**\n" diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 9f224a70..bd8e6946 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -36,7 +36,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true python: - version: 1.2.10 + version: 1.2.11 additionalDependencies: dev: {} main: {} diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index d538e7ab..83ef3f95 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -6402,14 +6402,14 @@ components: type: 'web_search_preview' properties: allowed_domains: - description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.' + description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.' items: type: 'string' type: 'array' engine: $ref: '#/components/schemas/WebSearchEngineEnum' excluded_domains: - description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.' + description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.' items: type: 'string' type: 'array' @@ -6445,6 +6445,8 @@ components: x-speakeasy-unknown-values: allow user_location: $ref: '#/components/schemas/WebSearchUserLocationServerTool' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'type' type: 'object' @@ -13253,6 +13255,8 @@ components: type: 'string' user_location: $ref: '#/components/schemas/WebSearchUserLocation' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'type' type: 'object' @@ -22533,6 +22537,8 @@ components: type: 'string' user_location: $ref: '#/components/schemas/Preview_WebSearchUserLocation' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'type' type: 'object' @@ -22563,6 +22569,8 @@ components: type: 'string' user_location: $ref: '#/components/schemas/Preview_WebSearchUserLocation' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'type' type: 'object' @@ -29101,14 +29109,14 @@ components: search_context_size: 'medium' properties: allowed_domains: - description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.' + description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.' items: type: 'string' type: 'array' engine: $ref: '#/components/schemas/WebSearchEngineEnum' excluded_domains: - description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.' + description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.' items: type: 'string' type: 'array' @@ -29134,6 +29142,8 @@ components: $ref: '#/components/schemas/SearchQualityLevel' user_location: $ref: '#/components/schemas/WebSearchUserLocationServerTool' + x_search: + $ref: '#/components/schemas/XSearchOptions' type: 'object' WebSearchDomainFilter: example: @@ -29257,6 +29267,8 @@ components: type: 'approximate' required: - 'type' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'id' type: 'object' @@ -29291,6 +29303,8 @@ components: type: 'string' user_location: $ref: '#/components/schemas/WebSearchUserLocation' + x_search: + $ref: '#/components/schemas/XSearchOptions' required: - 'type' type: 'object' @@ -29317,14 +29331,14 @@ components: search_context_size: 'medium' properties: allowed_domains: - description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.' + description: 'Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.' items: type: 'string' type: 'array' engine: $ref: '#/components/schemas/WebSearchEngineEnum' excluded_domains: - description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.' + description: 'Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.' items: type: 'string' type: 'array' @@ -29350,6 +29364,8 @@ components: $ref: '#/components/schemas/SearchQualityLevel' user_location: $ref: '#/components/schemas/WebSearchUserLocationServerTool' + x_search: + $ref: '#/components/schemas/XSearchOptions' type: 'object' WebSearchSource: example: @@ -29665,6 +29681,47 @@ components: - 'role' - 'created_at' type: 'object' + XSearchOptions: + additionalProperties: false + description: 'Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.' + example: + allowed_x_handles: + - 'OpenRouterAI' + from_date: '2025-01-01' + properties: + allowed_x_handles: + description: 'Only include posts from these X handles (max 20). Cannot be used with excluded_x_handles.' + example: + - 'OpenRouterAI' + items: + type: 'string' + maxItems: 20 + type: 'array' + enable_image_understanding: + description: 'Analyze images attached to matching posts.' + type: 'boolean' + enable_video_understanding: + description: 'Analyze videos attached to matching posts.' + type: 'boolean' + excluded_x_handles: + description: 'Exclude posts from these X handles (max 20). Cannot be used with allowed_x_handles.' + example: + - 'spamaccount' + items: + type: 'string' + maxItems: 20 + type: 'array' + from_date: + description: 'Start of the post date range (ISO 8601 date, e.g. "2025-01-01").' + example: '2025-01-01' + format: 'date' + type: 'string' + to_date: + description: 'End of the post date range (ISO 8601 date, e.g. "2025-12-31").' + example: '2025-12-31' + format: 'date' + type: 'string' + type: 'object' securitySchemes: apiKey: description: 'API key as bearer token in Authorization header' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 52221804..98493994 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:41fd4e4523c48a05aaa8a625ef6a38bd7fd40c888f3c244d2619ae191b8541e1 - sourceBlobDigest: sha256:97b7fdd541aaaab73c98651579266c3b218ecdde5e136b1339854b942d1694f3 + sourceRevisionDigest: sha256:74de8f20bb42a350b592daa622a1adf3f86b82145addc9650f1150ba07c5ba96 + sourceBlobDigest: sha256:8d2ecb843db7a0b1f4e7ab4db9ccf09fc4531b264789b8fac03f3337f92ea5e4 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: open-router: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:41fd4e4523c48a05aaa8a625ef6a38bd7fd40c888f3c244d2619ae191b8541e1 - sourceBlobDigest: sha256:97b7fdd541aaaab73c98651579266c3b218ecdde5e136b1339854b942d1694f3 + sourceRevisionDigest: sha256:74de8f20bb42a350b592daa622a1adf3f86b82145addc9650f1150ba07c5ba96 + sourceBlobDigest: sha256:8d2ecb843db7a0b1f4e7ab4db9ccf09fc4531b264789b8fac03f3337f92ea5e4 codeSamplesNamespace: open-router-python-code-samples - codeSamplesRevisionDigest: sha256:c6ec5f0b40ed9a4e83666a59b5d3294b6e2c29e7561ef00742294b3b7b3a315e + codeSamplesRevisionDigest: sha256:e3ae5ea70e5b2b1730d77e0084828c0c02d908cc22ff455eed790ca263a223d1 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index 958287f3..2c7a2cf6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2509,4 +2509,14 @@ Based on: ### Generated - [python v1.2.10] . ### Releases -- [PyPI v1.2.10] https://pypi.org/project/openrouter/1.2.10 - . \ No newline at end of file +- [PyPI v1.2.10] https://pypi.org/project/openrouter/1.2.10 - . + +## 2026-09-21 13:17:38 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.2.11] . +### Releases +- [PyPI v1.2.11] https://pypi.org/project/openrouter/1.2.11 - . \ No newline at end of file diff --git a/docs/components/chatwebsearchshorthand.mdx b/docs/components/chatwebsearchshorthand.mdx index 5833ac22..ae3a6874 100644 --- a/docs/components/chatwebsearchshorthand.mdx +++ b/docs/components/chatwebsearchshorthand.mdx @@ -9,9 +9,9 @@ Web search tool using OpenAI Responses API syntax. Automatically converted to op | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains. | | +| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains. | | | `engine` | [Optional[components.WebSearchEngineEnum]](../components/websearchengineenum.mdx) | :heavy_minus_sign: | Which search engine to use. "auto" (default) uses native if the provider supports it, otherwise Exa. "native" forces the provider's built-in search. "exa" forces the Exa search API. "firecrawl" uses Firecrawl (requires BYOK). "parallel" uses the Parallel search API. "perplexity" uses the Perplexity Search API (raw ranked results). | auto | -| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains. | | +| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains. | | | `max_characters` | *Optional[int]* | :heavy_minus_sign: | Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity). | 2000 | | `max_results` | *Optional[int]* | :heavy_minus_sign: | Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped. | 5 | | `max_total_results` | *Optional[int]* | :heavy_minus_sign: | Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified. | 50 | @@ -20,4 +20,5 @@ Web search tool using OpenAI Responses API syntax. Automatically converted to op | `parameters` | [Optional[components.WebSearchConfig]](../components/websearchconfig.mdx) | :heavy_minus_sign: | N/A | \{
"max_results": 5,
"search_context_size": "medium"
} | | `search_context_size` | [Optional[components.SearchQualityLevel]](../components/searchqualitylevel.mdx) | :heavy_minus_sign: | How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set. | medium | | `type` | [components.ChatWebSearchShorthandType](../components/chatwebsearchshorthandtype.mdx) | :heavy_check_mark: | N/A | | -| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/legacywebsearchservertool.mdx b/docs/components/legacywebsearchservertool.mdx index df8142b8..fc8f8785 100644 --- a/docs/components/legacywebsearchservertool.mdx +++ b/docs/components/legacywebsearchservertool.mdx @@ -16,4 +16,5 @@ Web search tool configuration | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchContextSizeEnum]](../components/searchcontextsizeenum.mdx) | :heavy_minus_sign: | Size of the search context for web search tools | medium | | `type` | [components.LegacyWebSearchServerToolType](../components/legacywebsearchservertooltype.mdx) | :heavy_check_mark: | N/A | | -| `user_location` | [OptionalNullable[components.WebSearchUserLocation]](../components/websearchuserlocation.mdx) | :heavy_minus_sign: | User location information for web search | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [OptionalNullable[components.WebSearchUserLocation]](../components/websearchuserlocation.mdx) | :heavy_minus_sign: | User location information for web search | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/preview20250311websearchservertool.mdx b/docs/components/preview20250311websearchservertool.mdx index 1bf764e9..750580a3 100644 --- a/docs/components/preview20250311websearchservertool.mdx +++ b/docs/components/preview20250311websearchservertool.mdx @@ -16,4 +16,5 @@ Web search preview tool configuration (2025-03-11 version) | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchContextSizeEnum]](../components/searchcontextsizeenum.mdx) | :heavy_minus_sign: | Size of the search context for web search tools | medium | | `type` | [components.Preview20250311WebSearchServerToolType](../components/preview20250311websearchservertooltype.mdx) | :heavy_check_mark: | N/A | | -| `user_location` | [OptionalNullable[components.PreviewWebSearchUserLocation]](../components/previewwebsearchuserlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [OptionalNullable[components.PreviewWebSearchUserLocation]](../components/previewwebsearchuserlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/previewwebsearchservertool.mdx b/docs/components/previewwebsearchservertool.mdx index 019ecc2e..ccbdb6a6 100644 --- a/docs/components/previewwebsearchservertool.mdx +++ b/docs/components/previewwebsearchservertool.mdx @@ -16,4 +16,5 @@ Web search preview tool configuration | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchContextSizeEnum]](../components/searchcontextsizeenum.mdx) | :heavy_minus_sign: | Size of the search context for web search tools | medium | | `type` | [components.PreviewWebSearchServerToolType](../components/previewwebsearchservertooltype.mdx) | :heavy_check_mark: | N/A | | -| `user_location` | [OptionalNullable[components.PreviewWebSearchUserLocation]](../components/previewwebsearchuserlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [OptionalNullable[components.PreviewWebSearchUserLocation]](../components/previewwebsearchuserlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/websearchconfig.mdx b/docs/components/websearchconfig.mdx index eaef734f..b7671cf8 100644 --- a/docs/components/websearchconfig.mdx +++ b/docs/components/websearchconfig.mdx @@ -6,13 +6,14 @@ title: "WebSearchConfig" | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains. | | +| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains. | | | `engine` | [Optional[components.WebSearchEngineEnum]](../components/websearchengineenum.mdx) | :heavy_minus_sign: | Which search engine to use. "auto" (default) uses native if the provider supports it, otherwise Exa. "native" forces the provider's built-in search. "exa" forces the Exa search API. "firecrawl" uses Firecrawl (requires BYOK). "parallel" uses the Parallel search API. "perplexity" uses the Perplexity Search API (raw ranked results). | auto | -| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains. | | +| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains. | | | `max_characters` | *Optional[int]* | :heavy_minus_sign: | Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity). | 2000 | | `max_results` | *Optional[int]* | :heavy_minus_sign: | Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped. | 5 | | `max_total_results` | *Optional[int]* | :heavy_minus_sign: | Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified. | 50 | | `max_uses` | *Optional[int]* | :heavy_minus_sign: | Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it. | 3 | | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchQualityLevel]](../components/searchqualitylevel.mdx) | :heavy_minus_sign: | How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set. | medium | -| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/websearchplugin.mdx b/docs/components/websearchplugin.mdx index c9c9b637..6cd0c9a7 100644 --- a/docs/components/websearchplugin.mdx +++ b/docs/components/websearchplugin.mdx @@ -4,15 +4,16 @@ title: "WebSearchPlugin" ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the web-search plugin for this request. Defaults to true. | | -| `engine` | [Optional[components.WebSearchEngine]](../components/websearchengine.mdx) | :heavy_minus_sign: | The search engine to use for web search. | exa | -| `exclude_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to exclude from web search results. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [
"example.com",
"*.substack.com",
"openai.com/blog"
] | -| `id` | [components.WebSearchPluginID](../components/websearchpluginid.mdx) | :heavy_check_mark: | N/A | | -| `include_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to restrict web search results to. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [
"example.com",
"*.substack.com",
"openai.com/blog"
] | -| `max_results` | *Optional[int]* | :heavy_minus_sign: | N/A | | -| `max_uses` | *Optional[int]* | :heavy_minus_sign: | Maximum number of times the model can invoke web search in a single turn. Passed through to native providers that support it (e.g. Anthropic). | | -| `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | -| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | | -| `user_location` | [OptionalNullable[components.UserLocation]](../components/userlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Set to false to disable the web-search plugin for this request. Defaults to true. | | +| `engine` | [Optional[components.WebSearchEngine]](../components/websearchengine.mdx) | :heavy_minus_sign: | The search engine to use for web search. | exa | +| `exclude_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to exclude from web search results. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [
"example.com",
"*.substack.com",
"openai.com/blog"
] | +| `id` | [components.WebSearchPluginID](../components/websearchpluginid.mdx) | :heavy_check_mark: | N/A | | +| `include_domains` | List[*str*] | :heavy_minus_sign: | A list of domains to restrict web search results to. Supports wildcards (e.g. "*.substack.com") and path filtering (e.g. "openai.com/blog"). | [
"example.com",
"*.substack.com",
"openai.com/blog"
] | +| `max_results` | *Optional[int]* | :heavy_minus_sign: | N/A | | +| `max_uses` | *Optional[int]* | :heavy_minus_sign: | Maximum number of times the model can invoke web search in a single turn. Passed through to native providers that support it (e.g. Anthropic). | | +| `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | +| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `user_location` | [OptionalNullable[components.UserLocation]](../components/userlocation.mdx) | :heavy_minus_sign: | N/A | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/websearchservertool.mdx b/docs/components/websearchservertool.mdx index 86c6d642..4a66fcbb 100644 --- a/docs/components/websearchservertool.mdx +++ b/docs/components/websearchservertool.mdx @@ -16,4 +16,5 @@ Web search tool configuration (2025-08-26 version) | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchContextSizeEnum]](../components/searchcontextsizeenum.mdx) | :heavy_minus_sign: | Size of the search context for web search tools | medium | | `type` | [components.WebSearchServerToolType](../components/websearchservertooltype.mdx) | :heavy_check_mark: | N/A | | -| `user_location` | [OptionalNullable[components.WebSearchUserLocation]](../components/websearchuserlocation.mdx) | :heavy_minus_sign: | User location information for web search | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [OptionalNullable[components.WebSearchUserLocation]](../components/websearchuserlocation.mdx) | :heavy_minus_sign: | User location information for web search | \{
"city": "San Francisco",
"country": "USA",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/websearchservertoolconfig.mdx b/docs/components/websearchservertoolconfig.mdx index a39dc889..206799c7 100644 --- a/docs/components/websearchservertoolconfig.mdx +++ b/docs/components/websearchservertoolconfig.mdx @@ -9,13 +9,14 @@ Configuration for the openrouter:web_search server tool | Field | Type | Required | Description | Example | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains. | | +| `allowed_domains` | List[*str*] | :heavy_minus_sign: | Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains. | | | `engine` | [Optional[components.WebSearchEngineEnum]](../components/websearchengineenum.mdx) | :heavy_minus_sign: | Which search engine to use. "auto" (default) uses native if the provider supports it, otherwise Exa. "native" forces the provider's built-in search. "exa" forces the Exa search API. "firecrawl" uses Firecrawl (requires BYOK). "parallel" uses the Parallel search API. "perplexity" uses the Perplexity Search API (raw ranked results). | auto | -| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains. | | +| `excluded_domains` | List[*str*] | :heavy_minus_sign: | Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains. | | | `max_characters` | *Optional[int]* | :heavy_minus_sign: | Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity). | 2000 | | `max_results` | *Optional[int]* | :heavy_minus_sign: | Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, Parallel, and Perplexity engines; ignored with native provider search. Perplexity supports a maximum of 20; values above 20 are clamped. | 5 | | `max_total_results` | *Optional[int]* | :heavy_minus_sign: | Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops. Defaults to 50 when not specified. | 50 | | `max_uses` | *Optional[int]* | :heavy_minus_sign: | Maximum number of web searches the model may perform in a single request. Once reached, further search calls return an error result instead of executing. Applies to the Exa, Firecrawl, Parallel, and Perplexity engines. With native provider search, forwarded only to Anthropic (as `max_uses`); other native search providers have no equivalent parameter and ignore it. | 3 | | `mode` | [Optional[components.WebSearchMode]](../components/websearchmode.mdx) | :heavy_minus_sign: | Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored. | auto | | `search_context_size` | [Optional[components.SearchQualityLevel]](../components/searchqualitylevel.mdx) | :heavy_minus_sign: | How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set. | medium | -| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | \ No newline at end of file +| `user_location` | [Optional[components.WebSearchUserLocationServerTool]](../components/websearchuserlocationservertool.mdx) | :heavy_minus_sign: | Approximate user location for location-biased results. | \{
"city": "San Francisco",
"country": "US",
"region": "California",
"timezone": "America/Los_Angeles",
"type": "approximate"
} | +| `x_search` | [Optional[components.XSearchOptions]](../components/xsearchoptions.mdx) | :heavy_minus_sign: | Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. | \{
"allowed_x_handles": [
"OpenRouterAI"
],
"from_date": "2025-01-01"
} | \ No newline at end of file diff --git a/docs/components/xsearchoptions.mdx b/docs/components/xsearchoptions.mdx new file mode 100644 index 00000000..d742b5c2 --- /dev/null +++ b/docs/components/xsearchoptions.mdx @@ -0,0 +1,17 @@ +--- +title: "XSearchOptions" +--- + +Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched. + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `allowed_x_handles` | List[*str*] | :heavy_minus_sign: | Only include posts from these X handles (max 20). Cannot be used with excluded_x_handles. | [
"OpenRouterAI"
] | +| `enable_image_understanding` | *Optional[bool]* | :heavy_minus_sign: | Analyze images attached to matching posts. | | +| `enable_video_understanding` | *Optional[bool]* | :heavy_minus_sign: | Analyze videos attached to matching posts. | | +| `excluded_x_handles` | List[*str*] | :heavy_minus_sign: | Exclude posts from these X handles (max 20). Cannot be used with allowed_x_handles. | [
"spamaccount"
] | +| `from_date` | [datetime](https://docs.python.org/3/library/datetime.html#datetime-objects) | :heavy_minus_sign: | Start of the post date range (ISO 8601 date, e.g. "2025-01-01"). | 2025-01-01 | +| `to_date` | [datetime](https://docs.python.org/3/library/datetime.html#datetime-objects) | :heavy_minus_sign: | End of the post date range (ISO 8601 date, e.g. "2025-12-31"). | 2025-12-31 | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ae1cadfe..4f3dc631 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "1.2.10" +version = "1.2.11" 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 6fbdc32f..4a594e60 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "1.2.10" +__version__: str = "1.2.11" __openapi_doc_version__: str = "1.0.0" __gen_version__: str = "2.914.0" -__user_agent__: str = "speakeasy-sdk/python 1.2.10 2.914.0 1.0.0 openrouter" +__user_agent__: str = "speakeasy-sdk/python 1.2.11 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 331cc515..32e9db75 100644 --- a/src/openrouter/components/__init__.py +++ b/src/openrouter/components/__init__.py @@ -3490,6 +3490,7 @@ WorkspaceMemberRole, WorkspaceMemberTypedDict, ) + from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict __all__ = [ "AABenchmarkEntry", @@ -6028,6 +6029,8 @@ "WorkspaceMemberRole", "WorkspaceMemberTypedDict", "WorkspaceTypedDict", + "XSearchOptions", + "XSearchOptionsTypedDict", ] _dynamic_imports: dict[str, str] = { @@ -8567,6 +8570,8 @@ "WorkspaceMember": ".workspacemember", "WorkspaceMemberRole": ".workspacemember", "WorkspaceMemberTypedDict": ".workspacemember", + "XSearchOptions": ".xsearchoptions", + "XSearchOptionsTypedDict": ".xsearchoptions", } diff --git a/src/openrouter/components/chatwebsearchshorthand.py b/src/openrouter/components/chatwebsearchshorthand.py index 5a4b645f..c69f9972 100644 --- a/src/openrouter/components/chatwebsearchshorthand.py +++ b/src/openrouter/components/chatwebsearchshorthand.py @@ -9,6 +9,7 @@ WebSearchUserLocationServerTool, WebSearchUserLocationServerToolTypedDict, ) +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import BaseModel, UNSET_SENTINEL, UnrecognizedStr from pydantic import model_serializer from typing import List, Literal, Optional, Union @@ -31,11 +32,11 @@ class ChatWebSearchShorthandTypedDict(TypedDict): type: ChatWebSearchShorthandType allowed_domains: NotRequired[List[str]] - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: NotRequired[WebSearchEngineEnum] r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: NotRequired[List[str]] - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: NotRequired[int] r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" max_results: NotRequired[int] @@ -51,6 +52,8 @@ class ChatWebSearchShorthandTypedDict(TypedDict): r"""How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set.""" user_location: NotRequired[WebSearchUserLocationServerToolTypedDict] r"""Approximate user location for location-biased results.""" + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class ChatWebSearchShorthand(BaseModel): @@ -59,13 +62,13 @@ class ChatWebSearchShorthand(BaseModel): type: ChatWebSearchShorthandType allowed_domains: Optional[List[str]] = None - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: Optional[WebSearchEngineEnum] = None r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: Optional[List[str]] = None - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: Optional[int] = None r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" @@ -90,6 +93,9 @@ class ChatWebSearchShorthand(BaseModel): user_location: Optional[WebSearchUserLocationServerTool] = None r"""Approximate user location for location-biased results.""" + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -105,6 +111,7 @@ def serialize_model(self, handler): "parameters", "search_context_size", "user_location", + "x_search", ] ) serialized = handler(self) diff --git a/src/openrouter/components/legacy_websearchservertool.py b/src/openrouter/components/legacy_websearchservertool.py index 25e499f0..a06a05fe 100644 --- a/src/openrouter/components/legacy_websearchservertool.py +++ b/src/openrouter/components/legacy_websearchservertool.py @@ -6,6 +6,7 @@ from .websearchengineenum import WebSearchEngineEnum from .websearchmode import WebSearchMode from .websearchuserlocation import WebSearchUserLocation, WebSearchUserLocationTypedDict +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -38,6 +39,8 @@ class LegacyWebSearchServerToolTypedDict(TypedDict): r"""Size of the search context for web search tools""" user_location: NotRequired[Nullable[WebSearchUserLocationTypedDict]] r"""User location information for web search""" + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class LegacyWebSearchServerTool(BaseModel): @@ -65,6 +68,9 @@ class LegacyWebSearchServerTool(BaseModel): user_location: OptionalNullable[WebSearchUserLocation] = UNSET r"""User location information for web search""" + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -76,6 +82,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) nullable_fields = set(["filters", "user_location"]) diff --git a/src/openrouter/components/openresponsesresult.py b/src/openrouter/components/openresponsesresult.py index 9301d127..bff0a6fe 100644 --- a/src/openrouter/components/openresponsesresult.py +++ b/src/openrouter/components/openresponsesresult.py @@ -141,10 +141,10 @@ def serialize_model(self, handler): FileSearchServerToolTypedDict, OpenResponsesResultToolFunctionTypedDict, LegacyWebSearchServerToolTypedDict, + McpServerToolTypedDict, WebSearchServerToolTypedDict, Preview20250311WebSearchServerToolTypedDict, PreviewWebSearchServerToolTypedDict, - McpServerToolTypedDict, ImageGenerationServerToolTypedDict, ], ) diff --git a/src/openrouter/components/preview_20250311_websearchservertool.py b/src/openrouter/components/preview_20250311_websearchservertool.py index 3df7c01d..3faa27e3 100644 --- a/src/openrouter/components/preview_20250311_websearchservertool.py +++ b/src/openrouter/components/preview_20250311_websearchservertool.py @@ -9,6 +9,7 @@ from .websearchdomainfilter import WebSearchDomainFilter, WebSearchDomainFilterTypedDict from .websearchengineenum import WebSearchEngineEnum from .websearchmode import WebSearchMode +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -40,6 +41,8 @@ class Preview20250311WebSearchServerToolTypedDict(TypedDict): search_context_size: NotRequired[SearchContextSizeEnum] r"""Size of the search context for web search tools""" user_location: NotRequired[Nullable[PreviewWebSearchUserLocationTypedDict]] + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class Preview20250311WebSearchServerTool(BaseModel): @@ -66,6 +69,9 @@ class Preview20250311WebSearchServerTool(BaseModel): user_location: OptionalNullable[PreviewWebSearchUserLocation] = UNSET + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -77,6 +83,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) nullable_fields = set(["filters", "user_location"]) diff --git a/src/openrouter/components/preview_websearchservertool.py b/src/openrouter/components/preview_websearchservertool.py index a6cf3bc0..8a0d4636 100644 --- a/src/openrouter/components/preview_websearchservertool.py +++ b/src/openrouter/components/preview_websearchservertool.py @@ -9,6 +9,7 @@ from .websearchdomainfilter import WebSearchDomainFilter, WebSearchDomainFilterTypedDict from .websearchengineenum import WebSearchEngineEnum from .websearchmode import WebSearchMode +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -40,6 +41,8 @@ class PreviewWebSearchServerToolTypedDict(TypedDict): search_context_size: NotRequired[SearchContextSizeEnum] r"""Size of the search context for web search tools""" user_location: NotRequired[Nullable[PreviewWebSearchUserLocationTypedDict]] + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class PreviewWebSearchServerTool(BaseModel): @@ -66,6 +69,9 @@ class PreviewWebSearchServerTool(BaseModel): user_location: OptionalNullable[PreviewWebSearchUserLocation] = UNSET + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -77,6 +83,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) nullable_fields = set(["filters", "user_location"]) diff --git a/src/openrouter/components/websearchconfig.py b/src/openrouter/components/websearchconfig.py index 3c4da59f..764e1c3a 100644 --- a/src/openrouter/components/websearchconfig.py +++ b/src/openrouter/components/websearchconfig.py @@ -8,6 +8,7 @@ WebSearchUserLocationServerTool, WebSearchUserLocationServerToolTypedDict, ) +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import BaseModel, UNSET_SENTINEL from pydantic import model_serializer from typing import List, Optional @@ -16,11 +17,11 @@ class WebSearchConfigTypedDict(TypedDict): allowed_domains: NotRequired[List[str]] - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: NotRequired[WebSearchEngineEnum] r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: NotRequired[List[str]] - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: NotRequired[int] r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" max_results: NotRequired[int] @@ -35,17 +36,19 @@ class WebSearchConfigTypedDict(TypedDict): r"""How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set.""" user_location: NotRequired[WebSearchUserLocationServerToolTypedDict] r"""Approximate user location for location-biased results.""" + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class WebSearchConfig(BaseModel): allowed_domains: Optional[List[str]] = None - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: Optional[WebSearchEngineEnum] = None r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: Optional[List[str]] = None - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: Optional[int] = None r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" @@ -68,6 +71,9 @@ class WebSearchConfig(BaseModel): user_location: Optional[WebSearchUserLocationServerTool] = None r"""Approximate user location for location-biased results.""" + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -82,6 +88,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) serialized = handler(self) diff --git a/src/openrouter/components/websearchplugin.py b/src/openrouter/components/websearchplugin.py index 338d13aa..77f977d0 100644 --- a/src/openrouter/components/websearchplugin.py +++ b/src/openrouter/components/websearchplugin.py @@ -3,6 +3,7 @@ from __future__ import annotations from .websearchengine import WebSearchEngine from .websearchmode import WebSearchMode +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -87,6 +88,8 @@ class WebSearchPluginTypedDict(TypedDict): r"""Engine-native search mode. Exa supports instant, fast, auto (default), deep-lite, deep, and deep-reasoning. Parallel supports turbo, fast, basic (default), and advanced. Modes unsupported by the selected engine are ignored.""" search_prompt: NotRequired[str] user_location: NotRequired[Nullable[UserLocationTypedDict]] + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class WebSearchPlugin(BaseModel): @@ -116,6 +119,9 @@ class WebSearchPlugin(BaseModel): user_location: OptionalNullable[UserLocation] = UNSET + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -129,6 +135,7 @@ def serialize_model(self, handler): "mode", "search_prompt", "user_location", + "x_search", ] ) nullable_fields = set(["user_location"]) diff --git a/src/openrouter/components/websearchservertool.py b/src/openrouter/components/websearchservertool.py index 2c4460d1..ca027ac4 100644 --- a/src/openrouter/components/websearchservertool.py +++ b/src/openrouter/components/websearchservertool.py @@ -6,6 +6,7 @@ from .websearchengineenum import WebSearchEngineEnum from .websearchmode import WebSearchMode from .websearchuserlocation import WebSearchUserLocation, WebSearchUserLocationTypedDict +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import ( BaseModel, Nullable, @@ -38,6 +39,8 @@ class WebSearchServerToolTypedDict(TypedDict): r"""Size of the search context for web search tools""" user_location: NotRequired[Nullable[WebSearchUserLocationTypedDict]] r"""User location information for web search""" + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class WebSearchServerTool(BaseModel): @@ -65,6 +68,9 @@ class WebSearchServerTool(BaseModel): user_location: OptionalNullable[WebSearchUserLocation] = UNSET r"""User location information for web search""" + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -76,6 +82,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) nullable_fields = set(["filters", "user_location"]) diff --git a/src/openrouter/components/websearchservertoolconfig.py b/src/openrouter/components/websearchservertoolconfig.py index 8a7ecce3..b8c30a3d 100644 --- a/src/openrouter/components/websearchservertoolconfig.py +++ b/src/openrouter/components/websearchservertoolconfig.py @@ -8,6 +8,7 @@ WebSearchUserLocationServerTool, WebSearchUserLocationServerToolTypedDict, ) +from .xsearchoptions import XSearchOptions, XSearchOptionsTypedDict from openrouter.types import BaseModel, UNSET_SENTINEL from pydantic import model_serializer from typing import List, Optional @@ -18,11 +19,11 @@ class WebSearchServerToolConfigTypedDict(TypedDict): r"""Configuration for the openrouter:web_search server tool""" allowed_domains: NotRequired[List[str]] - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: NotRequired[WebSearchEngineEnum] r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: NotRequired[List[str]] - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: NotRequired[int] r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" max_results: NotRequired[int] @@ -37,19 +38,21 @@ class WebSearchServerToolConfigTypedDict(TypedDict): r"""How much context to retrieve per result. Applies to Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, pins a fixed per-result character cap (low=5,000, medium=15,000, high=30,000); when omitted, Exa picks an adaptive size per query and document (typically ~2,000–4,000 characters per result). For Parallel, controls the total characters across all results; when omitted, Parallel uses its own default size. For Perplexity, maps directly to the Search API's native search_context_size parameter. Overridden by `max_characters` when both are set.""" user_location: NotRequired[WebSearchUserLocationServerToolTypedDict] r"""Approximate user location for location-biased results.""" + x_search: NotRequired[XSearchOptionsTypedDict] + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" class WebSearchServerToolConfig(BaseModel): r"""Configuration for the openrouter:web_search server tool""" allowed_domains: Optional[List[str]] = None - r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, xAI). Cannot be used with excluded_domains.""" + r"""Limit search results to these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, and most native providers (Anthropic, OpenAI, SpaceXAI). Cannot be used with excluded_domains.""" engine: Optional[WebSearchEngineEnum] = None r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API. \"perplexity\" uses the Perplexity Search API (raw ranked results).""" excluded_domains: Optional[List[str]] = None - r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and xAI. Cannot be used with allowed_domains.""" + r"""Exclude search results from these domains. Supported by Exa, Firecrawl, Parallel, Perplexity, Anthropic, OpenAI, and SpaceXAI. Cannot be used with allowed_domains.""" max_characters: Optional[int] = None r"""Exact maximum number of characters of content per search result. Applies to the Exa, Parallel, and Perplexity engines; ignored with native provider search and Firecrawl. For Exa, caps highlight content per result. For Parallel, caps excerpt content per result (default 1,500 when omitted). For Perplexity, maps to the native `max_tokens_per_page` parameter (converted from characters to tokens) and trims the response to the exact character cap. When both `max_characters` and `search_context_size` are set, `max_characters` takes precedence. When omitted, falls back to `search_context_size` mapping (Exa) or engine defaults (Parallel, Perplexity).""" @@ -72,6 +75,9 @@ class WebSearchServerToolConfig(BaseModel): user_location: Optional[WebSearchUserLocationServerTool] = None r"""Approximate user location for location-biased results.""" + x_search: Optional[XSearchOptions] = None + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( @@ -86,6 +92,7 @@ def serialize_model(self, handler): "mode", "search_context_size", "user_location", + "x_search", ] ) serialized = handler(self) diff --git a/src/openrouter/components/xsearchoptions.py b/src/openrouter/components/xsearchoptions.py new file mode 100644 index 00000000..72db9c53 --- /dev/null +++ b/src/openrouter/components/xsearchoptions.py @@ -0,0 +1,72 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from datetime import date +from openrouter.types import BaseModel, UNSET_SENTINEL +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class XSearchOptionsTypedDict(TypedDict): + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + + allowed_x_handles: NotRequired[List[str]] + r"""Only include posts from these X handles (max 20). Cannot be used with excluded_x_handles.""" + enable_image_understanding: NotRequired[bool] + r"""Analyze images attached to matching posts.""" + enable_video_understanding: NotRequired[bool] + r"""Analyze videos attached to matching posts.""" + excluded_x_handles: NotRequired[List[str]] + r"""Exclude posts from these X handles (max 20). Cannot be used with allowed_x_handles.""" + from_date: NotRequired[date] + r"""Start of the post date range (ISO 8601 date, e.g. \"2025-01-01\").""" + to_date: NotRequired[date] + r"""End of the post date range (ISO 8601 date, e.g. \"2025-12-31\").""" + + +class XSearchOptions(BaseModel): + r"""Enable SpaceXAI X (Twitter) search alongside native web search, with optional filters. Only applies to SpaceXAI endpoints with native search; omit to search the web only. X search is billed separately by SpaceXAI, per post and per user profile fetched.""" + + allowed_x_handles: Optional[List[str]] = None + r"""Only include posts from these X handles (max 20). Cannot be used with excluded_x_handles.""" + + enable_image_understanding: Optional[bool] = None + r"""Analyze images attached to matching posts.""" + + enable_video_understanding: Optional[bool] = None + r"""Analyze videos attached to matching posts.""" + + excluded_x_handles: Optional[List[str]] = None + r"""Exclude posts from these X handles (max 20). Cannot be used with allowed_x_handles.""" + + from_date: Optional[date] = None + r"""Start of the post date range (ISO 8601 date, e.g. \"2025-01-01\").""" + + to_date: Optional[date] = None + r"""End of the post date range (ISO 8601 date, e.g. \"2025-12-31\").""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = set( + [ + "allowed_x_handles", + "enable_image_understanding", + "enable_video_understanding", + "excluded_x_handles", + "from_date", + "to_date", + ] + ) + 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)) + + if val != UNSET_SENTINEL: + if val is not None or k not in optional_fields: + m[k] = val + + return m diff --git a/uv.lock b/uv.lock index 3a3b24bd..eaa61ce6 100644 --- a/uv.lock +++ b/uv.lock @@ -213,7 +213,7 @@ wheels = [ [[package]] name = "openrouter" -version = "1.2.10" +version = "1.2.11" source = { editable = "." } dependencies = [ { name = "httpcore" },