mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-08-02 12:50:48 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67ef52b03e | ||
|
|
d4474da1b8 | ||
|
|
aed8199b2b | ||
|
|
06b2ccc54a | ||
|
|
6cd0d2a76d |
+41
-28
@@ -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: 4cc4a9d9115d0eca9a5eb4786505579d
|
docChecksum: 01481f11e87a18cf1daa583fee2c88fb
|
||||||
docVersion: 1.0.0
|
docVersion: 1.0.0
|
||||||
speakeasyVersion: 1.658.2
|
speakeasyVersion: 1.666.0
|
||||||
generationVersion: 2.755.9
|
generationVersion: 2.768.0
|
||||||
releaseVersion: 0.0.19
|
releaseVersion: 0.0.21
|
||||||
configChecksum: 834d5c1cea368e35ab6535ffb2bf9e7a
|
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.9
|
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,8 +66,8 @@ 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
|
||||||
@@ -105,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
|
||||||
@@ -117,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
|
||||||
@@ -300,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
|
||||||
@@ -391,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
|
||||||
@@ -436,6 +441,7 @@ 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
|
||||||
@@ -467,6 +473,7 @@ generatedFiles:
|
|||||||
- 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
|
||||||
@@ -549,11 +556,13 @@ generatedFiles:
|
|||||||
- src/openrouter/components/assistantmessage.py
|
- src/openrouter/components/assistantmessage.py
|
||||||
- src/openrouter/components/badgatewayresponseerrordata.py
|
- src/openrouter/components/badgatewayresponseerrordata.py
|
||||||
- src/openrouter/components/badrequestresponseerrordata.py
|
- src/openrouter/components/badrequestresponseerrordata.py
|
||||||
|
- src/openrouter/components/chatcompletionfinishreason.py
|
||||||
- src/openrouter/components/chaterror.py
|
- src/openrouter/components/chaterror.py
|
||||||
- src/openrouter/components/chatgenerationparams.py
|
- src/openrouter/components/chatgenerationparams.py
|
||||||
- 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
|
||||||
@@ -562,6 +571,7 @@ generatedFiles:
|
|||||||
- src/openrouter/components/chatmessagetoolcall.py
|
- src/openrouter/components/chatmessagetoolcall.py
|
||||||
- src/openrouter/components/chatresponse.py
|
- src/openrouter/components/chatresponse.py
|
||||||
- src/openrouter/components/chatresponsechoice.py
|
- src/openrouter/components/chatresponsechoice.py
|
||||||
|
- src/openrouter/components/chatstreamingchoice.py
|
||||||
- src/openrouter/components/chatstreamingmessagechunk.py
|
- src/openrouter/components/chatstreamingmessagechunk.py
|
||||||
- src/openrouter/components/chatstreamingmessagetoolcall.py
|
- src/openrouter/components/chatstreamingmessagetoolcall.py
|
||||||
- src/openrouter/components/chatstreamingresponsechunk.py
|
- src/openrouter/components/chatstreamingresponsechunk.py
|
||||||
@@ -711,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
|
||||||
@@ -764,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":
|
||||||
@@ -814,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":
|
||||||
@@ -839,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": "allow", "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"}
|
||||||
@@ -868,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":
|
||||||
@@ -908,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":
|
||||||
@@ -917,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":
|
||||||
@@ -930,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":
|
||||||
@@ -939,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:
|
||||||
@@ -961,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:
|
||||||
@@ -972,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":
|
||||||
@@ -982,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":
|
||||||
@@ -1000,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":
|
||||||
@@ -1037,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":
|
||||||
@@ -1050,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":
|
||||||
@@ -1058,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"}
|
||||||
@@ -1071,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"}}
|
||||||
|
|||||||
+9
-5
@@ -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.19
|
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: Apache-2.0
|
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
|
||||||
|
|||||||
+94
-31
@@ -3447,12 +3447,14 @@ components:
|
|||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
- Arcee
|
- Arcee AI
|
||||||
- AtlasCloud
|
- AtlasCloud
|
||||||
- Avian
|
- Avian
|
||||||
- Azure
|
- Azure
|
||||||
- BaseTen
|
- BaseTen
|
||||||
|
- BytePlus
|
||||||
- Black Forest Labs
|
- Black Forest Labs
|
||||||
- Cerebras
|
- Cerebras
|
||||||
- Chutes
|
- Chutes
|
||||||
@@ -3467,6 +3469,7 @@ components:
|
|||||||
- Fireworks
|
- Fireworks
|
||||||
- Friendli
|
- Friendli
|
||||||
- GMICloud
|
- GMICloud
|
||||||
|
- GoPomelo
|
||||||
- Google
|
- Google
|
||||||
- Google AI Studio
|
- Google AI Studio
|
||||||
- Groq
|
- Groq
|
||||||
@@ -3496,7 +3499,9 @@ components:
|
|||||||
- Relace
|
- Relace
|
||||||
- SambaNova
|
- SambaNova
|
||||||
- SiliconFlow
|
- SiliconFlow
|
||||||
|
- Sourceful
|
||||||
- Stealth
|
- Stealth
|
||||||
|
- StreamLake
|
||||||
- Switchpoint
|
- Switchpoint
|
||||||
- Targon
|
- Targon
|
||||||
- Together
|
- Together
|
||||||
@@ -3628,17 +3633,13 @@ components:
|
|||||||
nullable: true
|
nullable: true
|
||||||
store:
|
store:
|
||||||
type: boolean
|
type: boolean
|
||||||
nullable: true
|
const: false
|
||||||
|
default: false
|
||||||
service_tier:
|
service_tier:
|
||||||
allOf:
|
type: string
|
||||||
- $ref: '#/components/schemas/OpenAIResponsesServiceTier'
|
enum:
|
||||||
- enum:
|
- auto
|
||||||
- auto
|
default: auto
|
||||||
- default
|
|
||||||
- flex
|
|
||||||
- scale
|
|
||||||
- priority
|
|
||||||
example: auto
|
|
||||||
truncation:
|
truncation:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/OpenAIResponsesTruncation'
|
- $ref: '#/components/schemas/OpenAIResponsesTruncation'
|
||||||
@@ -3789,6 +3790,14 @@ components:
|
|||||||
- native
|
- native
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- response-healing
|
||||||
|
required:
|
||||||
|
- id
|
||||||
description: Plugins you want to enable for this request, including their settings.
|
description: Plugins you want to enable for this request, including their settings.
|
||||||
user:
|
user:
|
||||||
type: string
|
type: string
|
||||||
@@ -3797,6 +3806,13 @@ components:
|
|||||||
A unique identifier representing your end-user, which helps distinguish between different users of your app.
|
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
|
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.
|
being affected by the actions of individual users. Maximum of 128 characters.
|
||||||
|
session_id:
|
||||||
|
type: string
|
||||||
|
maxLength: 128
|
||||||
|
description: >-
|
||||||
|
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.
|
||||||
description: Request schema for Responses endpoint
|
description: Request schema for Responses endpoint
|
||||||
example:
|
example:
|
||||||
model: anthropic/claude-4.5-sonnet-20250929
|
model: anthropic/claude-4.5-sonnet-20250929
|
||||||
@@ -4577,6 +4593,10 @@ components:
|
|||||||
status: default
|
status: default
|
||||||
uptime_last_30m: 99.5
|
uptime_last_30m: 99.5
|
||||||
supports_implicit_caching: true
|
supports_implicit_caching: true
|
||||||
|
__schema0:
|
||||||
|
anyOf:
|
||||||
|
- $ref: '#/components/schemas/ChatCompletionFinishReason'
|
||||||
|
- type: 'null'
|
||||||
ModelName:
|
ModelName:
|
||||||
type: string
|
type: string
|
||||||
ChatMessageContentItemText:
|
ChatMessageContentItemText:
|
||||||
@@ -4587,6 +4607,8 @@ components:
|
|||||||
const: text
|
const: text
|
||||||
text:
|
text:
|
||||||
type: string
|
type: string
|
||||||
|
cache_control:
|
||||||
|
$ref: '#/components/schemas/ChatMessageContentItemCacheControl'
|
||||||
required:
|
required:
|
||||||
- type
|
- type
|
||||||
- text
|
- text
|
||||||
@@ -4625,14 +4647,6 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
format:
|
format:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
|
||||||
- wav
|
|
||||||
- mp3
|
|
||||||
- flac
|
|
||||||
- m4a
|
|
||||||
- ogg
|
|
||||||
- pcm16
|
|
||||||
- pcm24
|
|
||||||
required:
|
required:
|
||||||
- data
|
- data
|
||||||
- format
|
- format
|
||||||
@@ -4810,15 +4824,13 @@ components:
|
|||||||
- prompt_tokens
|
- prompt_tokens
|
||||||
- total_tokens
|
- total_tokens
|
||||||
ChatCompletionFinishReason:
|
ChatCompletionFinishReason:
|
||||||
anyOf:
|
type: string
|
||||||
- type: string
|
enum:
|
||||||
enum:
|
- tool_calls
|
||||||
- tool_calls
|
- stop
|
||||||
- stop
|
- length
|
||||||
- length
|
- content_filter
|
||||||
- content_filter
|
- error
|
||||||
- error
|
|
||||||
- type: 'null'
|
|
||||||
JSONSchemaConfig:
|
JSONSchemaConfig:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -4860,6 +4872,19 @@ components:
|
|||||||
required:
|
required:
|
||||||
- type
|
- type
|
||||||
- grammar
|
- grammar
|
||||||
|
ChatMessageContentItemCacheControl:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
const: ephemeral
|
||||||
|
ttl:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- 5m
|
||||||
|
- 1h
|
||||||
|
required:
|
||||||
|
- type
|
||||||
SystemMessage:
|
SystemMessage:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -5170,13 +5195,18 @@ components:
|
|||||||
- type: 'null'
|
- type: 'null'
|
||||||
user:
|
user:
|
||||||
type: string
|
type: string
|
||||||
|
debug:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
echo_upstream_body:
|
||||||
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- messages
|
- messages
|
||||||
ChatResponseChoice:
|
ChatResponseChoice:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
finish_reason:
|
finish_reason:
|
||||||
$ref: '#/components/schemas/ChatCompletionFinishReason'
|
$ref: '#/components/schemas/__schema0'
|
||||||
index:
|
index:
|
||||||
type: number
|
type: number
|
||||||
message:
|
message:
|
||||||
@@ -5237,7 +5267,7 @@ components:
|
|||||||
delta:
|
delta:
|
||||||
$ref: '#/components/schemas/ChatStreamingMessageChunk'
|
$ref: '#/components/schemas/ChatStreamingMessageChunk'
|
||||||
finish_reason:
|
finish_reason:
|
||||||
$ref: '#/components/schemas/ChatCompletionFinishReason'
|
$ref: '#/components/schemas/__schema0'
|
||||||
index:
|
index:
|
||||||
type: number
|
type: number
|
||||||
logprobs:
|
logprobs:
|
||||||
@@ -5569,6 +5599,12 @@ components:
|
|||||||
- type: 'null'
|
- type: 'null'
|
||||||
finish_reason:
|
finish_reason:
|
||||||
$ref: '#/components/schemas/CompletionFinishReason'
|
$ref: '#/components/schemas/CompletionFinishReason'
|
||||||
|
native_finish_reason:
|
||||||
|
type: string
|
||||||
|
reasoning:
|
||||||
|
anyOf:
|
||||||
|
- type: string
|
||||||
|
- type: 'null'
|
||||||
required:
|
required:
|
||||||
- text
|
- text
|
||||||
- index
|
- index
|
||||||
@@ -5586,6 +5622,8 @@ components:
|
|||||||
type: number
|
type: number
|
||||||
model:
|
model:
|
||||||
type: string
|
type: string
|
||||||
|
provider:
|
||||||
|
type: string
|
||||||
system_fingerprint:
|
system_fingerprint:
|
||||||
type: string
|
type: string
|
||||||
choices:
|
choices:
|
||||||
@@ -5804,6 +5842,26 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
properties:
|
||||||
|
data:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
total_credits:
|
||||||
|
type: number
|
||||||
|
description: Total credits purchased
|
||||||
|
example: 100.5
|
||||||
|
total_usage:
|
||||||
|
type: number
|
||||||
|
description: Total credits used
|
||||||
|
example: 25.75
|
||||||
|
required:
|
||||||
|
- total_credits
|
||||||
|
- total_usage
|
||||||
|
example:
|
||||||
|
total_credits: 100.5
|
||||||
|
total_usage: 25.75
|
||||||
|
required:
|
||||||
|
- data
|
||||||
description: Total credits purchased and used
|
description: Total credits purchased and used
|
||||||
example:
|
example:
|
||||||
data:
|
data:
|
||||||
@@ -6726,12 +6784,14 @@ paths:
|
|||||||
- AionLabs
|
- AionLabs
|
||||||
- Alibaba
|
- Alibaba
|
||||||
- Amazon Bedrock
|
- Amazon Bedrock
|
||||||
|
- Amazon Nova
|
||||||
- Anthropic
|
- Anthropic
|
||||||
- Arcee
|
- Arcee AI
|
||||||
- AtlasCloud
|
- AtlasCloud
|
||||||
- Avian
|
- Avian
|
||||||
- Azure
|
- Azure
|
||||||
- BaseTen
|
- BaseTen
|
||||||
|
- BytePlus
|
||||||
- Black Forest Labs
|
- Black Forest Labs
|
||||||
- Cerebras
|
- Cerebras
|
||||||
- Chutes
|
- Chutes
|
||||||
@@ -6746,6 +6806,7 @@ paths:
|
|||||||
- Fireworks
|
- Fireworks
|
||||||
- Friendli
|
- Friendli
|
||||||
- GMICloud
|
- GMICloud
|
||||||
|
- GoPomelo
|
||||||
- Google
|
- Google
|
||||||
- Google AI Studio
|
- Google AI Studio
|
||||||
- Groq
|
- Groq
|
||||||
@@ -6775,7 +6836,9 @@ paths:
|
|||||||
- Relace
|
- Relace
|
||||||
- SambaNova
|
- SambaNova
|
||||||
- SiliconFlow
|
- SiliconFlow
|
||||||
|
- Sourceful
|
||||||
- Stealth
|
- Stealth
|
||||||
|
- StreamLake
|
||||||
- Switchpoint
|
- Switchpoint
|
||||||
- Targon
|
- Targon
|
||||||
- Together
|
- Together
|
||||||
|
|||||||
+8352
-8288
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
-11
@@ -1,31 +1,42 @@
|
|||||||
speakeasyVersion: 1.658.2
|
speakeasyVersion: 1.666.0
|
||||||
sources:
|
sources:
|
||||||
-OAS:
|
-OAS:
|
||||||
sourceNamespace: open-router-chat-completions-api
|
sourceNamespace: open-router-chat-completions-api
|
||||||
sourceRevisionDigest: sha256:fc0c90dc8ebb69ef4a571e4e63dcd7f8f33c3254c17ad2583b628fbbf3d1ac05
|
sourceRevisionDigest: sha256:f1b59b9b643de5e20d6e3299a8274783d8c0854615876f5d7f6f081814842695
|
||||||
sourceBlobDigest: sha256:635d63fd18db468c1dcc23700382af788de76594ba3b8292fae9b14c0e5c22c4
|
sourceBlobDigest: sha256:ee1f2422281b3ed5b38951c74636ad192c9bb160f216069c1f7931ccc4e52553
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
|
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:fc0c90dc8ebb69ef4a571e4e63dcd7f8f33c3254c17ad2583b628fbbf3d1ac05
|
sourceRevisionDigest: sha256:9b410c8cfafe475dc6d9550f97a1e755b9a02b54513d3a85efe606e9bb05ca57
|
||||||
sourceBlobDigest: sha256:635d63fd18db468c1dcc23700382af788de76594ba3b8292fae9b14c0e5c22c4
|
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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": "allow",
|
|
||||||
"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": "allow",
|
|
||||||
"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:
|
||||||
|
|||||||
@@ -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 |
|
||||||
@@ -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 |
|
||||||
@@ -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 |
|
||||||
@@ -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 |
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Debug
|
||||||
|
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
| -------------------- | -------------------- | -------------------- | -------------------- |
|
||||||
|
| `echo_upstream_body` | *Optional[bool]* | :heavy_minus_sign: | N/A |
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# IDResponseHealing
|
||||||
|
|
||||||
|
|
||||||
|
## Values
|
||||||
|
|
||||||
|
| Name | Value |
|
||||||
|
| ------------------ | ------------------ |
|
||||||
|
| `RESPONSE_HEALING` | response-healing |
|
||||||
@@ -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. | |
|
||||||
@@ -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 */
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# PluginResponseHealing
|
||||||
|
|
||||||
|
|
||||||
|
## Fields
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
||||||
|
| `id` | [components.IDResponseHealing](../components/idresponsehealing.md) | :heavy_check_mark: | N/A |
|
||||||
@@ -9,12 +9,14 @@
|
|||||||
| `AION_LABS` | AionLabs |
|
| `AION_LABS` | AionLabs |
|
||||||
| `ALIBABA` | Alibaba |
|
| `ALIBABA` | Alibaba |
|
||||||
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||||
|
| `AMAZON_NOVA` | Amazon Nova |
|
||||||
| `ANTHROPIC` | Anthropic |
|
| `ANTHROPIC` | Anthropic |
|
||||||
| `ARCEE` | Arcee |
|
| `ARCEE_AI` | Arcee AI |
|
||||||
| `ATLAS_CLOUD` | AtlasCloud |
|
| `ATLAS_CLOUD` | AtlasCloud |
|
||||||
| `AVIAN` | Avian |
|
| `AVIAN` | Avian |
|
||||||
| `AZURE` | Azure |
|
| `AZURE` | Azure |
|
||||||
| `BASE_TEN` | BaseTen |
|
| `BASE_TEN` | BaseTen |
|
||||||
|
| `BYTE_PLUS` | BytePlus |
|
||||||
| `BLACK_FOREST_LABS` | Black Forest Labs |
|
| `BLACK_FOREST_LABS` | Black Forest Labs |
|
||||||
| `CEREBRAS` | Cerebras |
|
| `CEREBRAS` | Cerebras |
|
||||||
| `CHUTES` | Chutes |
|
| `CHUTES` | Chutes |
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
| `FIREWORKS` | Fireworks |
|
| `FIREWORKS` | Fireworks |
|
||||||
| `FRIENDLI` | Friendli |
|
| `FRIENDLI` | Friendli |
|
||||||
| `GMI_CLOUD` | GMICloud |
|
| `GMI_CLOUD` | GMICloud |
|
||||||
|
| `GO_POMELO` | GoPomelo |
|
||||||
| `GOOGLE` | Google |
|
| `GOOGLE` | Google |
|
||||||
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
||||||
| `GROQ` | Groq |
|
| `GROQ` | Groq |
|
||||||
@@ -58,7 +61,9 @@
|
|||||||
| `RELACE` | Relace |
|
| `RELACE` | Relace |
|
||||||
| `SAMBA_NOVA` | SambaNova |
|
| `SAMBA_NOVA` | SambaNova |
|
||||||
| `SILICON_FLOW` | SiliconFlow |
|
| `SILICON_FLOW` | SiliconFlow |
|
||||||
|
| `SOURCEFUL` | Sourceful |
|
||||||
| `STEALTH` | Stealth |
|
| `STEALTH` | Stealth |
|
||||||
|
| `STREAM_LAKE` | StreamLake |
|
||||||
| `SWITCHPOINT` | Switchpoint |
|
| `SWITCHPOINT` | Switchpoint |
|
||||||
| `TARGON` | Targon |
|
| `TARGON` | Targon |
|
||||||
| `TOGETHER` | Together |
|
| `TOGETHER` | Together |
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
## Values
|
## Values
|
||||||
|
|
||||||
| Name | Value |
|
| Name | Value |
|
||||||
| ---------- | ---------- |
|
| ------ | ------ |
|
||||||
| `AUTO` | auto |
|
| `AUTO` | auto |
|
||||||
| `DEFAULT` | default |
|
|
||||||
| `FLEX` | flex |
|
|
||||||
| `PRIORITY` | priority |
|
|
||||||
| `SCALE` | scale |
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# TTL
|
||||||
|
|
||||||
|
|
||||||
|
## Values
|
||||||
|
|
||||||
|
| Name | Value |
|
||||||
|
| ------- | ------- |
|
||||||
|
| `FIVEM` | 5m |
|
||||||
|
| `ONEH` | 1h |
|
||||||
@@ -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/> |
|
||||||
@@ -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 |
|
||||||
@@ -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/>} |
|
||||||
@@ -9,12 +9,14 @@
|
|||||||
| `AION_LABS` | AionLabs |
|
| `AION_LABS` | AionLabs |
|
||||||
| `ALIBABA` | Alibaba |
|
| `ALIBABA` | Alibaba |
|
||||||
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
| `AMAZON_BEDROCK` | Amazon Bedrock |
|
||||||
|
| `AMAZON_NOVA` | Amazon Nova |
|
||||||
| `ANTHROPIC` | Anthropic |
|
| `ANTHROPIC` | Anthropic |
|
||||||
| `ARCEE` | Arcee |
|
| `ARCEE_AI` | Arcee AI |
|
||||||
| `ATLAS_CLOUD` | AtlasCloud |
|
| `ATLAS_CLOUD` | AtlasCloud |
|
||||||
| `AVIAN` | Avian |
|
| `AVIAN` | Avian |
|
||||||
| `AZURE` | Azure |
|
| `AZURE` | Azure |
|
||||||
| `BASE_TEN` | BaseTen |
|
| `BASE_TEN` | BaseTen |
|
||||||
|
| `BYTE_PLUS` | BytePlus |
|
||||||
| `BLACK_FOREST_LABS` | Black Forest Labs |
|
| `BLACK_FOREST_LABS` | Black Forest Labs |
|
||||||
| `CEREBRAS` | Cerebras |
|
| `CEREBRAS` | Cerebras |
|
||||||
| `CHUTES` | Chutes |
|
| `CHUTES` | Chutes |
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
| `FIREWORKS` | Fireworks |
|
| `FIREWORKS` | Fireworks |
|
||||||
| `FRIENDLI` | Friendli |
|
| `FRIENDLI` | Friendli |
|
||||||
| `GMI_CLOUD` | GMICloud |
|
| `GMI_CLOUD` | GMICloud |
|
||||||
|
| `GO_POMELO` | GoPomelo |
|
||||||
| `GOOGLE` | Google |
|
| `GOOGLE` | Google |
|
||||||
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
| `GOOGLE_AI_STUDIO` | Google AI Studio |
|
||||||
| `GROQ` | Groq |
|
| `GROQ` | Groq |
|
||||||
@@ -58,7 +61,9 @@
|
|||||||
| `RELACE` | Relace |
|
| `RELACE` | Relace |
|
||||||
| `SAMBA_NOVA` | SambaNova |
|
| `SAMBA_NOVA` | SambaNova |
|
||||||
| `SILICON_FLOW` | SiliconFlow |
|
| `SILICON_FLOW` | SiliconFlow |
|
||||||
|
| `SOURCEFUL` | Sourceful |
|
||||||
| `STEALTH` | Stealth |
|
| `STEALTH` | Stealth |
|
||||||
|
| `STREAM_LAKE` | StreamLake |
|
||||||
| `SWITCHPOINT` | Switchpoint |
|
| `SWITCHPOINT` | Switchpoint |
|
||||||
| `TARGON` | Targon |
|
| `TARGON` | Targon |
|
||||||
| `TOGETHER` | Together |
|
| `TOGETHER` | Together |
|
||||||
|
|||||||
@@ -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/>} |
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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": "allow",
|
|
||||||
"zdr": True,
|
|
||||||
"enforce_distillable_text": True,
|
|
||||||
"order": [
|
|
||||||
"OpenAI",
|
|
||||||
],
|
|
||||||
"only": [
|
|
||||||
"OpenAI",
|
|
||||||
],
|
|
||||||
"ignore": [
|
|
||||||
"OpenAI",
|
|
||||||
],
|
|
||||||
"quantizations": [
|
|
||||||
"fp16",
|
|
||||||
],
|
|
||||||
"sort": "price",
|
|
||||||
})
|
|
||||||
|
|
||||||
# Handle response
|
# Handle response
|
||||||
print(res)
|
print(res)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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": "allow",
|
|
||||||
"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
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "openrouter"
|
name = "openrouter"
|
||||||
version = "0.0.19"
|
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"
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
|
|
||||||
__title__: str = "openrouter"
|
__title__: str = "openrouter"
|
||||||
__version__: str = "0.0.19"
|
__version__: str = "0.0.21"
|
||||||
__openapi_doc_version__: str = "1.0.0"
|
__openapi_doc_version__: str = "1.0.0"
|
||||||
__gen_version__: str = "2.755.9"
|
__gen_version__: str = "2.768.0"
|
||||||
__user_agent__: str = "speakeasy-sdk/python 0.0.19 2.755.9 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:
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ if TYPE_CHECKING:
|
|||||||
BadRequestResponseErrorData,
|
BadRequestResponseErrorData,
|
||||||
BadRequestResponseErrorDataTypedDict,
|
BadRequestResponseErrorDataTypedDict,
|
||||||
)
|
)
|
||||||
|
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||||
from .chaterror import ChatErrorError, ChatErrorErrorTypedDict, Code, CodeTypedDict
|
from .chaterror import ChatErrorError, ChatErrorErrorTypedDict, Code, CodeTypedDict
|
||||||
from .chatgenerationparams import (
|
from .chatgenerationparams import (
|
||||||
ChatGenerationParams,
|
ChatGenerationParams,
|
||||||
@@ -35,6 +36,8 @@ if TYPE_CHECKING:
|
|||||||
ChatGenerationParamsStop,
|
ChatGenerationParamsStop,
|
||||||
ChatGenerationParamsStopTypedDict,
|
ChatGenerationParamsStopTypedDict,
|
||||||
ChatGenerationParamsTypedDict,
|
ChatGenerationParamsTypedDict,
|
||||||
|
Debug,
|
||||||
|
DebugTypedDict,
|
||||||
Effort,
|
Effort,
|
||||||
Reasoning,
|
Reasoning,
|
||||||
ReasoningTypedDict,
|
ReasoningTypedDict,
|
||||||
@@ -53,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,
|
||||||
@@ -98,13 +105,8 @@ if TYPE_CHECKING:
|
|||||||
ChatMessageToolCallTypedDict,
|
ChatMessageToolCallTypedDict,
|
||||||
)
|
)
|
||||||
from .chatresponse import ChatResponse, ChatResponseTypedDict
|
from .chatresponse import ChatResponse, ChatResponseTypedDict
|
||||||
from .chatresponsechoice import (
|
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
|
||||||
ChatCompletionFinishReason,
|
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||||
ChatResponseChoice,
|
|
||||||
ChatResponseChoiceTypedDict,
|
|
||||||
ChatStreamingChoice,
|
|
||||||
ChatStreamingChoiceTypedDict,
|
|
||||||
)
|
|
||||||
from .chatstreamingmessagechunk import (
|
from .chatstreamingmessagechunk import (
|
||||||
ChatStreamingMessageChunk,
|
ChatStreamingMessageChunk,
|
||||||
ChatStreamingMessageChunkRole,
|
ChatStreamingMessageChunkRole,
|
||||||
@@ -422,6 +424,7 @@ if TYPE_CHECKING:
|
|||||||
Engine,
|
Engine,
|
||||||
IDFileParser,
|
IDFileParser,
|
||||||
IDModeration,
|
IDModeration,
|
||||||
|
IDResponseHealing,
|
||||||
IDWeb,
|
IDWeb,
|
||||||
Ignore,
|
Ignore,
|
||||||
IgnoreTypedDict,
|
IgnoreTypedDict,
|
||||||
@@ -446,6 +449,8 @@ if TYPE_CHECKING:
|
|||||||
PluginFileParserTypedDict,
|
PluginFileParserTypedDict,
|
||||||
PluginModeration,
|
PluginModeration,
|
||||||
PluginModerationTypedDict,
|
PluginModerationTypedDict,
|
||||||
|
PluginResponseHealing,
|
||||||
|
PluginResponseHealingTypedDict,
|
||||||
PluginTypedDict,
|
PluginTypedDict,
|
||||||
PluginWeb,
|
PluginWeb,
|
||||||
PluginWebTypedDict,
|
PluginWebTypedDict,
|
||||||
@@ -820,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",
|
||||||
@@ -896,6 +902,8 @@ __all__ = [
|
|||||||
"CreateChargeRequest",
|
"CreateChargeRequest",
|
||||||
"CreateChargeRequestTypedDict",
|
"CreateChargeRequestTypedDict",
|
||||||
"DataCollection",
|
"DataCollection",
|
||||||
|
"Debug",
|
||||||
|
"DebugTypedDict",
|
||||||
"DefaultParameters",
|
"DefaultParameters",
|
||||||
"DefaultParametersTypedDict",
|
"DefaultParametersTypedDict",
|
||||||
"EdgeNetworkTimeoutResponseErrorData",
|
"EdgeNetworkTimeoutResponseErrorData",
|
||||||
@@ -913,6 +921,7 @@ __all__ = [
|
|||||||
"ForbiddenResponseErrorDataTypedDict",
|
"ForbiddenResponseErrorDataTypedDict",
|
||||||
"IDFileParser",
|
"IDFileParser",
|
||||||
"IDModeration",
|
"IDModeration",
|
||||||
|
"IDResponseHealing",
|
||||||
"IDWeb",
|
"IDWeb",
|
||||||
"Ignore",
|
"Ignore",
|
||||||
"IgnoreTypedDict",
|
"IgnoreTypedDict",
|
||||||
@@ -1206,6 +1215,8 @@ __all__ = [
|
|||||||
"PluginFileParserTypedDict",
|
"PluginFileParserTypedDict",
|
||||||
"PluginModeration",
|
"PluginModeration",
|
||||||
"PluginModerationTypedDict",
|
"PluginModerationTypedDict",
|
||||||
|
"PluginResponseHealing",
|
||||||
|
"PluginResponseHealingTypedDict",
|
||||||
"PluginTypedDict",
|
"PluginTypedDict",
|
||||||
"PluginWeb",
|
"PluginWeb",
|
||||||
"PluginWebTypedDict",
|
"PluginWebTypedDict",
|
||||||
@@ -1331,6 +1342,7 @@ __all__ = [
|
|||||||
"SystemMessageContent",
|
"SystemMessageContent",
|
||||||
"SystemMessageContentTypedDict",
|
"SystemMessageContentTypedDict",
|
||||||
"SystemMessageTypedDict",
|
"SystemMessageTypedDict",
|
||||||
|
"TTL",
|
||||||
"Tokenizer",
|
"Tokenizer",
|
||||||
"TooManyRequestsResponseErrorData",
|
"TooManyRequestsResponseErrorData",
|
||||||
"TooManyRequestsResponseErrorDataTypedDict",
|
"TooManyRequestsResponseErrorDataTypedDict",
|
||||||
@@ -1401,6 +1413,7 @@ _dynamic_imports: dict[str, str] = {
|
|||||||
"BadGatewayResponseErrorDataTypedDict": ".badgatewayresponseerrordata",
|
"BadGatewayResponseErrorDataTypedDict": ".badgatewayresponseerrordata",
|
||||||
"BadRequestResponseErrorData": ".badrequestresponseerrordata",
|
"BadRequestResponseErrorData": ".badrequestresponseerrordata",
|
||||||
"BadRequestResponseErrorDataTypedDict": ".badrequestresponseerrordata",
|
"BadRequestResponseErrorDataTypedDict": ".badrequestresponseerrordata",
|
||||||
|
"ChatCompletionFinishReason": ".chatcompletionfinishreason",
|
||||||
"ChatErrorError": ".chaterror",
|
"ChatErrorError": ".chaterror",
|
||||||
"ChatErrorErrorTypedDict": ".chaterror",
|
"ChatErrorErrorTypedDict": ".chaterror",
|
||||||
"Code": ".chaterror",
|
"Code": ".chaterror",
|
||||||
@@ -1417,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",
|
||||||
@@ -1429,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",
|
||||||
@@ -1462,11 +1479,10 @@ _dynamic_imports: dict[str, str] = {
|
|||||||
"ChatMessageToolCallTypedDict": ".chatmessagetoolcall",
|
"ChatMessageToolCallTypedDict": ".chatmessagetoolcall",
|
||||||
"ChatResponse": ".chatresponse",
|
"ChatResponse": ".chatresponse",
|
||||||
"ChatResponseTypedDict": ".chatresponse",
|
"ChatResponseTypedDict": ".chatresponse",
|
||||||
"ChatCompletionFinishReason": ".chatresponsechoice",
|
|
||||||
"ChatResponseChoice": ".chatresponsechoice",
|
"ChatResponseChoice": ".chatresponsechoice",
|
||||||
"ChatResponseChoiceTypedDict": ".chatresponsechoice",
|
"ChatResponseChoiceTypedDict": ".chatresponsechoice",
|
||||||
"ChatStreamingChoice": ".chatresponsechoice",
|
"ChatStreamingChoice": ".chatstreamingchoice",
|
||||||
"ChatStreamingChoiceTypedDict": ".chatresponsechoice",
|
"ChatStreamingChoiceTypedDict": ".chatstreamingchoice",
|
||||||
"ChatStreamingMessageChunk": ".chatstreamingmessagechunk",
|
"ChatStreamingMessageChunk": ".chatstreamingmessagechunk",
|
||||||
"ChatStreamingMessageChunkRole": ".chatstreamingmessagechunk",
|
"ChatStreamingMessageChunkRole": ".chatstreamingmessagechunk",
|
||||||
"ChatStreamingMessageChunkTypedDict": ".chatstreamingmessagechunk",
|
"ChatStreamingMessageChunkTypedDict": ".chatstreamingmessagechunk",
|
||||||
@@ -1713,6 +1729,7 @@ _dynamic_imports: dict[str, str] = {
|
|||||||
"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",
|
||||||
@@ -1737,6 +1754,8 @@ _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",
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from openrouter.types import UnrecognizedStr
|
||||||
|
from typing import Literal, Union
|
||||||
|
|
||||||
|
|
||||||
|
ChatCompletionFinishReason = Union[
|
||||||
|
Literal[
|
||||||
|
"tool_calls",
|
||||||
|
"stop",
|
||||||
|
"length",
|
||||||
|
"content_filter",
|
||||||
|
"error",
|
||||||
|
],
|
||||||
|
UnrecognizedStr,
|
||||||
|
]
|
||||||
@@ -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
|
||||||
@@ -134,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(
|
||||||
@@ -156,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]
|
||||||
@@ -179,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):
|
||||||
@@ -226,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 = [
|
||||||
@@ -250,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,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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,8 +2,9 @@
|
|||||||
|
|
||||||
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, Union
|
from typing import Literal, Union
|
||||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||||
@@ -64,7 +65,10 @@ ChatMessageContentItemVideoTypedDict = TypeAliasType(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
ChatMessageContentItemVideo = TypeAliasType(
|
ChatMessageContentItemVideo = Annotated[
|
||||||
"ChatMessageContentItemVideo",
|
Union[
|
||||||
Union[ChatMessageContentItemVideoInputVideo, ChatMessageContentItemVideoVideoURL],
|
Annotated[ChatMessageContentItemVideoInputVideo, Tag("input_video")],
|
||||||
)
|
Annotated[ChatMessageContentItemVideoVideoURL, Tag("video_url")],
|
||||||
|
],
|
||||||
|
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||||
|
]
|
||||||
|
|||||||
@@ -2,41 +2,24 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||||
|
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||||
from .chatmessagetokenlogprobs import (
|
from .chatmessagetokenlogprobs import (
|
||||||
ChatMessageTokenLogprobs,
|
ChatMessageTokenLogprobs,
|
||||||
ChatMessageTokenLogprobsTypedDict,
|
ChatMessageTokenLogprobsTypedDict,
|
||||||
)
|
)
|
||||||
from .chatstreamingmessagechunk import (
|
|
||||||
ChatStreamingMessageChunk,
|
|
||||||
ChatStreamingMessageChunkTypedDict,
|
|
||||||
)
|
|
||||||
from openrouter.types import (
|
from openrouter.types import (
|
||||||
BaseModel,
|
BaseModel,
|
||||||
Nullable,
|
Nullable,
|
||||||
OptionalNullable,
|
OptionalNullable,
|
||||||
UNSET,
|
UNSET,
|
||||||
UNSET_SENTINEL,
|
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_extensions import Annotated, NotRequired, TypedDict
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||||
|
|
||||||
|
|
||||||
ChatCompletionFinishReason = Union[
|
|
||||||
Literal[
|
|
||||||
"tool_calls",
|
|
||||||
"stop",
|
|
||||||
"length",
|
|
||||||
"content_filter",
|
|
||||||
"error",
|
|
||||||
],
|
|
||||||
UnrecognizedStr,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class ChatResponseChoiceTypedDict(TypedDict):
|
class ChatResponseChoiceTypedDict(TypedDict):
|
||||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||||
index: float
|
index: float
|
||||||
@@ -84,52 +67,3 @@ class ChatResponseChoice(BaseModel):
|
|||||||
m[k] = val
|
m[k] = val
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
class ChatStreamingChoiceTypedDict(TypedDict):
|
|
||||||
delta: ChatStreamingMessageChunkTypedDict
|
|
||||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
|
||||||
index: float
|
|
||||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
|
||||||
|
|
||||||
|
|
||||||
class ChatStreamingChoice(BaseModel):
|
|
||||||
delta: ChatStreamingMessageChunk
|
|
||||||
|
|
||||||
finish_reason: Annotated[
|
|
||||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
|
||||||
]
|
|
||||||
|
|
||||||
index: float
|
|
||||||
|
|
||||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
|
||||||
|
|
||||||
@model_serializer(mode="wrap")
|
|
||||||
def serialize_model(self, handler):
|
|
||||||
optional_fields = ["logprobs"]
|
|
||||||
nullable_fields = ["finish_reason", "logprobs"]
|
|
||||||
null_default_fields = []
|
|
||||||
|
|
||||||
serialized = handler(self)
|
|
||||||
|
|
||||||
m = {}
|
|
||||||
|
|
||||||
for n, f in type(self).model_fields.items():
|
|
||||||
k = f.alias or n
|
|
||||||
val = serialized.get(k)
|
|
||||||
serialized.pop(k, None)
|
|
||||||
|
|
||||||
optional_nullable = k in optional_fields and k in nullable_fields
|
|
||||||
is_set = (
|
|
||||||
self.__pydantic_fields_set__.intersection({n})
|
|
||||||
or k in null_default_fields
|
|
||||||
) # pylint: disable=no-member
|
|
||||||
|
|
||||||
if val is not None and val != UNSET_SENTINEL:
|
|
||||||
m[k] = val
|
|
||||||
elif val != UNSET_SENTINEL and (
|
|
||||||
not k in optional_fields or (optional_nullable and is_set)
|
|
||||||
):
|
|
||||||
m[k] = val
|
|
||||||
|
|
||||||
return m
|
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||||
|
from .chatmessagetokenlogprobs import (
|
||||||
|
ChatMessageTokenLogprobs,
|
||||||
|
ChatMessageTokenLogprobsTypedDict,
|
||||||
|
)
|
||||||
|
from .chatstreamingmessagechunk import (
|
||||||
|
ChatStreamingMessageChunk,
|
||||||
|
ChatStreamingMessageChunkTypedDict,
|
||||||
|
)
|
||||||
|
from openrouter.types import (
|
||||||
|
BaseModel,
|
||||||
|
Nullable,
|
||||||
|
OptionalNullable,
|
||||||
|
UNSET,
|
||||||
|
UNSET_SENTINEL,
|
||||||
|
)
|
||||||
|
from openrouter.utils import validate_open_enum
|
||||||
|
from pydantic import model_serializer
|
||||||
|
from pydantic.functional_validators import PlainValidator
|
||||||
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class ChatStreamingChoiceTypedDict(TypedDict):
|
||||||
|
delta: ChatStreamingMessageChunkTypedDict
|
||||||
|
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||||
|
index: float
|
||||||
|
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||||
|
|
||||||
|
|
||||||
|
class ChatStreamingChoice(BaseModel):
|
||||||
|
delta: ChatStreamingMessageChunk
|
||||||
|
|
||||||
|
finish_reason: Annotated[
|
||||||
|
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||||
|
]
|
||||||
|
|
||||||
|
index: float
|
||||||
|
|
||||||
|
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||||
|
|
||||||
|
@model_serializer(mode="wrap")
|
||||||
|
def serialize_model(self, handler):
|
||||||
|
optional_fields = ["logprobs"]
|
||||||
|
nullable_fields = ["finish_reason", "logprobs"]
|
||||||
|
null_default_fields = []
|
||||||
|
|
||||||
|
serialized = handler(self)
|
||||||
|
|
||||||
|
m = {}
|
||||||
|
|
||||||
|
for n, f in type(self).model_fields.items():
|
||||||
|
k = f.alias or n
|
||||||
|
val = serialized.get(k)
|
||||||
|
serialized.pop(k, None)
|
||||||
|
|
||||||
|
optional_nullable = k in optional_fields and k in nullable_fields
|
||||||
|
is_set = (
|
||||||
|
self.__pydantic_fields_set__.intersection({n})
|
||||||
|
or k in null_default_fields
|
||||||
|
) # pylint: disable=no-member
|
||||||
|
|
||||||
|
if val is not None and val != UNSET_SENTINEL:
|
||||||
|
m[k] = val
|
||||||
|
elif val != UNSET_SENTINEL and (
|
||||||
|
not k in optional_fields or (optional_nullable and is_set)
|
||||||
|
):
|
||||||
|
m[k] = val
|
||||||
|
|
||||||
|
return m
|
||||||
@@ -5,7 +5,7 @@ from .chatgenerationtokenusage import (
|
|||||||
ChatGenerationTokenUsage,
|
ChatGenerationTokenUsage,
|
||||||
ChatGenerationTokenUsageTypedDict,
|
ChatGenerationTokenUsageTypedDict,
|
||||||
)
|
)
|
||||||
from .chatresponsechoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||||
from openrouter.types import (
|
from openrouter.types import (
|
||||||
BaseModel,
|
BaseModel,
|
||||||
Nullable,
|
Nullable,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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")),
|
||||||
|
]
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -44,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
|
||||||
|
|
||||||
@@ -120,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",
|
||||||
@@ -353,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",]
|
||||||
|
|
||||||
|
|
||||||
@@ -434,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):
|
||||||
@@ -468,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]]
|
||||||
@@ -478,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):
|
||||||
@@ -533,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))
|
||||||
@@ -554,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 = [
|
||||||
@@ -584,6 +609,7 @@ class OpenResponsesRequest(BaseModel):
|
|||||||
"provider",
|
"provider",
|
||||||
"plugins",
|
"plugins",
|
||||||
"user",
|
"user",
|
||||||
|
"session_id",
|
||||||
]
|
]
|
||||||
nullable_fields = [
|
nullable_fields = [
|
||||||
"instructions",
|
"instructions",
|
||||||
@@ -599,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"""
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ ProviderName = Union[
|
|||||||
"AionLabs",
|
"AionLabs",
|
||||||
"Alibaba",
|
"Alibaba",
|
||||||
"Amazon Bedrock",
|
"Amazon Bedrock",
|
||||||
|
"Amazon Nova",
|
||||||
"Anthropic",
|
"Anthropic",
|
||||||
"Arcee",
|
"Arcee AI",
|
||||||
"AtlasCloud",
|
"AtlasCloud",
|
||||||
"Avian",
|
"Avian",
|
||||||
"Azure",
|
"Azure",
|
||||||
"BaseTen",
|
"BaseTen",
|
||||||
|
"BytePlus",
|
||||||
"Black Forest Labs",
|
"Black Forest Labs",
|
||||||
"Cerebras",
|
"Cerebras",
|
||||||
"Chutes",
|
"Chutes",
|
||||||
@@ -31,6 +33,7 @@ ProviderName = Union[
|
|||||||
"Fireworks",
|
"Fireworks",
|
||||||
"Friendli",
|
"Friendli",
|
||||||
"GMICloud",
|
"GMICloud",
|
||||||
|
"GoPomelo",
|
||||||
"Google",
|
"Google",
|
||||||
"Google AI Studio",
|
"Google AI Studio",
|
||||||
"Groq",
|
"Groq",
|
||||||
@@ -60,7 +63,9 @@ ProviderName = Union[
|
|||||||
"Relace",
|
"Relace",
|
||||||
"SambaNova",
|
"SambaNova",
|
||||||
"SiliconFlow",
|
"SiliconFlow",
|
||||||
|
"Sourceful",
|
||||||
"Stealth",
|
"Stealth",
|
||||||
|
"StreamLake",
|
||||||
"Switchpoint",
|
"Switchpoint",
|
||||||
"Targon",
|
"Targon",
|
||||||
"Together",
|
"Together",
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -96,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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -283,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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -431,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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -522,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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class Generations(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -193,6 +194,7 @@ class Generations(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||||
|
|
||||||
|
# package
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
from importlib import import_module
|
||||||
|
import builtins
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .globals import Globals, GlobalsTypedDict
|
||||||
|
|
||||||
|
__all__ = ["Globals", "GlobalsTypedDict"]
|
||||||
|
|
||||||
|
_dynamic_imports: dict[str, str] = {
|
||||||
|
"Globals": ".globals",
|
||||||
|
"GlobalsTypedDict": ".globals",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def dynamic_import(modname, retries=3):
|
||||||
|
for attempt in range(retries):
|
||||||
|
try:
|
||||||
|
return import_module(modname, __package__)
|
||||||
|
except KeyError:
|
||||||
|
# Clear any half-initialized module and retry
|
||||||
|
sys.modules.pop(modname, None)
|
||||||
|
if attempt == retries - 1:
|
||||||
|
break
|
||||||
|
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||||
|
|
||||||
|
|
||||||
|
def __getattr__(attr_name: str) -> object:
|
||||||
|
module_name = _dynamic_imports.get(attr_name)
|
||||||
|
if module_name is None:
|
||||||
|
raise AttributeError(
|
||||||
|
f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
module = dynamic_import(module_name)
|
||||||
|
result = getattr(module, attr_name)
|
||||||
|
return result
|
||||||
|
except ImportError as e:
|
||||||
|
raise ImportError(
|
||||||
|
f"Failed to import {attr_name} from {module_name}: {e}"
|
||||||
|
) from e
|
||||||
|
except AttributeError as e:
|
||||||
|
raise AttributeError(
|
||||||
|
f"Failed to get {attr_name} from {module_name}: {e}"
|
||||||
|
) from e
|
||||||
|
|
||||||
|
|
||||||
|
def __dir__():
|
||||||
|
lazy_attrs = builtins.list(_dynamic_imports.keys())
|
||||||
|
return builtins.sorted(lazy_attrs)
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
from openrouter.types import BaseModel
|
||||||
|
from openrouter.utils import FieldMetadata, HeaderMetadata
|
||||||
|
import pydantic
|
||||||
|
from typing import Optional
|
||||||
|
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class GlobalsTypedDict(TypedDict):
|
||||||
|
http_referer: NotRequired[str]
|
||||||
|
r"""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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
x_title: NotRequired[str]
|
||||||
|
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class Globals(BaseModel):
|
||||||
|
http_referer: Annotated[
|
||||||
|
Optional[str],
|
||||||
|
pydantic.Field(alias="HTTP-Referer"),
|
||||||
|
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||||
|
] = None
|
||||||
|
r"""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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
x_title: Annotated[
|
||||||
|
Optional[str],
|
||||||
|
pydantic.Field(alias="X-Title"),
|
||||||
|
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
|
||||||
|
] = None
|
||||||
|
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
|
||||||
|
|
||||||
|
"""
|
||||||
@@ -49,6 +49,7 @@ class Models(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -133,6 +134,7 @@ class Models(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -227,6 +229,7 @@ class Models(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -326,6 +329,7 @@ class Models(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -422,6 +426,7 @@ class Models(BaseSDK):
|
|||||||
security=utils.get_pydantic_model(
|
security=utils.get_pydantic_model(
|
||||||
security, operations.ListModelsUserSecurity
|
security, operations.ListModelsUserSecurity
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -516,6 +521,7 @@ class Models(BaseSDK):
|
|||||||
security=utils.get_pydantic_model(
|
security=utils.get_pydantic_model(
|
||||||
security, operations.ListModelsUserSecurity
|
security, operations.ListModelsUserSecurity
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ class OAuth(BaseSDK):
|
|||||||
"json",
|
"json",
|
||||||
operations.ExchangeAuthCodeForAPIKeyRequest,
|
operations.ExchangeAuthCodeForAPIKeyRequest,
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -194,6 +195,7 @@ class OAuth(BaseSDK):
|
|||||||
"json",
|
"json",
|
||||||
operations.ExchangeAuthCodeForAPIKeyRequest,
|
operations.ExchangeAuthCodeForAPIKeyRequest,
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -316,6 +318,7 @@ class OAuth(BaseSDK):
|
|||||||
get_serialized_body=lambda: utils.serialize_request_body(
|
get_serialized_body=lambda: utils.serialize_request_body(
|
||||||
request, False, False, "json", operations.CreateAuthKeysCodeRequest
|
request, False, False, "json", operations.CreateAuthKeysCodeRequest
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -438,6 +441,7 @@ class OAuth(BaseSDK):
|
|||||||
get_serialized_body=lambda: utils.serialize_request_body(
|
get_serialized_body=lambda: utils.serialize_request_body(
|
||||||
request, False, False, "json", operations.CreateAuthKeysCodeRequest
|
request, False, False, "json", operations.CreateAuthKeysCodeRequest
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,12 @@ if TYPE_CHECKING:
|
|||||||
ExchangeAuthCodeForAPIKeyResponse,
|
ExchangeAuthCodeForAPIKeyResponse,
|
||||||
ExchangeAuthCodeForAPIKeyResponseTypedDict,
|
ExchangeAuthCodeForAPIKeyResponseTypedDict,
|
||||||
)
|
)
|
||||||
from .getcredits import GetCreditsResponse, GetCreditsResponseTypedDict
|
from .getcredits import (
|
||||||
|
GetCreditsData,
|
||||||
|
GetCreditsDataTypedDict,
|
||||||
|
GetCreditsResponse,
|
||||||
|
GetCreditsResponseTypedDict,
|
||||||
|
)
|
||||||
from .getcurrentkey import (
|
from .getcurrentkey import (
|
||||||
GetCurrentKeyData,
|
GetCurrentKeyData,
|
||||||
GetCurrentKeyDataTypedDict,
|
GetCurrentKeyDataTypedDict,
|
||||||
@@ -242,6 +247,8 @@ __all__ = [
|
|||||||
"ExchangeAuthCodeForAPIKeyRequestTypedDict",
|
"ExchangeAuthCodeForAPIKeyRequestTypedDict",
|
||||||
"ExchangeAuthCodeForAPIKeyResponse",
|
"ExchangeAuthCodeForAPIKeyResponse",
|
||||||
"ExchangeAuthCodeForAPIKeyResponseTypedDict",
|
"ExchangeAuthCodeForAPIKeyResponseTypedDict",
|
||||||
|
"GetCreditsData",
|
||||||
|
"GetCreditsDataTypedDict",
|
||||||
"GetCreditsResponse",
|
"GetCreditsResponse",
|
||||||
"GetCreditsResponseTypedDict",
|
"GetCreditsResponseTypedDict",
|
||||||
"GetCurrentKeyData",
|
"GetCurrentKeyData",
|
||||||
@@ -416,6 +423,8 @@ _dynamic_imports: dict[str, str] = {
|
|||||||
"ExchangeAuthCodeForAPIKeyRequestTypedDict": ".exchangeauthcodeforapikey",
|
"ExchangeAuthCodeForAPIKeyRequestTypedDict": ".exchangeauthcodeforapikey",
|
||||||
"ExchangeAuthCodeForAPIKeyResponse": ".exchangeauthcodeforapikey",
|
"ExchangeAuthCodeForAPIKeyResponse": ".exchangeauthcodeforapikey",
|
||||||
"ExchangeAuthCodeForAPIKeyResponseTypedDict": ".exchangeauthcodeforapikey",
|
"ExchangeAuthCodeForAPIKeyResponseTypedDict": ".exchangeauthcodeforapikey",
|
||||||
|
"GetCreditsData": ".getcredits",
|
||||||
|
"GetCreditsDataTypedDict": ".getcredits",
|
||||||
"GetCreditsResponse": ".getcredits",
|
"GetCreditsResponse": ".getcredits",
|
||||||
"GetCreditsResponseTypedDict": ".getcredits",
|
"GetCreditsResponseTypedDict": ".getcredits",
|
||||||
"GetCurrentKeyData": ".getcurrentkey",
|
"GetCurrentKeyData": ".getcurrentkey",
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ from openrouter.types import (
|
|||||||
UNSET_SENTINEL,
|
UNSET_SENTINEL,
|
||||||
UnrecognizedStr,
|
UnrecognizedStr,
|
||||||
)
|
)
|
||||||
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, List, Literal, Optional, Union
|
from typing import Any, List, Literal, Optional, Union
|
||||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||||
@@ -63,7 +63,13 @@ ContentTypedDict = TypeAliasType(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
Content = TypeAliasType("Content", Union[ContentText, ContentImageURL])
|
Content = Annotated[
|
||||||
|
Union[
|
||||||
|
Annotated[ContentText, Tag("text")],
|
||||||
|
Annotated[ContentImageURL, Tag("image_url")],
|
||||||
|
],
|
||||||
|
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class InputTypedDict(TypedDict):
|
class InputTypedDict(TypedDict):
|
||||||
|
|||||||
@@ -5,9 +5,28 @@ from openrouter.types import BaseModel
|
|||||||
from typing_extensions import TypedDict
|
from typing_extensions import TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class GetCreditsDataTypedDict(TypedDict):
|
||||||
|
total_credits: float
|
||||||
|
r"""Total credits purchased"""
|
||||||
|
total_usage: float
|
||||||
|
r"""Total credits used"""
|
||||||
|
|
||||||
|
|
||||||
|
class GetCreditsData(BaseModel):
|
||||||
|
total_credits: float
|
||||||
|
r"""Total credits purchased"""
|
||||||
|
|
||||||
|
total_usage: float
|
||||||
|
r"""Total credits used"""
|
||||||
|
|
||||||
|
|
||||||
class GetCreditsResponseTypedDict(TypedDict):
|
class GetCreditsResponseTypedDict(TypedDict):
|
||||||
r"""Total credits purchased and used"""
|
r"""Total credits purchased and used"""
|
||||||
|
|
||||||
|
data: GetCreditsDataTypedDict
|
||||||
|
|
||||||
|
|
||||||
class GetCreditsResponse(BaseModel):
|
class GetCreditsResponse(BaseModel):
|
||||||
r"""Total credits purchased and used"""
|
r"""Total credits purchased and used"""
|
||||||
|
|
||||||
|
data: GetCreditsData
|
||||||
|
|||||||
@@ -38,12 +38,14 @@ GetParametersProvider = Union[
|
|||||||
"AionLabs",
|
"AionLabs",
|
||||||
"Alibaba",
|
"Alibaba",
|
||||||
"Amazon Bedrock",
|
"Amazon Bedrock",
|
||||||
|
"Amazon Nova",
|
||||||
"Anthropic",
|
"Anthropic",
|
||||||
"Arcee",
|
"Arcee AI",
|
||||||
"AtlasCloud",
|
"AtlasCloud",
|
||||||
"Avian",
|
"Avian",
|
||||||
"Azure",
|
"Azure",
|
||||||
"BaseTen",
|
"BaseTen",
|
||||||
|
"BytePlus",
|
||||||
"Black Forest Labs",
|
"Black Forest Labs",
|
||||||
"Cerebras",
|
"Cerebras",
|
||||||
"Chutes",
|
"Chutes",
|
||||||
@@ -58,6 +60,7 @@ GetParametersProvider = Union[
|
|||||||
"Fireworks",
|
"Fireworks",
|
||||||
"Friendli",
|
"Friendli",
|
||||||
"GMICloud",
|
"GMICloud",
|
||||||
|
"GoPomelo",
|
||||||
"Google",
|
"Google",
|
||||||
"Google AI Studio",
|
"Google AI Studio",
|
||||||
"Groq",
|
"Groq",
|
||||||
@@ -87,7 +90,9 @@ GetParametersProvider = Union[
|
|||||||
"Relace",
|
"Relace",
|
||||||
"SambaNova",
|
"SambaNova",
|
||||||
"SiliconFlow",
|
"SiliconFlow",
|
||||||
|
"Sourceful",
|
||||||
"Stealth",
|
"Stealth",
|
||||||
|
"StreamLake",
|
||||||
"Switchpoint",
|
"Switchpoint",
|
||||||
"Targon",
|
"Targon",
|
||||||
"Together",
|
"Together",
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class UpdateKeysRequestBody(BaseModel):
|
|||||||
class UpdateKeysRequestTypedDict(TypedDict):
|
class UpdateKeysRequestTypedDict(TypedDict):
|
||||||
hash: str
|
hash: str
|
||||||
r"""The hash identifier of the API key to update"""
|
r"""The hash identifier of the API key to update"""
|
||||||
body: UpdateKeysRequestBodyTypedDict
|
request_body: UpdateKeysRequestBodyTypedDict
|
||||||
|
|
||||||
|
|
||||||
class UpdateKeysRequest(BaseModel):
|
class UpdateKeysRequest(BaseModel):
|
||||||
@@ -114,7 +114,7 @@ class UpdateKeysRequest(BaseModel):
|
|||||||
]
|
]
|
||||||
r"""The hash identifier of the API key to update"""
|
r"""The hash identifier of the API key to update"""
|
||||||
|
|
||||||
body: Annotated[
|
request_body: Annotated[
|
||||||
UpdateKeysRequestBody,
|
UpdateKeysRequestBody,
|
||||||
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class Parameters(BaseSDK):
|
|||||||
security=utils.get_pydantic_model(
|
security=utils.get_pydantic_model(
|
||||||
security, operations.GetParametersSecurity
|
security, operations.GetParametersSecurity
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -179,6 +180,7 @@ class Parameters(BaseSDK):
|
|||||||
security=utils.get_pydantic_model(
|
security=utils.get_pydantic_model(
|
||||||
security, operations.GetParametersSecurity
|
security, operations.GetParametersSecurity
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class Providers(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -133,6 +134,7 @@ class Providers(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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+22
-20
@@ -69,8 +69,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Union[Literal[False], None] = None,
|
stream: Union[Literal[False], None] = None,
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -80,6 +79,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -109,13 +109,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -174,8 +174,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Literal[True],
|
stream: Literal[True],
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -185,6 +184,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -214,13 +214,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -278,8 +278,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Optional[bool] = False,
|
stream: Optional[bool] = False,
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -289,6 +288,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -318,13 +318,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -374,7 +374,6 @@ class Responses(BaseSDK):
|
|||||||
include=include,
|
include=include,
|
||||||
background=background,
|
background=background,
|
||||||
safety_identifier=safety_identifier,
|
safety_identifier=safety_identifier,
|
||||||
store=store,
|
|
||||||
service_tier=service_tier,
|
service_tier=service_tier,
|
||||||
truncation=truncation,
|
truncation=truncation,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
@@ -385,6 +384,7 @@ class Responses(BaseSDK):
|
|||||||
plugins, Optional[List[components.Plugin]]
|
plugins, Optional[List[components.Plugin]]
|
||||||
),
|
),
|
||||||
user=user,
|
user=user,
|
||||||
|
session_id=session_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
req = self._build_request(
|
req = self._build_request(
|
||||||
@@ -403,6 +403,7 @@ class Responses(BaseSDK):
|
|||||||
get_serialized_body=lambda: utils.serialize_request_body(
|
get_serialized_body=lambda: utils.serialize_request_body(
|
||||||
request, False, False, "json", components.OpenResponsesRequest
|
request, False, False, "json", components.OpenResponsesRequest
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -626,8 +627,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Union[Literal[False], None] = None,
|
stream: Union[Literal[False], None] = None,
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -637,6 +637,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -666,13 +667,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -731,8 +732,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Literal[True],
|
stream: Literal[True],
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -742,6 +742,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -771,13 +772,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -835,8 +836,7 @@ class Responses(BaseSDK):
|
|||||||
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
include: OptionalNullable[List[components.OpenAIResponsesIncludable]] = UNSET,
|
||||||
background: OptionalNullable[bool] = UNSET,
|
background: OptionalNullable[bool] = UNSET,
|
||||||
safety_identifier: OptionalNullable[str] = UNSET,
|
safety_identifier: OptionalNullable[str] = UNSET,
|
||||||
store: OptionalNullable[bool] = UNSET,
|
service_tier: Optional[components.ServiceTier] = "auto",
|
||||||
service_tier: OptionalNullable[components.ServiceTier] = UNSET,
|
|
||||||
truncation: OptionalNullable[components.Truncation] = UNSET,
|
truncation: OptionalNullable[components.Truncation] = UNSET,
|
||||||
stream: Optional[bool] = False,
|
stream: Optional[bool] = False,
|
||||||
provider: OptionalNullable[
|
provider: OptionalNullable[
|
||||||
@@ -846,6 +846,7 @@ class Responses(BaseSDK):
|
|||||||
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
Union[List[components.Plugin], List[components.PluginTypedDict]]
|
||||||
] = None,
|
] = None,
|
||||||
user: Optional[str] = None,
|
user: Optional[str] = None,
|
||||||
|
session_id: 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,
|
||||||
@@ -875,13 +876,13 @@ class Responses(BaseSDK):
|
|||||||
:param include:
|
:param include:
|
||||||
:param background:
|
:param background:
|
||||||
:param safety_identifier:
|
:param safety_identifier:
|
||||||
:param store:
|
|
||||||
:param service_tier:
|
:param service_tier:
|
||||||
:param truncation:
|
:param truncation:
|
||||||
:param stream:
|
:param stream:
|
||||||
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
:param provider: When multiple model providers are available, optionally indicate your routing preference.
|
||||||
:param plugins: Plugins you want to enable for this request, including their settings.
|
:param plugins: Plugins you want to enable for this request, including their settings.
|
||||||
:param user: 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.
|
:param user: 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.
|
||||||
|
:param session_id: 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.
|
||||||
: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
|
||||||
@@ -931,7 +932,6 @@ class Responses(BaseSDK):
|
|||||||
include=include,
|
include=include,
|
||||||
background=background,
|
background=background,
|
||||||
safety_identifier=safety_identifier,
|
safety_identifier=safety_identifier,
|
||||||
store=store,
|
|
||||||
service_tier=service_tier,
|
service_tier=service_tier,
|
||||||
truncation=truncation,
|
truncation=truncation,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
@@ -942,6 +942,7 @@ class Responses(BaseSDK):
|
|||||||
plugins, Optional[List[components.Plugin]]
|
plugins, Optional[List[components.Plugin]]
|
||||||
),
|
),
|
||||||
user=user,
|
user=user,
|
||||||
|
session_id=session_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
req = self._build_request_async(
|
req = self._build_request_async(
|
||||||
@@ -960,6 +961,7 @@ class Responses(BaseSDK):
|
|||||||
get_serialized_body=lambda: utils.serialize_request_body(
|
get_serialized_body=lambda: utils.serialize_request_body(
|
||||||
request, False, False, "json", components.OpenResponsesRequest
|
request, False, False, "json", components.OpenResponsesRequest
|
||||||
),
|
),
|
||||||
|
allow_empty_value=None,
|
||||||
timeout_ms=timeout_ms,
|
timeout_ms=timeout_ms,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import httpx
|
|||||||
import importlib
|
import importlib
|
||||||
from openrouter import components, utils
|
from openrouter import components, utils
|
||||||
from openrouter._hooks import SDKHooks
|
from openrouter._hooks import SDKHooks
|
||||||
|
from openrouter.models import internal
|
||||||
from openrouter.types import OptionalNullable, UNSET
|
from openrouter.types import OptionalNullable, UNSET
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
||||||
@@ -77,6 +78,8 @@ class OpenRouter(BaseSDK):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
api_key: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
|
api_key: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
|
||||||
|
http_referer: Optional[str] = None,
|
||||||
|
x_title: Optional[str] = None,
|
||||||
server: Optional[str] = None,
|
server: Optional[str] = None,
|
||||||
server_url: Optional[str] = None,
|
server_url: Optional[str] = None,
|
||||||
url_params: Optional[Dict[str, str]] = None,
|
url_params: Optional[Dict[str, str]] = None,
|
||||||
@@ -89,6 +92,8 @@ class OpenRouter(BaseSDK):
|
|||||||
r"""Instantiates the SDK configuring it with the provided parameters.
|
r"""Instantiates the SDK configuring it with the provided parameters.
|
||||||
|
|
||||||
:param api_key: The api_key required for authentication
|
:param api_key: The api_key required for authentication
|
||||||
|
:param http_referer: Configures the http_referer parameter for all supported operations
|
||||||
|
:param x_title: Configures the x_title parameter for all supported operations
|
||||||
:param server: The server by name to use for all methods
|
:param server: The server by name to use for all methods
|
||||||
:param server_url: The server URL to use for all methods
|
:param server_url: The server URL to use for all methods
|
||||||
:param url_params: Parameters to optionally template the server URL with
|
:param url_params: Parameters to optionally template the server URL with
|
||||||
@@ -129,6 +134,13 @@ class OpenRouter(BaseSDK):
|
|||||||
if url_params is not None:
|
if url_params is not None:
|
||||||
server_url = utils.template_url(server_url, url_params)
|
server_url = utils.template_url(server_url, url_params)
|
||||||
|
|
||||||
|
_globals = internal.Globals(
|
||||||
|
http_referer=utils.get_global_from_env(
|
||||||
|
http_referer, "OPENROUTER_HTTP_REFERER", str
|
||||||
|
),
|
||||||
|
x_title=utils.get_global_from_env(x_title, "OPENROUTER_X_TITLE", str),
|
||||||
|
)
|
||||||
|
|
||||||
BaseSDK.__init__(
|
BaseSDK.__init__(
|
||||||
self,
|
self,
|
||||||
SDKConfiguration(
|
SDKConfiguration(
|
||||||
@@ -136,6 +148,7 @@ class OpenRouter(BaseSDK):
|
|||||||
client_supplied=client_supplied,
|
client_supplied=client_supplied,
|
||||||
async_client=async_client,
|
async_client=async_client,
|
||||||
async_client_supplied=async_client_supplied,
|
async_client_supplied=async_client_supplied,
|
||||||
|
globals=_globals,
|
||||||
security=security,
|
security=security,
|
||||||
server_url=server_url,
|
server_url=server_url,
|
||||||
server=server,
|
server=server,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from .httpclient import AsyncHttpClient, HttpClient
|
|||||||
from .utils import Logger, RetryConfig, remove_suffix
|
from .utils import Logger, RetryConfig, remove_suffix
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from openrouter import components
|
from openrouter import components
|
||||||
|
from openrouter.models import internal
|
||||||
from openrouter.types import OptionalNullable, UNSET
|
from openrouter.types import OptionalNullable, UNSET
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
from typing import Callable, Dict, Optional, Tuple, Union
|
from typing import Callable, Dict, Optional, Tuple, Union
|
||||||
@@ -30,6 +31,7 @@ class SDKConfiguration:
|
|||||||
async_client: Union[AsyncHttpClient, None]
|
async_client: Union[AsyncHttpClient, None]
|
||||||
async_client_supplied: bool
|
async_client_supplied: bool
|
||||||
debug_logger: Logger
|
debug_logger: Logger
|
||||||
|
globals: internal.Globals
|
||||||
security: Optional[
|
security: Optional[
|
||||||
Union[components.Security, Callable[[], components.Security]]
|
Union[components.Security, Callable[[], components.Security]]
|
||||||
] = None
|
] = None
|
||||||
|
|||||||
@@ -142,16 +142,21 @@ def serialize_multipart_form(
|
|||||||
if field_metadata.file:
|
if field_metadata.file:
|
||||||
if isinstance(val, List):
|
if isinstance(val, List):
|
||||||
# Handle array of files
|
# Handle array of files
|
||||||
|
array_field_name = f_name + "[]"
|
||||||
for file_obj in val:
|
for file_obj in val:
|
||||||
if not _is_set(file_obj):
|
if not _is_set(file_obj):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_name, content, content_type = _extract_file_properties(file_obj)
|
file_name, content, content_type = _extract_file_properties(
|
||||||
|
file_obj
|
||||||
|
)
|
||||||
|
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
files.append((f_name + "[]", (file_name, content, content_type)))
|
files.append(
|
||||||
|
(array_field_name, (file_name, content, content_type))
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
files.append((f_name + "[]", (file_name, content)))
|
files.append((array_field_name, (file_name, content)))
|
||||||
else:
|
else:
|
||||||
# Handle single file
|
# Handle single file
|
||||||
file_name, content, content_type = _extract_file_properties(val)
|
file_name, content, content_type = _extract_file_properties(val)
|
||||||
@@ -161,11 +166,16 @@ def serialize_multipart_form(
|
|||||||
else:
|
else:
|
||||||
files.append((f_name, (file_name, content)))
|
files.append((f_name, (file_name, content)))
|
||||||
elif field_metadata.json:
|
elif field_metadata.json:
|
||||||
files.append((f_name, (
|
files.append(
|
||||||
None,
|
(
|
||||||
marshal_json(val, request_field_types[name]),
|
f_name,
|
||||||
"application/json",
|
(
|
||||||
)))
|
None,
|
||||||
|
marshal_json(val, request_field_types[name]),
|
||||||
|
"application/json",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if isinstance(val, List):
|
if isinstance(val, List):
|
||||||
values = []
|
values = []
|
||||||
@@ -175,7 +185,8 @@ def serialize_multipart_form(
|
|||||||
continue
|
continue
|
||||||
values.append(_val_to_string(value))
|
values.append(_val_to_string(value))
|
||||||
|
|
||||||
form[f_name + "[]"] = values
|
array_field_name = f_name + "[]"
|
||||||
|
form[array_field_name] = values
|
||||||
else:
|
else:
|
||||||
form[f_name] = _val_to_string(val)
|
form[f_name] = _val_to_string(val)
|
||||||
return media_type, form, files
|
return media_type, form, files
|
||||||
|
|||||||
@@ -27,12 +27,13 @@ from .forms import _populate_form
|
|||||||
def get_query_params(
|
def get_query_params(
|
||||||
query_params: Any,
|
query_params: Any,
|
||||||
gbls: Optional[Any] = None,
|
gbls: Optional[Any] = None,
|
||||||
|
allow_empty_value: Optional[List[str]] = None,
|
||||||
) -> Dict[str, List[str]]:
|
) -> Dict[str, List[str]]:
|
||||||
params: Dict[str, List[str]] = {}
|
params: Dict[str, List[str]] = {}
|
||||||
|
|
||||||
globals_already_populated = _populate_query_params(query_params, gbls, params, [])
|
globals_already_populated = _populate_query_params(query_params, gbls, params, [], allow_empty_value)
|
||||||
if _is_set(gbls):
|
if _is_set(gbls):
|
||||||
_populate_query_params(gbls, None, params, globals_already_populated)
|
_populate_query_params(gbls, None, params, globals_already_populated, allow_empty_value)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ def _populate_query_params(
|
|||||||
gbls: Any,
|
gbls: Any,
|
||||||
query_param_values: Dict[str, List[str]],
|
query_param_values: Dict[str, List[str]],
|
||||||
skip_fields: List[str],
|
skip_fields: List[str],
|
||||||
|
allow_empty_value: Optional[List[str]] = None,
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
globals_already_populated: List[str] = []
|
globals_already_populated: List[str] = []
|
||||||
|
|
||||||
@@ -69,6 +71,16 @@ def _populate_query_params(
|
|||||||
globals_already_populated.append(name)
|
globals_already_populated.append(name)
|
||||||
|
|
||||||
f_name = field.alias if field.alias is not None else name
|
f_name = field.alias if field.alias is not None else name
|
||||||
|
|
||||||
|
allow_empty_set = set(allow_empty_value or [])
|
||||||
|
should_include_empty = f_name in allow_empty_set and (
|
||||||
|
value is None or value == [] or value == ""
|
||||||
|
)
|
||||||
|
|
||||||
|
if should_include_empty:
|
||||||
|
query_param_values[f_name] = [""]
|
||||||
|
continue
|
||||||
|
|
||||||
serialization = metadata.serialization
|
serialization = metadata.serialization
|
||||||
if serialization is not None:
|
if serialization is not None:
|
||||||
serialized_parms = _get_serialized_params(
|
serialized_parms = _get_serialized_params(
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from typing import List
|
from datetime import datetime
|
||||||
|
from email.utils import parsedate_to_datetime
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
@@ -51,9 +53,11 @@ class Retries:
|
|||||||
|
|
||||||
class TemporaryError(Exception):
|
class TemporaryError(Exception):
|
||||||
response: httpx.Response
|
response: httpx.Response
|
||||||
|
retry_after: Optional[int]
|
||||||
|
|
||||||
def __init__(self, response: httpx.Response):
|
def __init__(self, response: httpx.Response):
|
||||||
self.response = response
|
self.response = response
|
||||||
|
self.retry_after = _parse_retry_after_header(response)
|
||||||
|
|
||||||
|
|
||||||
class PermanentError(Exception):
|
class PermanentError(Exception):
|
||||||
@@ -63,6 +67,62 @@ class PermanentError(Exception):
|
|||||||
self.inner = inner
|
self.inner = inner
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_retry_after_header(response: httpx.Response) -> Optional[int]:
|
||||||
|
"""Parse Retry-After header from response.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Retry interval in milliseconds, or None if header is missing or invalid.
|
||||||
|
"""
|
||||||
|
retry_after_header = response.headers.get("retry-after")
|
||||||
|
if not retry_after_header:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
seconds = float(retry_after_header)
|
||||||
|
return round(seconds * 1000)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
retry_date = parsedate_to_datetime(retry_after_header)
|
||||||
|
delta = (retry_date - datetime.now(retry_date.tzinfo)).total_seconds()
|
||||||
|
return round(max(0, delta) * 1000)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_sleep_interval(
|
||||||
|
exception: Exception,
|
||||||
|
initial_interval: int,
|
||||||
|
max_interval: int,
|
||||||
|
exponent: float,
|
||||||
|
retries: int,
|
||||||
|
) -> float:
|
||||||
|
"""Get sleep interval for retry with exponential backoff.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
exception: The exception that triggered the retry.
|
||||||
|
initial_interval: Initial retry interval in milliseconds.
|
||||||
|
max_interval: Maximum retry interval in milliseconds.
|
||||||
|
exponent: Base for exponential backoff calculation.
|
||||||
|
retries: Current retry attempt count.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Sleep interval in seconds.
|
||||||
|
"""
|
||||||
|
if (
|
||||||
|
isinstance(exception, TemporaryError)
|
||||||
|
and exception.retry_after is not None
|
||||||
|
and exception.retry_after > 0
|
||||||
|
):
|
||||||
|
return exception.retry_after / 1000
|
||||||
|
|
||||||
|
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
|
||||||
|
return min(sleep, max_interval / 1000)
|
||||||
|
|
||||||
|
|
||||||
def retry(func, retries: Retries):
|
def retry(func, retries: Retries):
|
||||||
if retries.config.strategy == "backoff":
|
if retries.config.strategy == "backoff":
|
||||||
|
|
||||||
@@ -183,8 +243,10 @@ def retry_with_backoff(
|
|||||||
return exception.response
|
return exception.response
|
||||||
|
|
||||||
raise
|
raise
|
||||||
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
|
|
||||||
sleep = min(sleep, max_interval / 1000)
|
sleep = _get_sleep_interval(
|
||||||
|
exception, initial_interval, max_interval, exponent, retries
|
||||||
|
)
|
||||||
time.sleep(sleep)
|
time.sleep(sleep)
|
||||||
retries += 1
|
retries += 1
|
||||||
|
|
||||||
@@ -211,7 +273,9 @@ async def retry_with_backoff_async(
|
|||||||
return exception.response
|
return exception.response
|
||||||
|
|
||||||
raise
|
raise
|
||||||
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
|
|
||||||
sleep = min(sleep, max_interval / 1000)
|
sleep = _get_sleep_interval(
|
||||||
|
exception, initial_interval, max_interval, exponent, retries
|
||||||
|
)
|
||||||
await asyncio.sleep(sleep)
|
await asyncio.sleep(sleep)
|
||||||
retries += 1
|
retries += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user