Compare commits

...
10 Commits
Author SHA1 Message Date
Matt AppersonandGitHub 67ef52b03e chore: Python SDK updates and regeneration (#24) 2025-12-04 13:09:00 -05:00
Matt Apperson d4474da1b8 more updates 2025-12-04 13:07:08 -05:00
Matt Apperson aed8199b2b updates 2025-12-04 13:07:01 -05:00
Matt AppersonandGitHub 06b2ccc54a chore: regenerate Python SDK v0.1.1 with new overlays (#23) 2025-12-04 10:48:48 -05:00
Matt Apperson 6cd0d2a76d latest updates 2025-12-04 10:46:19 -05:00
Matt AppersonandGitHub a1dae775cb chore: regenerate Python SDK v0.0.17 (#18) 2025-11-18 13:59:14 -05:00
Matt Apperson 10a76ba502 chore: regenerate SDK to v0.0.19 with speakeasy 2025-11-18 13:58:48 -05:00
Matt Apperson f4ffd51f40 chore: regenerate Python SDK v0.0.17
Update Python SDK with Speakeasy regeneration:
- Bump version from 0.0.16 to 0.0.17
- Refactor OpenAPI schema definitions:
  - Inline BigNumberUnion type into usage sites
  - Reorganize ProviderName enum location
  - Simplify provider order/only/ignore array types
  - Add plugins schema definitions
- Update gen.lock with new configChecksum
2025-11-18 13:56:41 -05:00
Matt AppersonandGitHub 20c63f6f13 feat: add monorepo sync notification workflow (#17) 2025-11-15 16:16:37 -05:00
Matt Apperson 0f9cb9787a feat: add monorepo sync notification workflow
Automatically notifies openrouter-web monorepo when changes are pushed to main.
This triggers the subtree sync workflow to create a PR with updates.

Requires MONOREPO_SYNC_TOKEN secret to be configured.
2025-11-15 15:53:15 -05:00
119 changed files with 18448 additions and 9220 deletions
+46
View File
@@ -0,0 +1,46 @@
name: Notify Monorepo of Changes
on:
push:
branches:
- main
jobs:
notify-monorepo:
runs-on: ubuntu-latest
steps:
- name: Send repository dispatch to monorepo
run: |
# Determine which event type to send based on repository name
REPO_NAME="${GITHUB_REPOSITORY#*/}" # Gets 'python-sdk' from 'OpenRouterTeam/python-sdk'
case "$REPO_NAME" in
"typescript-sdk")
EVENT_TYPE="sync-typescript-sdk"
;;
"python-sdk")
EVENT_TYPE="sync-python-sdk"
;;
"ai-sdk-provider")
EVENT_TYPE="sync-ai-sdk-provider"
;;
"cli")
EVENT_TYPE="sync-cli"
;;
*)
echo "Unknown repository: $REPO_NAME"
exit 1
;;
esac
echo "Sending repository_dispatch event: $EVENT_TYPE"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MONOREPO_SYNC_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OpenRouterTeam/openrouter-web/dispatches \
-d "{\"event_type\":\"$EVENT_TYPE\",\"client_payload\":{\"repository\":\"$GITHUB_REPOSITORY\",\"ref\":\"$GITHUB_REF\",\"sha\":\"$GITHUB_SHA\"}}"
echo "✅ Notification sent to monorepo"
+53 -34
View File
@@ -1,12 +1,12 @@
lockVersion: 2.0.0 lockVersion: 2.0.0
id: cfd52247-6a25-4c6d-bbce-fe6fce0cd69d id: cfd52247-6a25-4c6d-bbce-fe6fce0cd69d
management: management:
docChecksum: b1b97e85c6e3464e1fd6e2163c4ebc87 docChecksum: 01481f11e87a18cf1daa583fee2c88fb
docVersion: 1.0.0 docVersion: 1.0.0
speakeasyVersion: 1.658.1 speakeasyVersion: 1.666.0
generationVersion: 2.755.6 generationVersion: 2.768.0
releaseVersion: 0.0.16 releaseVersion: 0.0.21
configChecksum: bccceb456c96a46bcbe65fdff6bd5e1f configChecksum: 52c13d7fdf159611bf5d900363e322ac
repoURL: https://github.com/OpenRouterTeam/python-sdk.git repoURL: https://github.com/OpenRouterTeam/python-sdk.git
installationURL: https://github.com/OpenRouterTeam/python-sdk.git installationURL: https://github.com/OpenRouterTeam/python-sdk.git
published: true published: true
@@ -15,7 +15,7 @@ features:
acceptHeaders: 3.0.0 acceptHeaders: 3.0.0
additionalDependencies: 1.0.0 additionalDependencies: 1.0.0
constsAndDefaults: 1.0.5 constsAndDefaults: 1.0.5
core: 5.23.8 core: 5.23.13
defaultEnabledRetries: 0.2.0 defaultEnabledRetries: 0.2.0
deprecations: 3.0.2 deprecations: 3.0.2
devContainers: 3.0.0 devContainers: 3.0.0
@@ -27,6 +27,7 @@ features:
globalSecurityCallbacks: 1.0.0 globalSecurityCallbacks: 1.0.0
globalSecurityFlattening: 1.0.0 globalSecurityFlattening: 1.0.0
globalServerURLs: 3.2.0 globalServerURLs: 3.2.0
globals: 3.0.0
groups: 3.0.1 groups: 3.0.1
methodArguments: 1.0.2 methodArguments: 1.0.2
methodSecurity: 3.0.1 methodSecurity: 3.0.1
@@ -34,8 +35,8 @@ features:
nullables: 1.0.1 nullables: 1.0.1
openEnums: 1.0.1 openEnums: 1.0.1
responseFormat: 1.0.1 responseFormat: 1.0.1
retries: 3.0.2 retries: 3.0.3
sdkHooks: 1.1.0 sdkHooks: 1.2.0
serverEvents: 1.0.11 serverEvents: 1.0.11
serverEventsSentinels: 0.1.0 serverEventsSentinels: 0.1.0
serverIDs: 3.0.0 serverIDs: 3.0.0
@@ -65,12 +66,14 @@ generatedFiles:
- docs/components/chatgenerationtokenusage.md - docs/components/chatgenerationtokenusage.md
- docs/components/chatmessagecontentitem.md - docs/components/chatmessagecontentitem.md
- docs/components/chatmessagecontentitemaudio.md - docs/components/chatmessagecontentitemaudio.md
- docs/components/chatmessagecontentitemaudioformat.md
- docs/components/chatmessagecontentitemaudioinputaudio.md - docs/components/chatmessagecontentitemaudioinputaudio.md
- docs/components/chatmessagecontentitemcachecontrol.md
- docs/components/chatmessagecontentitemimage.md - docs/components/chatmessagecontentitemimage.md
- docs/components/chatmessagecontentitemimagedetail.md - docs/components/chatmessagecontentitemimagedetail.md
- docs/components/chatmessagecontentitemtext.md - docs/components/chatmessagecontentitemtext.md
- docs/components/chatmessagecontentitemvideo.md - docs/components/chatmessagecontentitemvideo.md
- docs/components/chatmessagecontentitemvideoinputvideo.md
- docs/components/chatmessagecontentitemvideovideourl.md
- docs/components/chatmessagetokenlogprob.md - docs/components/chatmessagetokenlogprob.md
- docs/components/chatmessagetokenlogprobs.md - docs/components/chatmessagetokenlogprobs.md
- docs/components/chatmessagetoolcall.md - docs/components/chatmessagetoolcall.md
@@ -103,6 +106,7 @@ generatedFiles:
- docs/components/costdetails.md - docs/components/costdetails.md
- docs/components/createchargerequest.md - docs/components/createchargerequest.md
- docs/components/datacollection.md - docs/components/datacollection.md
- docs/components/debug.md
- docs/components/defaultparameters.md - docs/components/defaultparameters.md
- docs/components/edgenetworktimeoutresponseerrordata.md - docs/components/edgenetworktimeoutresponseerrordata.md
- docs/components/effort.md - docs/components/effort.md
@@ -115,6 +119,7 @@ generatedFiles:
- docs/components/forbiddenresponseerrordata.md - docs/components/forbiddenresponseerrordata.md
- docs/components/idfileparser.md - docs/components/idfileparser.md
- docs/components/idmoderation.md - docs/components/idmoderation.md
- docs/components/idresponsehealing.md
- docs/components/idweb.md - docs/components/idweb.md
- docs/components/ignore.md - docs/components/ignore.md
- docs/components/imagegenerationstatus.md - docs/components/imagegenerationstatus.md
@@ -298,6 +303,7 @@ generatedFiles:
- docs/components/plugin.md - docs/components/plugin.md
- docs/components/pluginfileparser.md - docs/components/pluginfileparser.md
- docs/components/pluginmoderation.md - docs/components/pluginmoderation.md
- docs/components/pluginresponsehealing.md
- docs/components/pluginweb.md - docs/components/pluginweb.md
- docs/components/pricing.md - docs/components/pricing.md
- docs/components/prompt.md - docs/components/prompt.md
@@ -305,6 +311,7 @@ generatedFiles:
- docs/components/provider.md - docs/components/provider.md
- docs/components/providername.md - docs/components/providername.md
- docs/components/provideroverloadedresponseerrordata.md - docs/components/provideroverloadedresponseerrordata.md
- docs/components/providersort.md
- docs/components/publicendpoint.md - docs/components/publicendpoint.md
- docs/components/publicendpointquantization.md - docs/components/publicendpointquantization.md
- docs/components/publicpricing.md - docs/components/publicpricing.md
@@ -375,7 +382,6 @@ generatedFiles:
- docs/components/security.md - docs/components/security.md
- docs/components/servicetier.md - docs/components/servicetier.md
- docs/components/serviceunavailableresponseerrordata.md - docs/components/serviceunavailableresponseerrordata.md
- docs/components/sort.md
- docs/components/streamoptions.md - docs/components/streamoptions.md
- docs/components/systemmessage.md - docs/components/systemmessage.md
- docs/components/systemmessagecontent.md - docs/components/systemmessagecontent.md
@@ -389,6 +395,7 @@ generatedFiles:
- docs/components/toplogprob.md - docs/components/toplogprob.md
- docs/components/topproviderinfo.md - docs/components/topproviderinfo.md
- docs/components/truncation.md - docs/components/truncation.md
- docs/components/ttl.md
- docs/components/type.md - docs/components/type.md
- docs/components/typeresponsecompleted.md - docs/components/typeresponsecompleted.md
- docs/components/typeresponsecontentpartadded.md - docs/components/typeresponsecontentpartadded.md
@@ -414,7 +421,8 @@ generatedFiles:
- docs/components/usermessage.md - docs/components/usermessage.md
- docs/components/usermessagecontent.md - docs/components/usermessagecontent.md
- docs/components/variables.md - docs/components/variables.md
- docs/components/videourl.md - docs/components/videourl1.md
- docs/components/videourl2.md
- docs/components/websearchpreviewtooluserlocation.md - docs/components/websearchpreviewtooluserlocation.md
- docs/components/websearchpreviewtooluserlocationtype.md - docs/components/websearchpreviewtooluserlocationtype.md
- docs/components/websearchstatus.md - docs/components/websearchstatus.md
@@ -433,9 +441,13 @@ generatedFiles:
- docs/errors/toomanyrequestsresponseerror.md - docs/errors/toomanyrequestsresponseerror.md
- docs/errors/unauthorizedresponseerror.md - docs/errors/unauthorizedresponseerror.md
- docs/errors/unprocessableentityresponseerror.md - docs/errors/unprocessableentityresponseerror.md
- docs/models/internal/globals.md
- docs/models/utils/retryconfig.md - docs/models/utils/retryconfig.md
- docs/operations/apitype.md - docs/operations/apitype.md
- docs/operations/calldata.md - docs/operations/calldata.md
- docs/operations/content.md
- docs/operations/contentimageurl.md
- docs/operations/contenttext.md
- docs/operations/createauthkeyscodecodechallengemethod.md - docs/operations/createauthkeyscodecodechallengemethod.md
- docs/operations/createauthkeyscodedata.md - docs/operations/createauthkeyscodedata.md
- docs/operations/createauthkeyscoderequest.md - docs/operations/createauthkeyscoderequest.md
@@ -454,16 +466,14 @@ generatedFiles:
- docs/operations/createkeysresponse.md - docs/operations/createkeysresponse.md
- docs/operations/createresponsesresponse.md - docs/operations/createresponsesresponse.md
- docs/operations/createresponsesresponsebody.md - docs/operations/createresponsesresponsebody.md
- docs/operations/datacollection.md
- docs/operations/deletekeysrequest.md - docs/operations/deletekeysrequest.md
- docs/operations/deletekeysresponse.md - docs/operations/deletekeysresponse.md
- docs/operations/embedding.md - docs/operations/embedding.md
- docs/operations/encodingformat.md - docs/operations/encodingformat.md
- docs/operations/encodingformatbase64.md
- docs/operations/encodingformatfloat.md
- docs/operations/exchangeauthcodeforapikeycodechallengemethod.md - docs/operations/exchangeauthcodeforapikeycodechallengemethod.md
- docs/operations/exchangeauthcodeforapikeyrequest.md - docs/operations/exchangeauthcodeforapikeyrequest.md
- docs/operations/exchangeauthcodeforapikeyresponse.md - docs/operations/exchangeauthcodeforapikeyresponse.md
- docs/operations/getcreditsdata.md
- docs/operations/getcreditsresponse.md - docs/operations/getcreditsresponse.md
- docs/operations/getcurrentkeydata.md - docs/operations/getcurrentkeydata.md
- docs/operations/getcurrentkeyresponse.md - docs/operations/getcurrentkeyresponse.md
@@ -482,7 +492,9 @@ generatedFiles:
- docs/operations/getuseractivityrequest.md - docs/operations/getuseractivityrequest.md
- docs/operations/getuseractivityresponse.md - docs/operations/getuseractivityresponse.md
- docs/operations/ignore.md - docs/operations/ignore.md
- docs/operations/imageurl.md
- docs/operations/input.md - docs/operations/input.md
- docs/operations/inputunion.md
- docs/operations/listdata.md - docs/operations/listdata.md
- docs/operations/listendpointsrequest.md - docs/operations/listendpointsrequest.md
- docs/operations/listendpointsresponse.md - docs/operations/listendpointsresponse.md
@@ -500,9 +512,10 @@ generatedFiles:
- docs/operations/order.md - docs/operations/order.md
- docs/operations/ratelimit.md - docs/operations/ratelimit.md
- docs/operations/sendchatcompletionrequestresponse.md - docs/operations/sendchatcompletionrequestresponse.md
- docs/operations/sort.md
- docs/operations/supportedparameter.md - docs/operations/supportedparameter.md
- docs/operations/transferintent.md - docs/operations/transferintent.md
- docs/operations/typeimageurl.md
- docs/operations/typetext.md
- docs/operations/updatekeysdata.md - docs/operations/updatekeysdata.md
- docs/operations/updatekeyslimitreset.md - docs/operations/updatekeyslimitreset.md
- docs/operations/updatekeysrequest.md - docs/operations/updatekeysrequest.md
@@ -549,6 +562,7 @@ generatedFiles:
- src/openrouter/components/chatgenerationtokenusage.py - src/openrouter/components/chatgenerationtokenusage.py
- src/openrouter/components/chatmessagecontentitem.py - src/openrouter/components/chatmessagecontentitem.py
- src/openrouter/components/chatmessagecontentitemaudio.py - src/openrouter/components/chatmessagecontentitemaudio.py
- src/openrouter/components/chatmessagecontentitemcachecontrol.py
- src/openrouter/components/chatmessagecontentitemimage.py - src/openrouter/components/chatmessagecontentitemimage.py
- src/openrouter/components/chatmessagecontentitemtext.py - src/openrouter/components/chatmessagecontentitemtext.py
- src/openrouter/components/chatmessagecontentitemvideo.py - src/openrouter/components/chatmessagecontentitemvideo.py
@@ -568,6 +582,7 @@ generatedFiles:
- src/openrouter/components/completionresponse.py - src/openrouter/components/completionresponse.py
- src/openrouter/components/completionusage.py - src/openrouter/components/completionusage.py
- src/openrouter/components/createchargerequest.py - src/openrouter/components/createchargerequest.py
- src/openrouter/components/datacollection.py
- src/openrouter/components/defaultparameters.py - src/openrouter/components/defaultparameters.py
- src/openrouter/components/edgenetworktimeoutresponseerrordata.py - src/openrouter/components/edgenetworktimeoutresponseerrordata.py
- src/openrouter/components/endpointstatus.py - src/openrouter/components/endpointstatus.py
@@ -637,6 +652,7 @@ generatedFiles:
- src/openrouter/components/perrequestlimits.py - src/openrouter/components/perrequestlimits.py
- src/openrouter/components/providername.py - src/openrouter/components/providername.py
- src/openrouter/components/provideroverloadedresponseerrordata.py - src/openrouter/components/provideroverloadedresponseerrordata.py
- src/openrouter/components/providersort.py
- src/openrouter/components/publicendpoint.py - src/openrouter/components/publicendpoint.py
- src/openrouter/components/publicpricing.py - src/openrouter/components/publicpricing.py
- src/openrouter/components/quantization.py - src/openrouter/components/quantization.py
@@ -705,6 +721,9 @@ generatedFiles:
- src/openrouter/errors/unprocessableentityresponse_error.py - src/openrouter/errors/unprocessableentityresponse_error.py
- src/openrouter/generations.py - src/openrouter/generations.py
- src/openrouter/httpclient.py - src/openrouter/httpclient.py
- src/openrouter/models/__init__.py
- src/openrouter/models/internal/__init__.py
- src/openrouter/models/internal/globals.py
- src/openrouter/models_.py - src/openrouter/models_.py
- src/openrouter/oauth.py - src/openrouter/oauth.py
- src/openrouter/operations/__init__.py - src/openrouter/operations/__init__.py
@@ -758,10 +777,10 @@ examples:
createResponses: createResponses:
speakeasy-default-create-responses: speakeasy-default-create-responses:
requestBody: requestBody:
application/json: {"input": [{"type": "message", "role": "user", "content": "Hello, how are you?"}], "tools": [{"type": "function", "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": {"type": "object", "properties": {"location": {"type": "string"}}}}], "model": "anthropic/claude-4.5-sonnet-20250929", "temperature": 0.7, "top_p": 0.9, "stream": false} application/json: {"store": false, "service_tier": "auto", "stream": false}
responses: responses:
"200": "200":
application/json: {"id": "resp-abc123", "object": "response", "created_at": 1704067200, "model": "gpt-4", "status": "completed", "output": [{"id": "msg-abc123", "role": "assistant", "type": "message", "status": "completed", "content": [{"type": "output_text", "text": "Hello! How can I help you today?", "annotations": []}]}], "error": null, "incomplete_details": null, "usage": {"input_tokens": 10, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 25, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 35}, "max_output_tokens": null, "temperature": null, "top_p": null, "instructions": null, "metadata": null, "tools": [], "tool_choice": "auto", "parallel_tool_calls": true} application/json: {"id": "resp-abc123", "object": "response", "created_at": 1704067200, "model": "gpt-4", "output": [{"id": "msg-abc123", "role": "assistant", "type": "message", "content": [{"type": "output_text", "text": "Hello! How can I help you today?"}]}], "error": null, "incomplete_details": null, "temperature": null, "top_p": null, "instructions": null, "metadata": null, "tools": [], "tool_choice": "auto", "parallel_tool_calls": true}
"400": "400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"401": "401":
@@ -808,7 +827,7 @@ examples:
speakeasy-default-get-credits: speakeasy-default-get-credits:
responses: responses:
"200": "200":
application/json: {} application/json: {"data": {"total_credits": 100.5, "total_usage": 25.75}}
"401": "401":
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
"403": "403":
@@ -833,7 +852,7 @@ examples:
createEmbeddings: createEmbeddings:
speakeasy-default-create-embeddings: speakeasy-default-create-embeddings:
requestBody: requestBody:
application/json: {"input": "<value>", "model": "Taurus", "provider": {"data_collection": "deny", "zdr": true, "enforce_distillable_text": true, "order": ["OpenAI"], "only": ["OpenAI"], "ignore": ["OpenAI"], "quantizations": ["fp16"], "sort": "price"}} application/json: {"input": "<value>", "model": "Taurus"}
responses: responses:
"200": "200":
application/json: {"object": "list", "data": [], "model": "Land Cruiser"} application/json: {"object": "list", "data": [], "model": "Land Cruiser"}
@@ -862,7 +881,7 @@ examples:
speakeasy-default-list-embeddings-models: speakeasy-default-list-embeddings-models:
responses: responses:
"200": "200":
application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.", "pricing": {"prompt": "0.00003", "completion": "0.00006", "request": "0", "image": "0"}, "context_length": 8192, "architecture": {"tokenizer": "GPT", "instruct_type": "chatml", "modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"context_length": 8192, "max_completion_tokens": 4096, "is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]} application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "pricing": {"prompt": "0.00003", "completion": "0.00006"}, "context_length": 8192, "architecture": {"modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]}
"400": "400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"500": "500":
@@ -902,7 +921,7 @@ examples:
speakeasy-default-get-models: speakeasy-default-get-models:
responses: responses:
"200": "200":
application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.", "pricing": {"prompt": "0.00003", "completion": "0.00006", "request": "0", "image": "0"}, "context_length": 8192, "architecture": {"tokenizer": "GPT", "instruct_type": "chatml", "modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"context_length": 8192, "max_completion_tokens": 4096, "is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]} application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "pricing": {"prompt": "0.00003", "completion": "0.00006"}, "context_length": 8192, "architecture": {"modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]}
"400": "400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"500": "500":
@@ -911,7 +930,7 @@ examples:
speakeasy-default-list-models-user: speakeasy-default-list-models-user:
responses: responses:
"200": "200":
application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.", "pricing": {"prompt": "0.00003", "completion": "0.00006", "request": "0", "image": "0"}, "context_length": 8192, "architecture": {"tokenizer": "GPT", "instruct_type": "chatml", "modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"context_length": 8192, "max_completion_tokens": 4096, "is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]} application/json: {"data": [{"id": "openai/gpt-4", "canonical_slug": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "pricing": {"prompt": "0.00003", "completion": "0.00006"}, "context_length": 8192, "architecture": {"modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "top_provider": {"is_moderated": true}, "per_request_limits": null, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "default_parameters": null}]}
"401": "401":
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
"500": "500":
@@ -924,7 +943,7 @@ examples:
slug: "<value>" slug: "<value>"
responses: responses:
"200": "200":
application/json: {"data": {"id": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.", "architecture": {"tokenizer": "GPT", "instruct_type": "chatml", "modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "endpoints": [{"name": "OpenAI: GPT-4", "model_name": "GPT-4", "context_length": 8192, "pricing": {"prompt": "0.00003", "completion": "0.00006", "request": "0", "image": "0"}, "provider_name": "OpenAI", "tag": "openai", "quantization": "fp16", "max_completion_tokens": 4096, "max_prompt_tokens": 8192, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "status": -3, "uptime_last_30m": 99.5, "supports_implicit_caching": true}]}} application/json: {"data": {"id": "openai/gpt-4", "name": "GPT-4", "created": 1692901234, "description": "GPT-4 is a large multimodal model that can solve difficult problems with greater accuracy.", "architecture": {"tokenizer": "GPT", "instruct_type": "chatml", "modality": "text->text", "input_modalities": ["text"], "output_modalities": ["text"]}, "endpoints": [{"name": "OpenAI: GPT-4", "model_name": "GPT-4", "context_length": 8192, "pricing": {"prompt": "0.00003", "completion": "0.00006"}, "provider_name": "OpenAI", "tag": "openai", "quantization": "fp16", "max_completion_tokens": 4096, "max_prompt_tokens": 8192, "supported_parameters": ["temperature", "top_p", "max_tokens", "frequency_penalty", "presence_penalty"], "uptime_last_30m": 99.5, "supports_implicit_caching": true}]}}
"404": "404":
application/json: {"error": {"code": 404, "message": "Resource not found"}} application/json: {"error": {"code": 404, "message": "Resource not found"}}
"500": "500":
@@ -933,7 +952,7 @@ examples:
speakeasy-default-list-endpoints-zdr: speakeasy-default-list-endpoints-zdr:
responses: responses:
"200": "200":
application/json: {"data": [{"name": "OpenAI: GPT-4", "model_name": "GPT-4", "context_length": 8192, "pricing": {"prompt": "0.00003", "completion": "0.00006", "request": "0", "image": "0"}, "provider_name": "OpenAI", "tag": "openai", "quantization": "fp16", "max_completion_tokens": 4096, "max_prompt_tokens": 8192, "supported_parameters": ["temperature", "top_p", "max_tokens"], "status": 0, "uptime_last_30m": 99.5, "supports_implicit_caching": true}]} application/json: {"data": [{"name": "OpenAI: GPT-4", "model_name": "GPT-4", "context_length": 8192, "pricing": {"prompt": "0.00003", "completion": "0.00006"}, "provider_name": "OpenAI", "tag": "openai", "quantization": "fp16", "max_completion_tokens": 4096, "max_prompt_tokens": 8192, "supported_parameters": ["temperature", "top_p", "max_tokens"], "uptime_last_30m": 99.5, "supports_implicit_caching": true}]}
"500": "500":
application/json: {"error": {"code": 500, "message": "Internal Server Error"}} application/json: {"error": {"code": 500, "message": "Internal Server Error"}}
getParameters: getParameters:
@@ -955,7 +974,7 @@ examples:
speakeasy-default-list-providers: speakeasy-default-list-providers:
responses: responses:
"200": "200":
application/json: {"data": [{"name": "OpenAI", "slug": "openai", "privacy_policy_url": "https://openai.com/privacy", "terms_of_service_url": "https://openai.com/terms", "status_page_url": "https://status.openai.com"}]} application/json: {"data": [{"name": "OpenAI", "slug": "openai", "privacy_policy_url": "https://openai.com/privacy"}]}
"500": "500":
application/json: {"error": {"code": 500, "message": "Internal Server Error"}} application/json: {"error": {"code": 500, "message": "Internal Server Error"}}
list: list:
@@ -966,7 +985,7 @@ examples:
offset: "0" offset: "0"
responses: responses:
"200": "200":
application/json: {"data": [{"hash": "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", "name": "My Production Key", "label": "Production API Key", "disabled": false, "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T15:45:00Z", "expires_at": "2027-12-31T23:59:59Z"}]} application/json: {"data": [{"hash": "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", "name": "My Production Key", "label": "Production API Key", "disabled": false, "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T15:45:00Z"}]}
"401": "401":
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
"429": "429":
@@ -976,10 +995,10 @@ examples:
createKeys: createKeys:
speakeasy-default-create-keys: speakeasy-default-create-keys:
requestBody: requestBody:
application/json: {"name": "My New API Key", "limit": 50, "limit_reset": "monthly", "include_byok_in_limit": true, "expires_at": "2027-12-31T23:59:59Z"} application/json: {"name": "My New API Key"}
responses: responses:
"201": "201":
application/json: {"data": {"hash": "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", "name": "My New API Key", "label": "My New API Key", "disabled": false, "limit": 50, "limit_remaining": 50, "limit_reset": "monthly", "include_byok_in_limit": true, "usage": 0, "usage_daily": 0, "usage_weekly": 0, "usage_monthly": 0, "byok_usage": 0, "byok_usage_daily": 0, "byok_usage_weekly": 0, "byok_usage_monthly": 0, "created_at": "2025-08-24T10:30:00Z", "updated_at": null, "expires_at": "2027-12-31T23:59:59Z"}, "key": "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"} application/json: {"data": {"hash": "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", "name": "My New API Key", "label": "My New API Key", "disabled": false, "limit": 50, "limit_remaining": 50, "limit_reset": "monthly", "include_byok_in_limit": true, "usage": 0, "usage_daily": 0, "usage_weekly": 0, "usage_monthly": 0, "byok_usage": 0, "byok_usage_daily": 0, "byok_usage_weekly": 0, "byok_usage_monthly": 0, "created_at": "2025-08-24T10:30:00Z", "updated_at": null}, "key": "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"}
"400": "400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"401": "401":
@@ -994,10 +1013,10 @@ examples:
path: path:
hash: "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" hash: "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"
requestBody: requestBody:
application/json: {"name": "Updated API Key Name", "disabled": false, "limit": 75, "limit_reset": "daily", "include_byok_in_limit": true} application/json: {}
responses: responses:
"200": "200":
application/json: {"data": {"hash": "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", "name": "Updated API Key Name", "label": "Updated API Key Name", "disabled": false, "limit": 75, "limit_remaining": 49.5, "limit_reset": "daily", "include_byok_in_limit": true, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T16:00:00Z", "expires_at": null}} application/json: {"data": {"hash": "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", "name": "Updated API Key Name", "label": "Updated API Key Name", "disabled": false, "limit": 75, "limit_remaining": 49.5, "limit_reset": "daily", "include_byok_in_limit": true, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T16:00:00Z"}}
"400": "400":
application/json: {"error": {"code": 400, "message": "Invalid request parameters"}} application/json: {"error": {"code": 400, "message": "Invalid request parameters"}}
"401": "401":
@@ -1031,7 +1050,7 @@ examples:
hash: "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" hash: "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"
responses: responses:
"200": "200":
application/json: {"data": {"hash": "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", "name": "My Production Key", "label": "Production API Key", "disabled": false, "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T15:45:00Z", "expires_at": "2027-12-31T23:59:59Z"}} application/json: {"data": {"hash": "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", "name": "My Production Key", "label": "Production API Key", "disabled": false, "limit": 100, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "created_at": "2025-08-24T10:30:00Z", "updated_at": "2025-08-24T15:45:00Z"}}
"401": "401":
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
"404": "404":
@@ -1044,7 +1063,7 @@ examples:
speakeasy-default-get-current-key: speakeasy-default-get-current-key:
responses: responses:
"200": "200":
application/json: {"data": {"label": "sk-or-v1-au78b3456789012345678901234567890", "limit": 100, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "is_free_tier": false, "is_provisioning_key": false, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "expires_at": "2027-12-31T23:59:59Z", "rate_limit": {"requests": 1000, "interval": "1h", "note": "This field is deprecated and safe to ignore."}}} application/json: {"data": {"label": "sk-or-v1-au78b3456789012345678901234567890", "limit": 100, "usage": 25.5, "usage_daily": 25.5, "usage_weekly": 25.5, "usage_monthly": 25.5, "byok_usage": 17.38, "byok_usage_daily": 17.38, "byok_usage_weekly": 17.38, "byok_usage_monthly": 17.38, "is_free_tier": false, "is_provisioning_key": false, "limit_remaining": 74.5, "limit_reset": "monthly", "include_byok_in_limit": false, "rate_limit": {"requests": 1000, "interval": "1h", "note": "This field is deprecated and safe to ignore."}}}
"401": "401":
application/json: {"error": {"code": 401, "message": "Missing Authentication header"}} application/json: {"error": {"code": 401, "message": "Missing Authentication header"}}
"500": "500":
@@ -1052,7 +1071,7 @@ examples:
exchangeAuthCodeForAPIKey: exchangeAuthCodeForAPIKey:
speakeasy-default-exchange-auth-code-for-API-key: speakeasy-default-exchange-auth-code-for-API-key:
requestBody: requestBody:
application/json: {"code": "auth_code_abc123def456", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "code_challenge_method": "S256"} application/json: {"code": "auth_code_abc123def456"}
responses: responses:
"200": "200":
application/json: {"key": "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", "user_id": "user_2yOPcMpKoQhcd4bVgSMlELRaIah"} application/json: {"key": "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", "user_id": "user_2yOPcMpKoQhcd4bVgSMlELRaIah"}
@@ -1065,7 +1084,7 @@ examples:
createAuthKeysCode: createAuthKeysCode:
speakeasy-default-create-auth-keys-code: speakeasy-default-create-auth-keys-code:
requestBody: requestBody:
application/json: {"callback_url": "https://myapp.com/auth/callback", "code_challenge": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM", "code_challenge_method": "S256", "limit": 100} application/json: {"callback_url": "https://myapp.com/auth/callback"}
responses: responses:
"200": "200":
application/json: {"data": {"id": "auth_code_xyz789", "app_id": 12345, "created_at": "2025-08-24T10:30:00Z"}} application/json: {"data": {"id": "auth_code_xyz789", "app_id": 12345, "created_at": "2025-08-24T10:30:00Z"}}
+10 -6
View File
@@ -6,7 +6,7 @@ generation:
sdkClassName: OpenRouter sdkClassName: OpenRouter
maintainOpenAPIOrder: true maintainOpenAPIOrder: true
usageSnippets: usageSnippets:
optionalPropertyRendering: withExample optionalPropertyRendering: never
sdkInitStyle: constructor sdkInitStyle: constructor
useClassNamesForArrayFields: true useClassNamesForArrayFields: true
fixes: fixes:
@@ -24,13 +24,14 @@ generation:
sdkHooksConfigAccess: true sdkHooksConfigAccess: true
schemas: schemas:
allOfMergeStrategy: shallowMerge allOfMergeStrategy: shallowMerge
requestBodyFieldName: body requestBodyFieldName: ""
tests: tests:
generateTests: false generateTests: false
generateNewTests: true generateNewTests: true
skipResponseBodyAssertions: false skipResponseBodyAssertions: false
preApplyUnionDiscriminators: true
python: python:
version: 0.0.16 version: 0.0.21
additionalDependencies: additionalDependencies:
dev: {} dev: {}
main: {} main: {}
@@ -57,17 +58,20 @@ python:
imports: imports:
option: openapi option: openapi
paths: paths:
callbacks: "" callbacks: callbacks
errors: errors errors: errors
operations: operations operations: operations
shared: components shared: components
webhooks: "" webhooks: webhooks
inferSSEOverload: true
inferUnionDiscriminators: true
inputModelSuffix: input inputModelSuffix: input
legacyPyright: false legacyPyright: false
license: "" license: Apache-2.0
maxMethodParams: 999 maxMethodParams: 999
methodArguments: infer-optional-args methodArguments: infer-optional-args
moduleName: "" moduleName: ""
multipartArrayFormat: legacy
outputModelSuffix: output outputModelSuffix: output
packageManager: uv packageManager: uv
packageName: openrouter packageName: openrouter
File diff suppressed because it is too large Load Diff
+8372 -8292
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,35 @@
overlay: 1.0.0
x-speakeasy-jsonpath: rfc9535
info:
title: Add HTTP-Referer and X-Title as global parameters
version: 0.0.0
actions:
# Add global parameters for app identification
- target: $
description: Add x-speakeasy-globals for HTTP-Referer and X-Title headers
update:
x-speakeasy-globals:
parameters:
- $ref: "#/components/parameters/AppIdentifier"
- $ref: "#/components/parameters/AppDisplayName"
# Add component parameters
- target: $.components
description: Add parameters for app identification headers
update:
parameters:
AppIdentifier:
name: HTTP-Referer
in: header
schema:
type: string
description: |
The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
AppDisplayName:
name: X-Title
in: header
schema:
type: string
description: |
The app display name allows you to customize how your app appears in OpenRouter's dashboard.
@@ -0,0 +1,10 @@
overlay: 1.0.0
x-speakeasy-jsonpath: rfc9535
info:
title: Add open enums
version: 0.0.0
actions:
- target: $..[?length(@.enum) > 1]
description: Automatically open all enums that have length > 1
update:
x-speakeasy-unknown-values: allow
@@ -0,0 +1,15 @@
overlay: 1.0.0
x-speakeasy-jsonpath: rfc9535
info:
title: Remove RSS+XML response schemas and related parameters
version: 0.0.0
actions:
- target: $..responses.*.content["application/rss+xml"]
description: Remove application/rss+xml response schemas
remove: true
- target: $..parameters[?@.name == "use_rss"]
description: Remove use_rss parameter
remove: true
- target: $..parameters[?@.name == "use_rss_chat_links"]
description: Remove use_rss_chat_links parameter
remove: true
+22 -12
View File
@@ -1,32 +1,42 @@
speakeasyVersion: 1.658.1 speakeasyVersion: 1.666.0
sources: sources:
-OAS: -OAS:
sourceNamespace: open-router-chat-completions-api sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:08647b466c00989914e3a2436175152270f771f0a57d055f5bab14cc2d4be89e sourceRevisionDigest: sha256:f1b59b9b643de5e20d6e3299a8274783d8c0854615876f5d7f6f081814842695
sourceBlobDigest: sha256:53027ec57392d9617cc001ece83c2fe1aa6e5dbfd52d170381c34c33c6042c23 sourceBlobDigest: sha256:ee1f2422281b3ed5b38951c74636ad192c9bb160f216069c1f7931ccc4e52553
tags: tags:
- latest - latest
- speakeasy-sdk-regen-1763230596 OpenRouter API:
sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:9b410c8cfafe475dc6d9550f97a1e755b9a02b54513d3a85efe606e9bb05ca57
sourceBlobDigest: sha256:61a2d897cc5ddd893a5131bfacad7fcc311fe5b2eaaa5641fbb0a5b3321bfde7
tags:
- latest
- 1.0.0
targets: targets:
open-router: open-router:
source: -OAS source: OpenRouter API
sourceNamespace: open-router-chat-completions-api sourceNamespace: open-router-chat-completions-api
sourceRevisionDigest: sha256:08647b466c00989914e3a2436175152270f771f0a57d055f5bab14cc2d4be89e sourceRevisionDigest: sha256:9b410c8cfafe475dc6d9550f97a1e755b9a02b54513d3a85efe606e9bb05ca57
sourceBlobDigest: sha256:53027ec57392d9617cc001ece83c2fe1aa6e5dbfd52d170381c34c33c6042c23 sourceBlobDigest: sha256:61a2d897cc5ddd893a5131bfacad7fcc311fe5b2eaaa5641fbb0a5b3321bfde7
workflow: workflow:
workflowVersion: 1.0.0 workflowVersion: 1.0.0
speakeasyVersion: latest speakeasyVersion: 1.666.0
sources: sources:
-OAS: OpenRouter API:
inputs: inputs:
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main - location: .speakeasy/in.openapi.yaml
overlays:
- location: .speakeasy/overlays/open-enums.overlay.yaml
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
- location: .speakeasy/overlays/add-headers.overlay.yaml
output: .speakeasy/out.openapi.yaml output: .speakeasy/out.openapi.yaml
registry: registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
targets: targets:
open-router: open-router:
target: python target: python
source: -OAS source: OpenRouter API
publish: publish:
pypi: pypi:
token: $pypi_token token: $pypi_token
+10 -6
View File
@@ -1,22 +1,26 @@
workflowVersion: 1.0.0 workflowVersion: 1.0.0
speakeasyVersion: latest speakeasyVersion: 1.666.0
sources: sources:
-OAS: OpenRouter API:
inputs: inputs:
- location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api:main - location: .speakeasy/in.openapi.yaml
overlays:
- location: .speakeasy/overlays/open-enums.overlay.yaml
- location: .speakeasy/overlays/remove-rss-responses.overlay.yaml
- location: .speakeasy/overlays/add-headers.overlay.yaml
output: .speakeasy/out.openapi.yaml output: .speakeasy/out.openapi.yaml
registry: registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas location: registry.speakeasyapi.dev/openrouter/sdk/open-router-chat-completions-api
targets: targets:
open-router: open-router:
target: python target: python
source: -OAS source: OpenRouter API
publish: publish:
pypi: pypi:
token: $pypi_token token: $pypi_token
codeSamples: codeSamples:
registry: registry:
location: registry.speakeasyapi.dev/openrouter/sdk/-oas-python-code-samples location: registry.speakeasyapi.dev/openrouter/sdk/open-router-python-code-samples
labelOverride: labelOverride:
fixedValue: Python (SDK) fixedValue: Python (SDK)
blocking: false blocking: false
+2 -110
View File
@@ -9,61 +9,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.beta.responses.send(input=[ res = open_router.beta.responses.send(service_tier="auto", stream=False)
{
"type": "message",
"role": "user",
"content": "Hello, how are you?",
},
], metadata={
"user_id": "123",
"session_id": "abc-def-ghi",
}, tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
},
},
},
},
], model="anthropic/claude-4.5-sonnet-20250929", text={
"format_": {
"type": "text",
},
"verbosity": "medium",
}, reasoning={
"summary": "auto",
"enabled": True,
}, temperature=0.7, top_p=0.9, prompt={
"id": "<id>",
"variables": {
"key": {
"type": "input_text",
"text": "Hello, how can I help you?",
},
},
}, service_tier="auto", truncation="auto", stream=False, provider={
"data_collection": "deny",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": None,
"sort": "price",
})
with res as event_stream: with res as event_stream:
for event in event_stream: for event in event_stream:
@@ -87,61 +33,7 @@ async def main():
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = await open_router.beta.responses.send_async(input=[ res = await open_router.beta.responses.send_async(service_tier="auto", stream=False)
{
"type": "message",
"role": "user",
"content": "Hello, how are you?",
},
], metadata={
"user_id": "123",
"session_id": "abc-def-ghi",
}, tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
},
},
},
},
], model="anthropic/claude-4.5-sonnet-20250929", text={
"format_": {
"type": "text",
},
"verbosity": "medium",
}, reasoning={
"summary": "auto",
"enabled": True,
}, temperature=0.7, top_p=0.9, prompt={
"id": "<id>",
"variables": {
"key": {
"type": "input_text",
"text": "Hello, how can I help you?",
},
},
}, service_tier="auto", truncation="auto", stream=False, provider={
"data_collection": "deny",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": None,
"sort": "price",
})
async with res as event_stream: async with res as event_stream:
async for event in event_stream: async for event in event_stream:
+2 -1
View File
@@ -26,4 +26,5 @@
| `tool_choice` | *Optional[Any]* | :heavy_minus_sign: | N/A | | `tool_choice` | *Optional[Any]* | :heavy_minus_sign: | N/A |
| `tools` | List[[components.ToolDefinitionJSON](../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A | | `tools` | List[[components.ToolDefinitionJSON](../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A |
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | | `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A | | `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `debug` | [Optional[components.Debug]](../components/debug.md) | :heavy_minus_sign: | N/A |
@@ -27,3 +27,9 @@ value: components.ChatMessageContentItemAudio = /* values here */
value: components.ChatMessageContentItemVideo = /* values here */ value: components.ChatMessageContentItemVideo = /* values here */
``` ```
### `components.ChatMessageContentItemVideo`
```python
value: components.ChatMessageContentItemVideo = /* values here */
```
@@ -1,14 +0,0 @@
# ChatMessageContentItemAudioFormat
## Values
| Name | Value |
| ------- | ------- |
| `WAV` | wav |
| `MP3` | mp3 |
| `FLAC` | flac |
| `M4A` | m4a |
| `OGG` | ogg |
| `PCM16` | pcm16 |
| `PCM24` | pcm24 |
@@ -3,7 +3,7 @@
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description |
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | ------------------ | ------------------ | ------------------ | ------------------ |
| `data` | *str* | :heavy_check_mark: | N/A | | `data` | *str* | :heavy_check_mark: | N/A |
| `format_` | [components.ChatMessageContentItemAudioFormat](../components/chatmessagecontentitemaudioformat.md) | :heavy_check_mark: | N/A | | `format_` | *str* | :heavy_check_mark: | N/A |
@@ -0,0 +1,9 @@
# ChatMessageContentItemCacheControl
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ |
| `type` | *Literal["ephemeral"]* | :heavy_check_mark: | N/A |
| `ttl` | [Optional[components.TTL]](../components/ttl.md) | :heavy_minus_sign: | N/A |
@@ -3,7 +3,8 @@
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description |
| ------------------ | ------------------ | ------------------ | ------------------ | | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `type` | *Literal["text"]* | :heavy_check_mark: | N/A | | `type` | *Literal["text"]* | :heavy_check_mark: | N/A |
| `text` | *str* | :heavy_check_mark: | N/A | | `text` | *str* | :heavy_check_mark: | N/A |
| `cache_control` | [Optional[components.ChatMessageContentItemCacheControl]](../components/chatmessagecontentitemcachecontrol.md) | :heavy_minus_sign: | N/A |
+13 -5
View File
@@ -1,9 +1,17 @@
# ChatMessageContentItemVideo # ChatMessageContentItemVideo
## Fields ## Supported Types
### `components.ChatMessageContentItemVideoInputVideo`
```python
value: components.ChatMessageContentItemVideoInputVideo = /* values here */
```
### `components.ChatMessageContentItemVideoVideoURL`
```python
value: components.ChatMessageContentItemVideoVideoURL = /* values here */
```
| Field | Type | Required | Description |
| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ |
| `type` | *Literal["input_video"]* | :heavy_check_mark: | N/A |
| `video_url` | [components.VideoURL](../components/videourl.md) | :heavy_check_mark: | N/A |
@@ -0,0 +1,9 @@
# ChatMessageContentItemVideoInputVideo
## Fields
| Field | Type | Required | Description |
| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
| `type` | *Literal["input_video"]* | :heavy_check_mark: | N/A |
| `video_url` | [components.VideoURL1](../components/videourl1.md) | :heavy_check_mark: | N/A |
@@ -0,0 +1,9 @@
# ChatMessageContentItemVideoVideoURL
## Fields
| Field | Type | Required | Description |
| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
| `type` | *Literal["video_url"]* | :heavy_check_mark: | N/A |
| `video_url` | [components.VideoURL2](../components/videourl2.md) | :heavy_check_mark: | N/A |
+3 -1
View File
@@ -8,4 +8,6 @@
| `text` | *str* | :heavy_check_mark: | N/A | | `text` | *str* | :heavy_check_mark: | N/A |
| `index` | *float* | :heavy_check_mark: | N/A | | `index` | *float* | :heavy_check_mark: | N/A |
| `logprobs` | [Nullable[components.CompletionLogprobs]](../components/completionlogprobs.md) | :heavy_check_mark: | N/A | | `logprobs` | [Nullable[components.CompletionLogprobs]](../components/completionlogprobs.md) | :heavy_check_mark: | N/A |
| `finish_reason` | [Nullable[components.CompletionFinishReason]](../components/completionfinishreason.md) | :heavy_check_mark: | N/A | | `finish_reason` | [Nullable[components.CompletionFinishReason]](../components/completionfinishreason.md) | :heavy_check_mark: | N/A |
| `native_finish_reason` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A |
+1
View File
@@ -9,6 +9,7 @@
| `object` | *Literal["text_completion"]* | :heavy_check_mark: | N/A | | `object` | *Literal["text_completion"]* | :heavy_check_mark: | N/A |
| `created` | *float* | :heavy_check_mark: | N/A | | `created` | *float* | :heavy_check_mark: | N/A |
| `model` | *str* | :heavy_check_mark: | N/A | | `model` | *str* | :heavy_check_mark: | N/A |
| `provider` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `system_fingerprint` | *Optional[str]* | :heavy_minus_sign: | N/A | | `system_fingerprint` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `choices` | List[[components.CompletionChoice](../components/completionchoice.md)] | :heavy_check_mark: | N/A | | `choices` | List[[components.CompletionChoice](../components/completionchoice.md)] | :heavy_check_mark: | N/A |
| `usage` | [Optional[components.CompletionUsage]](../components/completionusage.md) | :heavy_minus_sign: | N/A | | `usage` | [Optional[components.CompletionUsage]](../components/completionusage.md) | :heavy_minus_sign: | N/A |
+1 -1
View File
@@ -2,8 +2,8 @@
Data collection setting. If no available model provider meets the requirement, your request will return an error. Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it - allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
- deny: use only providers which do not collect user data.
## Values ## Values
+8
View File
@@ -0,0 +1,8 @@
# Debug
## Fields
| Field | Type | Required | Description |
| -------------------- | -------------------- | -------------------- | -------------------- |
| `echo_upstream_body` | *Optional[bool]* | :heavy_minus_sign: | N/A |
+1
View File
@@ -5,6 +5,7 @@
| Name | Value | | Name | Value |
| --------- | --------- | | --------- | --------- |
| `NONE` | none |
| `MINIMAL` | minimal | | `MINIMAL` | minimal |
| `LOW` | low | | `LOW` | low |
| `MEDIUM` | medium | | `MEDIUM` | medium |
+8
View File
@@ -0,0 +1,8 @@
# IDResponseHealing
## Values
| Name | Value |
| ------------------ | ------------------ |
| `RESPONSE_HEALING` | response-healing |
@@ -8,4 +8,5 @@
| `HIGH` | high | | `HIGH` | high |
| `MEDIUM` | medium | | `MEDIUM` | medium |
| `LOW` | low | | `LOW` | low |
| `MINIMAL` | minimal | | `MINIMAL` | minimal |
| `NONE` | none |
@@ -8,4 +8,5 @@
| `UNKNOWN` | unknown | | `UNKNOWN` | unknown |
| `OPENAI_RESPONSES_V1` | openai-responses-v1 | | `OPENAI_RESPONSES_V1` | openai-responses-v1 |
| `XAI_RESPONSES_V1` | xai-responses-v1 | | `XAI_RESPONSES_V1` | xai-responses-v1 |
| `ANTHROPIC_CLAUDE_V1` | anthropic-claude-v1 | | `ANTHROPIC_CLAUDE_V1` | anthropic-claude-v1 |
| `GOOGLE_GEMINI_V1` | google-gemini-v1 |
+4 -3
View File
@@ -27,10 +27,11 @@ Request schema for Responses endpoint
| `include` | List[[components.OpenAIResponsesIncludable](../components/openairesponsesincludable.md)] | :heavy_minus_sign: | N/A | | | `include` | List[[components.OpenAIResponsesIncludable](../components/openairesponsesincludable.md)] | :heavy_minus_sign: | N/A | |
| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | | `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | | `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
| `store` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | | `store` | *Optional[Literal[False]]* | :heavy_minus_sign: | N/A | |
| `service_tier` | [OptionalNullable[components.ServiceTier]](../components/servicetier.md) | :heavy_minus_sign: | N/A | auto | | `service_tier` | [Optional[components.ServiceTier]](../components/servicetier.md) | :heavy_minus_sign: | N/A | |
| `truncation` | [OptionalNullable[components.Truncation]](../components/truncation.md) | :heavy_minus_sign: | N/A | auto | | `truncation` | [OptionalNullable[components.Truncation]](../components/truncation.md) | :heavy_minus_sign: | N/A | auto |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | | | `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
| `provider` | [OptionalNullable[components.Provider]](../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | | `provider` | [OptionalNullable[components.Provider]](../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
| `plugins` | List[[components.Plugin](../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | | `plugins` | List[[components.Plugin](../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
| `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | | | `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters. | |
+6
View File
@@ -21,3 +21,9 @@ value: components.PluginWeb = /* values here */
value: components.PluginFileParser = /* values here */ value: components.PluginFileParser = /* values here */
``` ```
### `components.PluginResponseHealing`
```python
value: components.PluginResponseHealing = /* values here */
```
+8
View File
@@ -0,0 +1,8 @@
# PluginResponseHealing
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
| `id` | [components.IDResponseHealing](../components/idresponsehealing.md) | :heavy_check_mark: | N/A |
+1
View File
@@ -9,6 +9,7 @@
| `completion` | *Any* | :heavy_check_mark: | A value in string or number format that is a large number | | `completion` | *Any* | :heavy_check_mark: | A value in string or number format that is a large number |
| `request` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `request` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `image` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image_token` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image_output` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `image_output` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `audio` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `audio` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `input_audio_cache` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `input_audio_cache` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
+2 -2
View File
@@ -9,12 +9,12 @@ When multiple model providers are available, optionally indicate your routing pr
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests<br/>- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.<br/>- false: use only the primary/custom provider, and return the upstream error if it's unavailable.<br/> | | | `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests<br/>- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.<br/>- false: use only the primary/custom provider, and return the upstream error if it's unavailable.<br/> | |
| `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | | | `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | |
| `data_collection` | [OptionalNullable[components.DataCollection]](../components/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.<br/>- allow: (default) allow providers which store user data non-transiently and may train on it<br/>- deny: use only providers which do not collect user data.<br/> | deny | | `data_collection` | [OptionalNullable[components.DataCollection]](../components/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.<br/>- allow: (default) allow providers which store user data non-transiently and may train on it<br/><br/>- deny: use only providers which do not collect user data. | allow |
| `zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used. | true | | `zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used. | true |
| `enforce_distillable_text` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used. | true | | `enforce_distillable_text` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used. | true |
| `order` | List[[components.Order](../components/order.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | | | `order` | List[[components.Order](../components/order.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | |
| `only` | List[[components.Only](../components/only.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | | | `only` | List[[components.Only](../components/only.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | |
| `ignore` | List[[components.Ignore](../components/ignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | | | `ignore` | List[[components.Ignore](../components/ignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | |
| `quantizations` | List[[components.Quantization](../components/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | | | `quantizations` | List[[components.Quantization](../components/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | |
| `sort` | [OptionalNullable[components.Sort]](../components/sort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | price | | `sort` | [OptionalNullable[components.ProviderSort]](../components/providersort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | price |
| `max_price` | [Optional[components.MaxPrice]](../components/maxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | | | `max_price` | [Optional[components.MaxPrice]](../components/maxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | |
+69 -88
View File
@@ -3,91 +3,72 @@
## Values ## Values
| Name | Value | | Name | Value |
| ------------------ | ------------------ | | ------------------- | ------------------- |
| `ANY_SCALE` | AnyScale | | `AI21` | AI21 |
| `CENT_ML` | Cent-ML | | `AION_LABS` | AionLabs |
| `HUGGING_FACE` | HuggingFace | | `ALIBABA` | Alibaba |
| `HYPERBOLIC_2` | Hyperbolic 2 | | `AMAZON_BEDROCK` | Amazon Bedrock |
| `LEPTON` | Lepton | | `AMAZON_NOVA` | Amazon Nova |
| `LYNN_2` | Lynn 2 | | `ANTHROPIC` | Anthropic |
| `LYNN` | Lynn | | `ARCEE_AI` | Arcee AI |
| `MANCER` | Mancer | | `ATLAS_CLOUD` | AtlasCloud |
| `MODAL` | Modal | | `AVIAN` | Avian |
| `OCTO_AI` | OctoAI | | `AZURE` | Azure |
| `RECURSAL` | Recursal | | `BASE_TEN` | BaseTen |
| `REFLECTION` | Reflection | | `BYTE_PLUS` | BytePlus |
| `REPLICATE` | Replicate | | `BLACK_FOREST_LABS` | Black Forest Labs |
| `SAMBA_NOVA_2` | SambaNova 2 | | `CEREBRAS` | Cerebras |
| `SF_COMPUTE` | SF Compute | | `CHUTES` | Chutes |
| `TOGETHER_2` | Together 2 | | `CIRRASCALE` | Cirrascale |
| `ONE_DOT_AI` | 01.AI | | `CLARIFAI` | Clarifai |
| `AI21` | AI21 | | `CLOUDFLARE` | Cloudflare |
| `AION_LABS` | AionLabs | | `COHERE` | Cohere |
| `ALIBABA` | Alibaba | | `CRUSOE` | Crusoe |
| `AMAZON_BEDROCK` | Amazon Bedrock | | `DEEP_INFRA` | DeepInfra |
| `ANTHROPIC` | Anthropic | | `DEEP_SEEK` | DeepSeek |
| `ATLAS_CLOUD` | AtlasCloud | | `FEATHERLESS` | Featherless |
| `ATOMA` | Atoma | | `FIREWORKS` | Fireworks |
| `AVIAN` | Avian | | `FRIENDLI` | Friendli |
| `AZURE` | Azure | | `GMI_CLOUD` | GMICloud |
| `BASE_TEN` | BaseTen | | `GO_POMELO` | GoPomelo |
| `CEREBRAS` | Cerebras | | `GOOGLE` | Google |
| `CHUTES` | Chutes | | `GOOGLE_AI_STUDIO` | Google AI Studio |
| `CIRRASCALE` | Cirrascale | | `GROQ` | Groq |
| `CLARIFAI` | Clarifai | | `HYPERBOLIC` | Hyperbolic |
| `CLOUDFLARE` | Cloudflare | | `INCEPTION` | Inception |
| `COHERE` | Cohere | | `INFERENCE_NET` | InferenceNet |
| `CROF_AI` | CrofAI | | `INFERMATIC` | Infermatic |
| `CRUSOE` | Crusoe | | `INFLECTION` | Inflection |
| `DEEP_INFRA` | DeepInfra | | `LIQUID` | Liquid |
| `DEEP_SEEK` | DeepSeek | | `MANCER_2` | Mancer 2 |
| `ENFER` | Enfer | | `MINIMAX` | Minimax |
| `FEATHERLESS` | Featherless | | `MODEL_RUN` | ModelRun |
| `FIREWORKS` | Fireworks | | `MISTRAL` | Mistral |
| `FRIENDLI` | Friendli | | `MODULAR` | Modular |
| `GMI_CLOUD` | GMICloud | | `MOONSHOT_AI` | Moonshot AI |
| `GOOGLE` | Google | | `MORPH` | Morph |
| `GOOGLE_AI_STUDIO` | Google AI Studio | | `N_COMPASS` | NCompass |
| `GROQ` | Groq | | `NEBIUS` | Nebius |
| `HYPERBOLIC` | Hyperbolic | | `NEXT_BIT` | NextBit |
| `INCEPTION` | Inception | | `NOVITA` | Novita |
| `INFERENCE_NET` | InferenceNet | | `NVIDIA` | Nvidia |
| `INFERMATIC` | Infermatic | | `OPEN_AI` | OpenAI |
| `INFLECTION` | Inflection | | `OPEN_INFERENCE` | OpenInference |
| `INO_CLOUD` | InoCloud | | `PARASAIL` | Parasail |
| `KLUSTER` | Kluster | | `PERPLEXITY` | Perplexity |
| `LAMBDA` | Lambda | | `PHALA` | Phala |
| `LIQUID` | Liquid | | `RELACE` | Relace |
| `MANCER_2` | Mancer 2 | | `SAMBA_NOVA` | SambaNova |
| `META` | Meta | | `SILICON_FLOW` | SiliconFlow |
| `MINIMAX` | Minimax | | `SOURCEFUL` | Sourceful |
| `MODEL_RUN` | ModelRun | | `STEALTH` | Stealth |
| `MISTRAL` | Mistral | | `STREAM_LAKE` | StreamLake |
| `MODULAR` | Modular | | `SWITCHPOINT` | Switchpoint |
| `MOONSHOT_AI` | Moonshot AI | | `TARGON` | Targon |
| `MORPH` | Morph | | `TOGETHER` | Together |
| `N_COMPASS` | NCompass | | `VENICE` | Venice |
| `NEBIUS` | Nebius | | `WAND_B` | WandB |
| `NEXT_BIT` | NextBit | | `X_AI` | xAI |
| `NINETEEN` | Nineteen | | `Z_AI` | Z.AI |
| `NOVITA` | Novita | | `FAKE_PROVIDER` | FakeProvider |
| `NVIDIA` | Nvidia |
| `OPEN_AI` | OpenAI |
| `OPEN_INFERENCE` | OpenInference |
| `PARASAIL` | Parasail |
| `PERPLEXITY` | Perplexity |
| `PHALA` | Phala |
| `RELACE` | Relace |
| `SAMBA_NOVA` | SambaNova |
| `SILICON_FLOW` | SiliconFlow |
| `STEALTH` | Stealth |
| `SWITCHPOINT` | Switchpoint |
| `TARGON` | Targon |
| `TOGETHER` | Together |
| `UBICLOUD` | Ubicloud |
| `VENICE` | Venice |
| `WAND_B` | WandB |
| `X_AI` | xAI |
| `Z_AI` | Z.AI |
| `FAKE_PROVIDER` | FakeProvider |
@@ -1,4 +1,4 @@
# Sort # ProviderSort
The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.
+1
View File
@@ -11,6 +11,7 @@ Pricing information for the model
| `completion` | *Any* | :heavy_check_mark: | A value in string or number format that is a large number | | `completion` | *Any* | :heavy_check_mark: | A value in string or number format that is a large number |
| `request` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `request` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `image` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image_token` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `image_output` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `image_output` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `audio` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `audio` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
| `input_audio_cache` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number | | `input_audio_cache` | *Optional[Any]* | :heavy_minus_sign: | A value in string or number format that is a large number |
+3 -7
View File
@@ -3,10 +3,6 @@
## Values ## Values
| Name | Value | | Name | Value |
| ---------- | ---------- | | ------ | ------ |
| `AUTO` | auto | | `AUTO` | auto |
| `DEFAULT` | default |
| `FLEX` | flex |
| `PRIORITY` | priority |
| `SCALE` | scale |
@@ -1,8 +1,9 @@
# EncodingFormatFloat # TTL
## Values ## Values
| Name | Value | | Name | Value |
| ------- | ------- | | ------- | ------- |
| `FLOAT` | float | | `FIVEM` | 5m |
| `ONEH` | 1h |
+8
View File
@@ -0,0 +1,8 @@
# VideoURL1
## Fields
| Field | Type | Required | Description |
| ------------------ | ------------------ | ------------------ | ------------------ |
| `url` | *str* | :heavy_check_mark: | N/A |
+8
View File
@@ -0,0 +1,8 @@
# VideoURL2
## Fields
| Field | Type | Required | Description |
| ------------------ | ------------------ | ------------------ | ------------------ |
| `url` | *str* | :heavy_check_mark: | N/A |
+9
View File
@@ -0,0 +1,9 @@
# Globals
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `http_referer` | *Optional[str]* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.<br/>This is used to track API usage per application.<br/> |
| `x_title` | *Optional[str]* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.<br/> |
+17
View File
@@ -0,0 +1,17 @@
# Content
## Supported Types
### `operations.ContentText`
```python
value: operations.ContentText = /* values here */
```
### `operations.ContentImageURL`
```python
value: operations.ContentImageURL = /* values here */
```
+9
View File
@@ -0,0 +1,9 @@
# ContentImageURL
## Fields
| Field | Type | Required | Description |
| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- |
| `type` | [operations.TypeImageURL](../operations/typeimageurl.md) | :heavy_check_mark: | N/A |
| `image_url` | [operations.ImageURL](../operations/imageurl.md) | :heavy_check_mark: | N/A |
+9
View File
@@ -0,0 +1,9 @@
# ContentText
## Fields
| Field | Type | Required | Description |
| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ |
| `type` | [operations.TypeText](../operations/typetext.md) | :heavy_check_mark: | N/A |
| `text` | *str* | :heavy_check_mark: | N/A |
+2 -2
View File
@@ -7,12 +7,12 @@
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests<br/>- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.<br/>- false: use only the primary/custom provider, and return the upstream error if it's unavailable.<br/> | | | `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests<br/>- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.<br/>- false: use only the primary/custom provider, and return the upstream error if it's unavailable.<br/> | |
| `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | | | `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | |
| `data_collection` | [OptionalNullable[operations.DataCollection]](../operations/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.<br/>- allow: (default) allow providers which store user data non-transiently and may train on it<br/>- deny: use only providers which do not collect user data.<br/> | deny | | `data_collection` | [OptionalNullable[components.DataCollection]](../components/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.<br/>- allow: (default) allow providers which store user data non-transiently and may train on it<br/><br/>- deny: use only providers which do not collect user data. | allow |
| `zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used. | true | | `zdr` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used. | true |
| `enforce_distillable_text` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used. | true | | `enforce_distillable_text` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used. | true |
| `order` | List[[operations.Order](../operations/order.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | | | `order` | List[[operations.Order](../operations/order.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | |
| `only` | List[[operations.Only](../operations/only.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | | | `only` | List[[operations.Only](../operations/only.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | |
| `ignore` | List[[operations.Ignore](../operations/ignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | | | `ignore` | List[[operations.Ignore](../operations/ignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | |
| `quantizations` | List[[components.Quantization](../components/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | | | `quantizations` | List[[components.Quantization](../components/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | |
| `sort` | [OptionalNullable[operations.Sort]](../operations/sort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | price | | `sort` | [OptionalNullable[components.ProviderSort]](../components/providersort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | price |
| `max_price` | [Optional[operations.MaxPrice]](../operations/maxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | | | `max_price` | [Optional[operations.MaxPrice]](../operations/maxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | |
+5 -3
View File
@@ -5,8 +5,10 @@
| Field | Type | Required | Description | | Field | Type | Required | Description |
| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| `input` | [operations.Input](../operations/input.md) | :heavy_check_mark: | N/A | | `input` | [operations.InputUnion](../operations/inputunion.md) | :heavy_check_mark: | N/A |
| `model` | *str* | :heavy_check_mark: | N/A | | `model` | *str* | :heavy_check_mark: | N/A |
| `provider` | [Optional[operations.CreateEmbeddingsProvider]](../operations/createembeddingsprovider.md) | :heavy_minus_sign: | N/A |
| `encoding_format` | [Optional[operations.EncodingFormat]](../operations/encodingformat.md) | :heavy_minus_sign: | N/A | | `encoding_format` | [Optional[operations.EncodingFormat]](../operations/encodingformat.md) | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A | | `dimensions` | *Optional[int]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `provider` | [Optional[operations.CreateEmbeddingsProvider]](../operations/createembeddingsprovider.md) | :heavy_minus_sign: | N/A |
| `input_type` | *Optional[str]* | :heavy_minus_sign: | N/A |
-14
View File
@@ -1,14 +0,0 @@
# DataCollection
Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
## Values
| Name | Value |
| ------- | ------- |
| `DENY` | deny |
| `ALLOW` | allow |
+5 -13
View File
@@ -1,17 +1,9 @@
# EncodingFormat # EncodingFormat
## Supported Types ## Values
### `operations.EncodingFormatFloat`
```python
value: operations.EncodingFormatFloat = /* values here */
```
### `operations.EncodingFormatBase64`
```python
value: operations.EncodingFormatBase64 = /* values here */
```
| Name | Value |
| -------- | -------- |
| `FLOAT` | float |
| `BASE64` | base64 |
-8
View File
@@ -1,8 +0,0 @@
# EncodingFormatBase64
## Values
| Name | Value |
| -------- | -------- |
| `BASE64` | base64 |
+9
View File
@@ -0,0 +1,9 @@
# GetCreditsData
## Fields
| Field | Type | Required | Description | Example |
| ----------------------- | ----------------------- | ----------------------- | ----------------------- | ----------------------- |
| `total_credits` | *float* | :heavy_check_mark: | Total credits purchased | 100.5 |
| `total_usage` | *float* | :heavy_check_mark: | Total credits used | 25.75 |
+3 -2
View File
@@ -5,5 +5,6 @@ Total credits purchased and used
## Fields ## Fields
| Field | Type | Required | Description | | Field | Type | Required | Description | Example |
| ----------- | ----------- | ----------- | ----------- | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| `data` | [operations.GetCreditsData](../operations/getcreditsdata.md) | :heavy_check_mark: | N/A | {<br/>"total_credits": 100.5,<br/>"total_usage": 25.75<br/>} |
+69 -70
View File
@@ -3,73 +3,72 @@
## Values ## Values
| Name | Value | | Name | Value |
| ------------------ | ------------------ | | ------------------- | ------------------- |
| `AI21` | AI21 | | `AI21` | AI21 |
| `AION_LABS` | AionLabs | | `AION_LABS` | AionLabs |
| `ALIBABA` | Alibaba | | `ALIBABA` | Alibaba |
| `AMAZON_BEDROCK` | Amazon Bedrock | | `AMAZON_BEDROCK` | Amazon Bedrock |
| `ANTHROPIC` | Anthropic | | `AMAZON_NOVA` | Amazon Nova |
| `ATLAS_CLOUD` | AtlasCloud | | `ANTHROPIC` | Anthropic |
| `ATOMA` | Atoma | | `ARCEE_AI` | Arcee AI |
| `AVIAN` | Avian | | `ATLAS_CLOUD` | AtlasCloud |
| `AZURE` | Azure | | `AVIAN` | Avian |
| `BASE_TEN` | BaseTen | | `AZURE` | Azure |
| `CEREBRAS` | Cerebras | | `BASE_TEN` | BaseTen |
| `CHUTES` | Chutes | | `BYTE_PLUS` | BytePlus |
| `CIRRASCALE` | Cirrascale | | `BLACK_FOREST_LABS` | Black Forest Labs |
| `CLARIFAI` | Clarifai | | `CEREBRAS` | Cerebras |
| `CLOUDFLARE` | Cloudflare | | `CHUTES` | Chutes |
| `COHERE` | Cohere | | `CIRRASCALE` | Cirrascale |
| `CROF_AI` | CrofAI | | `CLARIFAI` | Clarifai |
| `CRUSOE` | Crusoe | | `CLOUDFLARE` | Cloudflare |
| `DEEP_INFRA` | DeepInfra | | `COHERE` | Cohere |
| `DEEP_SEEK` | DeepSeek | | `CRUSOE` | Crusoe |
| `ENFER` | Enfer | | `DEEP_INFRA` | DeepInfra |
| `FEATHERLESS` | Featherless | | `DEEP_SEEK` | DeepSeek |
| `FIREWORKS` | Fireworks | | `FEATHERLESS` | Featherless |
| `FRIENDLI` | Friendli | | `FIREWORKS` | Fireworks |
| `GMI_CLOUD` | GMICloud | | `FRIENDLI` | Friendli |
| `GOOGLE` | Google | | `GMI_CLOUD` | GMICloud |
| `GOOGLE_AI_STUDIO` | Google AI Studio | | `GO_POMELO` | GoPomelo |
| `GROQ` | Groq | | `GOOGLE` | Google |
| `HYPERBOLIC` | Hyperbolic | | `GOOGLE_AI_STUDIO` | Google AI Studio |
| `INCEPTION` | Inception | | `GROQ` | Groq |
| `INFERENCE_NET` | InferenceNet | | `HYPERBOLIC` | Hyperbolic |
| `INFERMATIC` | Infermatic | | `INCEPTION` | Inception |
| `INFLECTION` | Inflection | | `INFERENCE_NET` | InferenceNet |
| `KLUSTER` | Kluster | | `INFERMATIC` | Infermatic |
| `LAMBDA` | Lambda | | `INFLECTION` | Inflection |
| `LIQUID` | Liquid | | `LIQUID` | Liquid |
| `MANCER_2` | Mancer 2 | | `MANCER_2` | Mancer 2 |
| `META` | Meta | | `MINIMAX` | Minimax |
| `MINIMAX` | Minimax | | `MODEL_RUN` | ModelRun |
| `MODEL_RUN` | ModelRun | | `MISTRAL` | Mistral |
| `MISTRAL` | Mistral | | `MODULAR` | Modular |
| `MODULAR` | Modular | | `MOONSHOT_AI` | Moonshot AI |
| `MOONSHOT_AI` | Moonshot AI | | `MORPH` | Morph |
| `MORPH` | Morph | | `N_COMPASS` | NCompass |
| `N_COMPASS` | NCompass | | `NEBIUS` | Nebius |
| `NEBIUS` | Nebius | | `NEXT_BIT` | NextBit |
| `NEXT_BIT` | NextBit | | `NOVITA` | Novita |
| `NINETEEN` | Nineteen | | `NVIDIA` | Nvidia |
| `NOVITA` | Novita | | `OPEN_AI` | OpenAI |
| `NVIDIA` | Nvidia | | `OPEN_INFERENCE` | OpenInference |
| `OPEN_AI` | OpenAI | | `PARASAIL` | Parasail |
| `OPEN_INFERENCE` | OpenInference | | `PERPLEXITY` | Perplexity |
| `PARASAIL` | Parasail | | `PHALA` | Phala |
| `PERPLEXITY` | Perplexity | | `RELACE` | Relace |
| `PHALA` | Phala | | `SAMBA_NOVA` | SambaNova |
| `RELACE` | Relace | | `SILICON_FLOW` | SiliconFlow |
| `SAMBA_NOVA` | SambaNova | | `SOURCEFUL` | Sourceful |
| `SILICON_FLOW` | SiliconFlow | | `STEALTH` | Stealth |
| `STEALTH` | Stealth | | `STREAM_LAKE` | StreamLake |
| `SWITCHPOINT` | Switchpoint | | `SWITCHPOINT` | Switchpoint |
| `TARGON` | Targon | | `TARGON` | Targon |
| `TOGETHER` | Together | | `TOGETHER` | Together |
| `UBICLOUD` | Ubicloud | | `VENICE` | Venice |
| `VENICE` | Venice | | `WAND_B` | WandB |
| `WAND_B` | WandB | | `X_AI` | xAI |
| `X_AI` | xAI | | `Z_AI` | Z.AI |
| `Z_AI` | Z.AI | | `FAKE_PROVIDER` | FakeProvider |
| `FAKE_PROVIDER` | FakeProvider |
@@ -1,4 +1,4 @@
# VideoURL # ImageURL
## Fields ## Fields
+4 -25
View File
@@ -1,29 +1,8 @@
# Input # Input
## Supported Types ## Fields
### `str`
```python
value: str = /* values here */
```
### `List[str]`
```python
value: List[str] = /* values here */
```
### `List[float]`
```python
value: List[float] = /* values here */
```
### `List[List[float]]`
```python
value: List[List[float]] = /* values here */
```
| Field | Type | Required | Description |
| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
| `content` | List[[operations.Content](../operations/content.md)] | :heavy_check_mark: | N/A |
+35
View File
@@ -0,0 +1,35 @@
# InputUnion
## Supported Types
### `str`
```python
value: str = /* values here */
```
### `List[str]`
```python
value: List[str] = /* values here */
```
### `List[float]`
```python
value: List[float] = /* values here */
```
### `List[List[float]]`
```python
value: List[List[float]] = /* values here */
```
### `List[operations.Input]`
```python
value: List[operations.Input] = /* values here */
```
-12
View File
@@ -1,12 +0,0 @@
# Sort
The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.
## Values
| Name | Value |
| ------------ | ------------ |
| `PRICE` | price |
| `THROUGHPUT` | throughput |
| `LATENCY` | latency |
+8
View File
@@ -0,0 +1,8 @@
# TypeImageURL
## Values
| Name | Value |
| ----------- | ----------- |
| `IMAGE_URL` | image_url |
+8
View File
@@ -0,0 +1,8 @@
# TypeText
## Values
| Name | Value |
| ------ | ------ |
| `TEXT` | text |
+1 -1
View File
@@ -6,4 +6,4 @@
| Field | Type | Required | Description | Example | | Field | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to update | 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 | | `hash` | *str* | :heavy_check_mark: | The hash identifier of the API key to update | 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 |
| `body` | [operations.UpdateKeysRequestBody](../operations/updatekeysrequestbody.md) | :heavy_check_mark: | N/A | {<br/>"name": "Updated API Key Name",<br/>"disabled": false,<br/>"limit": 75,<br/>"limit_reset": "daily",<br/>"include_byok_in_limit": true<br/>} | | `request_body` | [operations.UpdateKeysRequestBody](../operations/updatekeysrequestbody.md) | :heavy_check_mark: | N/A | {<br/>"name": "Updated API Key Name",<br/>"disabled": false,<br/>"limit": 75,<br/>"limit_reset": "daily",<br/>"include_byok_in_limit": true<br/>} |
+2 -3
View File
@@ -67,7 +67,6 @@ Create a new API key
<!-- UsageSnippet language="python" operationID="createKeys" method="post" path="/keys" --> <!-- UsageSnippet language="python" operationID="createKeys" method="post" path="/keys" -->
```python ```python
from openrouter import OpenRouter from openrouter import OpenRouter
from openrouter.utils import parse_datetime
import os import os
@@ -75,7 +74,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.api_keys.create(name="My New API Key", limit=50, limit_reset="monthly", include_byok_in_limit=True, expires_at=parse_datetime("2027-12-31T23:59:59Z")) res = open_router.api_keys.create(name="My New API Key")
# Handle response # Handle response
print(res) print(res)
@@ -123,7 +122,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.api_keys.update(hash="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", name="Updated API Key Name", disabled=False, limit=75, limit_reset="daily", include_byok_in_limit=True) res = open_router.api_keys.update(hash="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")
# Handle response # Handle response
print(res) print(res)
+1
View File
@@ -58,6 +58,7 @@ with OpenRouter(
| `tools` | List[[components.ToolDefinitionJSON](../../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A | | `tools` | List[[components.ToolDefinitionJSON](../../components/tooldefinitionjson.md)] | :heavy_minus_sign: | N/A |
| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A | | `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A | | `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `debug` | [Optional[components.Debug]](../../components/debug.md) | :heavy_minus_sign: | N/A |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response ### Response
+5 -20
View File
@@ -26,24 +26,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.embeddings.generate(input="<value>", model="Taurus", provider={ res = open_router.embeddings.generate(input="<value>", model="Taurus")
"data_collection": "deny",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": [
"fp16",
],
"sort": "price",
})
# Handle response # Handle response
print(res) print(res)
@@ -54,11 +37,13 @@ with OpenRouter(
| Parameter | Type | Required | Description | | Parameter | Type | Required | Description |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `input` | [operations.Input](../../operations/input.md) | :heavy_check_mark: | N/A | | `input` | [operations.InputUnion](../../operations/inputunion.md) | :heavy_check_mark: | N/A |
| `model` | *str* | :heavy_check_mark: | N/A | | `model` | *str* | :heavy_check_mark: | N/A |
| `provider` | [Optional[operations.CreateEmbeddingsProvider]](../../operations/createembeddingsprovider.md) | :heavy_minus_sign: | N/A |
| `encoding_format` | [Optional[operations.EncodingFormat]](../../operations/encodingformat.md) | :heavy_minus_sign: | N/A | | `encoding_format` | [Optional[operations.EncodingFormat]](../../operations/encodingformat.md) | :heavy_minus_sign: | N/A |
| `dimensions` | *Optional[int]* | :heavy_minus_sign: | N/A |
| `user` | *Optional[str]* | :heavy_minus_sign: | N/A | | `user` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `provider` | [Optional[operations.CreateEmbeddingsProvider]](../../operations/createembeddingsprovider.md) | :heavy_minus_sign: | N/A |
| `input_type` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
### Response ### Response
+2 -2
View File
@@ -26,7 +26,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.o_auth.exchange_auth_code_for_api_key(code="auth_code_abc123def456", code_verifier="dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", code_challenge_method="S256") res = open_router.o_auth.exchange_auth_code_for_api_key(code="auth_code_abc123def456")
# Handle response # Handle response
print(res) print(res)
@@ -71,7 +71,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.o_auth.create_auth_code(callback_url="https://myapp.com/auth/callback", code_challenge="E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM", code_challenge_method="S256", limit=100) res = open_router.o_auth.create_auth_code(callback_url="https://myapp.com/auth/callback")
# Handle response # Handle response
print(res) print(res)
+3 -57
View File
@@ -25,61 +25,7 @@ with OpenRouter(
api_key=os.getenv("OPENROUTER_API_KEY", ""), api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router: ) as open_router:
res = open_router.beta.responses.send(input=[ res = open_router.beta.responses.send(service_tier="auto", stream=False)
{
"type": "message",
"role": "user",
"content": "Hello, how are you?",
},
], metadata={
"user_id": "123",
"session_id": "abc-def-ghi",
}, tools=[
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
},
},
},
},
], model="anthropic/claude-4.5-sonnet-20250929", text={
"format_": {
"type": "text",
},
"verbosity": "medium",
}, reasoning={
"summary": "auto",
"enabled": True,
}, temperature=0.7, top_p=0.9, prompt={
"id": "<id>",
"variables": {
"key": {
"type": "input_text",
"text": "Hello, how can I help you?",
},
},
}, service_tier="auto", truncation="auto", stream=False, provider={
"data_collection": "deny",
"zdr": True,
"enforce_distillable_text": True,
"order": [
"OpenAI",
],
"only": [
"OpenAI",
],
"ignore": [
"OpenAI",
],
"quantizations": None,
"sort": "price",
})
with res as event_stream: with res as event_stream:
for event in event_stream: for event in event_stream:
@@ -112,13 +58,13 @@ with OpenRouter(
| `include` | List[[components.OpenAIResponsesIncludable](../../components/openairesponsesincludable.md)] | :heavy_minus_sign: | N/A | | | `include` | List[[components.OpenAIResponsesIncludable](../../components/openairesponsesincludable.md)] | :heavy_minus_sign: | N/A | |
| `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | | `background` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | |
| `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | | | `safety_identifier` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | |
| `store` | *OptionalNullable[bool]* | :heavy_minus_sign: | N/A | | | `service_tier` | [Optional[components.ServiceTier]](../../components/servicetier.md) | :heavy_minus_sign: | N/A | |
| `service_tier` | [OptionalNullable[components.ServiceTier]](../../components/servicetier.md) | :heavy_minus_sign: | N/A | auto |
| `truncation` | [OptionalNullable[components.Truncation]](../../components/truncation.md) | :heavy_minus_sign: | N/A | auto | | `truncation` | [OptionalNullable[components.Truncation]](../../components/truncation.md) | :heavy_minus_sign: | N/A | auto |
| `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | | | `stream` | *Optional[bool]* | :heavy_minus_sign: | N/A | |
| `provider` | [OptionalNullable[components.Provider]](../../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | | `provider` | [OptionalNullable[components.Provider]](../../components/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | |
| `plugins` | List[[components.Plugin](../../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | | `plugins` | List[[components.Plugin](../../components/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | |
| `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | | | `user` | *Optional[str]* | :heavy_minus_sign: | A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters. | |
| `session_id` | *Optional[str]* | :heavy_minus_sign: | A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters. | |
| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | | `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | |
### Response ### Response
+2 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "openrouter" name = "openrouter"
version = "0.0.16" version = "0.0.21"
description = "Official Python Client SDK for OpenRouter." description = "Official Python Client SDK for OpenRouter."
authors = [{ name = "OpenRouter" },] authors = [{ name = "OpenRouter" },]
readme = "README-PYPI.md" readme = "README-PYPI.md"
@@ -11,6 +11,7 @@ dependencies = [
"pydantic >=2.11.2", "pydantic >=2.11.2",
] ]
urls.repository = "https://github.com/OpenRouterTeam/python-sdk.git" urls.repository = "https://github.com/OpenRouterTeam/python-sdk.git"
license = { text = "Apache-2.0" }
[dependency-groups] [dependency-groups]
dev = [ dev = [
+3 -3
View File
@@ -3,10 +3,10 @@
import importlib.metadata import importlib.metadata
__title__: str = "openrouter" __title__: str = "openrouter"
__version__: str = "0.0.16" __version__: str = "0.0.21"
__openapi_doc_version__: str = "1.0.0" __openapi_doc_version__: str = "1.0.0"
__gen_version__: str = "2.755.6" __gen_version__: str = "2.768.0"
__user_agent__: str = "speakeasy-sdk/python 0.0.16 2.755.6 1.0.0 openrouter" __user_agent__: str = "speakeasy-sdk/python 0.0.21 2.768.0 1.0.0 openrouter"
try: try:
if __package__ is not None: if __package__ is not None:
+2
View File
@@ -58,6 +58,7 @@ class Analytics(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -166,6 +167,7 @@ class Analytics(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+24 -4
View File
@@ -60,6 +60,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -164,6 +165,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -280,6 +282,7 @@ class APIKeys(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", operations.CreateKeysRequest request, False, False, "json", operations.CreateKeysRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -401,6 +404,7 @@ class APIKeys(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", operations.CreateKeysRequest request, False, False, "json", operations.CreateKeysRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -502,7 +506,7 @@ class APIKeys(BaseSDK):
request = operations.UpdateKeysRequest( request = operations.UpdateKeysRequest(
hash=hash, hash=hash,
body=operations.UpdateKeysRequestBody( request_body=operations.UpdateKeysRequestBody(
name=name, name=name,
disabled=disabled, disabled=disabled,
limit=limit, limit=limit,
@@ -525,8 +529,13 @@ class APIKeys(BaseSDK):
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request.body, False, False, "json", operations.UpdateKeysRequestBody request.request_body,
False,
False,
"json",
operations.UpdateKeysRequestBody,
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -633,7 +642,7 @@ class APIKeys(BaseSDK):
request = operations.UpdateKeysRequest( request = operations.UpdateKeysRequest(
hash=hash, hash=hash,
body=operations.UpdateKeysRequestBody( request_body=operations.UpdateKeysRequestBody(
name=name, name=name,
disabled=disabled, disabled=disabled,
limit=limit, limit=limit,
@@ -656,8 +665,13 @@ class APIKeys(BaseSDK):
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request.body, False, False, "json", operations.UpdateKeysRequestBody request.request_body,
False,
False,
"json",
operations.UpdateKeysRequestBody,
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -769,6 +783,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -875,6 +890,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -981,6 +997,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -1087,6 +1104,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -1188,6 +1206,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -1279,6 +1298,7 @@ class APIKeys(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+6
View File
@@ -60,6 +60,7 @@ class BaseSDK:
] = None, ] = None,
url_override: Optional[str] = None, url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None, http_headers: Optional[Mapping[str, str]] = None,
allow_empty_value: Optional[List[str]] = None,
) -> httpx.Request: ) -> httpx.Request:
client = self.sdk_configuration.async_client client = self.sdk_configuration.async_client
return self._build_request_with_client( return self._build_request_with_client(
@@ -80,6 +81,7 @@ class BaseSDK:
get_serialized_body, get_serialized_body,
url_override, url_override,
http_headers, http_headers,
allow_empty_value,
) )
def _build_request( def _build_request(
@@ -102,6 +104,7 @@ class BaseSDK:
] = None, ] = None,
url_override: Optional[str] = None, url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None, http_headers: Optional[Mapping[str, str]] = None,
allow_empty_value: Optional[List[str]] = None,
) -> httpx.Request: ) -> httpx.Request:
client = self.sdk_configuration.client client = self.sdk_configuration.client
return self._build_request_with_client( return self._build_request_with_client(
@@ -122,6 +125,7 @@ class BaseSDK:
get_serialized_body, get_serialized_body,
url_override, url_override,
http_headers, http_headers,
allow_empty_value,
) )
def _build_request_with_client( def _build_request_with_client(
@@ -145,6 +149,7 @@ class BaseSDK:
] = None, ] = None,
url_override: Optional[str] = None, url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None, http_headers: Optional[Mapping[str, str]] = None,
allow_empty_value: Optional[List[str]] = None,
) -> httpx.Request: ) -> httpx.Request:
query_params = {} query_params = {}
@@ -160,6 +165,7 @@ class BaseSDK:
query_params = utils.get_query_params( query_params = utils.get_query_params(
request if request_has_query_params else None, request if request_has_query_params else None,
_globals if request_has_query_params else None, _globals if request_has_query_params else None,
allow_empty_value,
) )
else: else:
# Pick up the query parameter from the override so they can be # Pick up the query parameter from the override so they can be
+16
View File
@@ -61,6 +61,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -92,6 +93,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -144,6 +146,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -175,6 +178,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -226,6 +230,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -257,6 +262,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -305,6 +311,7 @@ class Chat(BaseSDK):
), ),
top_p=top_p, top_p=top_p,
user=user, user=user,
debug=utils.get_pydantic_model(debug, Optional[components.Debug]),
) )
req = self._build_request( req = self._build_request(
@@ -323,6 +330,7 @@ class Chat(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.ChatGenerationParams request, False, False, "json", components.ChatGenerationParams
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -438,6 +446,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -469,6 +478,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -521,6 +531,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -552,6 +563,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -603,6 +615,7 @@ class Chat(BaseSDK):
] = None, ] = None,
top_p: OptionalNullable[float] = UNSET, top_p: OptionalNullable[float] = UNSET,
user: Optional[str] = None, user: Optional[str] = None,
debug: Optional[Union[components.Debug, components.DebugTypedDict]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -634,6 +647,7 @@ class Chat(BaseSDK):
:param tools: :param tools:
:param top_p: :param top_p:
:param user: :param user:
:param debug:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -682,6 +696,7 @@ class Chat(BaseSDK):
), ),
top_p=top_p, top_p=top_p,
user=user, user=user,
debug=utils.get_pydantic_model(debug, Optional[components.Debug]),
) )
req = self._build_request_async( req = self._build_request_async(
@@ -700,6 +715,7 @@ class Chat(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.ChatGenerationParams request, False, False, "json", components.ChatGenerationParams
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+2
View File
@@ -136,6 +136,7 @@ class Completions(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.CompletionCreateParams request, False, False, "json", components.CompletionCreateParams
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -310,6 +311,7 @@ class Completions(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.CompletionCreateParams request, False, False, "json", components.CompletionCreateParams
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+55 -14
View File
@@ -36,6 +36,8 @@ if TYPE_CHECKING:
ChatGenerationParamsStop, ChatGenerationParamsStop,
ChatGenerationParamsStopTypedDict, ChatGenerationParamsStopTypedDict,
ChatGenerationParamsTypedDict, ChatGenerationParamsTypedDict,
Debug,
DebugTypedDict,
Effort, Effort,
Reasoning, Reasoning,
ReasoningTypedDict, ReasoningTypedDict,
@@ -54,11 +56,15 @@ if TYPE_CHECKING:
) )
from .chatmessagecontentitemaudio import ( from .chatmessagecontentitemaudio import (
ChatMessageContentItemAudio, ChatMessageContentItemAudio,
ChatMessageContentItemAudioFormat,
ChatMessageContentItemAudioInputAudio, ChatMessageContentItemAudioInputAudio,
ChatMessageContentItemAudioInputAudioTypedDict, ChatMessageContentItemAudioInputAudioTypedDict,
ChatMessageContentItemAudioTypedDict, ChatMessageContentItemAudioTypedDict,
) )
from .chatmessagecontentitemcachecontrol import (
ChatMessageContentItemCacheControl,
ChatMessageContentItemCacheControlTypedDict,
TTL,
)
from .chatmessagecontentitemimage import ( from .chatmessagecontentitemimage import (
ChatMessageContentItemImage, ChatMessageContentItemImage,
ChatMessageContentItemImageDetail, ChatMessageContentItemImageDetail,
@@ -72,9 +78,15 @@ if TYPE_CHECKING:
) )
from .chatmessagecontentitemvideo import ( from .chatmessagecontentitemvideo import (
ChatMessageContentItemVideo, ChatMessageContentItemVideo,
ChatMessageContentItemVideoInputVideo,
ChatMessageContentItemVideoInputVideoTypedDict,
ChatMessageContentItemVideoTypedDict, ChatMessageContentItemVideoTypedDict,
VideoURL, ChatMessageContentItemVideoVideoURL,
VideoURLTypedDict, ChatMessageContentItemVideoVideoURLTypedDict,
VideoURL1,
VideoURL1TypedDict,
VideoURL2,
VideoURL2TypedDict,
) )
from .chatmessagetokenlogprob import ( from .chatmessagetokenlogprob import (
ChatMessageTokenLogprob, ChatMessageTokenLogprob,
@@ -146,6 +158,7 @@ if TYPE_CHECKING:
CreateChargeRequest, CreateChargeRequest,
CreateChargeRequestTypedDict, CreateChargeRequestTypedDict,
) )
from .datacollection import DataCollection
from .defaultparameters import DefaultParameters, DefaultParametersTypedDict from .defaultparameters import DefaultParameters, DefaultParametersTypedDict
from .edgenetworktimeoutresponseerrordata import ( from .edgenetworktimeoutresponseerrordata import (
EdgeNetworkTimeoutResponseErrorData, EdgeNetworkTimeoutResponseErrorData,
@@ -408,10 +421,10 @@ if TYPE_CHECKING:
OpenResponsesReasoningSummaryTextDoneEventTypedDict, OpenResponsesReasoningSummaryTextDoneEventTypedDict,
) )
from .openresponsesrequest import ( from .openresponsesrequest import (
DataCollection,
Engine, Engine,
IDFileParser, IDFileParser,
IDModeration, IDModeration,
IDResponseHealing,
IDWeb, IDWeb,
Ignore, Ignore,
IgnoreTypedDict, IgnoreTypedDict,
@@ -436,13 +449,14 @@ if TYPE_CHECKING:
PluginFileParserTypedDict, PluginFileParserTypedDict,
PluginModeration, PluginModeration,
PluginModerationTypedDict, PluginModerationTypedDict,
PluginResponseHealing,
PluginResponseHealingTypedDict,
PluginTypedDict, PluginTypedDict,
PluginWeb, PluginWeb,
PluginWebTypedDict, PluginWebTypedDict,
Provider, Provider,
ProviderTypedDict, ProviderTypedDict,
ServiceTier, ServiceTier,
Sort,
Truncation, Truncation,
) )
from .openresponsesresponsetext import ( from .openresponsesresponsetext import (
@@ -581,6 +595,7 @@ if TYPE_CHECKING:
ProviderOverloadedResponseErrorData, ProviderOverloadedResponseErrorData,
ProviderOverloadedResponseErrorDataTypedDict, ProviderOverloadedResponseErrorDataTypedDict,
) )
from .providersort import ProviderSort
from .publicendpoint import ( from .publicendpoint import (
Pricing, Pricing,
PricingTypedDict, PricingTypedDict,
@@ -810,10 +825,11 @@ __all__ = [
"ChatGenerationTokenUsageTypedDict", "ChatGenerationTokenUsageTypedDict",
"ChatMessageContentItem", "ChatMessageContentItem",
"ChatMessageContentItemAudio", "ChatMessageContentItemAudio",
"ChatMessageContentItemAudioFormat",
"ChatMessageContentItemAudioInputAudio", "ChatMessageContentItemAudioInputAudio",
"ChatMessageContentItemAudioInputAudioTypedDict", "ChatMessageContentItemAudioInputAudioTypedDict",
"ChatMessageContentItemAudioTypedDict", "ChatMessageContentItemAudioTypedDict",
"ChatMessageContentItemCacheControl",
"ChatMessageContentItemCacheControlTypedDict",
"ChatMessageContentItemImage", "ChatMessageContentItemImage",
"ChatMessageContentItemImageDetail", "ChatMessageContentItemImageDetail",
"ChatMessageContentItemImageTypedDict", "ChatMessageContentItemImageTypedDict",
@@ -821,7 +837,11 @@ __all__ = [
"ChatMessageContentItemTextTypedDict", "ChatMessageContentItemTextTypedDict",
"ChatMessageContentItemTypedDict", "ChatMessageContentItemTypedDict",
"ChatMessageContentItemVideo", "ChatMessageContentItemVideo",
"ChatMessageContentItemVideoInputVideo",
"ChatMessageContentItemVideoInputVideoTypedDict",
"ChatMessageContentItemVideoTypedDict", "ChatMessageContentItemVideoTypedDict",
"ChatMessageContentItemVideoVideoURL",
"ChatMessageContentItemVideoVideoURLTypedDict",
"ChatMessageTokenLogprob", "ChatMessageTokenLogprob",
"ChatMessageTokenLogprobTypedDict", "ChatMessageTokenLogprobTypedDict",
"ChatMessageTokenLogprobs", "ChatMessageTokenLogprobs",
@@ -882,6 +902,8 @@ __all__ = [
"CreateChargeRequest", "CreateChargeRequest",
"CreateChargeRequestTypedDict", "CreateChargeRequestTypedDict",
"DataCollection", "DataCollection",
"Debug",
"DebugTypedDict",
"DefaultParameters", "DefaultParameters",
"DefaultParametersTypedDict", "DefaultParametersTypedDict",
"EdgeNetworkTimeoutResponseErrorData", "EdgeNetworkTimeoutResponseErrorData",
@@ -899,6 +921,7 @@ __all__ = [
"ForbiddenResponseErrorDataTypedDict", "ForbiddenResponseErrorDataTypedDict",
"IDFileParser", "IDFileParser",
"IDModeration", "IDModeration",
"IDResponseHealing",
"IDWeb", "IDWeb",
"Ignore", "Ignore",
"IgnoreTypedDict", "IgnoreTypedDict",
@@ -1192,6 +1215,8 @@ __all__ = [
"PluginFileParserTypedDict", "PluginFileParserTypedDict",
"PluginModeration", "PluginModeration",
"PluginModerationTypedDict", "PluginModerationTypedDict",
"PluginResponseHealing",
"PluginResponseHealingTypedDict",
"PluginTypedDict", "PluginTypedDict",
"PluginWeb", "PluginWeb",
"PluginWebTypedDict", "PluginWebTypedDict",
@@ -1205,6 +1230,7 @@ __all__ = [
"ProviderName", "ProviderName",
"ProviderOverloadedResponseErrorData", "ProviderOverloadedResponseErrorData",
"ProviderOverloadedResponseErrorDataTypedDict", "ProviderOverloadedResponseErrorDataTypedDict",
"ProviderSort",
"ProviderTypedDict", "ProviderTypedDict",
"PublicEndpoint", "PublicEndpoint",
"PublicEndpointQuantization", "PublicEndpointQuantization",
@@ -1310,13 +1336,13 @@ __all__ = [
"ServiceTier", "ServiceTier",
"ServiceUnavailableResponseErrorData", "ServiceUnavailableResponseErrorData",
"ServiceUnavailableResponseErrorDataTypedDict", "ServiceUnavailableResponseErrorDataTypedDict",
"Sort",
"StreamOptions", "StreamOptions",
"StreamOptionsTypedDict", "StreamOptionsTypedDict",
"SystemMessage", "SystemMessage",
"SystemMessageContent", "SystemMessageContent",
"SystemMessageContentTypedDict", "SystemMessageContentTypedDict",
"SystemMessageTypedDict", "SystemMessageTypedDict",
"TTL",
"Tokenizer", "Tokenizer",
"TooManyRequestsResponseErrorData", "TooManyRequestsResponseErrorData",
"TooManyRequestsResponseErrorDataTypedDict", "TooManyRequestsResponseErrorDataTypedDict",
@@ -1366,8 +1392,10 @@ __all__ = [
"UserMessageTypedDict", "UserMessageTypedDict",
"Variables", "Variables",
"VariablesTypedDict", "VariablesTypedDict",
"VideoURL", "VideoURL1",
"VideoURLTypedDict", "VideoURL1TypedDict",
"VideoURL2",
"VideoURL2TypedDict",
"WebSearchPreviewToolUserLocation", "WebSearchPreviewToolUserLocation",
"WebSearchPreviewToolUserLocationType", "WebSearchPreviewToolUserLocationType",
"WebSearchPreviewToolUserLocationTypedDict", "WebSearchPreviewToolUserLocationTypedDict",
@@ -1402,6 +1430,8 @@ _dynamic_imports: dict[str, str] = {
"ChatGenerationParamsStop": ".chatgenerationparams", "ChatGenerationParamsStop": ".chatgenerationparams",
"ChatGenerationParamsStopTypedDict": ".chatgenerationparams", "ChatGenerationParamsStopTypedDict": ".chatgenerationparams",
"ChatGenerationParamsTypedDict": ".chatgenerationparams", "ChatGenerationParamsTypedDict": ".chatgenerationparams",
"Debug": ".chatgenerationparams",
"DebugTypedDict": ".chatgenerationparams",
"Effort": ".chatgenerationparams", "Effort": ".chatgenerationparams",
"Reasoning": ".chatgenerationparams", "Reasoning": ".chatgenerationparams",
"ReasoningTypedDict": ".chatgenerationparams", "ReasoningTypedDict": ".chatgenerationparams",
@@ -1414,10 +1444,12 @@ _dynamic_imports: dict[str, str] = {
"ChatMessageContentItem": ".chatmessagecontentitem", "ChatMessageContentItem": ".chatmessagecontentitem",
"ChatMessageContentItemTypedDict": ".chatmessagecontentitem", "ChatMessageContentItemTypedDict": ".chatmessagecontentitem",
"ChatMessageContentItemAudio": ".chatmessagecontentitemaudio", "ChatMessageContentItemAudio": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioFormat": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioInputAudio": ".chatmessagecontentitemaudio", "ChatMessageContentItemAudioInputAudio": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioInputAudioTypedDict": ".chatmessagecontentitemaudio", "ChatMessageContentItemAudioInputAudioTypedDict": ".chatmessagecontentitemaudio",
"ChatMessageContentItemAudioTypedDict": ".chatmessagecontentitemaudio", "ChatMessageContentItemAudioTypedDict": ".chatmessagecontentitemaudio",
"ChatMessageContentItemCacheControl": ".chatmessagecontentitemcachecontrol",
"ChatMessageContentItemCacheControlTypedDict": ".chatmessagecontentitemcachecontrol",
"TTL": ".chatmessagecontentitemcachecontrol",
"ChatMessageContentItemImage": ".chatmessagecontentitemimage", "ChatMessageContentItemImage": ".chatmessagecontentitemimage",
"ChatMessageContentItemImageDetail": ".chatmessagecontentitemimage", "ChatMessageContentItemImageDetail": ".chatmessagecontentitemimage",
"ChatMessageContentItemImageTypedDict": ".chatmessagecontentitemimage", "ChatMessageContentItemImageTypedDict": ".chatmessagecontentitemimage",
@@ -1426,9 +1458,15 @@ _dynamic_imports: dict[str, str] = {
"ChatMessageContentItemText": ".chatmessagecontentitemtext", "ChatMessageContentItemText": ".chatmessagecontentitemtext",
"ChatMessageContentItemTextTypedDict": ".chatmessagecontentitemtext", "ChatMessageContentItemTextTypedDict": ".chatmessagecontentitemtext",
"ChatMessageContentItemVideo": ".chatmessagecontentitemvideo", "ChatMessageContentItemVideo": ".chatmessagecontentitemvideo",
"ChatMessageContentItemVideoInputVideo": ".chatmessagecontentitemvideo",
"ChatMessageContentItemVideoInputVideoTypedDict": ".chatmessagecontentitemvideo",
"ChatMessageContentItemVideoTypedDict": ".chatmessagecontentitemvideo", "ChatMessageContentItemVideoTypedDict": ".chatmessagecontentitemvideo",
"VideoURL": ".chatmessagecontentitemvideo", "ChatMessageContentItemVideoVideoURL": ".chatmessagecontentitemvideo",
"VideoURLTypedDict": ".chatmessagecontentitemvideo", "ChatMessageContentItemVideoVideoURLTypedDict": ".chatmessagecontentitemvideo",
"VideoURL1": ".chatmessagecontentitemvideo",
"VideoURL1TypedDict": ".chatmessagecontentitemvideo",
"VideoURL2": ".chatmessagecontentitemvideo",
"VideoURL2TypedDict": ".chatmessagecontentitemvideo",
"ChatMessageTokenLogprob": ".chatmessagetokenlogprob", "ChatMessageTokenLogprob": ".chatmessagetokenlogprob",
"ChatMessageTokenLogprobTypedDict": ".chatmessagetokenlogprob", "ChatMessageTokenLogprobTypedDict": ".chatmessagetokenlogprob",
"TopLogprob": ".chatmessagetokenlogprob", "TopLogprob": ".chatmessagetokenlogprob",
@@ -1488,6 +1526,7 @@ _dynamic_imports: dict[str, str] = {
"ChainID": ".createchargerequest", "ChainID": ".createchargerequest",
"CreateChargeRequest": ".createchargerequest", "CreateChargeRequest": ".createchargerequest",
"CreateChargeRequestTypedDict": ".createchargerequest", "CreateChargeRequestTypedDict": ".createchargerequest",
"DataCollection": ".datacollection",
"DefaultParameters": ".defaultparameters", "DefaultParameters": ".defaultparameters",
"DefaultParametersTypedDict": ".defaultparameters", "DefaultParametersTypedDict": ".defaultparameters",
"EdgeNetworkTimeoutResponseErrorData": ".edgenetworktimeoutresponseerrordata", "EdgeNetworkTimeoutResponseErrorData": ".edgenetworktimeoutresponseerrordata",
@@ -1687,10 +1726,10 @@ _dynamic_imports: dict[str, str] = {
"OpenResponsesReasoningSummaryTextDoneEvent": ".openresponsesreasoningsummarytextdoneevent", "OpenResponsesReasoningSummaryTextDoneEvent": ".openresponsesreasoningsummarytextdoneevent",
"OpenResponsesReasoningSummaryTextDoneEventType": ".openresponsesreasoningsummarytextdoneevent", "OpenResponsesReasoningSummaryTextDoneEventType": ".openresponsesreasoningsummarytextdoneevent",
"OpenResponsesReasoningSummaryTextDoneEventTypedDict": ".openresponsesreasoningsummarytextdoneevent", "OpenResponsesReasoningSummaryTextDoneEventTypedDict": ".openresponsesreasoningsummarytextdoneevent",
"DataCollection": ".openresponsesrequest",
"Engine": ".openresponsesrequest", "Engine": ".openresponsesrequest",
"IDFileParser": ".openresponsesrequest", "IDFileParser": ".openresponsesrequest",
"IDModeration": ".openresponsesrequest", "IDModeration": ".openresponsesrequest",
"IDResponseHealing": ".openresponsesrequest",
"IDWeb": ".openresponsesrequest", "IDWeb": ".openresponsesrequest",
"Ignore": ".openresponsesrequest", "Ignore": ".openresponsesrequest",
"IgnoreTypedDict": ".openresponsesrequest", "IgnoreTypedDict": ".openresponsesrequest",
@@ -1715,13 +1754,14 @@ _dynamic_imports: dict[str, str] = {
"PluginFileParserTypedDict": ".openresponsesrequest", "PluginFileParserTypedDict": ".openresponsesrequest",
"PluginModeration": ".openresponsesrequest", "PluginModeration": ".openresponsesrequest",
"PluginModerationTypedDict": ".openresponsesrequest", "PluginModerationTypedDict": ".openresponsesrequest",
"PluginResponseHealing": ".openresponsesrequest",
"PluginResponseHealingTypedDict": ".openresponsesrequest",
"PluginTypedDict": ".openresponsesrequest", "PluginTypedDict": ".openresponsesrequest",
"PluginWeb": ".openresponsesrequest", "PluginWeb": ".openresponsesrequest",
"PluginWebTypedDict": ".openresponsesrequest", "PluginWebTypedDict": ".openresponsesrequest",
"Provider": ".openresponsesrequest", "Provider": ".openresponsesrequest",
"ProviderTypedDict": ".openresponsesrequest", "ProviderTypedDict": ".openresponsesrequest",
"ServiceTier": ".openresponsesrequest", "ServiceTier": ".openresponsesrequest",
"Sort": ".openresponsesrequest",
"Truncation": ".openresponsesrequest", "Truncation": ".openresponsesrequest",
"OpenResponsesResponseText": ".openresponsesresponsetext", "OpenResponsesResponseText": ".openresponsesresponsetext",
"OpenResponsesResponseTextTypedDict": ".openresponsesresponsetext", "OpenResponsesResponseTextTypedDict": ".openresponsesresponsetext",
@@ -1834,6 +1874,7 @@ _dynamic_imports: dict[str, str] = {
"ProviderName": ".providername", "ProviderName": ".providername",
"ProviderOverloadedResponseErrorData": ".provideroverloadedresponseerrordata", "ProviderOverloadedResponseErrorData": ".provideroverloadedresponseerrordata",
"ProviderOverloadedResponseErrorDataTypedDict": ".provideroverloadedresponseerrordata", "ProviderOverloadedResponseErrorDataTypedDict": ".provideroverloadedresponseerrordata",
"ProviderSort": ".providersort",
"Pricing": ".publicendpoint", "Pricing": ".publicendpoint",
"PricingTypedDict": ".publicendpoint", "PricingTypedDict": ".publicendpoint",
"PublicEndpoint": ".publicendpoint", "PublicEndpoint": ".publicendpoint",
@@ -21,9 +21,9 @@ from openrouter.types import (
UNSET_SENTINEL, UNSET_SENTINEL,
UnrecognizedStr, UnrecognizedStr,
) )
from openrouter.utils import validate_const, validate_open_enum from openrouter.utils import get_discriminator, validate_const, validate_open_enum
import pydantic import pydantic
from pydantic import model_serializer from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import AfterValidator, PlainValidator from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -31,6 +31,7 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
Effort = Union[ Effort = Union[
Literal[ Literal[
"none",
"minimal", "minimal",
"low", "low",
"medium", "medium",
@@ -133,16 +134,16 @@ ChatGenerationParamsResponseFormatUnionTypedDict = TypeAliasType(
) )
ChatGenerationParamsResponseFormatUnion = TypeAliasType( ChatGenerationParamsResponseFormatUnion = Annotated[
"ChatGenerationParamsResponseFormatUnion",
Union[ Union[
ChatGenerationParamsResponseFormatText, Annotated[ChatGenerationParamsResponseFormatText, Tag("text")],
ChatGenerationParamsResponseFormatJSONObject, Annotated[ChatGenerationParamsResponseFormatJSONObject, Tag("json_object")],
ChatGenerationParamsResponseFormatPython, Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
ResponseFormatJSONSchema, Annotated[ResponseFormatTextGrammar, Tag("grammar")],
ResponseFormatTextGrammar, Annotated[ChatGenerationParamsResponseFormatPython, Tag("python")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ChatGenerationParamsStopTypedDict = TypeAliasType( ChatGenerationParamsStopTypedDict = TypeAliasType(
@@ -155,6 +156,14 @@ ChatGenerationParamsStop = TypeAliasType(
) )
class DebugTypedDict(TypedDict):
echo_upstream_body: NotRequired[bool]
class Debug(BaseModel):
echo_upstream_body: Optional[bool] = None
class ChatGenerationParamsTypedDict(TypedDict): class ChatGenerationParamsTypedDict(TypedDict):
messages: List[MessageTypedDict] messages: List[MessageTypedDict]
model: NotRequired[str] model: NotRequired[str]
@@ -178,6 +187,7 @@ class ChatGenerationParamsTypedDict(TypedDict):
tools: NotRequired[List[ToolDefinitionJSONTypedDict]] tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
top_p: NotRequired[Nullable[float]] top_p: NotRequired[Nullable[float]]
user: NotRequired[str] user: NotRequired[str]
debug: NotRequired[DebugTypedDict]
class ChatGenerationParams(BaseModel): class ChatGenerationParams(BaseModel):
@@ -225,6 +235,8 @@ class ChatGenerationParams(BaseModel):
user: Optional[str] = None user: Optional[str] = None
debug: Optional[Debug] = None
@model_serializer(mode="wrap") @model_serializer(mode="wrap")
def serialize_model(self, handler): def serialize_model(self, handler):
optional_fields = [ optional_fields = [
@@ -249,6 +261,7 @@ class ChatGenerationParams(BaseModel):
"tools", "tools",
"top_p", "top_p",
"user", "user",
"debug",
] ]
nullable_fields = [ nullable_fields = [
"frequency_penalty", "frequency_penalty",
@@ -26,9 +26,9 @@ from typing_extensions import Annotated, TypeAliasType
ChatMessageContentItemTypedDict = TypeAliasType( ChatMessageContentItemTypedDict = TypeAliasType(
"ChatMessageContentItemTypedDict", "ChatMessageContentItemTypedDict",
Union[ Union[
ChatMessageContentItemTextTypedDict,
ChatMessageContentItemImageTypedDict, ChatMessageContentItemImageTypedDict,
ChatMessageContentItemAudioTypedDict, ChatMessageContentItemAudioTypedDict,
ChatMessageContentItemTextTypedDict,
ChatMessageContentItemVideoTypedDict, ChatMessageContentItemVideoTypedDict,
], ],
) )
@@ -40,6 +40,7 @@ ChatMessageContentItem = Annotated[
Annotated[ChatMessageContentItemImage, Tag("image_url")], Annotated[ChatMessageContentItemImage, Tag("image_url")],
Annotated[ChatMessageContentItemAudio, Tag("input_audio")], Annotated[ChatMessageContentItemAudio, Tag("input_audio")],
Annotated[ChatMessageContentItemVideo, Tag("input_video")], Annotated[ChatMessageContentItemVideo, Tag("input_video")],
Annotated[ChatMessageContentItemVideo, Tag("video_url")],
], ],
Discriminator(lambda m: get_discriminator(m, "type", "type")), Discriminator(lambda m: get_discriminator(m, "type", "type")),
] ]
@@ -1,42 +1,23 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr from openrouter.types import BaseModel
from openrouter.utils import validate_const, validate_open_enum from openrouter.utils import validate_const
import pydantic import pydantic
from pydantic.functional_validators import AfterValidator, PlainValidator from pydantic.functional_validators import AfterValidator
from typing import Literal, Union from typing import Literal
from typing_extensions import Annotated, TypedDict from typing_extensions import Annotated, TypedDict
ChatMessageContentItemAudioFormat = Union[
Literal[
"wav",
"mp3",
"flac",
"m4a",
"ogg",
"pcm16",
"pcm24",
],
UnrecognizedStr,
]
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict): class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
data: str data: str
format_: ChatMessageContentItemAudioFormat format_: str
class ChatMessageContentItemAudioInputAudio(BaseModel): class ChatMessageContentItemAudioInputAudio(BaseModel):
data: str data: str
format_: Annotated[ format_: Annotated[str, pydantic.Field(alias="format")]
Annotated[
ChatMessageContentItemAudioFormat, PlainValidator(validate_open_enum(False))
],
pydantic.Field(alias="format"),
]
class ChatMessageContentItemAudioTypedDict(TypedDict): class ChatMessageContentItemAudioTypedDict(TypedDict):
@@ -0,0 +1,32 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_const, validate_open_enum
import pydantic
from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
TTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
class ChatMessageContentItemCacheControlTypedDict(TypedDict):
type: Literal["ephemeral"]
ttl: NotRequired[TTL]
class ChatMessageContentItemCacheControl(BaseModel):
TYPE: Annotated[
Annotated[Literal["ephemeral"], AfterValidator(validate_const("ephemeral"))],
pydantic.Field(alias="type"),
] = "ephemeral"
ttl: Annotated[Optional[TTL], PlainValidator(validate_open_enum(False))] = None
@@ -1,17 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations from __future__ import annotations
from .chatmessagecontentitemcachecontrol import (
ChatMessageContentItemCacheControl,
ChatMessageContentItemCacheControlTypedDict,
)
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import validate_const from openrouter.utils import validate_const
import pydantic import pydantic
from pydantic.functional_validators import AfterValidator from pydantic.functional_validators import AfterValidator
from typing import Literal from typing import Literal, Optional
from typing_extensions import Annotated, TypedDict from typing_extensions import Annotated, NotRequired, TypedDict
class ChatMessageContentItemTextTypedDict(TypedDict): class ChatMessageContentItemTextTypedDict(TypedDict):
text: str text: str
type: Literal["text"] type: Literal["text"]
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
class ChatMessageContentItemText(BaseModel): class ChatMessageContentItemText(BaseModel):
@@ -21,3 +26,5 @@ class ChatMessageContentItemText(BaseModel):
Annotated[Literal["text"], AfterValidator(validate_const("text"))], Annotated[Literal["text"], AfterValidator(validate_const("text"))],
pydantic.Field(alias="type"), pydantic.Field(alias="type"),
] = "text" ] = "text"
cache_control: Optional[ChatMessageContentItemCacheControl] = None
@@ -2,28 +2,51 @@
from __future__ import annotations from __future__ import annotations
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import validate_const from openrouter.utils import get_discriminator, validate_const
import pydantic import pydantic
from pydantic import Discriminator, Tag
from pydantic.functional_validators import AfterValidator from pydantic.functional_validators import AfterValidator
from typing import Literal from typing import Literal, Union
from typing_extensions import Annotated, TypedDict from typing_extensions import Annotated, TypeAliasType, TypedDict
class VideoURLTypedDict(TypedDict): class VideoURL2TypedDict(TypedDict):
url: str url: str
class VideoURL(BaseModel): class VideoURL2(BaseModel):
url: str url: str
class ChatMessageContentItemVideoTypedDict(TypedDict): class ChatMessageContentItemVideoVideoURLTypedDict(TypedDict):
video_url: VideoURLTypedDict video_url: VideoURL2TypedDict
type: Literal["video_url"]
class ChatMessageContentItemVideoVideoURL(BaseModel):
video_url: VideoURL2
TYPE: Annotated[
Annotated[Literal["video_url"], AfterValidator(validate_const("video_url"))],
pydantic.Field(alias="type"),
] = "video_url"
class VideoURL1TypedDict(TypedDict):
url: str
class VideoURL1(BaseModel):
url: str
class ChatMessageContentItemVideoInputVideoTypedDict(TypedDict):
video_url: VideoURL1TypedDict
type: Literal["input_video"] type: Literal["input_video"]
class ChatMessageContentItemVideo(BaseModel): class ChatMessageContentItemVideoInputVideo(BaseModel):
video_url: VideoURL video_url: VideoURL1
TYPE: Annotated[ TYPE: Annotated[
Annotated[ Annotated[
@@ -31,3 +54,21 @@ class ChatMessageContentItemVideo(BaseModel):
], ],
pydantic.Field(alias="type"), pydantic.Field(alias="type"),
] = "input_video" ] = "input_video"
ChatMessageContentItemVideoTypedDict = TypeAliasType(
"ChatMessageContentItemVideoTypedDict",
Union[
ChatMessageContentItemVideoInputVideoTypedDict,
ChatMessageContentItemVideoVideoURLTypedDict,
],
)
ChatMessageContentItemVideo = Annotated[
Union[
Annotated[ChatMessageContentItemVideoInputVideo, Tag("input_video")],
Annotated[ChatMessageContentItemVideoVideoURL, Tag("video_url")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
+18 -5
View File
@@ -2,12 +2,19 @@
from __future__ import annotations from __future__ import annotations
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum from openrouter.utils import validate_open_enum
from pydantic import model_serializer from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator from pydantic.functional_validators import PlainValidator
from typing import Literal, Union from typing import Literal, Optional, Union
from typing_extensions import Annotated, TypedDict from typing_extensions import Annotated, NotRequired, TypedDict
CompletionFinishReason = Union[ CompletionFinishReason = Union[
@@ -25,6 +32,8 @@ class CompletionChoiceTypedDict(TypedDict):
index: float index: float
logprobs: Nullable[CompletionLogprobsTypedDict] logprobs: Nullable[CompletionLogprobsTypedDict]
finish_reason: Nullable[CompletionFinishReason] finish_reason: Nullable[CompletionFinishReason]
native_finish_reason: NotRequired[str]
reasoning: NotRequired[Nullable[str]]
class CompletionChoice(BaseModel): class CompletionChoice(BaseModel):
@@ -38,10 +47,14 @@ class CompletionChoice(BaseModel):
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False)) Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
] ]
native_finish_reason: Optional[str] = None
reasoning: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap") @model_serializer(mode="wrap")
def serialize_model(self, handler): def serialize_model(self, handler):
optional_fields = [] optional_fields = ["native_finish_reason", "reasoning"]
nullable_fields = ["logprobs", "finish_reason"] nullable_fields = ["logprobs", "finish_reason", "reasoning"]
null_default_fields = [] null_default_fields = []
serialized = handler(self) serialized = handler(self)
@@ -16,9 +16,9 @@ from openrouter.types import (
UNSET, UNSET,
UNSET_SENTINEL, UNSET_SENTINEL,
) )
from openrouter.utils import validate_const from openrouter.utils import get_discriminator, validate_const
import pydantic import pydantic
from pydantic import model_serializer from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import AfterValidator from pydantic.functional_validators import AfterValidator
from typing import Dict, List, Literal, Optional, Union from typing import Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -127,16 +127,16 @@ CompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType(
) )
CompletionCreateParamsResponseFormatUnion = TypeAliasType( CompletionCreateParamsResponseFormatUnion = Annotated[
"CompletionCreateParamsResponseFormatUnion",
Union[ Union[
CompletionCreateParamsResponseFormatText, Annotated[CompletionCreateParamsResponseFormatText, Tag("text")],
CompletionCreateParamsResponseFormatJSONObject, Annotated[CompletionCreateParamsResponseFormatJSONObject, Tag("json_object")],
CompletionCreateParamsResponseFormatPython, Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
ResponseFormatJSONSchema, Annotated[ResponseFormatTextGrammar, Tag("grammar")],
ResponseFormatTextGrammar, Annotated[CompletionCreateParamsResponseFormatPython, Tag("python")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class CompletionCreateParamsTypedDict(TypedDict): class CompletionCreateParamsTypedDict(TypedDict):
@@ -17,6 +17,7 @@ class CompletionResponseTypedDict(TypedDict):
model: str model: str
choices: List[CompletionChoiceTypedDict] choices: List[CompletionChoiceTypedDict]
object: Literal["text_completion"] object: Literal["text_completion"]
provider: NotRequired[str]
system_fingerprint: NotRequired[str] system_fingerprint: NotRequired[str]
usage: NotRequired[CompletionUsageTypedDict] usage: NotRequired[CompletionUsageTypedDict]
@@ -38,6 +39,8 @@ class CompletionResponse(BaseModel):
pydantic.Field(alias="object"), pydantic.Field(alias="object"),
] = "text_completion" ] = "text_completion"
provider: Optional[str] = None
system_fingerprint: Optional[str] = None system_fingerprint: Optional[str] = None
usage: Optional[CompletionUsage] = None usage: Optional[CompletionUsage] = None
@@ -0,0 +1,19 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
DataCollection = Union[
Literal[
"deny",
"allow",
],
UnrecognizedStr,
]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
+10 -9
View File
@@ -10,8 +10,9 @@ from .systemmessage import SystemMessage, SystemMessageTypedDict
from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict
from .usermessage import UserMessage, UserMessageTypedDict from .usermessage import UserMessage, UserMessageTypedDict
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import validate_const from openrouter.utils import get_discriminator, validate_const
import pydantic import pydantic
from pydantic import Discriminator, Tag
from pydantic.functional_validators import AfterValidator from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional, Union from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -56,13 +57,13 @@ MessageTypedDict = TypeAliasType(
) )
Message = TypeAliasType( Message = Annotated[
"Message",
Union[ Union[
SystemMessage, Annotated[SystemMessage, Tag("system")],
UserMessage, Annotated[UserMessage, Tag("user")],
MessageDeveloper, Annotated[MessageDeveloper, Tag("developer")],
ToolResponseMessage, Annotated[AssistantMessage, Tag("assistant")],
AssistantMessage, Annotated[ToolResponseMessage, Tag("tool")],
], ],
) Discriminator(lambda m: get_discriminator(m, "role", "role")),
]
@@ -4,8 +4,10 @@ from __future__ import annotations
from .filecitation import FileCitation, FileCitationTypedDict from .filecitation import FileCitation, FileCitationTypedDict
from .filepath import FilePath, FilePathTypedDict from .filepath import FilePath, FilePathTypedDict
from .urlcitation import URLCitation, URLCitationTypedDict from .urlcitation import URLCitation, URLCitationTypedDict
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union from typing import Union
from typing_extensions import TypeAliasType from typing_extensions import Annotated, TypeAliasType
OpenAIResponsesAnnotationTypedDict = TypeAliasType( OpenAIResponsesAnnotationTypedDict = TypeAliasType(
@@ -14,6 +16,11 @@ OpenAIResponsesAnnotationTypedDict = TypeAliasType(
) )
OpenAIResponsesAnnotation = TypeAliasType( OpenAIResponsesAnnotation = Annotated[
"OpenAIResponsesAnnotation", Union[FilePath, FileCitation, URLCitation] Union[
) Annotated[FileCitation, Tag("file_citation")],
Annotated[URLCitation, Tag("url_citation")],
Annotated[FilePath, Tag("file_path")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
@@ -11,6 +11,7 @@ OpenAIResponsesReasoningEffort = Union[
"medium", "medium",
"low", "low",
"minimal", "minimal",
"none",
], ],
UnrecognizedStr, UnrecognizedStr,
] ]
@@ -48,8 +48,8 @@ from openrouter.types import (
UNSET, UNSET,
UNSET_SENTINEL, UNSET_SENTINEL,
) )
from openrouter.utils import validate_open_enum from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import model_serializer from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator from pydantic.functional_validators import PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -127,16 +127,19 @@ OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
) )
OpenResponsesNonStreamingResponseToolUnion = TypeAliasType( OpenResponsesNonStreamingResponseToolUnion = Annotated[
"OpenResponsesNonStreamingResponseToolUnion",
Union[ Union[
OpenResponsesWebSearchPreviewTool, Annotated[OpenResponsesNonStreamingResponseToolFunction, Tag("function")],
OpenResponsesWebSearchPreview20250311Tool, Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
OpenResponsesWebSearchTool, Annotated[
OpenResponsesWebSearch20250826Tool, OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesNonStreamingResponseToolFunction, Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesNonStreamingResponseTypedDict(TypedDict): class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
@@ -57,6 +57,7 @@ OpenResponsesReasoningFormat = Union[
"openai-responses-v1", "openai-responses-v1",
"xai-responses-v1", "xai-responses-v1",
"anthropic-claude-v1", "anthropic-claude-v1",
"google-gemini-v1",
], ],
UnrecognizedStr, UnrecognizedStr,
] ]
@@ -1,6 +1,7 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations from __future__ import annotations
from .datacollection import DataCollection
from .openairesponsesincludable import OpenAIResponsesIncludable from .openairesponsesincludable import OpenAIResponsesIncludable
from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict
from .openairesponsestoolchoice_union import ( from .openairesponsestoolchoice_union import (
@@ -33,6 +34,7 @@ from .openresponseswebsearchtool import (
OpenResponsesWebSearchToolTypedDict, OpenResponsesWebSearchToolTypedDict,
) )
from .providername import ProviderName from .providername import ProviderName
from .providersort import ProviderSort
from .quantization import Quantization from .quantization import Quantization
from openrouter.types import ( from openrouter.types import (
BaseModel, BaseModel,
@@ -42,9 +44,10 @@ from openrouter.types import (
UNSET_SENTINEL, UNSET_SENTINEL,
UnrecognizedStr, UnrecognizedStr,
) )
from openrouter.utils import validate_open_enum from openrouter.utils import get_discriminator, validate_const, validate_open_enum
from pydantic import model_serializer import pydantic
from pydantic.functional_validators import PlainValidator from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -118,30 +121,24 @@ OpenResponsesRequestToolUnionTypedDict = TypeAliasType(
) )
OpenResponsesRequestToolUnion = TypeAliasType( OpenResponsesRequestToolUnion = Annotated[
"OpenResponsesRequestToolUnion",
Union[ Union[
OpenResponsesWebSearchPreviewTool, Annotated[OpenResponsesRequestToolFunction, Tag("function")],
OpenResponsesWebSearchPreview20250311Tool, Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
OpenResponsesWebSearchTool, Annotated[
OpenResponsesWebSearch20250826Tool, OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesRequestToolFunction, Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
ServiceTier = Union[
Literal[
"auto",
"default",
"flex",
"priority",
"scale",
],
UnrecognizedStr,
] ]
ServiceTier = Literal["auto",]
Truncation = Union[ Truncation = Union[
Literal[ Literal[
"auto", "auto",
@@ -151,20 +148,6 @@ Truncation = Union[
] ]
DataCollection = Union[
Literal[
"deny",
"allow",
],
UnrecognizedStr,
]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
OrderTypedDict = TypeAliasType("OrderTypedDict", Union[ProviderName, str]) OrderTypedDict = TypeAliasType("OrderTypedDict", Union[ProviderName, str])
@@ -192,17 +175,6 @@ Ignore = TypeAliasType(
) )
Sort = Union[
Literal[
"price",
"throughput",
"latency",
],
UnrecognizedStr,
]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
class MaxPriceTypedDict(TypedDict): class MaxPriceTypedDict(TypedDict):
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
@@ -251,8 +223,8 @@ class ProviderTypedDict(TypedDict):
data_collection: NotRequired[Nullable[DataCollection]] data_collection: NotRequired[Nullable[DataCollection]]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it - allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
- deny: use only providers which do not collect user data.
""" """
zdr: NotRequired[Nullable[bool]] zdr: NotRequired[Nullable[bool]]
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used.""" r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
@@ -266,7 +238,7 @@ class ProviderTypedDict(TypedDict):
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.""" r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: NotRequired[Nullable[List[Quantization]]] quantizations: NotRequired[Nullable[List[Quantization]]]
r"""A list of quantization levels to filter the provider by.""" r"""A list of quantization levels to filter the provider by."""
sort: NotRequired[Nullable[Sort]] sort: NotRequired[Nullable[ProviderSort]]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: NotRequired[MaxPriceTypedDict] max_price: NotRequired[MaxPriceTypedDict]
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
@@ -290,8 +262,8 @@ class Provider(BaseModel):
] = UNSET ] = UNSET
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it - allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
- deny: use only providers which do not collect user data.
""" """
zdr: OptionalNullable[bool] = UNSET zdr: OptionalNullable[bool] = UNSET
@@ -315,7 +287,7 @@ class Provider(BaseModel):
r"""A list of quantization levels to filter the provider by.""" r"""A list of quantization levels to filter the provider by."""
sort: Annotated[ sort: Annotated[
OptionalNullable[Sort], PlainValidator(validate_open_enum(False)) OptionalNullable[ProviderSort], PlainValidator(validate_open_enum(False))
] = UNSET ] = UNSET
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
@@ -376,6 +348,17 @@ class Provider(BaseModel):
return m return m
IDResponseHealing = Literal["response-healing",]
class PluginResponseHealingTypedDict(TypedDict):
id: IDResponseHealing
class PluginResponseHealing(BaseModel):
id: IDResponseHealing
IDFileParser = Literal["file-parser",] IDFileParser = Literal["file-parser",]
@@ -457,11 +440,24 @@ class PluginModeration(BaseModel):
PluginTypedDict = TypeAliasType( PluginTypedDict = TypeAliasType(
"PluginTypedDict", "PluginTypedDict",
Union[PluginModerationTypedDict, PluginFileParserTypedDict, PluginWebTypedDict], Union[
PluginModerationTypedDict,
PluginResponseHealingTypedDict,
PluginFileParserTypedDict,
PluginWebTypedDict,
],
) )
Plugin = TypeAliasType("Plugin", Union[PluginModeration, PluginFileParser, PluginWeb]) Plugin = Annotated[
Union[
Annotated[PluginModeration, Tag("moderation")],
Annotated[PluginWeb, Tag("web")],
Annotated[PluginFileParser, Tag("file-parser")],
Annotated[PluginResponseHealing, Tag("response-healing")],
],
Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
class OpenResponsesRequestTypedDict(TypedDict): class OpenResponsesRequestTypedDict(TypedDict):
@@ -491,8 +487,8 @@ class OpenResponsesRequestTypedDict(TypedDict):
include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]] include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]]
background: NotRequired[Nullable[bool]] background: NotRequired[Nullable[bool]]
safety_identifier: NotRequired[Nullable[str]] safety_identifier: NotRequired[Nullable[str]]
store: NotRequired[Nullable[bool]] store: Literal[False]
service_tier: NotRequired[Nullable[ServiceTier]] service_tier: NotRequired[ServiceTier]
truncation: NotRequired[Nullable[Truncation]] truncation: NotRequired[Nullable[Truncation]]
stream: NotRequired[bool] stream: NotRequired[bool]
provider: NotRequired[Nullable[ProviderTypedDict]] provider: NotRequired[Nullable[ProviderTypedDict]]
@@ -501,6 +497,8 @@ class OpenResponsesRequestTypedDict(TypedDict):
r"""Plugins you want to enable for this request, including their settings.""" r"""Plugins you want to enable for this request, including their settings."""
user: NotRequired[str] user: NotRequired[str]
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.""" r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
session_id: NotRequired[str]
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
class OpenResponsesRequest(BaseModel): class OpenResponsesRequest(BaseModel):
@@ -556,11 +554,12 @@ class OpenResponsesRequest(BaseModel):
safety_identifier: OptionalNullable[str] = UNSET safety_identifier: OptionalNullable[str] = UNSET
store: OptionalNullable[bool] = UNSET STORE: Annotated[
Annotated[Optional[Literal[False]], AfterValidator(validate_const(False))],
pydantic.Field(alias="store"),
] = False
service_tier: Annotated[ service_tier: Optional[ServiceTier] = "auto"
OptionalNullable[ServiceTier], PlainValidator(validate_open_enum(False))
] = UNSET
truncation: Annotated[ truncation: Annotated[
OptionalNullable[Truncation], PlainValidator(validate_open_enum(False)) OptionalNullable[Truncation], PlainValidator(validate_open_enum(False))
@@ -577,6 +576,9 @@ class OpenResponsesRequest(BaseModel):
user: Optional[str] = None user: Optional[str] = None
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters.""" r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
session_id: Optional[str] = None
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
@model_serializer(mode="wrap") @model_serializer(mode="wrap")
def serialize_model(self, handler): def serialize_model(self, handler):
optional_fields = [ optional_fields = [
@@ -607,6 +609,7 @@ class OpenResponsesRequest(BaseModel):
"provider", "provider",
"plugins", "plugins",
"user", "user",
"session_id",
] ]
nullable_fields = [ nullable_fields = [
"instructions", "instructions",
@@ -622,8 +625,6 @@ class OpenResponsesRequest(BaseModel):
"include", "include",
"background", "background",
"safety_identifier", "safety_identifier",
"store",
"service_tier",
"truncation", "truncation",
"provider", "provider",
] ]
@@ -59,8 +59,10 @@ from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentType
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Union from typing import List, Literal, Union
from typing_extensions import TypeAliasType, TypedDict from typing_extensions import Annotated, TypeAliasType, TypedDict
TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",] TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",]
@@ -328,10 +330,14 @@ Part2TypedDict = TypeAliasType(
) )
Part2 = TypeAliasType( Part2 = Annotated[
"Part2", Union[
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText], Annotated[ResponseOutputText, Tag("output_text")],
) Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict): class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict):
@@ -374,10 +380,14 @@ Part1TypedDict = TypeAliasType(
) )
Part1 = TypeAliasType( Part1 = Annotated[
"Part1", Union[
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText], Annotated[ResponseOutputText, Tag("output_text")],
) Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict): class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict):
@@ -609,36 +619,97 @@ OpenResponsesStreamEventTypedDict = TypeAliasType(
r"""Union of all possible event types emitted during response streaming""" r"""Union of all possible event types emitted during response streaming"""
OpenResponsesStreamEvent = TypeAliasType( OpenResponsesStreamEvent = Annotated[
"OpenResponsesStreamEvent",
Union[ Union[
OpenResponsesStreamEventResponseCreated, Annotated[OpenResponsesStreamEventResponseCreated, Tag("response.created")],
OpenResponsesStreamEventResponseInProgress, Annotated[
OpenResponsesStreamEventResponseCompleted, OpenResponsesStreamEventResponseInProgress, Tag("response.in_progress")
OpenResponsesStreamEventResponseIncomplete, ],
OpenResponsesStreamEventResponseFailed, Annotated[OpenResponsesStreamEventResponseCompleted, Tag("response.completed")],
OpenResponsesStreamEventResponseOutputItemAdded, Annotated[
OpenResponsesStreamEventResponseOutputItemDone, OpenResponsesStreamEventResponseIncomplete, Tag("response.incomplete")
OpenResponsesImageGenCallCompleted, ],
OpenResponsesImageGenCallGenerating, Annotated[OpenResponsesStreamEventResponseFailed, Tag("response.failed")],
OpenResponsesImageGenCallInProgress, Annotated[OpenResponsesErrorEvent, Tag("error")],
OpenResponsesErrorEvent, Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta, OpenResponsesStreamEventResponseOutputItemAdded,
OpenResponsesStreamEventResponseRefusalDelta, Tag("response.output_item.added"),
OpenResponsesReasoningSummaryPartAddedEvent, ],
OpenResponsesStreamEventResponseContentPartAdded, Annotated[
OpenResponsesImageGenCallPartialImage, OpenResponsesStreamEventResponseOutputItemDone,
OpenResponsesStreamEventResponseFunctionCallArgumentsDone, Tag("response.output_item.done"),
OpenResponsesReasoningDeltaEvent, ],
OpenResponsesReasoningDoneEvent, Annotated[
OpenResponsesStreamEventResponseRefusalDone, OpenResponsesStreamEventResponseContentPartAdded,
OpenResponsesStreamEventResponseReasoningSummaryPartDone, Tag("response.content_part.added"),
OpenResponsesReasoningSummaryTextDeltaEvent, ],
OpenResponsesReasoningSummaryTextDoneEvent, Annotated[
OpenResponsesStreamEventResponseContentPartDone, OpenResponsesStreamEventResponseContentPartDone,
OpenResponsesStreamEventResponseOutputTextDelta, Tag("response.content_part.done"),
OpenResponsesStreamEventResponseOutputTextDone, ],
OpenResponsesStreamEventResponseOutputTextAnnotationAdded, Annotated[
OpenResponsesStreamEventResponseOutputTextDelta,
Tag("response.output_text.delta"),
],
Annotated[
OpenResponsesStreamEventResponseOutputTextDone,
Tag("response.output_text.done"),
],
Annotated[
OpenResponsesStreamEventResponseRefusalDelta, Tag("response.refusal.delta")
],
Annotated[
OpenResponsesStreamEventResponseRefusalDone, Tag("response.refusal.done")
],
Annotated[
OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
Tag("response.output_text.annotation.added"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
Tag("response.function_call_arguments.delta"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
Tag("response.function_call_arguments.done"),
],
Annotated[
OpenResponsesReasoningDeltaEvent, Tag("response.reasoning_text.delta")
],
Annotated[OpenResponsesReasoningDoneEvent, Tag("response.reasoning_text.done")],
Annotated[
OpenResponsesReasoningSummaryPartAddedEvent,
Tag("response.reasoning_summary_part.added"),
],
Annotated[
OpenResponsesStreamEventResponseReasoningSummaryPartDone,
Tag("response.reasoning_summary_part.done"),
],
Annotated[
OpenResponsesReasoningSummaryTextDeltaEvent,
Tag("response.reasoning_summary_text.delta"),
],
Annotated[
OpenResponsesReasoningSummaryTextDoneEvent,
Tag("response.reasoning_summary_text.done"),
],
Annotated[
OpenResponsesImageGenCallInProgress,
Tag("response.image_generation_call.in_progress"),
],
Annotated[
OpenResponsesImageGenCallGenerating,
Tag("response.image_generation_call.generating"),
],
Annotated[
OpenResponsesImageGenCallPartialImage,
Tag("response.image_generation_call.partial_image"),
],
Annotated[
OpenResponsesImageGenCallCompleted,
Tag("response.image_generation_call.completed"),
],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Union of all possible event types emitted during response streaming""" r"""Union of all possible event types emitted during response streaming"""
+10 -4
View File
@@ -7,8 +7,10 @@ from .openairesponsesrefusalcontent import (
) )
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Optional, Union from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OutputMessageRole = Literal["assistant",] OutputMessageRole = Literal["assistant",]
@@ -52,9 +54,13 @@ OutputMessageContentTypedDict = TypeAliasType(
) )
OutputMessageContent = TypeAliasType( OutputMessageContent = Annotated[
"OutputMessageContent", Union[OpenAIResponsesRefusalContent, ResponseOutputText] Union[
) Annotated[ResponseOutputText, Tag("output_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OutputMessageTypedDict(TypedDict): class OutputMessageTypedDict(TypedDict):
+7 -26
View File
@@ -7,48 +7,33 @@ from typing import Literal, Union
ProviderName = Union[ ProviderName = Union[
Literal[ Literal[
"AnyScale",
"Cent-ML",
"HuggingFace",
"Hyperbolic 2",
"Lepton",
"Lynn 2",
"Lynn",
"Mancer",
"Modal",
"OctoAI",
"Recursal",
"Reflection",
"Replicate",
"SambaNova 2",
"SF Compute",
"Together 2",
"01.AI",
"AI21", "AI21",
"AionLabs", "AionLabs",
"Alibaba", "Alibaba",
"Amazon Bedrock", "Amazon Bedrock",
"Amazon Nova",
"Anthropic", "Anthropic",
"Arcee AI",
"AtlasCloud", "AtlasCloud",
"Atoma",
"Avian", "Avian",
"Azure", "Azure",
"BaseTen", "BaseTen",
"BytePlus",
"Black Forest Labs",
"Cerebras", "Cerebras",
"Chutes", "Chutes",
"Cirrascale", "Cirrascale",
"Clarifai", "Clarifai",
"Cloudflare", "Cloudflare",
"Cohere", "Cohere",
"CrofAI",
"Crusoe", "Crusoe",
"DeepInfra", "DeepInfra",
"DeepSeek", "DeepSeek",
"Enfer",
"Featherless", "Featherless",
"Fireworks", "Fireworks",
"Friendli", "Friendli",
"GMICloud", "GMICloud",
"GoPomelo",
"Google", "Google",
"Google AI Studio", "Google AI Studio",
"Groq", "Groq",
@@ -57,12 +42,8 @@ ProviderName = Union[
"InferenceNet", "InferenceNet",
"Infermatic", "Infermatic",
"Inflection", "Inflection",
"InoCloud",
"Kluster",
"Lambda",
"Liquid", "Liquid",
"Mancer 2", "Mancer 2",
"Meta",
"Minimax", "Minimax",
"ModelRun", "ModelRun",
"Mistral", "Mistral",
@@ -72,7 +53,6 @@ ProviderName = Union[
"NCompass", "NCompass",
"Nebius", "Nebius",
"NextBit", "NextBit",
"Nineteen",
"Novita", "Novita",
"Nvidia", "Nvidia",
"OpenAI", "OpenAI",
@@ -83,11 +63,12 @@ ProviderName = Union[
"Relace", "Relace",
"SambaNova", "SambaNova",
"SiliconFlow", "SiliconFlow",
"Sourceful",
"Stealth", "Stealth",
"StreamLake",
"Switchpoint", "Switchpoint",
"Targon", "Targon",
"Together", "Together",
"Ubicloud",
"Venice", "Venice",
"WandB", "WandB",
"xAI", "xAI",
+16
View File
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ProviderSort = Union[
Literal[
"price",
"throughput",
"latency",
],
UnrecognizedStr,
]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
@@ -21,6 +21,8 @@ class PricingTypedDict(TypedDict):
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image: NotRequired[Any] image: NotRequired[Any]
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image_token: NotRequired[Any]
r"""A value in string or number format that is a large number"""
image_output: NotRequired[Any] image_output: NotRequired[Any]
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
audio: NotRequired[Any] audio: NotRequired[Any]
@@ -51,6 +53,9 @@ class Pricing(BaseModel):
image: Optional[Any] = None image: Optional[Any] = None
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image_token: Optional[Any] = None
r"""A value in string or number format that is a large number"""
image_output: Optional[Any] = None image_output: Optional[Any] = None
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
@@ -17,6 +17,8 @@ class PublicPricingTypedDict(TypedDict):
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image: NotRequired[Any] image: NotRequired[Any]
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image_token: NotRequired[Any]
r"""A value in string or number format that is a large number"""
image_output: NotRequired[Any] image_output: NotRequired[Any]
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
audio: NotRequired[Any] audio: NotRequired[Any]
@@ -49,6 +51,9 @@ class PublicPricing(BaseModel):
image: Optional[Any] = None image: Optional[Any] = None
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
image_token: Optional[Any] = None
r"""A value in string or number format that is a large number"""
image_output: Optional[Any] = None image_output: Optional[Any] = None
r"""A value in string or number format that is a large number""" r"""A value in string or number format that is a large number"""
@@ -10,8 +10,10 @@ from .responsesformattextjsonschemaconfig import (
ResponsesFormatTextJSONSchemaConfig, ResponsesFormatTextJSONSchemaConfig,
ResponsesFormatTextJSONSchemaConfigTypedDict, ResponsesFormatTextJSONSchemaConfigTypedDict,
) )
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union from typing import Union
from typing_extensions import TypeAliasType from typing_extensions import Annotated, TypeAliasType
ResponseFormatTextConfigTypedDict = TypeAliasType( ResponseFormatTextConfigTypedDict = TypeAliasType(
@@ -25,12 +27,12 @@ ResponseFormatTextConfigTypedDict = TypeAliasType(
r"""Text response format configuration""" r"""Text response format configuration"""
ResponseFormatTextConfig = TypeAliasType( ResponseFormatTextConfig = Annotated[
"ResponseFormatTextConfig",
Union[ Union[
ResponsesFormatText, Annotated[ResponsesFormatText, Tag("text")],
ResponsesFormatJSONObject, Annotated[ResponsesFormatJSONObject, Tag("json_object")],
ResponsesFormatTextJSONSchemaConfig, Annotated[ResponsesFormatTextJSONSchemaConfig, Tag("json_schema")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Text response format configuration""" r"""Text response format configuration"""
@@ -25,8 +25,10 @@ from .responseswebsearchcalloutput import (
ResponsesWebSearchCallOutput, ResponsesWebSearchCallOutput,
ResponsesWebSearchCallOutputTypedDict, ResponsesWebSearchCallOutputTypedDict,
) )
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union from typing import Union
from typing_extensions import TypeAliasType from typing_extensions import Annotated, TypeAliasType
ResponsesOutputItemTypedDict = TypeAliasType( ResponsesOutputItemTypedDict = TypeAliasType(
@@ -43,15 +45,15 @@ ResponsesOutputItemTypedDict = TypeAliasType(
r"""An output item from the response""" r"""An output item from the response"""
ResponsesOutputItem = TypeAliasType( ResponsesOutputItem = Annotated[
"ResponsesOutputItem",
Union[ Union[
ResponsesWebSearchCallOutput, Annotated[ResponsesOutputMessage, Tag("message")],
ResponsesOutputItemFileSearchCall, Annotated[ResponsesOutputItemReasoning, Tag("reasoning")],
ResponsesImageGenerationCall, Annotated[ResponsesOutputItemFunctionCall, Tag("function_call")],
ResponsesOutputMessage, Annotated[ResponsesWebSearchCallOutput, Tag("web_search_call")],
ResponsesOutputItemReasoning, Annotated[ResponsesOutputItemFileSearchCall, Tag("file_search_call")],
ResponsesOutputItemFunctionCall, Annotated[ResponsesImageGenerationCall, Tag("image_generation_call")],
], ],
) Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""An output item from the response""" r"""An output item from the response"""
@@ -7,8 +7,10 @@ from .openairesponsesrefusalcontent import (
) )
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import BaseModel from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import List, Literal, Optional, Union from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ResponsesOutputMessageRole = Literal["assistant",] ResponsesOutputMessageRole = Literal["assistant",]
@@ -52,10 +54,13 @@ ResponsesOutputMessageContentTypedDict = TypeAliasType(
) )
ResponsesOutputMessageContent = TypeAliasType( ResponsesOutputMessageContent = Annotated[
"ResponsesOutputMessageContent", Union[
Union[OpenAIResponsesRefusalContent, ResponseOutputText], Annotated[ResponseOutputText, Tag("output_text")],
) Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class ResponsesOutputMessageTypedDict(TypedDict): class ResponsesOutputMessageTypedDict(TypedDict):
+4
View File
@@ -51,6 +51,7 @@ class Credits(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -147,6 +148,7 @@ class Credits(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -266,6 +268,7 @@ class Credits(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.CreateChargeRequest request, False, False, "json", components.CreateChargeRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -390,6 +393,7 @@ class Credits(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", components.CreateChargeRequest request, False, False, "json", components.CreateChargeRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+30 -18
View File
@@ -21,18 +21,18 @@ class Embeddings(BaseSDK):
def generate( def generate(
self, self,
*, *,
input: Union[operations.Input, operations.InputTypedDict], input: Union[operations.InputUnion, operations.InputUnionTypedDict],
model: str, model: str,
encoding_format: Optional[operations.EncodingFormat] = None,
dimensions: Optional[int] = None,
user: Optional[str] = None,
provider: Optional[ provider: Optional[
Union[ Union[
operations.CreateEmbeddingsProvider, operations.CreateEmbeddingsProvider,
operations.CreateEmbeddingsProviderTypedDict, operations.CreateEmbeddingsProviderTypedDict,
] ]
] = None, ] = None,
encoding_format: Optional[ input_type: Optional[str] = None,
Union[operations.EncodingFormat, operations.EncodingFormatTypedDict]
] = None,
user: Optional[str] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -45,9 +45,11 @@ class Embeddings(BaseSDK):
:param input: :param input:
:param model: :param model:
:param provider:
:param encoding_format: :param encoding_format:
:param dimensions:
:param user: :param user:
:param provider:
:param input_type:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -65,13 +67,15 @@ class Embeddings(BaseSDK):
base_url = self._get_url(base_url, url_variables) base_url = self._get_url(base_url, url_variables)
request = operations.CreateEmbeddingsRequest( request = operations.CreateEmbeddingsRequest(
input=input, input=utils.get_pydantic_model(input, operations.InputUnion),
model=model, model=model,
encoding_format=encoding_format,
dimensions=dimensions,
user=user,
provider=utils.get_pydantic_model( provider=utils.get_pydantic_model(
provider, Optional[operations.CreateEmbeddingsProvider] provider, Optional[operations.CreateEmbeddingsProvider]
), ),
encoding_format=encoding_format, input_type=input_type,
user=user,
) )
req = self._build_request( req = self._build_request(
@@ -92,6 +96,7 @@ class Embeddings(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", operations.CreateEmbeddingsRequest request, False, False, "json", operations.CreateEmbeddingsRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -204,18 +209,18 @@ class Embeddings(BaseSDK):
async def generate_async( async def generate_async(
self, self,
*, *,
input: Union[operations.Input, operations.InputTypedDict], input: Union[operations.InputUnion, operations.InputUnionTypedDict],
model: str, model: str,
encoding_format: Optional[operations.EncodingFormat] = None,
dimensions: Optional[int] = None,
user: Optional[str] = None,
provider: Optional[ provider: Optional[
Union[ Union[
operations.CreateEmbeddingsProvider, operations.CreateEmbeddingsProvider,
operations.CreateEmbeddingsProviderTypedDict, operations.CreateEmbeddingsProviderTypedDict,
] ]
] = None, ] = None,
encoding_format: Optional[ input_type: Optional[str] = None,
Union[operations.EncodingFormat, operations.EncodingFormatTypedDict]
] = None,
user: Optional[str] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET, retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None, server_url: Optional[str] = None,
timeout_ms: Optional[int] = None, timeout_ms: Optional[int] = None,
@@ -228,9 +233,11 @@ class Embeddings(BaseSDK):
:param input: :param input:
:param model: :param model:
:param provider:
:param encoding_format: :param encoding_format:
:param dimensions:
:param user: :param user:
:param provider:
:param input_type:
:param retries: Override the default retry configuration for this method :param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method :param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -248,13 +255,15 @@ class Embeddings(BaseSDK):
base_url = self._get_url(base_url, url_variables) base_url = self._get_url(base_url, url_variables)
request = operations.CreateEmbeddingsRequest( request = operations.CreateEmbeddingsRequest(
input=input, input=utils.get_pydantic_model(input, operations.InputUnion),
model=model, model=model,
encoding_format=encoding_format,
dimensions=dimensions,
user=user,
provider=utils.get_pydantic_model( provider=utils.get_pydantic_model(
provider, Optional[operations.CreateEmbeddingsProvider] provider, Optional[operations.CreateEmbeddingsProvider]
), ),
encoding_format=encoding_format, input_type=input_type,
user=user,
) )
req = self._build_request_async( req = self._build_request_async(
@@ -275,6 +284,7 @@ class Embeddings(BaseSDK):
get_serialized_body=lambda: utils.serialize_request_body( get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", operations.CreateEmbeddingsRequest request, False, False, "json", operations.CreateEmbeddingsRequest
), ),
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -423,6 +433,7 @@ class Embeddings(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -514,6 +525,7 @@ class Embeddings(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
+4
View File
@@ -59,6 +59,7 @@ class Endpoints(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -158,6 +159,7 @@ class Endpoints(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -247,6 +249,7 @@ class Endpoints(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )
@@ -333,6 +336,7 @@ class Endpoints(BaseSDK):
accept_header_value="application/json", accept_header_value="application/json",
http_headers=http_headers, http_headers=http_headers,
security=self.sdk_configuration.security, security=self.sdk_configuration.security,
allow_empty_value=None,
timeout_ms=timeout_ms, timeout_ms=timeout_ms,
) )

Some files were not shown because too many files have changed in this diff Show More