diff --git a/.speakeasy/OAS_files/chat-completions-openapi.yaml b/.speakeasy/OAS_files/chat-completions-openapi.yaml index 0a1ca40..1b3dc5d 100644 --- a/.speakeasy/OAS_files/chat-completions-openapi.yaml +++ b/.speakeasy/OAS_files/chat-completions-openapi.yaml @@ -17,7 +17,7 @@ servers: default: openrouter.ai description: Production server security: - - BearerAuth: [] + - ApiKey: [] tags: - name: Chat description: Chat completion operations @@ -26,11 +26,17 @@ externalDocs: url: https://openrouter.ai/docs components: securitySchemes: - BearerAuth: + ApiKey: type: http scheme: bearer description: API key as bearer token in Authorization header schemas: + ChatCompletionChunkWrapper: + type: object + required: [data] + properties: + data: + $ref: '#/components/schemas/ChatCompletionChunk' ChatCompletionMessageToolCall: type: object properties: @@ -433,6 +439,7 @@ components: system_fingerprint: type: string description: System fingerprint + nullable: true usage: $ref: '#/components/schemas/CompletionUsage' required: @@ -449,7 +456,7 @@ components: type: object properties: code: - type: string + type: number nullable: true message: type: string @@ -461,8 +468,6 @@ components: required: - code - message - - param - - type description: Error object structure required: - error @@ -572,6 +577,7 @@ components: - chat.completion.chunk system_fingerprint: type: string + nullable: true usage: $ref: '#/components/schemas/CompletionUsage' required: @@ -1055,7 +1061,7 @@ components: type: string description: Unique user identifier models: - x-speakeasy-name-override: models_llm + x-speakeasy-name-override: model_list type: array nullable: true items: @@ -1497,6 +1503,8 @@ paths: /chat/completions: post: operationId: createChatCompletion + x-speakeasy-group: chat + x-speakeasy-name-override: complete summary: Create a chat completion description: Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. tags: @@ -1514,14 +1522,12 @@ paths: content: application/json: schema: - oneOf: - - $ref: '#/components/schemas/ChatCompletion' - description: Non-streaming response when stream=false - - $ref: '#/components/schemas/ChatCompletionChunk' - description: Individual chunk in streaming response when stream=true + $ref: '#/components/schemas/ChatCompletion' + description: Non-streaming response when stream=false text/event-stream: + x-speakeasy-sse-sentinel: '[DONE]' schema: - $ref: '#/components/schemas/ChatCompletionChunk' + $ref: '#/components/schemas/ChatCompletionChunkWrapper' '400': description: Bad request - invalid parameters content: diff --git a/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml b/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml deleted file mode 100644 index 48c33da..0000000 --- a/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml +++ /dev/null @@ -1,28 +0,0 @@ -overlay: 1.0.0 -x-speakeasy-jsonpath: rfc9535 -info: - title: Speakeasy Modifications - version: 0.0.2 - x-speakeasy-metadata: - after: "" - before: "" - type: speakeasy-modifications -actions: - - target: $["paths"]["/chat/completions"]["post"] - update: - x-speakeasy-name-override: complete - x-speakeasy-metadata: - after: sdk.chat.complete() - before: sdk.Chat.createChatCompletion() - created_at: 1755805257797 - reviewed_at: 1755805262583 - type: method-name - - target: $["paths"]["/chat/completions#stream"]["post"] - update: - x-speakeasy-name-override: completeStream - x-speakeasy-metadata: - after: sdk.chat.completeStream() - before: sdk.Chat.streamChatCompletion() - created_at: 1755805257798 - reviewed_at: 1755805262583 - type: method-name diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 485c0e9..3383009 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,21 @@ lockVersion: 2.0.0 id: 232c6d4f-b0fd-4172-8f1b-e2421566e9b4 management: - docChecksum: 003bbbc167e4db8bd3f147793a6648e1 + docChecksum: 3b6b1c16df754c251634311623cd5995 docVersion: 1.0.0 - speakeasyVersion: 1.606.2 - generationVersion: 2.687.1 - releaseVersion: 0.1.3 - configChecksum: d572a56cfb69d7061ad0319f157ff5d8 + speakeasyVersion: 1.611.1 + generationVersion: 2.694.1 + releaseVersion: 0.3.1 + configChecksum: 769cc7b4eef2760d1114b6b64a644f57 repoURL: https://github.com/speakeasy-sdks/openrouter-python-sdk.git installationURL: https://github.com/speakeasy-sdks/openrouter-python-sdk.git features: python: + acceptHeaders: 3.0.0 additionalDependencies: 1.0.0 constsAndDefaults: 1.0.5 - core: 5.19.9 + core: 5.20.3 + customCodeRegions: 0.1.1 defaultEnabledRetries: 0.2.0 devContainers: 3.0.0 enumUnions: 0.1.0 @@ -23,13 +25,14 @@ features: globalSecurityCallbacks: 1.0.0 globalSecurityFlattening: 1.0.0 globalServerURLs: 3.1.1 + groups: 3.0.0 methodArguments: 1.0.2 nameOverrides: 3.0.1 nullables: 1.0.1 responseFormat: 1.0.1 retries: 3.0.2 sdkHooks: 1.1.0 - serverEvents: 1.0.7 + serverEvents: 1.0.8 serverEventsSentinels: 0.1.0 unions: 3.0.4 generatedFiles: @@ -41,6 +44,7 @@ generatedFiles: - USAGE.md - docs/errors/chatcompletionerror.md - docs/models/annotationdetail.md + - docs/models/audio.md - docs/models/chatcompletion.md - docs/models/chatcompletionassistantmessageparam.md - docs/models/chatcompletionassistantmessageparamcontent.md @@ -56,6 +60,7 @@ generatedFiles: - docs/models/chatcompletionchunkchoicedeltatoolcalltype.md - docs/models/chatcompletionchunkchoicefinishreason.md - docs/models/chatcompletionchunkobject.md + - docs/models/chatcompletionchunkwrapper.md - docs/models/chatcompletioncontentpart.md - docs/models/chatcompletioncontentpartaudio.md - docs/models/chatcompletioncontentpartaudioformat.md @@ -66,50 +71,6 @@ generatedFiles: - docs/models/chatcompletioncontentparttext.md - docs/models/chatcompletioncontentparttexttype.md - docs/models/chatcompletioncreateparams.md - - docs/models/chatcompletioncreateparamsaudio.md - - docs/models/chatcompletioncreateparamscompletion.md - - docs/models/chatcompletioncreateparamsdatacollection.md - - docs/models/chatcompletioncreateparamseffort.md - - docs/models/chatcompletioncreateparamsengine.md - - docs/models/chatcompletioncreateparamsidchainofthought.md - - docs/models/chatcompletioncreateparamsidfileparser.md - - docs/models/chatcompletioncreateparamsidmoderation.md - - docs/models/chatcompletioncreateparamsidweb.md - - docs/models/chatcompletioncreateparamsignoreenum.md - - docs/models/chatcompletioncreateparamsignoreunion.md - - docs/models/chatcompletioncreateparamsimage.md - - docs/models/chatcompletioncreateparamsjsonschema.md - - docs/models/chatcompletioncreateparamsmaxprice.md - - docs/models/chatcompletioncreateparamsonlyenum.md - - docs/models/chatcompletioncreateparamsonlyunion.md - - docs/models/chatcompletioncreateparamsorderenum.md - - docs/models/chatcompletioncreateparamsorderunion.md - - docs/models/chatcompletioncreateparamspdf.md - - docs/models/chatcompletioncreateparamspdfengine.md - - docs/models/chatcompletioncreateparamspluginchainofthought.md - - docs/models/chatcompletioncreateparamspluginfileparser.md - - docs/models/chatcompletioncreateparamspluginmoderation.md - - docs/models/chatcompletioncreateparamspluginunion.md - - docs/models/chatcompletioncreateparamspluginweb.md - - docs/models/chatcompletioncreateparamsprompt.md - - docs/models/chatcompletioncreateparamsprovider.md - - docs/models/chatcompletioncreateparamsquantization.md - - docs/models/chatcompletioncreateparamsreasoning.md - - docs/models/chatcompletioncreateparamsreasoningeffort.md - - docs/models/chatcompletioncreateparamsrequest.md - - docs/models/chatcompletioncreateparamsresponseformatgrammar.md - - docs/models/chatcompletioncreateparamsresponseformatjsonobject.md - - docs/models/chatcompletioncreateparamsresponseformatjsonschema.md - - docs/models/chatcompletioncreateparamsresponseformatpython.md - - docs/models/chatcompletioncreateparamsresponseformattext.md - - docs/models/chatcompletioncreateparamsresponseformatunion.md - - docs/models/chatcompletioncreateparamssort.md - - docs/models/chatcompletioncreateparamsstop.md - - docs/models/chatcompletioncreateparamsstreamoptions.md - - docs/models/chatcompletioncreateparamstypegrammar.md - - docs/models/chatcompletioncreateparamstypejsonobject.md - - docs/models/chatcompletioncreateparamstypejsonschema.md - - docs/models/chatcompletioncreateparamstypepython.md - docs/models/chatcompletioncreateparamstypetext.md - docs/models/chatcompletionmessage.md - docs/models/chatcompletionmessageparam.md @@ -139,67 +100,50 @@ generatedFiles: - docs/models/chatcompletionusermessageparam.md - docs/models/chatcompletionusermessageparamcontent.md - docs/models/chatcompletionusermessageparamrole.md - - docs/models/chatstreamcompletioncreateparams.md - - docs/models/chatstreamcompletioncreateparamsaudio.md - - docs/models/chatstreamcompletioncreateparamscompletion.md - - docs/models/chatstreamcompletioncreateparamsdatacollection.md - - docs/models/chatstreamcompletioncreateparamseffort.md - - docs/models/chatstreamcompletioncreateparamsengine.md - - docs/models/chatstreamcompletioncreateparamsidchainofthought.md - - docs/models/chatstreamcompletioncreateparamsidfileparser.md - - docs/models/chatstreamcompletioncreateparamsidmoderation.md - - docs/models/chatstreamcompletioncreateparamsidweb.md - - docs/models/chatstreamcompletioncreateparamsignoreenum.md - - docs/models/chatstreamcompletioncreateparamsignoreunion.md - - docs/models/chatstreamcompletioncreateparamsimage.md - - docs/models/chatstreamcompletioncreateparamsjsonschema.md - - docs/models/chatstreamcompletioncreateparamsmaxprice.md - - docs/models/chatstreamcompletioncreateparamsonlyenum.md - - docs/models/chatstreamcompletioncreateparamsonlyunion.md - - docs/models/chatstreamcompletioncreateparamsorderenum.md - - docs/models/chatstreamcompletioncreateparamsorderunion.md - - docs/models/chatstreamcompletioncreateparamspdf.md - - docs/models/chatstreamcompletioncreateparamspdfengine.md - - docs/models/chatstreamcompletioncreateparamspluginchainofthought.md - - docs/models/chatstreamcompletioncreateparamspluginfileparser.md - - docs/models/chatstreamcompletioncreateparamspluginmoderation.md - - docs/models/chatstreamcompletioncreateparamspluginunion.md - - docs/models/chatstreamcompletioncreateparamspluginweb.md - - docs/models/chatstreamcompletioncreateparamsprompt.md - - docs/models/chatstreamcompletioncreateparamsprovider.md - - docs/models/chatstreamcompletioncreateparamsquantization.md - - docs/models/chatstreamcompletioncreateparamsreasoning.md - - docs/models/chatstreamcompletioncreateparamsreasoningeffort.md - - docs/models/chatstreamcompletioncreateparamsrequest.md - - docs/models/chatstreamcompletioncreateparamsresponseformatgrammar.md - - docs/models/chatstreamcompletioncreateparamsresponseformatjsonobject.md - - docs/models/chatstreamcompletioncreateparamsresponseformatjsonschema.md - - docs/models/chatstreamcompletioncreateparamsresponseformatpython.md - - docs/models/chatstreamcompletioncreateparamsresponseformattext.md - - docs/models/chatstreamcompletioncreateparamsresponseformatunion.md - - docs/models/chatstreamcompletioncreateparamssort.md - - docs/models/chatstreamcompletioncreateparamsstop.md - - docs/models/chatstreamcompletioncreateparamsstreamoptions.md - - docs/models/chatstreamcompletioncreateparamstypegrammar.md - - docs/models/chatstreamcompletioncreateparamstypejsonobject.md - - docs/models/chatstreamcompletioncreateparamstypejsonschema.md - - docs/models/chatstreamcompletioncreateparamstypepython.md - - docs/models/chatstreamcompletioncreateparamstypetext.md + - docs/models/completion.md - docs/models/completiontokensdetails.md - docs/models/completionusage.md - docs/models/contentimageurl.md - docs/models/contenttext.md - docs/models/contenttypeimageurl.md - docs/models/contenttypetext.md + - docs/models/createchatcompletionresponse.md + - docs/models/datacollection.md - docs/models/detail.md + - docs/models/effort.md + - docs/models/engine.md - docs/models/error.md - docs/models/file.md - docs/models/fileannotationdetail.md - docs/models/fileannotationdetailcontentunion.md - docs/models/fileannotationdetailimageurl.md + - docs/models/idchainofthought.md + - docs/models/idfileparser.md + - docs/models/idmoderation.md + - docs/models/idweb.md + - docs/models/ignore.md + - docs/models/ignoreenum.md + - docs/models/image.md - docs/models/inputaudio.md + - docs/models/jsonschema.md + - docs/models/maxprice.md + - docs/models/only.md + - docs/models/onlyenum.md + - docs/models/order.md + - docs/models/orderenum.md - docs/models/parameters.md + - docs/models/pdf.md + - docs/models/pdfengine.md + - docs/models/plugin.md + - docs/models/pluginchainofthought.md + - docs/models/pluginfileparser.md + - docs/models/pluginmoderation.md + - docs/models/pluginweb.md + - docs/models/prompt.md - docs/models/prompttokensdetails.md + - docs/models/provider.md + - docs/models/quantization.md + - docs/models/reasoning.md - docs/models/reasoningdetail.md - docs/models/reasoningdetailencrypted.md - docs/models/reasoningdetailencryptedformat.md @@ -210,11 +154,25 @@ generatedFiles: - docs/models/reasoningdetailtext.md - docs/models/reasoningdetailtextformat.md - docs/models/reasoningdetailtexttype.md + - docs/models/reasoningeffort.md + - docs/models/request.md + - docs/models/responseformat.md + - docs/models/responseformatgrammar.md + - docs/models/responseformatjsonobject.md + - docs/models/responseformatjsonschema.md - docs/models/responseformatjsonschemaschema.md + - docs/models/responseformatpython.md + - docs/models/responseformattext.md - docs/models/security.md - - docs/models/streamchatcompletionresponsebody.md + - docs/models/sort.md + - docs/models/stop.md + - docs/models/streamoptions.md - docs/models/toplogprob.md - docs/models/typefile.md + - docs/models/typegrammar.md + - docs/models/typejsonobject.md + - docs/models/typejsonschema.md + - docs/models/typepython.md - docs/models/urlcitation.md - docs/models/urlcitationannotationdetail.md - docs/models/urlcitationannotationdetailtype.md @@ -249,6 +207,7 @@ generatedFiles: - src/openrouter/models/chatcompletionchunkchoice.py - src/openrouter/models/chatcompletionchunkchoicedelta.py - src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py + - src/openrouter/models/chatcompletionchunkwrapper.py - src/openrouter/models/chatcompletioncontentpart.py - src/openrouter/models/chatcompletioncontentpartaudio.py - src/openrouter/models/chatcompletioncontentpartimage.py @@ -266,8 +225,8 @@ generatedFiles: - src/openrouter/models/chatcompletiontoolchoiceoption.py - src/openrouter/models/chatcompletiontoolmessageparam.py - src/openrouter/models/chatcompletionusermessageparam.py - - src/openrouter/models/chatstreamcompletioncreateparams.py - src/openrouter/models/completionusage.py + - src/openrouter/models/createchatcompletionop.py - src/openrouter/models/fileannotationdetail.py - src/openrouter/models/reasoningdetail.py - src/openrouter/models/reasoningdetailencrypted.py @@ -275,7 +234,6 @@ generatedFiles: - src/openrouter/models/reasoningdetailtext.py - src/openrouter/models/responseformatjsonschemaschema.py - src/openrouter/models/security.py - - src/openrouter/models/streamchatcompletionop.py - src/openrouter/models/urlcitationannotationdetail.py - src/openrouter/py.typed - src/openrouter/sdk.py @@ -308,9 +266,9 @@ examples: "200": application/json: {"id": "", "choices": [], "created": 6977.95, "model": "El Camino", "object": "chat.completion"} "400": - application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} + application/json: {"error": {"code": null, "message": ""}} "500": - application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} + application/json: {"error": {"code": null, "message": ""}} streamChatCompletion: speakeasy-default-stream-chat-completion: requestBody: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index dbc0051..5c5b519 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -25,18 +25,21 @@ generation: generateNewTests: true skipResponseBodyAssertions: false python: - version: 0.1.3 + version: 0.3.1 additionalDependencies: dev: {} main: {} + allowedRedefinedBuiltins: + - id + - object authors: - Speakeasy baseErrorName: OpenRouterError clientServerStatusCodesAsErrors: true defaultErrorName: OpenRouterDefaultError description: Python Client SDK Generated by Speakeasy. - enableCustomCodeRegions: false - enumFormat: enum + enableCustomCodeRegions: true + enumFormat: union envVarPrefix: OPENROUTER fixFlags: responseRequiredSep2024: true diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 3f27afd..1b3dc5d 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -17,7 +17,7 @@ servers: default: openrouter.ai description: Production server security: - - BearerAuth: [] + - ApiKey: [] tags: - name: Chat description: Chat completion operations @@ -26,11 +26,17 @@ externalDocs: url: https://openrouter.ai/docs components: securitySchemes: - BearerAuth: + ApiKey: type: http scheme: bearer description: API key as bearer token in Authorization header schemas: + ChatCompletionChunkWrapper: + type: object + required: [data] + properties: + data: + $ref: '#/components/schemas/ChatCompletionChunk' ChatCompletionMessageToolCall: type: object properties: @@ -450,7 +456,7 @@ components: type: object properties: code: - type: string + type: number nullable: true message: type: string @@ -462,8 +468,6 @@ components: required: - code - message - - param - - type description: Error object structure required: - error @@ -1057,7 +1061,7 @@ components: type: string description: Unique user identifier models: - x-speakeasy-name-override: models_llm + x-speakeasy-name-override: model_list type: array nullable: true items: @@ -1082,15 +1086,17 @@ components: description: > Whether to allow backup providers to serve requests - - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider. + - true: (default) when the primary provider (or your custom providers in "order") is unavailable, use + the next best provider. - false: use only the primary/custom provider, and return the upstream error if it's unavailable. - require_parameters: type: boolean nullable: true description: >- - Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. + Whether to filter providers to only those that support the parameters you've provided. If this setting + is omitted or set to false, then providers will receive only the parameters they support, and ignore the + rest. data_collection: type: string nullable: true @@ -1098,12 +1104,12 @@ components: - deny - allow description: > - Data collection setting. If no available model provider meets the requirement, your request will return an error. + Data collection setting. If no available model provider meets the requirement, your request will return + an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data. - order: type: array nullable: true @@ -1191,7 +1197,9 @@ components: - Z.AI - type: string description: >- - An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. + An ordered list of provider slugs. The router will attempt to use the first provider in the subset of + this list that supports your requested model, and fall back to the next if it is unavailable. If no + providers are available, the request will fail with an error message. only: type: array nullable: true @@ -1279,7 +1287,8 @@ components: - Z.AI - type: string description: >- - List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. + List of provider slugs to allow. If provided, this list is merged with your account-wide allowed + provider settings for this request. ignore: type: array nullable: true @@ -1367,7 +1376,8 @@ components: - Z.AI - type: string description: >- - List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. + List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored + provider settings for this request. quantizations: type: array nullable: true @@ -1392,7 +1402,8 @@ components: - throughput - latency description: >- - The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. + The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing + is performed. max_price: type: object properties: @@ -1423,7 +1434,8 @@ components: - {} additionalProperties: false description: >- - The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. + The object specifying the maximum price you want to pay for this request. USD price per million tokens, + for prompt and completion. additionalProperties: false description: When multiple model providers are available, optionally indicate your routing preference. plugins: @@ -1486,22 +1498,13 @@ components: required: - messages description: Chat completion request parameters - ChatStreamCompletionCreateParams: - allOf: - - $ref: "#/components/schemas/ChatCompletionCreateParams" - - type: object - properties: - stream: - type: boolean - enum: - - true - default: true - description: Enable streaming response parameters: {} paths: /chat/completions: post: operationId: createChatCompletion + x-speakeasy-group: chat + x-speakeasy-name-override: complete summary: Create a chat completion description: Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. tags: @@ -1521,57 +1524,10 @@ paths: schema: $ref: '#/components/schemas/ChatCompletion' description: Non-streaming response when stream=false - '400': - description: Bad request - invalid parameters - content: - application/json: - schema: - $ref: '#/components/schemas/ChatCompletionError' - '401': - description: Unauthorized - invalid API key - content: - application/json: - schema: - $ref: '#/components/schemas/ChatCompletionError' - '429': - description: Too many requests - rate limit exceeded - content: - application/json: - schema: - $ref: '#/components/schemas/ChatCompletionError' - '500': - description: Internal server error - content: - application/json: - schema: - $ref: '#/components/schemas/ChatCompletionError' - x-speakeasy-name-override: complete - /chat/completions#stream: - post: - operationId: streamChatCompletion - summary: Create a chat completion - description: Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. - tags: - - Chat - requestBody: - description: Chat completion request parameters - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ChatStreamCompletionCreateParams' - responses: - '200': - description: Successful chat completion response - content: text/event-stream: x-speakeasy-sse-sentinel: '[DONE]' schema: - type: object - required: [data] - properties: - data: - $ref: '#/components/schemas/ChatCompletionChunk' + $ref: '#/components/schemas/ChatCompletionChunkWrapper' '400': description: Bad request - invalid parameters content: @@ -1596,4 +1552,3 @@ paths: application/json: schema: $ref: '#/components/schemas/ChatCompletionError' - x-speakeasy-name-override: completeStream diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 7d26e5f..d272702 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.606.2 +speakeasyVersion: 1.611.1 sources: OpenRouter Chat Completions API: sourceNamespace: open-router-chat-completions-api @@ -14,8 +14,6 @@ targets: sourceNamespace: open-router-chat-completions-api sourceRevisionDigest: sha256:30b19a8759608792fb4d27f6bf28d5982d7e2a8cf5b3faf34ba3507a62f9f106 sourceBlobDigest: sha256:454f1b880a0882a70f78eacccb2c33e3d9d19134a0738b0e21487984a7bf2e63 - codeSamplesNamespace: open-router-chat-completions-api-python-code-samples - codeSamplesRevisionDigest: sha256:9ce1951254983ff6edc533d67fea93254d9e0d124057ce826721a1449a9ba36c workflow: workflowVersion: 1.0.0 speakeasyVersion: latest @@ -23,9 +21,6 @@ workflow: OpenRouter Chat Completions API: inputs: - location: .speakeasy/OAS_files/chat-completions-openapi.yaml - overlays: - - location: .speakeasy/OAS_files/overlay.yaml - - location: .speakeasy/OAS_files/speakeasy-modifications-overlay.yaml output: .speakeasy/out.openapi.yaml registry: location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 4069f05..edac766 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -4,9 +4,6 @@ sources: OpenRouter Chat Completions API: inputs: - location: .speakeasy/OAS_files/chat-completions-openapi.yaml - overlays: - - location: .speakeasy/OAS_files/overlay.yaml - - location: .speakeasy/OAS_files/speakeasy-modifications-overlay.yaml output: .speakeasy/out.openapi.yaml registry: location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api diff --git a/README-PYPI.md b/README-PYPI.md index 6a6a3c0..0eaf719 100644 --- a/README-PYPI.md +++ b/README-PYPI.md @@ -125,23 +125,25 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u ```python # Synchronous Example -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ```
@@ -150,24 +152,26 @@ The same SDK client can also be used to make asynchronous requests by importing ```python # Asynchronous Example import asyncio -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os async def main(): async with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = await open_router.chat.complete_async(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + async with res as event_stream: + async for event in event_stream: + # handle event + print(event, flush=True) asyncio.run(main()) ``` @@ -180,29 +184,31 @@ asyncio.run(main()) This SDK supports the following security scheme globally: -| Name | Type | Scheme | Environment Variable | -| ------------- | ---- | ----------- | ------------------------ | -| `bearer_auth` | http | HTTP Bearer | `OPENROUTER_BEARER_AUTH` | +| Name | Type | Scheme | Environment Variable | +| --------- | ---- | ----------- | -------------------- | +| `api_key` | http | HTTP Bearer | `OPENROUTER_API_KEY` | -To authenticate with the API the `bearer_auth` parameter must be set when initializing the SDK client instance. For example: +To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -216,7 +222,6 @@ with OpenRouter( ### [chat](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/docs/sdks/chat/README.md) * [complete](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/docs/sdks/chat/README.md#complete) - Create a chat completion -* [complete_stream](https://github.com/speakeasy-sdks/openrouter-python-sdk/blob/master/docs/sdks/chat/README.md#complete_stream) - Create a chat completion @@ -235,20 +240,20 @@ The stream is also a [Context Manager][context-manager] and can be used with the underlying connection when the context is exited. ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: - res = open_router.chat.complete_stream(messages=[ + res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, - ], stream=True, temperature=1, top_p=1) + ], stream=False, temperature=1, top_p=1) with res as event_stream: for event in event_stream: @@ -269,49 +274,53 @@ Some of the endpoints in this SDK support retries. If you use the SDK without an To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter from openrouter.utils import BackoffStrategy, RetryConfig import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1, RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False)) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter from openrouter.utils import BackoffStrategy, RetryConfig import os with OpenRouter( retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False), - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -332,25 +341,27 @@ with OpenRouter( ### Example ```python -from openrouter import OpenRouter, errors, models +from openrouter import OpenRouter, errors import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = None try: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) except errors.OpenRouterError as e: @@ -401,24 +412,26 @@ The default server `https://{provider_url}/api/v1` contains variables and is set #### Example ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( provider_url="https://ruddy-guacamole.info/" - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -426,24 +439,26 @@ with OpenRouter( The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( server_url="https://openrouter.ai/api/v1", - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -542,7 +557,7 @@ import os def main(): with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: # Rest of application here... @@ -551,7 +566,7 @@ def main(): async def amain(): async with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: # Rest of application here... ``` diff --git a/README.md b/README.md index a005fd9..4bdfdbe 100644 --- a/README.md +++ b/README.md @@ -125,23 +125,25 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u ```python # Synchronous Example -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ```
@@ -150,24 +152,26 @@ The same SDK client can also be used to make asynchronous requests by importing ```python # Asynchronous Example import asyncio -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os async def main(): async with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = await open_router.chat.complete_async(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + async with res as event_stream: + async for event in event_stream: + # handle event + print(event, flush=True) asyncio.run(main()) ``` @@ -180,29 +184,31 @@ asyncio.run(main()) This SDK supports the following security scheme globally: -| Name | Type | Scheme | Environment Variable | -| ------------- | ---- | ----------- | ------------------------ | -| `bearer_auth` | http | HTTP Bearer | `OPENROUTER_BEARER_AUTH` | +| Name | Type | Scheme | Environment Variable | +| --------- | ---- | ----------- | -------------------- | +| `api_key` | http | HTTP Bearer | `OPENROUTER_API_KEY` | -To authenticate with the API the `bearer_auth` parameter must be set when initializing the SDK client instance. For example: +To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -216,7 +222,6 @@ with OpenRouter( ### [chat](docs/sdks/chat/README.md) * [complete](docs/sdks/chat/README.md#complete) - Create a chat completion -* [complete_stream](docs/sdks/chat/README.md#complete_stream) - Create a chat completion @@ -235,20 +240,20 @@ The stream is also a [Context Manager][context-manager] and can be used with the underlying connection when the context is exited. ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: - res = open_router.chat.complete_stream(messages=[ + res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, - ], stream=True, temperature=1, top_p=1) + ], stream=False, temperature=1, top_p=1) with res as event_stream: for event in event_stream: @@ -269,49 +274,53 @@ Some of the endpoints in this SDK support retries. If you use the SDK without an To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter from openrouter.utils import BackoffStrategy, RetryConfig import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1, RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False)) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter from openrouter.utils import BackoffStrategy, RetryConfig import os with OpenRouter( retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False), - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -332,25 +341,27 @@ with OpenRouter( ### Example ```python -from openrouter import OpenRouter, errors, models +from openrouter import OpenRouter, errors import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = None try: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) except errors.OpenRouterError as e: @@ -401,24 +412,26 @@ The default server `https://{provider_url}/api/v1` contains variables and is set #### Example ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( provider_url="https://ruddy-guacamole.info/" - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -426,24 +439,26 @@ with OpenRouter( The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( server_url="https://openrouter.ai/api/v1", - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ``` @@ -542,7 +557,7 @@ import os def main(): with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: # Rest of application here... @@ -551,7 +566,7 @@ def main(): async def amain(): async with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: # Rest of application here... ``` diff --git a/USAGE.md b/USAGE.md index 4df956d..3eba06a 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1,23 +1,25 @@ ```python # Synchronous Example -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + with res as event_stream: + for event in event_stream: + # handle event + print(event, flush=True) ```
@@ -26,24 +28,26 @@ The same SDK client can also be used to make asynchronous requests by importing ```python # Asynchronous Example import asyncio -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os async def main(): async with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = await open_router.chat.complete_async(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) + async with res as event_stream: + async for event in event_stream: + # handle event + print(event, flush=True) asyncio.run(main()) ``` diff --git a/docs/models/chatcompletioncreateparamsimage.md b/docs/models/audio.md similarity index 85% rename from docs/models/chatcompletioncreateparamsimage.md rename to docs/models/audio.md index c61f30d..8c0f701 100644 --- a/docs/models/chatcompletioncreateparamsimage.md +++ b/docs/models/audio.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsImage +# Audio ## Supported Types diff --git a/docs/models/streamchatcompletionresponsebody.md b/docs/models/chatcompletionchunkwrapper.md similarity index 91% rename from docs/models/streamchatcompletionresponsebody.md rename to docs/models/chatcompletionchunkwrapper.md index a0cca72..7d111d0 100644 --- a/docs/models/streamchatcompletionresponsebody.md +++ b/docs/models/chatcompletionchunkwrapper.md @@ -1,6 +1,4 @@ -# StreamChatCompletionResponseBody - -Successful chat completion response +# ChatCompletionChunkWrapper ## Fields diff --git a/docs/models/chatcompletioncreateparams.md b/docs/models/chatcompletioncreateparams.md index e06608e..aa2576a 100644 --- a/docs/models/chatcompletioncreateparams.md +++ b/docs/models/chatcompletioncreateparams.md @@ -5,30 +5,30 @@ Chat completion request parameters ## Fields -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `messages` | List[[models.ChatCompletionMessageParam](../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | -| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | -| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | -| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | -| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | -| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | -| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | -| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | -| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | -| `reasoning` | [OptionalNullable[models.ChatCompletionCreateParamsReasoning]](../models/chatcompletioncreateparamsreasoning.md) | :heavy_minus_sign: | Reasoning configuration | | -| `response_format` | [Optional[models.ChatCompletionCreateParamsResponseFormatUnion]](../models/chatcompletioncreateparamsresponseformatunion.md) | :heavy_minus_sign: | Response format configuration | | -| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | -| `stop` | [OptionalNullable[models.ChatCompletionCreateParamsStop]](../models/chatcompletioncreateparamsstop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | -| `stream` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable streaming response | | -| `stream_options` | [OptionalNullable[models.ChatCompletionCreateParamsStreamOptions]](../models/chatcompletioncreateparamsstreamoptions.md) | :heavy_minus_sign: | N/A | | -| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | -| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | -| `tools` | List[[models.ChatCompletionTool](../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | -| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | -| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | -| `models_llm` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | -| `reasoning_effort` | [OptionalNullable[models.ChatCompletionCreateParamsReasoningEffort]](../models/chatcompletioncreateparamsreasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | -| `provider` | [OptionalNullable[models.ChatCompletionCreateParamsProvider]](../models/chatcompletioncreateparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | -| `plugins` | List[[models.ChatCompletionCreateParamsPluginUnion](../models/chatcompletioncreateparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `messages` | List[[models.ChatCompletionMessageParam](../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | +| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | +| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | +| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | +| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | +| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | +| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | +| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | +| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | +| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | +| `reasoning` | [OptionalNullable[models.Reasoning]](../models/reasoning.md) | :heavy_minus_sign: | Reasoning configuration | | +| `response_format` | [Optional[models.ResponseFormat]](../models/responseformat.md) | :heavy_minus_sign: | Response format configuration | | +| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | +| `stop` | [OptionalNullable[models.Stop]](../models/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | +| `stream` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable streaming response | | +| `stream_options` | [OptionalNullable[models.StreamOptions]](../models/streamoptions.md) | :heavy_minus_sign: | N/A | | +| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | +| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | +| `tools` | List[[models.ChatCompletionTool](../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | +| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | +| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | +| `model_list` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | +| `reasoning_effort` | [OptionalNullable[models.ReasoningEffort]](../models/reasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | +| `provider` | [OptionalNullable[models.Provider]](../models/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | +| `plugins` | List[[models.Plugin](../models/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamscompletion.md b/docs/models/chatcompletioncreateparamscompletion.md deleted file mode 100644 index 0718ff0..0000000 --- a/docs/models/chatcompletioncreateparamscompletion.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatCompletionCreateParamsCompletion - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatcompletioncreateparamsignoreunion.md b/docs/models/chatcompletioncreateparamsignoreunion.md deleted file mode 100644 index 96cc708..0000000 --- a/docs/models/chatcompletioncreateparamsignoreunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatCompletionCreateParamsIgnoreUnion - - -## Supported Types - -### `models.ChatCompletionCreateParamsIgnoreEnum` - -```python -value: models.ChatCompletionCreateParamsIgnoreEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatcompletioncreateparamsmaxprice.md b/docs/models/chatcompletioncreateparamsmaxprice.md deleted file mode 100644 index 21a9f9d..0000000 --- a/docs/models/chatcompletioncreateparamsmaxprice.md +++ /dev/null @@ -1,14 +0,0 @@ -# ChatCompletionCreateParamsMaxPrice - -The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| `prompt` | [Optional[models.ChatCompletionCreateParamsPrompt]](../models/chatcompletioncreateparamsprompt.md) | :heavy_minus_sign: | N/A | -| `completion` | [Optional[models.ChatCompletionCreateParamsCompletion]](../models/chatcompletioncreateparamscompletion.md) | :heavy_minus_sign: | N/A | -| `image` | [Optional[models.ChatCompletionCreateParamsImage]](../models/chatcompletioncreateparamsimage.md) | :heavy_minus_sign: | N/A | -| `audio` | [Optional[models.ChatCompletionCreateParamsAudio]](../models/chatcompletioncreateparamsaudio.md) | :heavy_minus_sign: | N/A | -| `request` | [Optional[models.ChatCompletionCreateParamsRequest]](../models/chatcompletioncreateparamsrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsonlyunion.md b/docs/models/chatcompletioncreateparamsonlyunion.md deleted file mode 100644 index 190e394..0000000 --- a/docs/models/chatcompletioncreateparamsonlyunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatCompletionCreateParamsOnlyUnion - - -## Supported Types - -### `models.ChatCompletionCreateParamsOnlyEnum` - -```python -value: models.ChatCompletionCreateParamsOnlyEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatcompletioncreateparamsorderunion.md b/docs/models/chatcompletioncreateparamsorderunion.md deleted file mode 100644 index 5b1429e..0000000 --- a/docs/models/chatcompletioncreateparamsorderunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatCompletionCreateParamsOrderUnion - - -## Supported Types - -### `models.ChatCompletionCreateParamsOrderEnum` - -```python -value: models.ChatCompletionCreateParamsOrderEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatcompletioncreateparamspdf.md b/docs/models/chatcompletioncreateparamspdf.md deleted file mode 100644 index e95b198..0000000 --- a/docs/models/chatcompletioncreateparamspdf.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatCompletionCreateParamsPdf - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| `engine` | [Optional[models.ChatCompletionCreateParamsPdfEngine]](../models/chatcompletioncreateparamspdfengine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspluginchainofthought.md b/docs/models/chatcompletioncreateparamspluginchainofthought.md deleted file mode 100644 index 98d012b..0000000 --- a/docs/models/chatcompletioncreateparamspluginchainofthought.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatCompletionCreateParamsPluginChainOfThought - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | -| `id` | [models.ChatCompletionCreateParamsIDChainOfThought](../models/chatcompletioncreateparamsidchainofthought.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspluginfileparser.md b/docs/models/chatcompletioncreateparamspluginfileparser.md deleted file mode 100644 index 6d060a6..0000000 --- a/docs/models/chatcompletioncreateparamspluginfileparser.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatCompletionCreateParamsPluginFileParser - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatCompletionCreateParamsIDFileParser](../models/chatcompletioncreateparamsidfileparser.md) | :heavy_check_mark: | N/A | -| `max_files` | *Optional[float]* | :heavy_minus_sign: | N/A | -| `pdf` | [Optional[models.ChatCompletionCreateParamsPdf]](../models/chatcompletioncreateparamspdf.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspluginmoderation.md b/docs/models/chatcompletioncreateparamspluginmoderation.md deleted file mode 100644 index a213ea0..0000000 --- a/docs/models/chatcompletioncreateparamspluginmoderation.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatCompletionCreateParamsPluginModeration - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatCompletionCreateParamsIDModeration](../models/chatcompletioncreateparamsidmoderation.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspluginunion.md b/docs/models/chatcompletioncreateparamspluginunion.md deleted file mode 100644 index f326c21..0000000 --- a/docs/models/chatcompletioncreateparamspluginunion.md +++ /dev/null @@ -1,29 +0,0 @@ -# ChatCompletionCreateParamsPluginUnion - - -## Supported Types - -### `models.ChatCompletionCreateParamsPluginModeration` - -```python -value: models.ChatCompletionCreateParamsPluginModeration = /* values here */ -``` - -### `models.ChatCompletionCreateParamsPluginWeb` - -```python -value: models.ChatCompletionCreateParamsPluginWeb = /* values here */ -``` - -### `models.ChatCompletionCreateParamsPluginChainOfThought` - -```python -value: models.ChatCompletionCreateParamsPluginChainOfThought = /* values here */ -``` - -### `models.ChatCompletionCreateParamsPluginFileParser` - -```python -value: models.ChatCompletionCreateParamsPluginFileParser = /* values here */ -``` - diff --git a/docs/models/chatcompletioncreateparamspluginweb.md b/docs/models/chatcompletioncreateparamspluginweb.md deleted file mode 100644 index 9796a17..0000000 --- a/docs/models/chatcompletioncreateparamspluginweb.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatCompletionCreateParamsPluginWeb - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatCompletionCreateParamsIDWeb](../models/chatcompletioncreateparamsidweb.md) | :heavy_check_mark: | N/A | -| `max_results` | *Optional[float]* | :heavy_minus_sign: | N/A | -| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | -| `engine` | [Optional[models.ChatCompletionCreateParamsEngine]](../models/chatcompletioncreateparamsengine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsreasoning.md b/docs/models/chatcompletioncreateparamsreasoning.md deleted file mode 100644 index d2374f7..0000000 --- a/docs/models/chatcompletioncreateparamsreasoning.md +++ /dev/null @@ -1,13 +0,0 @@ -# ChatCompletionCreateParamsReasoning - -Reasoning configuration - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Enables reasoning with default settings. Only work for some models. | -| `effort` | [OptionalNullable[models.ChatCompletionCreateParamsEffort]](../models/chatcompletioncreateparamseffort.md) | :heavy_minus_sign: | OpenAI-style reasoning effort setting | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | non-OpenAI-style reasoning effort setting | -| `exclude` | *Optional[bool]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatgrammar.md b/docs/models/chatcompletioncreateparamsresponseformatgrammar.md deleted file mode 100644 index 4b4275a..0000000 --- a/docs/models/chatcompletioncreateparamsresponseformatgrammar.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatCompletionCreateParamsResponseFormatGrammar - -Custom grammar response format - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatCompletionCreateParamsTypeGrammar](../models/chatcompletioncreateparamstypegrammar.md) | :heavy_check_mark: | N/A | -| `grammar` | *str* | :heavy_check_mark: | Custom grammar for text generation | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatjsonobject.md b/docs/models/chatcompletioncreateparamsresponseformatjsonobject.md deleted file mode 100644 index 0de86bb..0000000 --- a/docs/models/chatcompletioncreateparamsresponseformatjsonobject.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatCompletionCreateParamsResponseFormatJSONObject - -JSON object response format - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatCompletionCreateParamsTypeJSONObject](../models/chatcompletioncreateparamstypejsonobject.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatjsonschema.md b/docs/models/chatcompletioncreateparamsresponseformatjsonschema.md deleted file mode 100644 index 9bd34e0..0000000 --- a/docs/models/chatcompletioncreateparamsresponseformatjsonschema.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatCompletionCreateParamsResponseFormatJSONSchema - -JSON Schema response format for structured outputs - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatCompletionCreateParamsTypeJSONSchema](../models/chatcompletioncreateparamstypejsonschema.md) | :heavy_check_mark: | N/A | -| `json_schema` | [models.ChatCompletionCreateParamsJSONSchema](../models/chatcompletioncreateparamsjsonschema.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatpython.md b/docs/models/chatcompletioncreateparamsresponseformatpython.md deleted file mode 100644 index 770b61a..0000000 --- a/docs/models/chatcompletioncreateparamsresponseformatpython.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatCompletionCreateParamsResponseFormatPython - -Python code response format - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | -| `type` | [models.ChatCompletionCreateParamsTypePython](../models/chatcompletioncreateparamstypepython.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatunion.md b/docs/models/chatcompletioncreateparamsresponseformatunion.md deleted file mode 100644 index 5b66aef..0000000 --- a/docs/models/chatcompletioncreateparamsresponseformatunion.md +++ /dev/null @@ -1,37 +0,0 @@ -# ChatCompletionCreateParamsResponseFormatUnion - -Response format configuration - - -## Supported Types - -### `models.ChatCompletionCreateParamsResponseFormatText` - -```python -value: models.ChatCompletionCreateParamsResponseFormatText = /* values here */ -``` - -### `models.ChatCompletionCreateParamsResponseFormatJSONObject` - -```python -value: models.ChatCompletionCreateParamsResponseFormatJSONObject = /* values here */ -``` - -### `models.ChatCompletionCreateParamsResponseFormatJSONSchema` - -```python -value: models.ChatCompletionCreateParamsResponseFormatJSONSchema = /* values here */ -``` - -### `models.ChatCompletionCreateParamsResponseFormatGrammar` - -```python -value: models.ChatCompletionCreateParamsResponseFormatGrammar = /* values here */ -``` - -### `models.ChatCompletionCreateParamsResponseFormatPython` - -```python -value: models.ChatCompletionCreateParamsResponseFormatPython = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparams.md b/docs/models/chatstreamcompletioncreateparams.md deleted file mode 100644 index 951d638..0000000 --- a/docs/models/chatstreamcompletioncreateparams.md +++ /dev/null @@ -1,34 +0,0 @@ -# ChatStreamCompletionCreateParams - -Chat completion request parameters - - -## Fields - -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| `messages` | List[[models.ChatCompletionMessageParam](../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | -| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | -| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | -| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | -| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | -| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | -| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | -| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | -| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | -| `reasoning` | [OptionalNullable[models.ChatStreamCompletionCreateParamsReasoning]](../models/chatstreamcompletioncreateparamsreasoning.md) | :heavy_minus_sign: | Reasoning configuration | | -| `response_format` | [Optional[models.ChatStreamCompletionCreateParamsResponseFormatUnion]](../models/chatstreamcompletioncreateparamsresponseformatunion.md) | :heavy_minus_sign: | Response format configuration | | -| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | -| `stop` | [OptionalNullable[models.ChatStreamCompletionCreateParamsStop]](../models/chatstreamcompletioncreateparamsstop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | -| `stream` | *Optional[bool]* | :heavy_minus_sign: | Enable streaming response | | -| `stream_options` | [OptionalNullable[models.ChatStreamCompletionCreateParamsStreamOptions]](../models/chatstreamcompletioncreateparamsstreamoptions.md) | :heavy_minus_sign: | N/A | | -| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | -| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | -| `tools` | List[[models.ChatCompletionTool](../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | -| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | -| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | -| `models_llm` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | -| `reasoning_effort` | [OptionalNullable[models.ChatStreamCompletionCreateParamsReasoningEffort]](../models/chatstreamcompletioncreateparamsreasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | -| `provider` | [OptionalNullable[models.ChatStreamCompletionCreateParamsProvider]](../models/chatstreamcompletioncreateparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | -| `plugins` | List[[models.ChatStreamCompletionCreateParamsPluginUnion](../models/chatstreamcompletioncreateparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsaudio.md b/docs/models/chatstreamcompletioncreateparamsaudio.md deleted file mode 100644 index af8432b..0000000 --- a/docs/models/chatstreamcompletioncreateparamsaudio.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatStreamCompletionCreateParamsAudio - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamscompletion.md b/docs/models/chatstreamcompletioncreateparamscompletion.md deleted file mode 100644 index ce56e0b..0000000 --- a/docs/models/chatstreamcompletioncreateparamscompletion.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatStreamCompletionCreateParamsCompletion - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsdatacollection.md b/docs/models/chatstreamcompletioncreateparamsdatacollection.md deleted file mode 100644 index 9972e0c..0000000 --- a/docs/models/chatstreamcompletioncreateparamsdatacollection.md +++ /dev/null @@ -1,14 +0,0 @@ -# ChatStreamCompletionCreateParamsDataCollection - -Data collection setting. If no available model provider meets the requirement, your request will return an error. -- allow: (default) allow providers which store user data non-transiently and may train on it -- deny: use only providers which do not collect user data. - - - -## Values - -| Name | Value | -| ------- | ------- | -| `DENY` | deny | -| `ALLOW` | allow | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamseffort.md b/docs/models/chatstreamcompletioncreateparamseffort.md deleted file mode 100644 index 3a250fe..0000000 --- a/docs/models/chatstreamcompletioncreateparamseffort.md +++ /dev/null @@ -1,13 +0,0 @@ -# ChatStreamCompletionCreateParamsEffort - -OpenAI-style reasoning effort setting - - -## Values - -| Name | Value | -| --------- | --------- | -| `HIGH` | high | -| `MEDIUM` | medium | -| `LOW` | low | -| `MINIMAL` | minimal | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsengine.md b/docs/models/chatstreamcompletioncreateparamsengine.md deleted file mode 100644 index eab43e0..0000000 --- a/docs/models/chatstreamcompletioncreateparamsengine.md +++ /dev/null @@ -1,9 +0,0 @@ -# ChatStreamCompletionCreateParamsEngine - - -## Values - -| Name | Value | -| -------- | -------- | -| `NATIVE` | native | -| `EXA` | exa | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsidchainofthought.md b/docs/models/chatstreamcompletioncreateparamsidchainofthought.md deleted file mode 100644 index b27f206..0000000 --- a/docs/models/chatstreamcompletioncreateparamsidchainofthought.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsIDChainOfThought - - -## Values - -| Name | Value | -| ------------------ | ------------------ | -| `CHAIN_OF_THOUGHT` | chain-of-thought | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsidfileparser.md b/docs/models/chatstreamcompletioncreateparamsidfileparser.md deleted file mode 100644 index 1f968ce..0000000 --- a/docs/models/chatstreamcompletioncreateparamsidfileparser.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsIDFileParser - - -## Values - -| Name | Value | -| ------------- | ------------- | -| `FILE_PARSER` | file-parser | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsidmoderation.md b/docs/models/chatstreamcompletioncreateparamsidmoderation.md deleted file mode 100644 index 3d87f7f..0000000 --- a/docs/models/chatstreamcompletioncreateparamsidmoderation.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsIDModeration - - -## Values - -| Name | Value | -| ------------ | ------------ | -| `MODERATION` | moderation | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsidweb.md b/docs/models/chatstreamcompletioncreateparamsidweb.md deleted file mode 100644 index 19e697e..0000000 --- a/docs/models/chatstreamcompletioncreateparamsidweb.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsIDWeb - - -## Values - -| Name | Value | -| ----- | ----- | -| `WEB` | web | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsignoreenum.md b/docs/models/chatstreamcompletioncreateparamsignoreenum.md deleted file mode 100644 index e46f946..0000000 --- a/docs/models/chatstreamcompletioncreateparamsignoreenum.md +++ /dev/null @@ -1,85 +0,0 @@ -# ChatStreamCompletionCreateParamsIgnoreEnum - - -## Values - -| Name | Value | -| ------------------ | ------------------ | -| `ANY_SCALE` | AnyScale | -| `CENT_ML` | Cent-ML | -| `HUGGING_FACE` | HuggingFace | -| `HYPERBOLIC_2` | Hyperbolic 2 | -| `LEPTON` | Lepton | -| `LYNN_2` | Lynn 2 | -| `LYNN` | Lynn | -| `MANCER` | Mancer | -| `MODAL` | Modal | -| `OCTO_AI` | OctoAI | -| `RECURSAL` | Recursal | -| `REFLECTION` | Reflection | -| `REPLICATE` | Replicate | -| `SAMBA_NOVA_2` | SambaNova 2 | -| `SF_COMPUTE` | SF Compute | -| `TOGETHER_2` | Together 2 | -| `ONE_DOT_AI` | 01.AI | -| `AI21` | AI21 | -| `AION_LABS` | AionLabs | -| `ALIBABA` | Alibaba | -| `AMAZON_BEDROCK` | Amazon Bedrock | -| `ANTHROPIC` | Anthropic | -| `ATLAS_CLOUD` | AtlasCloud | -| `ATOMA` | Atoma | -| `AVIAN` | Avian | -| `AZURE` | Azure | -| `BASE_TEN` | BaseTen | -| `CEREBRAS` | Cerebras | -| `CHUTES` | Chutes | -| `CLOUDFLARE` | Cloudflare | -| `COHERE` | Cohere | -| `CROF_AI` | CrofAI | -| `CRUSOE` | Crusoe | -| `DEEP_INFRA` | DeepInfra | -| `DEEP_SEEK` | DeepSeek | -| `ENFER` | Enfer | -| `FEATHERLESS` | Featherless | -| `FIREWORKS` | Fireworks | -| `FRIENDLI` | Friendli | -| `GMI_CLOUD` | GMICloud | -| `GOOGLE` | Google | -| `GOOGLE_AI_STUDIO` | Google AI Studio | -| `GROQ` | Groq | -| `HYPERBOLIC` | Hyperbolic | -| `INCEPTION` | Inception | -| `INFERENCE_NET` | InferenceNet | -| `INFERMATIC` | Infermatic | -| `INFLECTION` | Inflection | -| `INO_CLOUD` | InoCloud | -| `KLUSTER` | Kluster | -| `LAMBDA` | Lambda | -| `LIQUID` | Liquid | -| `MANCER_2` | Mancer 2 | -| `META` | Meta | -| `MINIMAX` | Minimax | -| `MISTRAL` | Mistral | -| `MOONSHOT_AI` | Moonshot AI | -| `MORPH` | Morph | -| `N_COMPASS` | NCompass | -| `NEBIUS` | Nebius | -| `NEXT_BIT` | NextBit | -| `NINETEEN` | Nineteen | -| `NOVITA` | Novita | -| `OPEN_AI` | OpenAI | -| `OPEN_INFERENCE` | OpenInference | -| `PARASAIL` | Parasail | -| `PERPLEXITY` | Perplexity | -| `PHALA` | Phala | -| `SAMBA_NOVA` | SambaNova | -| `STEALTH` | Stealth | -| `SWITCHPOINT` | Switchpoint | -| `TARGON` | Targon | -| `TOGETHER` | Together | -| `UBICLOUD` | Ubicloud | -| `VENICE` | Venice | -| `WAND_B` | WandB | -| `X_AI` | xAI | -| `Z_AI` | Z.AI | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsignoreunion.md b/docs/models/chatstreamcompletioncreateparamsignoreunion.md deleted file mode 100644 index 46fc295..0000000 --- a/docs/models/chatstreamcompletioncreateparamsignoreunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatStreamCompletionCreateParamsIgnoreUnion - - -## Supported Types - -### `models.ChatStreamCompletionCreateParamsIgnoreEnum` - -```python -value: models.ChatStreamCompletionCreateParamsIgnoreEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsimage.md b/docs/models/chatstreamcompletioncreateparamsimage.md deleted file mode 100644 index 29e9b4b..0000000 --- a/docs/models/chatstreamcompletioncreateparamsimage.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatStreamCompletionCreateParamsImage - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsjsonschema.md b/docs/models/chatstreamcompletioncreateparamsjsonschema.md deleted file mode 100644 index 8a7dc08..0000000 --- a/docs/models/chatstreamcompletioncreateparamsjsonschema.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatStreamCompletionCreateParamsJSONSchema - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -| `name` | *str* | :heavy_check_mark: | Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) | -| `description` | *Optional[str]* | :heavy_minus_sign: | Schema description for the model | -| `schema_` | [Optional[models.ResponseFormatJSONSchemaSchema]](../models/responseformatjsonschemaschema.md) | :heavy_minus_sign: | The schema for the response format, described as a JSON Schema object | -| `strict` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable strict schema adherence | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsmaxprice.md b/docs/models/chatstreamcompletioncreateparamsmaxprice.md deleted file mode 100644 index a631f50..0000000 --- a/docs/models/chatstreamcompletioncreateparamsmaxprice.md +++ /dev/null @@ -1,14 +0,0 @@ -# ChatStreamCompletionCreateParamsMaxPrice - -The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -| `prompt` | [Optional[models.ChatStreamCompletionCreateParamsPrompt]](../models/chatstreamcompletioncreateparamsprompt.md) | :heavy_minus_sign: | N/A | -| `completion` | [Optional[models.ChatStreamCompletionCreateParamsCompletion]](../models/chatstreamcompletioncreateparamscompletion.md) | :heavy_minus_sign: | N/A | -| `image` | [Optional[models.ChatStreamCompletionCreateParamsImage]](../models/chatstreamcompletioncreateparamsimage.md) | :heavy_minus_sign: | N/A | -| `audio` | [Optional[models.ChatStreamCompletionCreateParamsAudio]](../models/chatstreamcompletioncreateparamsaudio.md) | :heavy_minus_sign: | N/A | -| `request` | [Optional[models.ChatStreamCompletionCreateParamsRequest]](../models/chatstreamcompletioncreateparamsrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsonlyenum.md b/docs/models/chatstreamcompletioncreateparamsonlyenum.md deleted file mode 100644 index e038932..0000000 --- a/docs/models/chatstreamcompletioncreateparamsonlyenum.md +++ /dev/null @@ -1,85 +0,0 @@ -# ChatStreamCompletionCreateParamsOnlyEnum - - -## Values - -| Name | Value | -| ------------------ | ------------------ | -| `ANY_SCALE` | AnyScale | -| `CENT_ML` | Cent-ML | -| `HUGGING_FACE` | HuggingFace | -| `HYPERBOLIC_2` | Hyperbolic 2 | -| `LEPTON` | Lepton | -| `LYNN_2` | Lynn 2 | -| `LYNN` | Lynn | -| `MANCER` | Mancer | -| `MODAL` | Modal | -| `OCTO_AI` | OctoAI | -| `RECURSAL` | Recursal | -| `REFLECTION` | Reflection | -| `REPLICATE` | Replicate | -| `SAMBA_NOVA_2` | SambaNova 2 | -| `SF_COMPUTE` | SF Compute | -| `TOGETHER_2` | Together 2 | -| `ONE_DOT_AI` | 01.AI | -| `AI21` | AI21 | -| `AION_LABS` | AionLabs | -| `ALIBABA` | Alibaba | -| `AMAZON_BEDROCK` | Amazon Bedrock | -| `ANTHROPIC` | Anthropic | -| `ATLAS_CLOUD` | AtlasCloud | -| `ATOMA` | Atoma | -| `AVIAN` | Avian | -| `AZURE` | Azure | -| `BASE_TEN` | BaseTen | -| `CEREBRAS` | Cerebras | -| `CHUTES` | Chutes | -| `CLOUDFLARE` | Cloudflare | -| `COHERE` | Cohere | -| `CROF_AI` | CrofAI | -| `CRUSOE` | Crusoe | -| `DEEP_INFRA` | DeepInfra | -| `DEEP_SEEK` | DeepSeek | -| `ENFER` | Enfer | -| `FEATHERLESS` | Featherless | -| `FIREWORKS` | Fireworks | -| `FRIENDLI` | Friendli | -| `GMI_CLOUD` | GMICloud | -| `GOOGLE` | Google | -| `GOOGLE_AI_STUDIO` | Google AI Studio | -| `GROQ` | Groq | -| `HYPERBOLIC` | Hyperbolic | -| `INCEPTION` | Inception | -| `INFERENCE_NET` | InferenceNet | -| `INFERMATIC` | Infermatic | -| `INFLECTION` | Inflection | -| `INO_CLOUD` | InoCloud | -| `KLUSTER` | Kluster | -| `LAMBDA` | Lambda | -| `LIQUID` | Liquid | -| `MANCER_2` | Mancer 2 | -| `META` | Meta | -| `MINIMAX` | Minimax | -| `MISTRAL` | Mistral | -| `MOONSHOT_AI` | Moonshot AI | -| `MORPH` | Morph | -| `N_COMPASS` | NCompass | -| `NEBIUS` | Nebius | -| `NEXT_BIT` | NextBit | -| `NINETEEN` | Nineteen | -| `NOVITA` | Novita | -| `OPEN_AI` | OpenAI | -| `OPEN_INFERENCE` | OpenInference | -| `PARASAIL` | Parasail | -| `PERPLEXITY` | Perplexity | -| `PHALA` | Phala | -| `SAMBA_NOVA` | SambaNova | -| `STEALTH` | Stealth | -| `SWITCHPOINT` | Switchpoint | -| `TARGON` | Targon | -| `TOGETHER` | Together | -| `UBICLOUD` | Ubicloud | -| `VENICE` | Venice | -| `WAND_B` | WandB | -| `X_AI` | xAI | -| `Z_AI` | Z.AI | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsonlyunion.md b/docs/models/chatstreamcompletioncreateparamsonlyunion.md deleted file mode 100644 index 18f6d13..0000000 --- a/docs/models/chatstreamcompletioncreateparamsonlyunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatStreamCompletionCreateParamsOnlyUnion - - -## Supported Types - -### `models.ChatStreamCompletionCreateParamsOnlyEnum` - -```python -value: models.ChatStreamCompletionCreateParamsOnlyEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsorderenum.md b/docs/models/chatstreamcompletioncreateparamsorderenum.md deleted file mode 100644 index 2b1105c..0000000 --- a/docs/models/chatstreamcompletioncreateparamsorderenum.md +++ /dev/null @@ -1,85 +0,0 @@ -# ChatStreamCompletionCreateParamsOrderEnum - - -## Values - -| Name | Value | -| ------------------ | ------------------ | -| `ANY_SCALE` | AnyScale | -| `CENT_ML` | Cent-ML | -| `HUGGING_FACE` | HuggingFace | -| `HYPERBOLIC_2` | Hyperbolic 2 | -| `LEPTON` | Lepton | -| `LYNN_2` | Lynn 2 | -| `LYNN` | Lynn | -| `MANCER` | Mancer | -| `MODAL` | Modal | -| `OCTO_AI` | OctoAI | -| `RECURSAL` | Recursal | -| `REFLECTION` | Reflection | -| `REPLICATE` | Replicate | -| `SAMBA_NOVA_2` | SambaNova 2 | -| `SF_COMPUTE` | SF Compute | -| `TOGETHER_2` | Together 2 | -| `ONE_DOT_AI` | 01.AI | -| `AI21` | AI21 | -| `AION_LABS` | AionLabs | -| `ALIBABA` | Alibaba | -| `AMAZON_BEDROCK` | Amazon Bedrock | -| `ANTHROPIC` | Anthropic | -| `ATLAS_CLOUD` | AtlasCloud | -| `ATOMA` | Atoma | -| `AVIAN` | Avian | -| `AZURE` | Azure | -| `BASE_TEN` | BaseTen | -| `CEREBRAS` | Cerebras | -| `CHUTES` | Chutes | -| `CLOUDFLARE` | Cloudflare | -| `COHERE` | Cohere | -| `CROF_AI` | CrofAI | -| `CRUSOE` | Crusoe | -| `DEEP_INFRA` | DeepInfra | -| `DEEP_SEEK` | DeepSeek | -| `ENFER` | Enfer | -| `FEATHERLESS` | Featherless | -| `FIREWORKS` | Fireworks | -| `FRIENDLI` | Friendli | -| `GMI_CLOUD` | GMICloud | -| `GOOGLE` | Google | -| `GOOGLE_AI_STUDIO` | Google AI Studio | -| `GROQ` | Groq | -| `HYPERBOLIC` | Hyperbolic | -| `INCEPTION` | Inception | -| `INFERENCE_NET` | InferenceNet | -| `INFERMATIC` | Infermatic | -| `INFLECTION` | Inflection | -| `INO_CLOUD` | InoCloud | -| `KLUSTER` | Kluster | -| `LAMBDA` | Lambda | -| `LIQUID` | Liquid | -| `MANCER_2` | Mancer 2 | -| `META` | Meta | -| `MINIMAX` | Minimax | -| `MISTRAL` | Mistral | -| `MOONSHOT_AI` | Moonshot AI | -| `MORPH` | Morph | -| `N_COMPASS` | NCompass | -| `NEBIUS` | Nebius | -| `NEXT_BIT` | NextBit | -| `NINETEEN` | Nineteen | -| `NOVITA` | Novita | -| `OPEN_AI` | OpenAI | -| `OPEN_INFERENCE` | OpenInference | -| `PARASAIL` | Parasail | -| `PERPLEXITY` | Perplexity | -| `PHALA` | Phala | -| `SAMBA_NOVA` | SambaNova | -| `STEALTH` | Stealth | -| `SWITCHPOINT` | Switchpoint | -| `TARGON` | Targon | -| `TOGETHER` | Together | -| `UBICLOUD` | Ubicloud | -| `VENICE` | Venice | -| `WAND_B` | WandB | -| `X_AI` | xAI | -| `Z_AI` | Z.AI | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsorderunion.md b/docs/models/chatstreamcompletioncreateparamsorderunion.md deleted file mode 100644 index ff57c40..0000000 --- a/docs/models/chatstreamcompletioncreateparamsorderunion.md +++ /dev/null @@ -1,17 +0,0 @@ -# ChatStreamCompletionCreateParamsOrderUnion - - -## Supported Types - -### `models.ChatStreamCompletionCreateParamsOrderEnum` - -```python -value: models.ChatStreamCompletionCreateParamsOrderEnum = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamspdf.md b/docs/models/chatstreamcompletioncreateparamspdf.md deleted file mode 100644 index 60c51a2..0000000 --- a/docs/models/chatstreamcompletioncreateparamspdf.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsPdf - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| `engine` | [Optional[models.ChatStreamCompletionCreateParamsPdfEngine]](../models/chatstreamcompletioncreateparamspdfengine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamspdfengine.md b/docs/models/chatstreamcompletioncreateparamspdfengine.md deleted file mode 100644 index 709c8f0..0000000 --- a/docs/models/chatstreamcompletioncreateparamspdfengine.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsPdfEngine - - -## Values - -| Name | Value | -| ------------- | ------------- | -| `MISTRAL_OCR` | mistral-ocr | -| `PDF_TEXT` | pdf-text | -| `NATIVE` | native | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamspluginchainofthought.md b/docs/models/chatstreamcompletioncreateparamspluginchainofthought.md deleted file mode 100644 index 6f31a2d..0000000 --- a/docs/models/chatstreamcompletioncreateparamspluginchainofthought.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsPluginChainOfThought - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | -| `id` | [models.ChatStreamCompletionCreateParamsIDChainOfThought](../models/chatstreamcompletioncreateparamsidchainofthought.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamspluginfileparser.md b/docs/models/chatstreamcompletioncreateparamspluginfileparser.md deleted file mode 100644 index 37e3b19..0000000 --- a/docs/models/chatstreamcompletioncreateparamspluginfileparser.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsPluginFileParser - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatStreamCompletionCreateParamsIDFileParser](../models/chatstreamcompletioncreateparamsidfileparser.md) | :heavy_check_mark: | N/A | -| `max_files` | *Optional[float]* | :heavy_minus_sign: | N/A | -| `pdf` | [Optional[models.ChatStreamCompletionCreateParamsPdf]](../models/chatstreamcompletioncreateparamspdf.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamspluginmoderation.md b/docs/models/chatstreamcompletioncreateparamspluginmoderation.md deleted file mode 100644 index 16e8729..0000000 --- a/docs/models/chatstreamcompletioncreateparamspluginmoderation.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsPluginModeration - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatStreamCompletionCreateParamsIDModeration](../models/chatstreamcompletioncreateparamsidmoderation.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamspluginunion.md b/docs/models/chatstreamcompletioncreateparamspluginunion.md deleted file mode 100644 index 47101cc..0000000 --- a/docs/models/chatstreamcompletioncreateparamspluginunion.md +++ /dev/null @@ -1,29 +0,0 @@ -# ChatStreamCompletionCreateParamsPluginUnion - - -## Supported Types - -### `models.ChatStreamCompletionCreateParamsPluginModeration` - -```python -value: models.ChatStreamCompletionCreateParamsPluginModeration = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsPluginWeb` - -```python -value: models.ChatStreamCompletionCreateParamsPluginWeb = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsPluginChainOfThought` - -```python -value: models.ChatStreamCompletionCreateParamsPluginChainOfThought = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsPluginFileParser` - -```python -value: models.ChatStreamCompletionCreateParamsPluginFileParser = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamspluginweb.md b/docs/models/chatstreamcompletioncreateparamspluginweb.md deleted file mode 100644 index 28d113d..0000000 --- a/docs/models/chatstreamcompletioncreateparamspluginweb.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatStreamCompletionCreateParamsPluginWeb - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -| `id` | [models.ChatStreamCompletionCreateParamsIDWeb](../models/chatstreamcompletioncreateparamsidweb.md) | :heavy_check_mark: | N/A | -| `max_results` | *Optional[float]* | :heavy_minus_sign: | N/A | -| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | -| `engine` | [Optional[models.ChatStreamCompletionCreateParamsEngine]](../models/chatstreamcompletioncreateparamsengine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsprompt.md b/docs/models/chatstreamcompletioncreateparamsprompt.md deleted file mode 100644 index dbb7049..0000000 --- a/docs/models/chatstreamcompletioncreateparamsprompt.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatStreamCompletionCreateParamsPrompt - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsprovider.md b/docs/models/chatstreamcompletioncreateparamsprovider.md deleted file mode 100644 index 69bc3d2..0000000 --- a/docs/models/chatstreamcompletioncreateparamsprovider.md +++ /dev/null @@ -1,18 +0,0 @@ -# ChatStreamCompletionCreateParamsProvider - -When multiple model providers are available, optionally indicate your routing preference. - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
| -| `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | -| `data_collection` | [OptionalNullable[models.ChatStreamCompletionCreateParamsDataCollection]](../models/chatstreamcompletioncreateparamsdatacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
| -| `order` | List[[models.ChatStreamCompletionCreateParamsOrderUnion](../models/chatstreamcompletioncreateparamsorderunion.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | -| `only` | List[[models.ChatStreamCompletionCreateParamsOnlyUnion](../models/chatstreamcompletioncreateparamsonlyunion.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | -| `ignore` | List[[models.ChatStreamCompletionCreateParamsIgnoreUnion](../models/chatstreamcompletioncreateparamsignoreunion.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | -| `quantizations` | List[[models.ChatStreamCompletionCreateParamsQuantization](../models/chatstreamcompletioncreateparamsquantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | -| `sort` | [OptionalNullable[models.ChatStreamCompletionCreateParamsSort]](../models/chatstreamcompletioncreateparamssort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | -| `max_price` | [Optional[models.ChatStreamCompletionCreateParamsMaxPrice]](../models/chatstreamcompletioncreateparamsmaxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsquantization.md b/docs/models/chatstreamcompletioncreateparamsquantization.md deleted file mode 100644 index 180a43e..0000000 --- a/docs/models/chatstreamcompletioncreateparamsquantization.md +++ /dev/null @@ -1,16 +0,0 @@ -# ChatStreamCompletionCreateParamsQuantization - - -## Values - -| Name | Value | -| --------- | --------- | -| `INT4` | int4 | -| `INT8` | int8 | -| `FP4` | fp4 | -| `FP6` | fp6 | -| `FP8` | fp8 | -| `FP16` | fp16 | -| `BF16` | bf16 | -| `FP32` | fp32 | -| `UNKNOWN` | unknown | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsreasoning.md b/docs/models/chatstreamcompletioncreateparamsreasoning.md deleted file mode 100644 index 1d001f6..0000000 --- a/docs/models/chatstreamcompletioncreateparamsreasoning.md +++ /dev/null @@ -1,13 +0,0 @@ -# ChatStreamCompletionCreateParamsReasoning - -Reasoning configuration - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Enables reasoning with default settings. Only work for some models. | -| `effort` | [OptionalNullable[models.ChatStreamCompletionCreateParamsEffort]](../models/chatstreamcompletioncreateparamseffort.md) | :heavy_minus_sign: | OpenAI-style reasoning effort setting | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | non-OpenAI-style reasoning effort setting | -| `exclude` | *Optional[bool]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsreasoningeffort.md b/docs/models/chatstreamcompletioncreateparamsreasoningeffort.md deleted file mode 100644 index 8d4800a..0000000 --- a/docs/models/chatstreamcompletioncreateparamsreasoningeffort.md +++ /dev/null @@ -1,13 +0,0 @@ -# ChatStreamCompletionCreateParamsReasoningEffort - -Reasoning effort - - -## Values - -| Name | Value | -| --------- | --------- | -| `HIGH` | high | -| `MEDIUM` | medium | -| `LOW` | low | -| `MINIMAL` | minimal | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsrequest.md b/docs/models/chatstreamcompletioncreateparamsrequest.md deleted file mode 100644 index ef75853..0000000 --- a/docs/models/chatstreamcompletioncreateparamsrequest.md +++ /dev/null @@ -1,23 +0,0 @@ -# ChatStreamCompletionCreateParamsRequest - - -## Supported Types - -### `float` - -```python -value: float = /* values here */ -``` - -### `str` - -```python -value: str = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformatgrammar.md b/docs/models/chatstreamcompletioncreateparamsresponseformatgrammar.md deleted file mode 100644 index d6fb376..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformatgrammar.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatGrammar - -Custom grammar response format - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatStreamCompletionCreateParamsTypeGrammar](../models/chatstreamcompletioncreateparamstypegrammar.md) | :heavy_check_mark: | N/A | -| `grammar` | *str* | :heavy_check_mark: | Custom grammar for text generation | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformatjsonobject.md b/docs/models/chatstreamcompletioncreateparamsresponseformatjsonobject.md deleted file mode 100644 index 30c9be5..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformatjsonobject.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatJSONObject - -JSON object response format - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatStreamCompletionCreateParamsTypeJSONObject](../models/chatstreamcompletioncreateparamstypejsonobject.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformatjsonschema.md b/docs/models/chatstreamcompletioncreateparamsresponseformatjsonschema.md deleted file mode 100644 index 63068dd..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformatjsonschema.md +++ /dev/null @@ -1,11 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatJSONSchema - -JSON Schema response format for structured outputs - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatStreamCompletionCreateParamsTypeJSONSchema](../models/chatstreamcompletioncreateparamstypejsonschema.md) | :heavy_check_mark: | N/A | -| `json_schema` | [models.ChatStreamCompletionCreateParamsJSONSchema](../models/chatstreamcompletioncreateparamsjsonschema.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformatpython.md b/docs/models/chatstreamcompletioncreateparamsresponseformatpython.md deleted file mode 100644 index 7aa985c..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformatpython.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatPython - -Python code response format - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | -| `type` | [models.ChatStreamCompletionCreateParamsTypePython](../models/chatstreamcompletioncreateparamstypepython.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformattext.md b/docs/models/chatstreamcompletioncreateparamsresponseformattext.md deleted file mode 100644 index ba4bcc4..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformattext.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatText - -Default text response format - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| `type` | [models.ChatStreamCompletionCreateParamsTypeText](../models/chatstreamcompletioncreateparamstypetext.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsresponseformatunion.md b/docs/models/chatstreamcompletioncreateparamsresponseformatunion.md deleted file mode 100644 index f6ba15b..0000000 --- a/docs/models/chatstreamcompletioncreateparamsresponseformatunion.md +++ /dev/null @@ -1,37 +0,0 @@ -# ChatStreamCompletionCreateParamsResponseFormatUnion - -Response format configuration - - -## Supported Types - -### `models.ChatStreamCompletionCreateParamsResponseFormatText` - -```python -value: models.ChatStreamCompletionCreateParamsResponseFormatText = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsResponseFormatJSONObject` - -```python -value: models.ChatStreamCompletionCreateParamsResponseFormatJSONObject = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsResponseFormatJSONSchema` - -```python -value: models.ChatStreamCompletionCreateParamsResponseFormatJSONSchema = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsResponseFormatGrammar` - -```python -value: models.ChatStreamCompletionCreateParamsResponseFormatGrammar = /* values here */ -``` - -### `models.ChatStreamCompletionCreateParamsResponseFormatPython` - -```python -value: models.ChatStreamCompletionCreateParamsResponseFormatPython = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamssort.md b/docs/models/chatstreamcompletioncreateparamssort.md deleted file mode 100644 index e2f845a..0000000 --- a/docs/models/chatstreamcompletioncreateparamssort.md +++ /dev/null @@ -1,12 +0,0 @@ -# ChatStreamCompletionCreateParamsSort - -The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. - - -## Values - -| Name | Value | -| ------------ | ------------ | -| `PRICE` | price | -| `THROUGHPUT` | throughput | -| `LATENCY` | latency | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsstop.md b/docs/models/chatstreamcompletioncreateparamsstop.md deleted file mode 100644 index d3cd163..0000000 --- a/docs/models/chatstreamcompletioncreateparamsstop.md +++ /dev/null @@ -1,25 +0,0 @@ -# ChatStreamCompletionCreateParamsStop - -Stop sequences (up to 4) - - -## Supported Types - -### `str` - -```python -value: str = /* values here */ -``` - -### `List[str]` - -```python -value: List[str] = /* values here */ -``` - -### `Any` - -```python -value: Any = /* values here */ -``` - diff --git a/docs/models/chatstreamcompletioncreateparamsstreamoptions.md b/docs/models/chatstreamcompletioncreateparamsstreamoptions.md deleted file mode 100644 index c70a614..0000000 --- a/docs/models/chatstreamcompletioncreateparamsstreamoptions.md +++ /dev/null @@ -1,10 +0,0 @@ -# ChatStreamCompletionCreateParamsStreamOptions - -Streaming configuration options - - -## Fields - -| Field | Type | Required | Description | -| ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | -| `include_usage` | *Optional[bool]* | :heavy_minus_sign: | Include usage information in streaming response | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypegrammar.md b/docs/models/chatstreamcompletioncreateparamstypegrammar.md deleted file mode 100644 index 8e64f10..0000000 --- a/docs/models/chatstreamcompletioncreateparamstypegrammar.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsTypeGrammar - - -## Values - -| Name | Value | -| --------- | --------- | -| `GRAMMAR` | grammar | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypejsonobject.md b/docs/models/chatstreamcompletioncreateparamstypejsonobject.md deleted file mode 100644 index bb9c748..0000000 --- a/docs/models/chatstreamcompletioncreateparamstypejsonobject.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsTypeJSONObject - - -## Values - -| Name | Value | -| ------------- | ------------- | -| `JSON_OBJECT` | json_object | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypejsonschema.md b/docs/models/chatstreamcompletioncreateparamstypejsonschema.md deleted file mode 100644 index 172f379..0000000 --- a/docs/models/chatstreamcompletioncreateparamstypejsonschema.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsTypeJSONSchema - - -## Values - -| Name | Value | -| ------------- | ------------- | -| `JSON_SCHEMA` | json_schema | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypepython.md b/docs/models/chatstreamcompletioncreateparamstypepython.md deleted file mode 100644 index 4c2a41e..0000000 --- a/docs/models/chatstreamcompletioncreateparamstypepython.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsTypePython - - -## Values - -| Name | Value | -| -------- | -------- | -| `PYTHON` | python | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypetext.md b/docs/models/chatstreamcompletioncreateparamstypetext.md deleted file mode 100644 index 2a5cd35..0000000 --- a/docs/models/chatstreamcompletioncreateparamstypetext.md +++ /dev/null @@ -1,8 +0,0 @@ -# ChatStreamCompletionCreateParamsTypeText - - -## Values - -| Name | Value | -| ------ | ------ | -| `TEXT` | text | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsaudio.md b/docs/models/completion.md similarity index 85% rename from docs/models/chatcompletioncreateparamsaudio.md rename to docs/models/completion.md index e60d0c8..ce9609b 100644 --- a/docs/models/chatcompletioncreateparamsaudio.md +++ b/docs/models/completion.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsAudio +# Completion ## Supported Types diff --git a/docs/models/createchatcompletionresponse.md b/docs/models/createchatcompletionresponse.md new file mode 100644 index 0000000..3bd6bc4 --- /dev/null +++ b/docs/models/createchatcompletionresponse.md @@ -0,0 +1,17 @@ +# CreateChatCompletionResponse + + +## Supported Types + +### `models.ChatCompletion` + +```python +value: models.ChatCompletion = /* values here */ +``` + +### `Union[eventstreaming.EventStream[models.ChatCompletionChunkWrapper], eventstreaming.EventStreamAsync[models.ChatCompletionChunkWrapper]]` + +```python +value: Union[eventstreaming.EventStream[models.ChatCompletionChunkWrapper], eventstreaming.EventStreamAsync[models.ChatCompletionChunkWrapper]] = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsdatacollection.md b/docs/models/datacollection.md similarity index 89% rename from docs/models/chatcompletioncreateparamsdatacollection.md rename to docs/models/datacollection.md index 0f05804..bb07fc4 100644 --- a/docs/models/chatcompletioncreateparamsdatacollection.md +++ b/docs/models/datacollection.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsDataCollection +# DataCollection Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it diff --git a/docs/models/chatcompletioncreateparamseffort.md b/docs/models/effort.md similarity index 85% rename from docs/models/chatcompletioncreateparamseffort.md rename to docs/models/effort.md index 15adb4b..eac615b 100644 --- a/docs/models/chatcompletioncreateparamseffort.md +++ b/docs/models/effort.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsEffort +# Effort OpenAI-style reasoning effort setting diff --git a/docs/models/chatcompletioncreateparamsengine.md b/docs/models/engine.md similarity index 75% rename from docs/models/chatcompletioncreateparamsengine.md rename to docs/models/engine.md index 5f1bb21..fcea19c 100644 --- a/docs/models/chatcompletioncreateparamsengine.md +++ b/docs/models/engine.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsEngine +# Engine ## Values diff --git a/docs/models/error.md b/docs/models/error.md index 72bc8b6..30530e7 100644 --- a/docs/models/error.md +++ b/docs/models/error.md @@ -5,9 +5,9 @@ Error object structure ## Fields -| Field | Type | Required | Description | -| ------------------ | ------------------ | ------------------ | ------------------ | -| `code` | *Nullable[str]* | :heavy_check_mark: | N/A | -| `message` | *str* | :heavy_check_mark: | N/A | -| `param` | *Nullable[str]* | :heavy_check_mark: | N/A | -| `type` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file +| Field | Type | Required | Description | +| ----------------------- | ----------------------- | ----------------------- | ----------------------- | +| `code` | *Nullable[float]* | :heavy_check_mark: | N/A | +| `message` | *str* | :heavy_check_mark: | N/A | +| `param` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `type` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsidchainofthought.md b/docs/models/idchainofthought.md similarity index 76% rename from docs/models/chatcompletioncreateparamsidchainofthought.md rename to docs/models/idchainofthought.md index e13847b..a704b14 100644 --- a/docs/models/chatcompletioncreateparamsidchainofthought.md +++ b/docs/models/idchainofthought.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsIDChainOfThought +# IDChainOfThought ## Values diff --git a/docs/models/chatcompletioncreateparamsidfileparser.md b/docs/models/idfileparser.md similarity index 73% rename from docs/models/chatcompletioncreateparamsidfileparser.md rename to docs/models/idfileparser.md index 7d664f1..1a27fa0 100644 --- a/docs/models/chatcompletioncreateparamsidfileparser.md +++ b/docs/models/idfileparser.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsIDFileParser +# IDFileParser ## Values diff --git a/docs/models/chatcompletioncreateparamsidmoderation.md b/docs/models/idmoderation.md similarity index 72% rename from docs/models/chatcompletioncreateparamsidmoderation.md rename to docs/models/idmoderation.md index a605649..2284d6c 100644 --- a/docs/models/chatcompletioncreateparamsidmoderation.md +++ b/docs/models/idmoderation.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsIDModeration +# IDModeration ## Values diff --git a/docs/models/chatcompletioncreateparamsidweb.md b/docs/models/idweb.md similarity index 66% rename from docs/models/chatcompletioncreateparamsidweb.md rename to docs/models/idweb.md index 62d1f02..8c668e6 100644 --- a/docs/models/chatcompletioncreateparamsidweb.md +++ b/docs/models/idweb.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsIDWeb +# IDWeb ## Values diff --git a/docs/models/ignore.md b/docs/models/ignore.md new file mode 100644 index 0000000..2115a3b --- /dev/null +++ b/docs/models/ignore.md @@ -0,0 +1,17 @@ +# Ignore + + +## Supported Types + +### `models.IgnoreEnum` + +```python +value: models.IgnoreEnum = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsonlyenum.md b/docs/models/ignoreenum.md similarity index 98% rename from docs/models/chatcompletioncreateparamsonlyenum.md rename to docs/models/ignoreenum.md index ac7e092..ad28f68 100644 --- a/docs/models/chatcompletioncreateparamsonlyenum.md +++ b/docs/models/ignoreenum.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsOnlyEnum +# IgnoreEnum ## Values diff --git a/docs/models/chatcompletioncreateparamsprompt.md b/docs/models/image.md similarity index 84% rename from docs/models/chatcompletioncreateparamsprompt.md rename to docs/models/image.md index 12c0a17..cae2edf 100644 --- a/docs/models/chatcompletioncreateparamsprompt.md +++ b/docs/models/image.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsPrompt +# Image ## Supported Types diff --git a/docs/models/chatcompletioncreateparamsjsonschema.md b/docs/models/jsonschema.md similarity index 98% rename from docs/models/chatcompletioncreateparamsjsonschema.md rename to docs/models/jsonschema.md index f7b77cc..9787b1d 100644 --- a/docs/models/chatcompletioncreateparamsjsonschema.md +++ b/docs/models/jsonschema.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsJSONSchema +# JSONSchema ## Fields diff --git a/docs/models/maxprice.md b/docs/models/maxprice.md new file mode 100644 index 0000000..6a1e11b --- /dev/null +++ b/docs/models/maxprice.md @@ -0,0 +1,14 @@ +# MaxPrice + +The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `prompt` | [Optional[models.Prompt]](../models/prompt.md) | :heavy_minus_sign: | N/A | +| `completion` | [Optional[models.Completion]](../models/completion.md) | :heavy_minus_sign: | N/A | +| `image` | [Optional[models.Image]](../models/image.md) | :heavy_minus_sign: | N/A | +| `audio` | [Optional[models.Audio]](../models/audio.md) | :heavy_minus_sign: | N/A | +| `request` | [Optional[models.Request]](../models/request.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/only.md b/docs/models/only.md new file mode 100644 index 0000000..85cd513 --- /dev/null +++ b/docs/models/only.md @@ -0,0 +1,17 @@ +# Only + + +## Supported Types + +### `models.OnlyEnum` + +```python +value: models.OnlyEnum = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsorderenum.md b/docs/models/onlyenum.md similarity index 98% rename from docs/models/chatcompletioncreateparamsorderenum.md rename to docs/models/onlyenum.md index a83b3e5..1c55f80 100644 --- a/docs/models/chatcompletioncreateparamsorderenum.md +++ b/docs/models/onlyenum.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsOrderEnum +# OnlyEnum ## Values diff --git a/docs/models/order.md b/docs/models/order.md new file mode 100644 index 0000000..cfbc63f --- /dev/null +++ b/docs/models/order.md @@ -0,0 +1,17 @@ +# Order + + +## Supported Types + +### `models.OrderEnum` + +```python +value: models.OrderEnum = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsignoreenum.md b/docs/models/orderenum.md similarity index 98% rename from docs/models/chatcompletioncreateparamsignoreenum.md rename to docs/models/orderenum.md index 39a3791..2e00a0d 100644 --- a/docs/models/chatcompletioncreateparamsignoreenum.md +++ b/docs/models/orderenum.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsIgnoreEnum +# OrderEnum ## Values diff --git a/docs/models/pdf.md b/docs/models/pdf.md new file mode 100644 index 0000000..aa1a388 --- /dev/null +++ b/docs/models/pdf.md @@ -0,0 +1,8 @@ +# Pdf + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `engine` | [Optional[models.PdfEngine]](../models/pdfengine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspdfengine.md b/docs/models/pdfengine.md similarity index 82% rename from docs/models/chatcompletioncreateparamspdfengine.md rename to docs/models/pdfengine.md index 1330e18..55bca5e 100644 --- a/docs/models/chatcompletioncreateparamspdfengine.md +++ b/docs/models/pdfengine.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsPdfEngine +# PdfEngine ## Values diff --git a/docs/models/plugin.md b/docs/models/plugin.md new file mode 100644 index 0000000..ec50fd4 --- /dev/null +++ b/docs/models/plugin.md @@ -0,0 +1,29 @@ +# Plugin + + +## Supported Types + +### `models.PluginModeration` + +```python +value: models.PluginModeration = /* values here */ +``` + +### `models.PluginWeb` + +```python +value: models.PluginWeb = /* values here */ +``` + +### `models.PluginChainOfThought` + +```python +value: models.PluginChainOfThought = /* values here */ +``` + +### `models.PluginFileParser` + +```python +value: models.PluginFileParser = /* values here */ +``` + diff --git a/docs/models/pluginchainofthought.md b/docs/models/pluginchainofthought.md new file mode 100644 index 0000000..e5f069d --- /dev/null +++ b/docs/models/pluginchainofthought.md @@ -0,0 +1,8 @@ +# PluginChainOfThought + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `id` | [models.IDChainOfThought](../models/idchainofthought.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/pluginfileparser.md b/docs/models/pluginfileparser.md new file mode 100644 index 0000000..c49e7aa --- /dev/null +++ b/docs/models/pluginfileparser.md @@ -0,0 +1,10 @@ +# PluginFileParser + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | +| `id` | [models.IDFileParser](../models/idfileparser.md) | :heavy_check_mark: | N/A | +| `max_files` | *Optional[float]* | :heavy_minus_sign: | N/A | +| `pdf` | [Optional[models.Pdf]](../models/pdf.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/pluginmoderation.md b/docs/models/pluginmoderation.md new file mode 100644 index 0000000..0e58d2f --- /dev/null +++ b/docs/models/pluginmoderation.md @@ -0,0 +1,8 @@ +# PluginModeration + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------ | +| `id` | [models.IDModeration](../models/idmoderation.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/pluginweb.md b/docs/models/pluginweb.md new file mode 100644 index 0000000..50e2c17 --- /dev/null +++ b/docs/models/pluginweb.md @@ -0,0 +1,11 @@ +# PluginWeb + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | +| `id` | [models.IDWeb](../models/idweb.md) | :heavy_check_mark: | N/A | +| `max_results` | *Optional[float]* | :heavy_minus_sign: | N/A | +| `search_prompt` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `engine` | [Optional[models.Engine]](../models/engine.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsrequest.md b/docs/models/prompt.md similarity index 84% rename from docs/models/chatcompletioncreateparamsrequest.md rename to docs/models/prompt.md index 05c8a09..f242343 100644 --- a/docs/models/chatcompletioncreateparamsrequest.md +++ b/docs/models/prompt.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsRequest +# Prompt ## Supported Types diff --git a/docs/models/chatcompletioncreateparamsprovider.md b/docs/models/provider.md similarity index 91% rename from docs/models/chatcompletioncreateparamsprovider.md rename to docs/models/provider.md index e217d53..22de09c 100644 --- a/docs/models/chatcompletioncreateparamsprovider.md +++ b/docs/models/provider.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsProvider +# Provider When multiple model providers are available, optionally indicate your routing preference. @@ -9,10 +9,10 @@ When multiple model providers are available, optionally indicate your routing pr | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `allow_fallbacks` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in "order") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
| | `require_parameters` | *OptionalNullable[bool]* | :heavy_minus_sign: | Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest. | -| `data_collection` | [OptionalNullable[models.ChatCompletionCreateParamsDataCollection]](../models/chatcompletioncreateparamsdatacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
| -| `order` | List[[models.ChatCompletionCreateParamsOrderUnion](../models/chatcompletioncreateparamsorderunion.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | -| `only` | List[[models.ChatCompletionCreateParamsOnlyUnion](../models/chatcompletioncreateparamsonlyunion.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | -| `ignore` | List[[models.ChatCompletionCreateParamsIgnoreUnion](../models/chatcompletioncreateparamsignoreunion.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | -| `quantizations` | List[[models.ChatCompletionCreateParamsQuantization](../models/chatcompletioncreateparamsquantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | -| `sort` | [OptionalNullable[models.ChatCompletionCreateParamsSort]](../models/chatcompletioncreateparamssort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | -| `max_price` | [Optional[models.ChatCompletionCreateParamsMaxPrice]](../models/chatcompletioncreateparamsmaxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | \ No newline at end of file +| `data_collection` | [OptionalNullable[models.DataCollection]](../models/datacollection.md) | :heavy_minus_sign: | Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
| +| `order` | List[[models.Order](../models/order.md)] | :heavy_minus_sign: | An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message. | +| `only` | List[[models.Only](../models/only.md)] | :heavy_minus_sign: | List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request. | +| `ignore` | List[[models.Ignore](../models/ignore.md)] | :heavy_minus_sign: | List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request. | +| `quantizations` | List[[models.Quantization](../models/quantization.md)] | :heavy_minus_sign: | A list of quantization levels to filter the provider by. | +| `sort` | [OptionalNullable[models.Sort]](../models/sort.md) | :heavy_minus_sign: | The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. | +| `max_price` | [Optional[models.MaxPrice]](../models/maxprice.md) | :heavy_minus_sign: | The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion. | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsquantization.md b/docs/models/quantization.md similarity index 87% rename from docs/models/chatcompletioncreateparamsquantization.md rename to docs/models/quantization.md index 2c6c357..7a0574a 100644 --- a/docs/models/chatcompletioncreateparamsquantization.md +++ b/docs/models/quantization.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsQuantization +# Quantization ## Values diff --git a/docs/models/reasoning.md b/docs/models/reasoning.md new file mode 100644 index 0000000..b8c6d85 --- /dev/null +++ b/docs/models/reasoning.md @@ -0,0 +1,13 @@ +# Reasoning + +Reasoning configuration + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | +| `enabled` | *Optional[bool]* | :heavy_minus_sign: | Enables reasoning with default settings. Only work for some models. | +| `effort` | [OptionalNullable[models.Effort]](../models/effort.md) | :heavy_minus_sign: | OpenAI-style reasoning effort setting | +| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | non-OpenAI-style reasoning effort setting | +| `exclude` | *Optional[bool]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsreasoningeffort.md b/docs/models/reasoningeffort.md similarity index 80% rename from docs/models/chatcompletioncreateparamsreasoningeffort.md rename to docs/models/reasoningeffort.md index 771aab3..004197f 100644 --- a/docs/models/chatcompletioncreateparamsreasoningeffort.md +++ b/docs/models/reasoningeffort.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsReasoningEffort +# ReasoningEffort Reasoning effort diff --git a/docs/models/request.md b/docs/models/request.md new file mode 100644 index 0000000..1456e9b --- /dev/null +++ b/docs/models/request.md @@ -0,0 +1,23 @@ +# Request + + +## Supported Types + +### `float` + +```python +value: float = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + +### `Any` + +```python +value: Any = /* values here */ +``` + diff --git a/docs/models/responseformat.md b/docs/models/responseformat.md new file mode 100644 index 0000000..1ab9a0b --- /dev/null +++ b/docs/models/responseformat.md @@ -0,0 +1,37 @@ +# ResponseFormat + +Response format configuration + + +## Supported Types + +### `models.ResponseFormatText` + +```python +value: models.ResponseFormatText = /* values here */ +``` + +### `models.ResponseFormatJSONObject` + +```python +value: models.ResponseFormatJSONObject = /* values here */ +``` + +### `models.ResponseFormatJSONSchema` + +```python +value: models.ResponseFormatJSONSchema = /* values here */ +``` + +### `models.ResponseFormatGrammar` + +```python +value: models.ResponseFormatGrammar = /* values here */ +``` + +### `models.ResponseFormatPython` + +```python +value: models.ResponseFormatPython = /* values here */ +``` + diff --git a/docs/models/responseformatgrammar.md b/docs/models/responseformatgrammar.md new file mode 100644 index 0000000..95ac8aa --- /dev/null +++ b/docs/models/responseformatgrammar.md @@ -0,0 +1,11 @@ +# ResponseFormatGrammar + +Custom grammar response format + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | +| `type` | [models.TypeGrammar](../models/typegrammar.md) | :heavy_check_mark: | N/A | +| `grammar` | *str* | :heavy_check_mark: | Custom grammar for text generation | \ No newline at end of file diff --git a/docs/models/responseformatjsonobject.md b/docs/models/responseformatjsonobject.md new file mode 100644 index 0000000..8c1cbdb --- /dev/null +++ b/docs/models/responseformatjsonobject.md @@ -0,0 +1,10 @@ +# ResponseFormatJSONObject + +JSON object response format + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `type` | [models.TypeJSONObject](../models/typejsonobject.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/responseformatjsonschema.md b/docs/models/responseformatjsonschema.md new file mode 100644 index 0000000..90afdaf --- /dev/null +++ b/docs/models/responseformatjsonschema.md @@ -0,0 +1,11 @@ +# ResponseFormatJSONSchema + +JSON Schema response format for structured outputs + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `type` | [models.TypeJSONSchema](../models/typejsonschema.md) | :heavy_check_mark: | N/A | +| `json_schema` | [models.JSONSchema](../models/jsonschema.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/responseformatpython.md b/docs/models/responseformatpython.md new file mode 100644 index 0000000..a7285bd --- /dev/null +++ b/docs/models/responseformatpython.md @@ -0,0 +1,10 @@ +# ResponseFormatPython + +Python code response format + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `type` | [models.TypePython](../models/typepython.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformattext.md b/docs/models/responseformattext.md similarity index 96% rename from docs/models/chatcompletioncreateparamsresponseformattext.md rename to docs/models/responseformattext.md index 0eadf11..7634448 100644 --- a/docs/models/chatcompletioncreateparamsresponseformattext.md +++ b/docs/models/responseformattext.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsResponseFormatText +# ResponseFormatText Default text response format diff --git a/docs/models/security.md b/docs/models/security.md index 8ca6325..2e0839d 100644 --- a/docs/models/security.md +++ b/docs/models/security.md @@ -5,4 +5,4 @@ | Field | Type | Required | Description | | ------------------ | ------------------ | ------------------ | ------------------ | -| `bearer_auth` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file +| `api_key` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamssort.md b/docs/models/sort.md similarity index 89% rename from docs/models/chatcompletioncreateparamssort.md rename to docs/models/sort.md index a11c83a..65b6edb 100644 --- a/docs/models/chatcompletioncreateparamssort.md +++ b/docs/models/sort.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsSort +# Sort The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed. diff --git a/docs/models/chatcompletioncreateparamsstop.md b/docs/models/stop.md similarity index 87% rename from docs/models/chatcompletioncreateparamsstop.md rename to docs/models/stop.md index 5b4be00..c36d910 100644 --- a/docs/models/chatcompletioncreateparamsstop.md +++ b/docs/models/stop.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsStop +# Stop Stop sequences (up to 4) diff --git a/docs/models/chatcompletioncreateparamsstreamoptions.md b/docs/models/streamoptions.md similarity index 93% rename from docs/models/chatcompletioncreateparamsstreamoptions.md rename to docs/models/streamoptions.md index 9f75def..f004063 100644 --- a/docs/models/chatcompletioncreateparamsstreamoptions.md +++ b/docs/models/streamoptions.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsStreamOptions +# StreamOptions Streaming configuration options diff --git a/docs/models/chatcompletioncreateparamstypegrammar.md b/docs/models/typegrammar.md similarity index 69% rename from docs/models/chatcompletioncreateparamstypegrammar.md rename to docs/models/typegrammar.md index c3cf87f..ecd24b7 100644 --- a/docs/models/chatcompletioncreateparamstypegrammar.md +++ b/docs/models/typegrammar.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsTypeGrammar +# TypeGrammar ## Values diff --git a/docs/models/chatcompletioncreateparamstypejsonobject.md b/docs/models/typejsonobject.md similarity index 72% rename from docs/models/chatcompletioncreateparamstypejsonobject.md rename to docs/models/typejsonobject.md index b3724f9..47eebd5 100644 --- a/docs/models/chatcompletioncreateparamstypejsonobject.md +++ b/docs/models/typejsonobject.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsTypeJSONObject +# TypeJSONObject ## Values diff --git a/docs/models/chatcompletioncreateparamstypejsonschema.md b/docs/models/typejsonschema.md similarity index 72% rename from docs/models/chatcompletioncreateparamstypejsonschema.md rename to docs/models/typejsonschema.md index 9f307a4..47333d3 100644 --- a/docs/models/chatcompletioncreateparamstypejsonschema.md +++ b/docs/models/typejsonschema.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsTypeJSONSchema +# TypeJSONSchema ## Values diff --git a/docs/models/chatcompletioncreateparamstypepython.md b/docs/models/typepython.md similarity index 68% rename from docs/models/chatcompletioncreateparamstypepython.md rename to docs/models/typepython.md index 991e9ac..4304c4b 100644 --- a/docs/models/chatcompletioncreateparamstypepython.md +++ b/docs/models/typepython.md @@ -1,4 +1,4 @@ -# ChatCompletionCreateParamsTypePython +# TypePython ## Values diff --git a/docs/sdks/chat/README.md b/docs/sdks/chat/README.md index 343d180..0f7207d 100644 --- a/docs/sdks/chat/README.md +++ b/docs/sdks/chat/README.md @@ -3,12 +3,9 @@ ## Overview -Chat completion operations - ### Available Operations * [complete](#complete) - Create a chat completion -* [complete_stream](#complete_stream) - Create a chat completion ## complete @@ -18,92 +15,21 @@ Creates a model response for the given chat conversation. Supports both streamin ```python -from openrouter import OpenRouter, models +from openrouter import OpenRouter import os with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: res = open_router.chat.complete(messages=[ { - "role": models.ChatCompletionUserMessageParamRole.USER, + "role": "user", "content": "Hello, how are you?", }, ], stream=False, temperature=1, top_p=1) - # Handle response - print(res) - -``` - -### Parameters - -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -| `messages` | List[[models.ChatCompletionMessageParam](../../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | -| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | -| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | -| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | -| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | -| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | -| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | -| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | -| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | -| `reasoning` | [OptionalNullable[models.ChatCompletionCreateParamsReasoning]](../../models/chatcompletioncreateparamsreasoning.md) | :heavy_minus_sign: | Reasoning configuration | | -| `response_format` | [Optional[models.ChatCompletionCreateParamsResponseFormatUnion]](../../models/chatcompletioncreateparamsresponseformatunion.md) | :heavy_minus_sign: | Response format configuration | | -| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | -| `stop` | [OptionalNullable[models.ChatCompletionCreateParamsStop]](../../models/chatcompletioncreateparamsstop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | -| `stream` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable streaming response | | -| `stream_options` | [OptionalNullable[models.ChatCompletionCreateParamsStreamOptions]](../../models/chatcompletioncreateparamsstreamoptions.md) | :heavy_minus_sign: | N/A | | -| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | -| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | -| `tools` | List[[models.ChatCompletionTool](../../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | -| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | -| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | -| `models_llm` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | -| `reasoning_effort` | [OptionalNullable[models.ChatCompletionCreateParamsReasoningEffort]](../../models/chatcompletioncreateparamsreasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | -| `provider` | [OptionalNullable[models.ChatCompletionCreateParamsProvider]](../../models/chatcompletioncreateparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | -| `plugins` | List[[models.ChatCompletionCreateParamsPluginUnion](../../models/chatcompletioncreateparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | - -### Response - -**[models.ChatCompletion](../../models/chatcompletion.md)** - -### Errors - -| Error Type | Status Code | Content Type | -| ----------------------------- | ----------------------------- | ----------------------------- | -| errors.ChatCompletionError | 400, 401, 429 | application/json | -| errors.ChatCompletionError | 500 | application/json | -| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | - -## complete_stream - -Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. - -### Example Usage - - -```python -from openrouter import OpenRouter, models -import os - - -with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), -) as open_router: - - res = open_router.chat.complete_stream(messages=[ - { - "role": models.ChatCompletionUserMessageParamRole.USER, - "content": "Hello, how are you?", - }, - ], stream=True, temperature=1, top_p=1) - with res as event_stream: for event in event_stream: # handle event @@ -113,38 +39,38 @@ with OpenRouter( ### Parameters -| Parameter | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | -| `messages` | List[[models.ChatCompletionMessageParam](../../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | -| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | -| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | -| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | -| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | -| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | -| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | -| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | -| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | -| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | -| `reasoning` | [OptionalNullable[models.ChatStreamCompletionCreateParamsReasoning]](../../models/chatstreamcompletioncreateparamsreasoning.md) | :heavy_minus_sign: | Reasoning configuration | | -| `response_format` | [Optional[models.ChatStreamCompletionCreateParamsResponseFormatUnion]](../../models/chatstreamcompletioncreateparamsresponseformatunion.md) | :heavy_minus_sign: | Response format configuration | | -| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | -| `stop` | [OptionalNullable[models.ChatStreamCompletionCreateParamsStop]](../../models/chatstreamcompletioncreateparamsstop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | -| `stream` | *Optional[bool]* | :heavy_minus_sign: | Enable streaming response | | -| `stream_options` | [OptionalNullable[models.ChatStreamCompletionCreateParamsStreamOptions]](../../models/chatstreamcompletioncreateparamsstreamoptions.md) | :heavy_minus_sign: | N/A | | -| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | -| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | -| `tools` | List[[models.ChatCompletionTool](../../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | -| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | -| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | -| `models_llm` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | -| `reasoning_effort` | [OptionalNullable[models.ChatStreamCompletionCreateParamsReasoningEffort]](../../models/chatstreamcompletioncreateparamsreasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | -| `provider` | [OptionalNullable[models.ChatStreamCompletionCreateParamsProvider]](../../models/chatstreamcompletioncreateparamsprovider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | -| `plugins` | List[[models.ChatStreamCompletionCreateParamsPluginUnion](../../models/chatstreamcompletioncreateparamspluginunion.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | -| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `messages` | List[[models.ChatCompletionMessageParam](../../models/chatcompletionmessageparam.md)] | :heavy_check_mark: | List of messages for the conversation | [
{
"role": "user",
"content": "Hello, how are you?"
}
] | +| `model` | *Optional[str]* | :heavy_minus_sign: | Model to use for completion | | +| `frequency_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Frequency penalty (-2.0 to 2.0) | | +| `logit_bias` | Dict[str, *float*] | :heavy_minus_sign: | Token logit bias adjustments | | +| `logprobs` | *OptionalNullable[bool]* | :heavy_minus_sign: | Return log probabilities | | +| `top_logprobs` | *OptionalNullable[float]* | :heavy_minus_sign: | Number of top log probabilities to return (0-20) | | +| `max_completion_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens in completion | | +| `max_tokens` | *OptionalNullable[float]* | :heavy_minus_sign: | Maximum tokens (deprecated, use max_completion_tokens) | | +| `metadata` | Dict[str, *str*] | :heavy_minus_sign: | Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) | | +| `presence_penalty` | *OptionalNullable[float]* | :heavy_minus_sign: | Presence penalty (-2.0 to 2.0) | | +| `reasoning` | [OptionalNullable[models.Reasoning]](../../models/reasoning.md) | :heavy_minus_sign: | Reasoning configuration | | +| `response_format` | [Optional[models.ResponseFormat]](../../models/responseformat.md) | :heavy_minus_sign: | Response format configuration | | +| `seed` | *OptionalNullable[int]* | :heavy_minus_sign: | Random seed for deterministic outputs | | +| `stop` | [OptionalNullable[models.Stop]](../../models/stop.md) | :heavy_minus_sign: | Stop sequences (up to 4) | | +| `stream` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable streaming response | | +| `stream_options` | [OptionalNullable[models.StreamOptions]](../../models/streamoptions.md) | :heavy_minus_sign: | N/A | | +| `temperature` | *OptionalNullable[float]* | :heavy_minus_sign: | Sampling temperature (0-2) | | +| `tool_choice` | [Optional[models.ChatCompletionToolChoiceOption]](../../models/chatcompletiontoolchoiceoption.md) | :heavy_minus_sign: | Tool choice configuration | | +| `tools` | List[[models.ChatCompletionTool](../../models/chatcompletiontool.md)] | :heavy_minus_sign: | Available tools for function calling | | +| `top_p` | *OptionalNullable[float]* | :heavy_minus_sign: | Nucleus sampling parameter (0-1) | | +| `user` | *Optional[str]* | :heavy_minus_sign: | Unique user identifier | | +| `model_list` | List[*str*] | :heavy_minus_sign: | Order of models to fallback to for this request | | +| `reasoning_effort` | [OptionalNullable[models.ReasoningEffort]](../../models/reasoningeffort.md) | :heavy_minus_sign: | Reasoning effort | | +| `provider` | [OptionalNullable[models.Provider]](../../models/provider.md) | :heavy_minus_sign: | When multiple model providers are available, optionally indicate your routing preference. | | +| `plugins` | List[[models.Plugin](../../models/plugin.md)] | :heavy_minus_sign: | Plugins you want to enable for this request, including their settings. | | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | | ### Response -**[Union[eventstreaming.EventStream[models.StreamChatCompletionResponseBody], eventstreaming.EventStreamAsync[models.StreamChatCompletionResponseBody]]](../../models/.md)** +**[models.CreateChatCompletionResponse](../../models/createchatcompletionresponse.md)** ### Errors diff --git a/examples/.env b/examples/.env deleted file mode 100644 index 85d3b39..0000000 --- a/examples/.env +++ /dev/null @@ -1 +0,0 @@ -OPENROUTER_API_KEY="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" \ No newline at end of file diff --git a/examples/chatCompletion.py b/examples/chatCompletion.py index b422014..d970250 100644 --- a/examples/chatCompletion.py +++ b/examples/chatCompletion.py @@ -8,13 +8,12 @@ import os from openrouter import OpenRouter with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_API_KEY"), + api_key=os.getenv("OPENROUTER_API_KEY"), ) as sdk: result = sdk.chat.complete( - model="openai/gpt-3.5-turbo", messages=[ {"role": "user", "content": "Hello, world!"}, ], + model="openai/gpt-3.5-turbo", ) - -print(result) \ No newline at end of file + print("Basic completion:", result) diff --git a/examples/sseChatCompletion.py b/examples/sseChatCompletion.py index 6b16dfc..c3f252b 100644 --- a/examples/sseChatCompletion.py +++ b/examples/sseChatCompletion.py @@ -5,22 +5,24 @@ dependencies = [ ] import os -from openrouter import OpenRouter, models +from openrouter import OpenRouter with OpenRouter( - bearer_auth=os.getenv("OPENROUTER_API_KEY", ""), + api_key=os.getenv("OPENROUTER_API_KEY", ""), ) as open_router: - - res = open_router.chat.complete_stream(messages=[ - { - "role": "user", - "content": "Hello, how are you?", - }, - - ], model="openai/gpt-3.5-turbo", stream=True, temperature=1, top_p=1) + res = open_router.chat.complete( + messages=[ + { + "role": "user", + "content": "Hello, how are you?", + }, + ], + model="openai/gpt-3.5-turbo", + stream=True + ) with res as event_stream: for event in event_stream: if event.data.choices and event.data.choices[0].delta.content: print(event.data.choices[0].delta.content, end='', flush=True) - print() # New line at the end \ No newline at end of file + print() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index fb838d2..fff931f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openrouter" -version = "0.1.3" +version = "0.3.1" description = "Python Client SDK Generated by Speakeasy." authors = [{ name = "Speakeasy" },] readme = "README-PYPI.md" @@ -30,6 +30,7 @@ build-backend = "setuptools.build_meta" [tool.pytest.ini_options] asyncio_default_fixture_loop_scope = "function" +asyncio_mode = "auto" pythonpath = ["src"] [tool.mypy] diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py index 0fdc8ca..4e9622d 100644 --- a/src/openrouter/_version.py +++ b/src/openrouter/_version.py @@ -3,10 +3,10 @@ import importlib.metadata __title__: str = "openrouter" -__version__: str = "0.1.3" +__version__: str = "0.3.1" __openapi_doc_version__: str = "1.0.0" -__gen_version__: str = "2.687.1" -__user_agent__: str = "speakeasy-sdk/python 0.1.3 2.687.1 1.0.0 openrouter" +__gen_version__: str = "2.694.1" +__user_agent__: str = "speakeasy-sdk/python 0.3.1 2.694.1 1.0.0 openrouter" try: if __package__ is not None: diff --git a/src/openrouter/basesdk.py b/src/openrouter/basesdk.py index de6dfd0..a550aff 100644 --- a/src/openrouter/basesdk.py +++ b/src/openrouter/basesdk.py @@ -15,9 +15,19 @@ from urllib.parse import parse_qs, urlparse class BaseSDK: sdk_configuration: SDKConfiguration + parent_ref: Optional[object] = None + """ + Reference to the root SDK instance, if any. This will prevent it from + being garbage collected while there are active streams. + """ - def __init__(self, sdk_config: SDKConfiguration) -> None: + def __init__( + self, + sdk_config: SDKConfiguration, + parent_ref: Optional[object] = None, + ) -> None: self.sdk_configuration = sdk_config + self.parent_ref = parent_ref def _get_url(self, base_url, url_variables): sdk_url, sdk_variables = self.sdk_configuration.get_server_details() diff --git a/src/openrouter/chat.py b/src/openrouter/chat.py index 0b8f344..7a0a39e 100644 --- a/src/openrouter/chat.py +++ b/src/openrouter/chat.py @@ -1,6 +1,7 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from .basesdk import BaseSDK +from enum import Enum from openrouter import errors, models, utils from openrouter._hooks import HookContext from openrouter.types import OptionalNullable, UNSET @@ -8,9 +9,120 @@ from openrouter.utils import eventstreaming, get_security_from_env from openrouter.utils.unmarshal_json_response import unmarshal_json_response from typing import Any, Dict, List, Mapping, Optional, Union +# region imports +from typing import overload +from typing_extensions import Literal +# endregion imports + + +class CompleteAcceptEnum(str, Enum): + APPLICATION_JSON = "application/json" + TEXT_EVENT_STREAM = "text/event-stream" + class Chat(BaseSDK): - r"""Chat completion operations""" + # region sdk-class-body + @overload + def complete( + self, + *, + messages: Union[ + List[models.ChatCompletionMessageParam], + List[models.ChatCompletionMessageParamTypedDict], + ], + model: Optional[str] = None, + stream: Literal[True], + stream_options: OptionalNullable[ + Union[models.StreamOptions, models.StreamOptionsTypedDict] + ] = UNSET, + temperature: OptionalNullable[float] = 1, + tool_choice: Optional[ + Union[ + models.ChatCompletionToolChoiceOption, + models.ChatCompletionToolChoiceOptionTypedDict, + ] + ] = None, + tools: Optional[ + Union[ + List[models.ChatCompletionTool], + List[models.ChatCompletionToolTypedDict], + ] + ] = None, + top_p: OptionalNullable[float] = 1, + user: Optional[str] = None, + model_list: OptionalNullable[List[str]] = UNSET, + reasoning_effort: OptionalNullable[models.ReasoningEffort] = UNSET, + provider: OptionalNullable[ + Union[models.Provider, models.ProviderTypedDict] + ] = UNSET, + plugins: Optional[ + Union[List[models.Plugin], List[models.PluginTypedDict]] + ] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + accept_header_override: Optional[CompleteAcceptEnum] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> eventstreaming.EventStream[models.ChatCompletionChunkWrapper]: ... + @overload + def complete( + self, + *, + messages: Union[ + List[models.ChatCompletionMessageParam], + List[models.ChatCompletionMessageParamTypedDict], + ], + model: Optional[str] = None, + frequency_penalty: OptionalNullable[float] = UNSET, + logit_bias: OptionalNullable[Dict[str, float]] = UNSET, + logprobs: OptionalNullable[bool] = UNSET, + top_logprobs: OptionalNullable[float] = UNSET, + max_completion_tokens: OptionalNullable[float] = UNSET, + max_tokens: OptionalNullable[float] = UNSET, + metadata: Optional[Dict[str, str]] = None, + presence_penalty: OptionalNullable[float] = UNSET, + reasoning: OptionalNullable[ + Union[models.Reasoning, models.ReasoningTypedDict] + ] = UNSET, + response_format: Optional[ + Union[models.ResponseFormat, models.ResponseFormatTypedDict] + ] = None, + seed: OptionalNullable[int] = UNSET, + stop: OptionalNullable[Union[models.Stop, models.StopTypedDict]] = UNSET, + stream: Union[Literal[False], None] = None, + stream_options: OptionalNullable[ + Union[models.StreamOptions, models.StreamOptionsTypedDict] + ] = UNSET, + temperature: OptionalNullable[float] = 1, + tool_choice: Optional[ + Union[ + models.ChatCompletionToolChoiceOption, + models.ChatCompletionToolChoiceOptionTypedDict, + ] + ] = None, + tools: Optional[ + Union[ + List[models.ChatCompletionTool], + List[models.ChatCompletionToolTypedDict], + ] + ] = None, + top_p: OptionalNullable[float] = 1, + user: Optional[str] = None, + model_list: OptionalNullable[List[str]] = UNSET, + reasoning_effort: OptionalNullable[models.ReasoningEffort] = UNSET, + provider: OptionalNullable[ + Union[models.Provider, models.ProviderTypedDict] + ] = UNSET, + plugins: Optional[ + Union[List[models.Plugin], List[models.PluginTypedDict]] + ] = None, + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + accept_header_override: Optional[CompleteAcceptEnum] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> models.ChatCompletion: ... + # endregion sdk-class-body def complete( self, @@ -29,30 +141,16 @@ class Chat(BaseSDK): metadata: Optional[Dict[str, str]] = None, presence_penalty: OptionalNullable[float] = UNSET, reasoning: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsReasoning, - models.ChatCompletionCreateParamsReasoningTypedDict, - ] + Union[models.Reasoning, models.ReasoningTypedDict] ] = UNSET, response_format: Optional[ - Union[ - models.ChatCompletionCreateParamsResponseFormatUnion, - models.ChatCompletionCreateParamsResponseFormatUnionTypedDict, - ] + Union[models.ResponseFormat, models.ResponseFormatTypedDict] ] = None, seed: OptionalNullable[int] = UNSET, - stop: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsStop, - models.ChatCompletionCreateParamsStopTypedDict, - ] - ] = UNSET, + stop: OptionalNullable[Union[models.Stop, models.StopTypedDict]] = UNSET, stream: OptionalNullable[bool] = False, stream_options: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsStreamOptions, - models.ChatCompletionCreateParamsStreamOptionsTypedDict, - ] + Union[models.StreamOptions, models.StreamOptionsTypedDict] ] = UNSET, temperature: OptionalNullable[float] = 1, tool_choice: Optional[ @@ -69,27 +167,20 @@ class Chat(BaseSDK): ] = None, top_p: OptionalNullable[float] = 1, user: Optional[str] = None, - models_llm: OptionalNullable[List[str]] = UNSET, - reasoning_effort: OptionalNullable[ - models.ChatCompletionCreateParamsReasoningEffort - ] = UNSET, + model_list: OptionalNullable[List[str]] = UNSET, + reasoning_effort: OptionalNullable[models.ReasoningEffort] = UNSET, provider: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsProvider, - models.ChatCompletionCreateParamsProviderTypedDict, - ] + Union[models.Provider, models.ProviderTypedDict] ] = UNSET, plugins: Optional[ - Union[ - List[models.ChatCompletionCreateParamsPluginUnion], - List[models.ChatCompletionCreateParamsPluginUnionTypedDict], - ] + Union[List[models.Plugin], List[models.PluginTypedDict]] ] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, + accept_header_override: Optional[CompleteAcceptEnum] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> models.ChatCompletion: + ) -> models.CreateChatCompletionResponse: r"""Create a chat completion Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. @@ -115,13 +206,14 @@ class Chat(BaseSDK): :param tools: Available tools for function calling :param top_p: Nucleus sampling parameter (0-1) :param user: Unique user identifier - :param models_llm: Order of models to fallback to for this request + :param model_list: Order of models to fallback to for this request :param reasoning_effort: Reasoning effort :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 retries: Override the default retry configuration 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 accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ base_url = None @@ -148,18 +240,16 @@ class Chat(BaseSDK): metadata=metadata, presence_penalty=presence_penalty, reasoning=utils.get_pydantic_model( - reasoning, OptionalNullable[models.ChatCompletionCreateParamsReasoning] + reasoning, OptionalNullable[models.Reasoning] ), response_format=utils.get_pydantic_model( - response_format, - Optional[models.ChatCompletionCreateParamsResponseFormatUnion], + response_format, Optional[models.ResponseFormat] ), seed=seed, stop=stop, stream=stream, stream_options=utils.get_pydantic_model( - stream_options, - OptionalNullable[models.ChatCompletionCreateParamsStreamOptions], + stream_options, OptionalNullable[models.StreamOptions] ), temperature=temperature, tool_choice=utils.get_pydantic_model( @@ -170,14 +260,12 @@ class Chat(BaseSDK): ), top_p=top_p, user=user, - models_llm=models_llm, + model_list=model_list, reasoning_effort=reasoning_effort, provider=utils.get_pydantic_model( - provider, OptionalNullable[models.ChatCompletionCreateParamsProvider] - ), - plugins=utils.get_pydantic_model( - plugins, Optional[List[models.ChatCompletionCreateParamsPluginUnion]] + provider, OptionalNullable[models.Provider] ), + plugins=utils.get_pydantic_model(plugins, Optional[List[models.Plugin]]), ) req = self._build_request( @@ -190,7 +278,9 @@ class Chat(BaseSDK): request_has_path_params=False, request_has_query_params=True, user_agent_header="user-agent", - accept_header_value="application/json", + accept_header_value=accept_header_override.value + if accept_header_override is not None + else "application/json;q=1, text/event-stream;q=0", http_headers=http_headers, security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( @@ -219,493 +309,24 @@ class Chat(BaseSDK): ), request=req, error_status_codes=["400", "401", "429", "4XX", "500", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return unmarshal_json_response(models.ChatCompletion, http_res) - if utils.match_response(http_res, ["400", "401", "429"], "application/json"): - response_data = unmarshal_json_response( - errors.ChatCompletionErrorData, http_res - ) - raise errors.ChatCompletionError(response_data, http_res) - if utils.match_response(http_res, "500", "application/json"): - response_data = unmarshal_json_response( - errors.ChatCompletionErrorData, http_res - ) - raise errors.ChatCompletionError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.OpenRouterDefaultError( - "API error occurred", http_res, http_res_text - ) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = utils.stream_to_text(http_res) - raise errors.OpenRouterDefaultError( - "API error occurred", http_res, http_res_text - ) - - raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - - async def complete_async( - self, - *, - messages: Union[ - List[models.ChatCompletionMessageParam], - List[models.ChatCompletionMessageParamTypedDict], - ], - model: Optional[str] = None, - frequency_penalty: OptionalNullable[float] = UNSET, - logit_bias: OptionalNullable[Dict[str, float]] = UNSET, - logprobs: OptionalNullable[bool] = UNSET, - top_logprobs: OptionalNullable[float] = UNSET, - max_completion_tokens: OptionalNullable[float] = UNSET, - max_tokens: OptionalNullable[float] = UNSET, - metadata: Optional[Dict[str, str]] = None, - presence_penalty: OptionalNullable[float] = UNSET, - reasoning: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsReasoning, - models.ChatCompletionCreateParamsReasoningTypedDict, - ] - ] = UNSET, - response_format: Optional[ - Union[ - models.ChatCompletionCreateParamsResponseFormatUnion, - models.ChatCompletionCreateParamsResponseFormatUnionTypedDict, - ] - ] = None, - seed: OptionalNullable[int] = UNSET, - stop: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsStop, - models.ChatCompletionCreateParamsStopTypedDict, - ] - ] = UNSET, - stream: OptionalNullable[bool] = False, - stream_options: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsStreamOptions, - models.ChatCompletionCreateParamsStreamOptionsTypedDict, - ] - ] = UNSET, - temperature: OptionalNullable[float] = 1, - tool_choice: Optional[ - Union[ - models.ChatCompletionToolChoiceOption, - models.ChatCompletionToolChoiceOptionTypedDict, - ] - ] = None, - tools: Optional[ - Union[ - List[models.ChatCompletionTool], - List[models.ChatCompletionToolTypedDict], - ] - ] = None, - top_p: OptionalNullable[float] = 1, - user: Optional[str] = None, - models_llm: OptionalNullable[List[str]] = UNSET, - reasoning_effort: OptionalNullable[ - models.ChatCompletionCreateParamsReasoningEffort - ] = UNSET, - provider: OptionalNullable[ - Union[ - models.ChatCompletionCreateParamsProvider, - models.ChatCompletionCreateParamsProviderTypedDict, - ] - ] = UNSET, - plugins: Optional[ - Union[ - List[models.ChatCompletionCreateParamsPluginUnion], - List[models.ChatCompletionCreateParamsPluginUnionTypedDict], - ] - ] = None, - retries: OptionalNullable[utils.RetryConfig] = UNSET, - server_url: Optional[str] = None, - timeout_ms: Optional[int] = None, - http_headers: Optional[Mapping[str, str]] = None, - ) -> models.ChatCompletion: - r"""Create a chat completion - - Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. - - :param messages: List of messages for the conversation - :param model: Model to use for completion - :param frequency_penalty: Frequency penalty (-2.0 to 2.0) - :param logit_bias: Token logit bias adjustments - :param logprobs: Return log probabilities - :param top_logprobs: Number of top log probabilities to return (0-20) - :param max_completion_tokens: Maximum tokens in completion - :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens) - :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) - :param presence_penalty: Presence penalty (-2.0 to 2.0) - :param reasoning: Reasoning configuration - :param response_format: Response format configuration - :param seed: Random seed for deterministic outputs - :param stop: Stop sequences (up to 4) - :param stream: Enable streaming response - :param stream_options: - :param temperature: Sampling temperature (0-2) - :param tool_choice: Tool choice configuration - :param tools: Available tools for function calling - :param top_p: Nucleus sampling parameter (0-1) - :param user: Unique user identifier - :param models_llm: Order of models to fallback to for this request - :param reasoning_effort: Reasoning effort - :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 retries: Override the default retry configuration 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 http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - request = models.ChatCompletionCreateParams( - messages=utils.get_pydantic_model( - messages, List[models.ChatCompletionMessageParam] - ), - model=model, - frequency_penalty=frequency_penalty, - logit_bias=logit_bias, - logprobs=logprobs, - top_logprobs=top_logprobs, - max_completion_tokens=max_completion_tokens, - max_tokens=max_tokens, - metadata=metadata, - presence_penalty=presence_penalty, - reasoning=utils.get_pydantic_model( - reasoning, OptionalNullable[models.ChatCompletionCreateParamsReasoning] - ), - response_format=utils.get_pydantic_model( - response_format, - Optional[models.ChatCompletionCreateParamsResponseFormatUnion], - ), - seed=seed, - stop=stop, - stream=stream, - stream_options=utils.get_pydantic_model( - stream_options, - OptionalNullable[models.ChatCompletionCreateParamsStreamOptions], - ), - temperature=temperature, - tool_choice=utils.get_pydantic_model( - tool_choice, Optional[models.ChatCompletionToolChoiceOption] - ), - tools=utils.get_pydantic_model( - tools, Optional[List[models.ChatCompletionTool]] - ), - top_p=top_p, - user=user, - models_llm=models_llm, - reasoning_effort=reasoning_effort, - provider=utils.get_pydantic_model( - provider, OptionalNullable[models.ChatCompletionCreateParamsProvider] - ), - plugins=utils.get_pydantic_model( - plugins, Optional[List[models.ChatCompletionCreateParamsPluginUnion]] - ), - ) - - req = self._build_request_async( - method="POST", - path="/chat/completions", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=True, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="application/json", - http_headers=http_headers, - security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request, False, False, "json", models.ChatCompletionCreateParams - ), - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["429", "500", "502", "503", "504"]) - - http_res = await self.do_request_async( - hook_ctx=HookContext( - config=self.sdk_configuration, - base_url=base_url or "", - operation_id="createChatCompletion", - oauth2_scopes=[], - security_source=get_security_from_env( - self.sdk_configuration.security, models.Security - ), - ), - request=req, - error_status_codes=["400", "401", "429", "4XX", "500", "5XX"], - retry_config=retry_config, - ) - - response_data: Any = None - if utils.match_response(http_res, "200", "application/json"): - return unmarshal_json_response(models.ChatCompletion, http_res) - if utils.match_response(http_res, ["400", "401", "429"], "application/json"): - response_data = unmarshal_json_response( - errors.ChatCompletionErrorData, http_res - ) - raise errors.ChatCompletionError(response_data, http_res) - if utils.match_response(http_res, "500", "application/json"): - response_data = unmarshal_json_response( - errors.ChatCompletionErrorData, http_res - ) - raise errors.ChatCompletionError(response_data, http_res) - if utils.match_response(http_res, "4XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.OpenRouterDefaultError( - "API error occurred", http_res, http_res_text - ) - if utils.match_response(http_res, "5XX", "*"): - http_res_text = await utils.stream_to_text_async(http_res) - raise errors.OpenRouterDefaultError( - "API error occurred", http_res, http_res_text - ) - - raise errors.OpenRouterDefaultError("Unexpected response received", http_res) - - def complete_stream( - self, - *, - messages: Union[ - List[models.ChatCompletionMessageParam], - List[models.ChatCompletionMessageParamTypedDict], - ], - model: Optional[str] = None, - frequency_penalty: OptionalNullable[float] = UNSET, - logit_bias: OptionalNullable[Dict[str, float]] = UNSET, - logprobs: OptionalNullable[bool] = UNSET, - top_logprobs: OptionalNullable[float] = UNSET, - max_completion_tokens: OptionalNullable[float] = UNSET, - max_tokens: OptionalNullable[float] = UNSET, - metadata: Optional[Dict[str, str]] = None, - presence_penalty: OptionalNullable[float] = UNSET, - reasoning: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsReasoning, - models.ChatStreamCompletionCreateParamsReasoningTypedDict, - ] - ] = UNSET, - response_format: Optional[ - Union[ - models.ChatStreamCompletionCreateParamsResponseFormatUnion, - models.ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict, - ] - ] = None, - seed: OptionalNullable[int] = UNSET, - stop: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsStop, - models.ChatStreamCompletionCreateParamsStopTypedDict, - ] - ] = UNSET, - stream: Optional[bool] = True, - stream_options: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsStreamOptions, - models.ChatStreamCompletionCreateParamsStreamOptionsTypedDict, - ] - ] = UNSET, - temperature: OptionalNullable[float] = 1, - tool_choice: Optional[ - Union[ - models.ChatCompletionToolChoiceOption, - models.ChatCompletionToolChoiceOptionTypedDict, - ] - ] = None, - tools: Optional[ - Union[ - List[models.ChatCompletionTool], - List[models.ChatCompletionToolTypedDict], - ] - ] = None, - top_p: OptionalNullable[float] = 1, - user: Optional[str] = None, - models_llm: OptionalNullable[List[str]] = UNSET, - reasoning_effort: OptionalNullable[ - models.ChatStreamCompletionCreateParamsReasoningEffort - ] = UNSET, - provider: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsProvider, - models.ChatStreamCompletionCreateParamsProviderTypedDict, - ] - ] = UNSET, - plugins: Optional[ - Union[ - List[models.ChatStreamCompletionCreateParamsPluginUnion], - List[models.ChatStreamCompletionCreateParamsPluginUnionTypedDict], - ] - ] = None, - retries: OptionalNullable[utils.RetryConfig] = UNSET, - server_url: Optional[str] = None, - timeout_ms: Optional[int] = None, - http_headers: Optional[Mapping[str, str]] = None, - ) -> eventstreaming.EventStream[models.StreamChatCompletionResponseBody]: - r"""Create a chat completion - - Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. - - :param messages: List of messages for the conversation - :param model: Model to use for completion - :param frequency_penalty: Frequency penalty (-2.0 to 2.0) - :param logit_bias: Token logit bias adjustments - :param logprobs: Return log probabilities - :param top_logprobs: Number of top log probabilities to return (0-20) - :param max_completion_tokens: Maximum tokens in completion - :param max_tokens: Maximum tokens (deprecated, use max_completion_tokens) - :param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) - :param presence_penalty: Presence penalty (-2.0 to 2.0) - :param reasoning: Reasoning configuration - :param response_format: Response format configuration - :param seed: Random seed for deterministic outputs - :param stop: Stop sequences (up to 4) - :param stream: Enable streaming response - :param stream_options: - :param temperature: Sampling temperature (0-2) - :param tool_choice: Tool choice configuration - :param tools: Available tools for function calling - :param top_p: Nucleus sampling parameter (0-1) - :param user: Unique user identifier - :param models_llm: Order of models to fallback to for this request - :param reasoning_effort: Reasoning effort - :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 retries: Override the default retry configuration 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 http_headers: Additional headers to set or replace on requests. - """ - base_url = None - url_variables = None - if timeout_ms is None: - timeout_ms = self.sdk_configuration.timeout_ms - - if server_url is not None: - base_url = server_url - else: - base_url = self._get_url(base_url, url_variables) - - request = models.ChatStreamCompletionCreateParams( - messages=utils.get_pydantic_model( - messages, List[models.ChatCompletionMessageParam] - ), - model=model, - frequency_penalty=frequency_penalty, - logit_bias=logit_bias, - logprobs=logprobs, - top_logprobs=top_logprobs, - max_completion_tokens=max_completion_tokens, - max_tokens=max_tokens, - metadata=metadata, - presence_penalty=presence_penalty, - reasoning=utils.get_pydantic_model( - reasoning, - OptionalNullable[models.ChatStreamCompletionCreateParamsReasoning], - ), - response_format=utils.get_pydantic_model( - response_format, - Optional[models.ChatStreamCompletionCreateParamsResponseFormatUnion], - ), - seed=seed, - stop=stop, - stream=stream, - stream_options=utils.get_pydantic_model( - stream_options, - OptionalNullable[models.ChatStreamCompletionCreateParamsStreamOptions], - ), - temperature=temperature, - tool_choice=utils.get_pydantic_model( - tool_choice, Optional[models.ChatCompletionToolChoiceOption] - ), - tools=utils.get_pydantic_model( - tools, Optional[List[models.ChatCompletionTool]] - ), - top_p=top_p, - user=user, - models_llm=models_llm, - reasoning_effort=reasoning_effort, - provider=utils.get_pydantic_model( - provider, - OptionalNullable[models.ChatStreamCompletionCreateParamsProvider], - ), - plugins=utils.get_pydantic_model( - plugins, - Optional[List[models.ChatStreamCompletionCreateParamsPluginUnion]], - ), - ) - - req = self._build_request( - method="POST", - path="/chat/completions#stream", - base_url=base_url, - url_variables=url_variables, - request=request, - request_body_required=True, - request_has_path_params=False, - request_has_query_params=True, - user_agent_header="user-agent", - accept_header_value="text/event-stream", - http_headers=http_headers, - security=self.sdk_configuration.security, - get_serialized_body=lambda: utils.serialize_request_body( - request, False, False, "json", models.ChatStreamCompletionCreateParams - ), - timeout_ms=timeout_ms, - ) - - if retries == UNSET: - if self.sdk_configuration.retry_config is not UNSET: - retries = self.sdk_configuration.retry_config - - retry_config = None - if isinstance(retries, utils.RetryConfig): - retry_config = (retries, ["429", "500", "502", "503", "504"]) - - http_res = self.do_request( - hook_ctx=HookContext( - config=self.sdk_configuration, - base_url=base_url or "", - operation_id="streamChatCompletion", - oauth2_scopes=[], - security_source=get_security_from_env( - self.sdk_configuration.security, models.Security - ), - ), - request=req, - error_status_codes=["400", "401", "429", "4XX", "500", "5XX"], stream=True, retry_config=retry_config, ) response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + http_res_text = utils.stream_to_text(http_res) + return unmarshal_json_response( + models.ChatCompletion, http_res, http_res_text + ) if utils.match_response(http_res, "200", "text/event-stream"): return eventstreaming.EventStream( http_res, lambda raw: utils.unmarshal_json( - raw, models.StreamChatCompletionResponseBody + raw, models.ChatCompletionChunkWrapper ), sentinel="[DONE]", + client_ref=self, ) if utils.match_response(http_res, ["400", "401", "429"], "application/json"): http_res_text = utils.stream_to_text(http_res) @@ -735,7 +356,7 @@ class Chat(BaseSDK): "Unexpected response received", http_res, http_res_text ) - async def complete_stream_async( + async def complete_async( self, *, messages: Union[ @@ -752,30 +373,16 @@ class Chat(BaseSDK): metadata: Optional[Dict[str, str]] = None, presence_penalty: OptionalNullable[float] = UNSET, reasoning: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsReasoning, - models.ChatStreamCompletionCreateParamsReasoningTypedDict, - ] + Union[models.Reasoning, models.ReasoningTypedDict] ] = UNSET, response_format: Optional[ - Union[ - models.ChatStreamCompletionCreateParamsResponseFormatUnion, - models.ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict, - ] + Union[models.ResponseFormat, models.ResponseFormatTypedDict] ] = None, seed: OptionalNullable[int] = UNSET, - stop: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsStop, - models.ChatStreamCompletionCreateParamsStopTypedDict, - ] - ] = UNSET, - stream: Optional[bool] = True, + stop: OptionalNullable[Union[models.Stop, models.StopTypedDict]] = UNSET, + stream: OptionalNullable[bool] = False, stream_options: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsStreamOptions, - models.ChatStreamCompletionCreateParamsStreamOptionsTypedDict, - ] + Union[models.StreamOptions, models.StreamOptionsTypedDict] ] = UNSET, temperature: OptionalNullable[float] = 1, tool_choice: Optional[ @@ -792,27 +399,20 @@ class Chat(BaseSDK): ] = None, top_p: OptionalNullable[float] = 1, user: Optional[str] = None, - models_llm: OptionalNullable[List[str]] = UNSET, - reasoning_effort: OptionalNullable[ - models.ChatStreamCompletionCreateParamsReasoningEffort - ] = UNSET, + model_list: OptionalNullable[List[str]] = UNSET, + reasoning_effort: OptionalNullable[models.ReasoningEffort] = UNSET, provider: OptionalNullable[ - Union[ - models.ChatStreamCompletionCreateParamsProvider, - models.ChatStreamCompletionCreateParamsProviderTypedDict, - ] + Union[models.Provider, models.ProviderTypedDict] ] = UNSET, plugins: Optional[ - Union[ - List[models.ChatStreamCompletionCreateParamsPluginUnion], - List[models.ChatStreamCompletionCreateParamsPluginUnionTypedDict], - ] + Union[List[models.Plugin], List[models.PluginTypedDict]] ] = None, retries: OptionalNullable[utils.RetryConfig] = UNSET, server_url: Optional[str] = None, timeout_ms: Optional[int] = None, + accept_header_override: Optional[CompleteAcceptEnum] = None, http_headers: Optional[Mapping[str, str]] = None, - ) -> eventstreaming.EventStreamAsync[models.StreamChatCompletionResponseBody]: + ) -> models.CreateChatCompletionResponse: r"""Create a chat completion Creates a model response for the given chat conversation. Supports both streaming and non-streaming modes. @@ -838,13 +438,14 @@ class Chat(BaseSDK): :param tools: Available tools for function calling :param top_p: Nucleus sampling parameter (0-1) :param user: Unique user identifier - :param models_llm: Order of models to fallback to for this request + :param model_list: Order of models to fallback to for this request :param reasoning_effort: Reasoning effort :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 retries: Override the default retry configuration 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 accept_header_override: Override the default accept header for this method :param http_headers: Additional headers to set or replace on requests. """ base_url = None @@ -857,7 +458,7 @@ class Chat(BaseSDK): else: base_url = self._get_url(base_url, url_variables) - request = models.ChatStreamCompletionCreateParams( + request = models.ChatCompletionCreateParams( messages=utils.get_pydantic_model( messages, List[models.ChatCompletionMessageParam] ), @@ -871,19 +472,16 @@ class Chat(BaseSDK): metadata=metadata, presence_penalty=presence_penalty, reasoning=utils.get_pydantic_model( - reasoning, - OptionalNullable[models.ChatStreamCompletionCreateParamsReasoning], + reasoning, OptionalNullable[models.Reasoning] ), response_format=utils.get_pydantic_model( - response_format, - Optional[models.ChatStreamCompletionCreateParamsResponseFormatUnion], + response_format, Optional[models.ResponseFormat] ), seed=seed, stop=stop, stream=stream, stream_options=utils.get_pydantic_model( - stream_options, - OptionalNullable[models.ChatStreamCompletionCreateParamsStreamOptions], + stream_options, OptionalNullable[models.StreamOptions] ), temperature=temperature, tool_choice=utils.get_pydantic_model( @@ -894,21 +492,17 @@ class Chat(BaseSDK): ), top_p=top_p, user=user, - models_llm=models_llm, + model_list=model_list, reasoning_effort=reasoning_effort, provider=utils.get_pydantic_model( - provider, - OptionalNullable[models.ChatStreamCompletionCreateParamsProvider], - ), - plugins=utils.get_pydantic_model( - plugins, - Optional[List[models.ChatStreamCompletionCreateParamsPluginUnion]], + provider, OptionalNullable[models.Provider] ), + plugins=utils.get_pydantic_model(plugins, Optional[List[models.Plugin]]), ) req = self._build_request_async( method="POST", - path="/chat/completions#stream", + path="/chat/completions", base_url=base_url, url_variables=url_variables, request=request, @@ -916,11 +510,13 @@ class Chat(BaseSDK): request_has_path_params=False, request_has_query_params=True, user_agent_header="user-agent", - accept_header_value="text/event-stream", + accept_header_value=accept_header_override.value + if accept_header_override is not None + else "application/json;q=1, text/event-stream;q=0", http_headers=http_headers, security=self.sdk_configuration.security, get_serialized_body=lambda: utils.serialize_request_body( - request, False, False, "json", models.ChatStreamCompletionCreateParams + request, False, False, "json", models.ChatCompletionCreateParams ), timeout_ms=timeout_ms, ) @@ -937,7 +533,7 @@ class Chat(BaseSDK): hook_ctx=HookContext( config=self.sdk_configuration, base_url=base_url or "", - operation_id="streamChatCompletion", + operation_id="createChatCompletion", oauth2_scopes=[], security_source=get_security_from_env( self.sdk_configuration.security, models.Security @@ -950,13 +546,19 @@ class Chat(BaseSDK): ) response_data: Any = None + if utils.match_response(http_res, "200", "application/json"): + http_res_text = await utils.stream_to_text_async(http_res) + return unmarshal_json_response( + models.ChatCompletion, http_res, http_res_text + ) if utils.match_response(http_res, "200", "text/event-stream"): return eventstreaming.EventStreamAsync( http_res, lambda raw: utils.unmarshal_json( - raw, models.StreamChatCompletionResponseBody + raw, models.ChatCompletionChunkWrapper ), sentinel="[DONE]", + client_ref=self, ) if utils.match_response(http_res, ["400", "401", "429"], "application/json"): http_res_text = await utils.stream_to_text_async(http_res) diff --git a/src/openrouter/errors/__init__.py b/src/openrouter/errors/__init__.py index 5cf95f1..67b0e5d 100644 --- a/src/openrouter/errors/__init__.py +++ b/src/openrouter/errors/__init__.py @@ -1,14 +1,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" +from .openroutererror import OpenRouterError from typing import TYPE_CHECKING from importlib import import_module import builtins +import sys if TYPE_CHECKING: from .chatcompletionerror import ChatCompletionError, ChatCompletionErrorData from .no_response_error import NoResponseError from .openrouterdefaulterror import OpenRouterDefaultError - from .openroutererror import OpenRouterError from .responsevalidationerror import ResponseValidationError __all__ = [ @@ -25,11 +26,22 @@ _dynamic_imports: dict[str, str] = { "ChatCompletionErrorData": ".chatcompletionerror", "NoResponseError": ".no_response_error", "OpenRouterDefaultError": ".openrouterdefaulterror", - "OpenRouterError": ".openroutererror", "ResponseValidationError": ".responsevalidationerror", } +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: @@ -38,7 +50,7 @@ def __getattr__(attr_name: str) -> object: ) try: - module = import_module(module_name, __package__) + module = dynamic_import(module_name) result = getattr(module, attr_name) return result except ImportError as e: diff --git a/src/openrouter/models/__init__.py b/src/openrouter/models/__init__.py index 59080c2..9ec727c 100644 --- a/src/openrouter/models/__init__.py +++ b/src/openrouter/models/__init__.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING from importlib import import_module import builtins +import sys if TYPE_CHECKING: from .annotationdetail import AnnotationDetail, AnnotationDetailTypedDict @@ -45,6 +46,10 @@ if TYPE_CHECKING: ChatCompletionChunkChoiceDeltaToolCallType, ChatCompletionChunkChoiceDeltaToolCallTypedDict, ) + from .chatcompletionchunkwrapper import ( + ChatCompletionChunkWrapper, + ChatCompletionChunkWrapperTypedDict, + ) from .chatcompletioncontentpart import ( ChatCompletionContentPart, ChatCompletionContentPartTypedDict, @@ -71,79 +76,79 @@ if TYPE_CHECKING: ChatCompletionContentPartTextTypedDict, ) from .chatcompletioncreateparams import ( + Audio, + AudioTypedDict, ChatCompletionCreateParams, - ChatCompletionCreateParamsAudio, - ChatCompletionCreateParamsAudioTypedDict, - ChatCompletionCreateParamsCompletion, - ChatCompletionCreateParamsCompletionTypedDict, - ChatCompletionCreateParamsDataCollection, - ChatCompletionCreateParamsEffort, - ChatCompletionCreateParamsEngine, - ChatCompletionCreateParamsIDChainOfThought, - ChatCompletionCreateParamsIDFileParser, - ChatCompletionCreateParamsIDModeration, - ChatCompletionCreateParamsIDWeb, - ChatCompletionCreateParamsIgnoreEnum, - ChatCompletionCreateParamsIgnoreUnion, - ChatCompletionCreateParamsIgnoreUnionTypedDict, - ChatCompletionCreateParamsImage, - ChatCompletionCreateParamsImageTypedDict, - ChatCompletionCreateParamsJSONSchema, - ChatCompletionCreateParamsJSONSchemaTypedDict, - ChatCompletionCreateParamsMaxPrice, - ChatCompletionCreateParamsMaxPriceTypedDict, - ChatCompletionCreateParamsOnlyEnum, - ChatCompletionCreateParamsOnlyUnion, - ChatCompletionCreateParamsOnlyUnionTypedDict, - ChatCompletionCreateParamsOrderEnum, - ChatCompletionCreateParamsOrderUnion, - ChatCompletionCreateParamsOrderUnionTypedDict, - ChatCompletionCreateParamsPdf, - ChatCompletionCreateParamsPdfEngine, - ChatCompletionCreateParamsPdfTypedDict, - ChatCompletionCreateParamsPluginChainOfThought, - ChatCompletionCreateParamsPluginChainOfThoughtTypedDict, - ChatCompletionCreateParamsPluginFileParser, - ChatCompletionCreateParamsPluginFileParserTypedDict, - ChatCompletionCreateParamsPluginModeration, - ChatCompletionCreateParamsPluginModerationTypedDict, - ChatCompletionCreateParamsPluginUnion, - ChatCompletionCreateParamsPluginUnionTypedDict, - ChatCompletionCreateParamsPluginWeb, - ChatCompletionCreateParamsPluginWebTypedDict, - ChatCompletionCreateParamsPrompt, - ChatCompletionCreateParamsPromptTypedDict, - ChatCompletionCreateParamsProvider, - ChatCompletionCreateParamsProviderTypedDict, - ChatCompletionCreateParamsQuantization, - ChatCompletionCreateParamsReasoning, - ChatCompletionCreateParamsReasoningEffort, - ChatCompletionCreateParamsReasoningTypedDict, - ChatCompletionCreateParamsRequest, - ChatCompletionCreateParamsRequestTypedDict, - ChatCompletionCreateParamsResponseFormatGrammar, - ChatCompletionCreateParamsResponseFormatGrammarTypedDict, - ChatCompletionCreateParamsResponseFormatJSONObject, - ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict, - ChatCompletionCreateParamsResponseFormatJSONSchema, - ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict, - ChatCompletionCreateParamsResponseFormatPython, - ChatCompletionCreateParamsResponseFormatPythonTypedDict, - ChatCompletionCreateParamsResponseFormatText, - ChatCompletionCreateParamsResponseFormatTextTypedDict, - ChatCompletionCreateParamsResponseFormatUnion, - ChatCompletionCreateParamsResponseFormatUnionTypedDict, - ChatCompletionCreateParamsSort, - ChatCompletionCreateParamsStop, - ChatCompletionCreateParamsStopTypedDict, - ChatCompletionCreateParamsStreamOptions, - ChatCompletionCreateParamsStreamOptionsTypedDict, - ChatCompletionCreateParamsTypeGrammar, - ChatCompletionCreateParamsTypeJSONObject, - ChatCompletionCreateParamsTypeJSONSchema, - ChatCompletionCreateParamsTypePython, ChatCompletionCreateParamsTypeText, ChatCompletionCreateParamsTypedDict, + Completion, + CompletionTypedDict, + DataCollection, + Effort, + Engine, + IDChainOfThought, + IDFileParser, + IDModeration, + IDWeb, + Ignore, + IgnoreEnum, + IgnoreTypedDict, + Image, + ImageTypedDict, + JSONSchema, + JSONSchemaTypedDict, + MaxPrice, + MaxPriceTypedDict, + Only, + OnlyEnum, + OnlyTypedDict, + Order, + OrderEnum, + OrderTypedDict, + Pdf, + PdfEngine, + PdfTypedDict, + Plugin, + PluginChainOfThought, + PluginChainOfThoughtTypedDict, + PluginFileParser, + PluginFileParserTypedDict, + PluginModeration, + PluginModerationTypedDict, + PluginTypedDict, + PluginWeb, + PluginWebTypedDict, + Prompt, + PromptTypedDict, + Provider, + ProviderTypedDict, + Quantization, + Reasoning, + ReasoningEffort, + ReasoningTypedDict, + Request, + RequestTypedDict, + ResponseFormat, + ResponseFormatGrammar, + ResponseFormatGrammarTypedDict, + ResponseFormatJSONObject, + ResponseFormatJSONObjectTypedDict, + ResponseFormatJSONSchema, + ResponseFormatJSONSchemaTypedDict, + ResponseFormatPython, + ResponseFormatPythonTypedDict, + ResponseFormatText, + ResponseFormatTextTypedDict, + ResponseFormatTypedDict, + Sort, + Stop, + StopTypedDict, + StreamOptions, + StreamOptionsTypedDict, + TypeGrammar, + TypeJSONObject, + TypeJSONSchema, + TypePython, ) from .chatcompletionerror import Error, ErrorTypedDict from .chatcompletionmessage import ( @@ -216,81 +221,6 @@ if TYPE_CHECKING: ChatCompletionUserMessageParamRole, ChatCompletionUserMessageParamTypedDict, ) - from .chatstreamcompletioncreateparams import ( - ChatStreamCompletionCreateParams, - ChatStreamCompletionCreateParamsAudio, - ChatStreamCompletionCreateParamsAudioTypedDict, - ChatStreamCompletionCreateParamsCompletion, - ChatStreamCompletionCreateParamsCompletionTypedDict, - ChatStreamCompletionCreateParamsDataCollection, - ChatStreamCompletionCreateParamsEffort, - ChatStreamCompletionCreateParamsEngine, - ChatStreamCompletionCreateParamsIDChainOfThought, - ChatStreamCompletionCreateParamsIDFileParser, - ChatStreamCompletionCreateParamsIDModeration, - ChatStreamCompletionCreateParamsIDWeb, - ChatStreamCompletionCreateParamsIgnoreEnum, - ChatStreamCompletionCreateParamsIgnoreUnion, - ChatStreamCompletionCreateParamsIgnoreUnionTypedDict, - ChatStreamCompletionCreateParamsImage, - ChatStreamCompletionCreateParamsImageTypedDict, - ChatStreamCompletionCreateParamsJSONSchema, - ChatStreamCompletionCreateParamsJSONSchemaTypedDict, - ChatStreamCompletionCreateParamsMaxPrice, - ChatStreamCompletionCreateParamsMaxPriceTypedDict, - ChatStreamCompletionCreateParamsOnlyEnum, - ChatStreamCompletionCreateParamsOnlyUnion, - ChatStreamCompletionCreateParamsOnlyUnionTypedDict, - ChatStreamCompletionCreateParamsOrderEnum, - ChatStreamCompletionCreateParamsOrderUnion, - ChatStreamCompletionCreateParamsOrderUnionTypedDict, - ChatStreamCompletionCreateParamsPdf, - ChatStreamCompletionCreateParamsPdfEngine, - ChatStreamCompletionCreateParamsPdfTypedDict, - ChatStreamCompletionCreateParamsPluginChainOfThought, - ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict, - ChatStreamCompletionCreateParamsPluginFileParser, - ChatStreamCompletionCreateParamsPluginFileParserTypedDict, - ChatStreamCompletionCreateParamsPluginModeration, - ChatStreamCompletionCreateParamsPluginModerationTypedDict, - ChatStreamCompletionCreateParamsPluginUnion, - ChatStreamCompletionCreateParamsPluginUnionTypedDict, - ChatStreamCompletionCreateParamsPluginWeb, - ChatStreamCompletionCreateParamsPluginWebTypedDict, - ChatStreamCompletionCreateParamsPrompt, - ChatStreamCompletionCreateParamsPromptTypedDict, - ChatStreamCompletionCreateParamsProvider, - ChatStreamCompletionCreateParamsProviderTypedDict, - ChatStreamCompletionCreateParamsQuantization, - ChatStreamCompletionCreateParamsReasoning, - ChatStreamCompletionCreateParamsReasoningEffort, - ChatStreamCompletionCreateParamsReasoningTypedDict, - ChatStreamCompletionCreateParamsRequest, - ChatStreamCompletionCreateParamsRequestTypedDict, - ChatStreamCompletionCreateParamsResponseFormatGrammar, - ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict, - ChatStreamCompletionCreateParamsResponseFormatJSONObject, - ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict, - ChatStreamCompletionCreateParamsResponseFormatJSONSchema, - ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict, - ChatStreamCompletionCreateParamsResponseFormatPython, - ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict, - ChatStreamCompletionCreateParamsResponseFormatText, - ChatStreamCompletionCreateParamsResponseFormatTextTypedDict, - ChatStreamCompletionCreateParamsResponseFormatUnion, - ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict, - ChatStreamCompletionCreateParamsSort, - ChatStreamCompletionCreateParamsStop, - ChatStreamCompletionCreateParamsStopTypedDict, - ChatStreamCompletionCreateParamsStreamOptions, - ChatStreamCompletionCreateParamsStreamOptionsTypedDict, - ChatStreamCompletionCreateParamsTypeGrammar, - ChatStreamCompletionCreateParamsTypeJSONObject, - ChatStreamCompletionCreateParamsTypeJSONSchema, - ChatStreamCompletionCreateParamsTypePython, - ChatStreamCompletionCreateParamsTypeText, - ChatStreamCompletionCreateParamsTypedDict, - ) from .completionusage import ( CompletionTokensDetails, CompletionTokensDetailsTypedDict, @@ -299,6 +229,10 @@ if TYPE_CHECKING: PromptTokensDetails, PromptTokensDetailsTypedDict, ) + from .createchatcompletionop import ( + CreateChatCompletionResponse, + CreateChatCompletionResponseTypedDict, + ) from .fileannotationdetail import ( ContentImageURL, ContentImageURLTypedDict, @@ -340,10 +274,6 @@ if TYPE_CHECKING: ResponseFormatJSONSchemaSchemaTypedDict, ) from .security import Security, SecurityTypedDict - from .streamchatcompletionop import ( - StreamChatCompletionResponseBody, - StreamChatCompletionResponseBodyTypedDict, - ) from .urlcitationannotationdetail import ( URLCitation, URLCitationAnnotationDetail, @@ -355,6 +285,8 @@ if TYPE_CHECKING: __all__ = [ "AnnotationDetail", "AnnotationDetailTypedDict", + "Audio", + "AudioTypedDict", "ChatCompletion", "ChatCompletionAssistantMessageParam", "ChatCompletionAssistantMessageParamContent", @@ -378,6 +310,8 @@ __all__ = [ "ChatCompletionChunkChoiceTypedDict", "ChatCompletionChunkObject", "ChatCompletionChunkTypedDict", + "ChatCompletionChunkWrapper", + "ChatCompletionChunkWrapperTypedDict", "ChatCompletionContentPart", "ChatCompletionContentPartAudio", "ChatCompletionContentPartAudioFormat", @@ -393,76 +327,6 @@ __all__ = [ "ChatCompletionContentPartTextTypedDict", "ChatCompletionContentPartTypedDict", "ChatCompletionCreateParams", - "ChatCompletionCreateParamsAudio", - "ChatCompletionCreateParamsAudioTypedDict", - "ChatCompletionCreateParamsCompletion", - "ChatCompletionCreateParamsCompletionTypedDict", - "ChatCompletionCreateParamsDataCollection", - "ChatCompletionCreateParamsEffort", - "ChatCompletionCreateParamsEngine", - "ChatCompletionCreateParamsIDChainOfThought", - "ChatCompletionCreateParamsIDFileParser", - "ChatCompletionCreateParamsIDModeration", - "ChatCompletionCreateParamsIDWeb", - "ChatCompletionCreateParamsIgnoreEnum", - "ChatCompletionCreateParamsIgnoreUnion", - "ChatCompletionCreateParamsIgnoreUnionTypedDict", - "ChatCompletionCreateParamsImage", - "ChatCompletionCreateParamsImageTypedDict", - "ChatCompletionCreateParamsJSONSchema", - "ChatCompletionCreateParamsJSONSchemaTypedDict", - "ChatCompletionCreateParamsMaxPrice", - "ChatCompletionCreateParamsMaxPriceTypedDict", - "ChatCompletionCreateParamsOnlyEnum", - "ChatCompletionCreateParamsOnlyUnion", - "ChatCompletionCreateParamsOnlyUnionTypedDict", - "ChatCompletionCreateParamsOrderEnum", - "ChatCompletionCreateParamsOrderUnion", - "ChatCompletionCreateParamsOrderUnionTypedDict", - "ChatCompletionCreateParamsPdf", - "ChatCompletionCreateParamsPdfEngine", - "ChatCompletionCreateParamsPdfTypedDict", - "ChatCompletionCreateParamsPluginChainOfThought", - "ChatCompletionCreateParamsPluginChainOfThoughtTypedDict", - "ChatCompletionCreateParamsPluginFileParser", - "ChatCompletionCreateParamsPluginFileParserTypedDict", - "ChatCompletionCreateParamsPluginModeration", - "ChatCompletionCreateParamsPluginModerationTypedDict", - "ChatCompletionCreateParamsPluginUnion", - "ChatCompletionCreateParamsPluginUnionTypedDict", - "ChatCompletionCreateParamsPluginWeb", - "ChatCompletionCreateParamsPluginWebTypedDict", - "ChatCompletionCreateParamsPrompt", - "ChatCompletionCreateParamsPromptTypedDict", - "ChatCompletionCreateParamsProvider", - "ChatCompletionCreateParamsProviderTypedDict", - "ChatCompletionCreateParamsQuantization", - "ChatCompletionCreateParamsReasoning", - "ChatCompletionCreateParamsReasoningEffort", - "ChatCompletionCreateParamsReasoningTypedDict", - "ChatCompletionCreateParamsRequest", - "ChatCompletionCreateParamsRequestTypedDict", - "ChatCompletionCreateParamsResponseFormatGrammar", - "ChatCompletionCreateParamsResponseFormatGrammarTypedDict", - "ChatCompletionCreateParamsResponseFormatJSONObject", - "ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict", - "ChatCompletionCreateParamsResponseFormatJSONSchema", - "ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict", - "ChatCompletionCreateParamsResponseFormatPython", - "ChatCompletionCreateParamsResponseFormatPythonTypedDict", - "ChatCompletionCreateParamsResponseFormatText", - "ChatCompletionCreateParamsResponseFormatTextTypedDict", - "ChatCompletionCreateParamsResponseFormatUnion", - "ChatCompletionCreateParamsResponseFormatUnionTypedDict", - "ChatCompletionCreateParamsSort", - "ChatCompletionCreateParamsStop", - "ChatCompletionCreateParamsStopTypedDict", - "ChatCompletionCreateParamsStreamOptions", - "ChatCompletionCreateParamsStreamOptionsTypedDict", - "ChatCompletionCreateParamsTypeGrammar", - "ChatCompletionCreateParamsTypeJSONObject", - "ChatCompletionCreateParamsTypeJSONSchema", - "ChatCompletionCreateParamsTypePython", "ChatCompletionCreateParamsTypeText", "ChatCompletionCreateParamsTypedDict", "ChatCompletionMessage", @@ -511,81 +375,10 @@ __all__ = [ "ChatCompletionUserMessageParamContentTypedDict", "ChatCompletionUserMessageParamRole", "ChatCompletionUserMessageParamTypedDict", - "ChatStreamCompletionCreateParams", - "ChatStreamCompletionCreateParamsAudio", - "ChatStreamCompletionCreateParamsAudioTypedDict", - "ChatStreamCompletionCreateParamsCompletion", - "ChatStreamCompletionCreateParamsCompletionTypedDict", - "ChatStreamCompletionCreateParamsDataCollection", - "ChatStreamCompletionCreateParamsEffort", - "ChatStreamCompletionCreateParamsEngine", - "ChatStreamCompletionCreateParamsIDChainOfThought", - "ChatStreamCompletionCreateParamsIDFileParser", - "ChatStreamCompletionCreateParamsIDModeration", - "ChatStreamCompletionCreateParamsIDWeb", - "ChatStreamCompletionCreateParamsIgnoreEnum", - "ChatStreamCompletionCreateParamsIgnoreUnion", - "ChatStreamCompletionCreateParamsIgnoreUnionTypedDict", - "ChatStreamCompletionCreateParamsImage", - "ChatStreamCompletionCreateParamsImageTypedDict", - "ChatStreamCompletionCreateParamsJSONSchema", - "ChatStreamCompletionCreateParamsJSONSchemaTypedDict", - "ChatStreamCompletionCreateParamsMaxPrice", - "ChatStreamCompletionCreateParamsMaxPriceTypedDict", - "ChatStreamCompletionCreateParamsOnlyEnum", - "ChatStreamCompletionCreateParamsOnlyUnion", - "ChatStreamCompletionCreateParamsOnlyUnionTypedDict", - "ChatStreamCompletionCreateParamsOrderEnum", - "ChatStreamCompletionCreateParamsOrderUnion", - "ChatStreamCompletionCreateParamsOrderUnionTypedDict", - "ChatStreamCompletionCreateParamsPdf", - "ChatStreamCompletionCreateParamsPdfEngine", - "ChatStreamCompletionCreateParamsPdfTypedDict", - "ChatStreamCompletionCreateParamsPluginChainOfThought", - "ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict", - "ChatStreamCompletionCreateParamsPluginFileParser", - "ChatStreamCompletionCreateParamsPluginFileParserTypedDict", - "ChatStreamCompletionCreateParamsPluginModeration", - "ChatStreamCompletionCreateParamsPluginModerationTypedDict", - "ChatStreamCompletionCreateParamsPluginUnion", - "ChatStreamCompletionCreateParamsPluginUnionTypedDict", - "ChatStreamCompletionCreateParamsPluginWeb", - "ChatStreamCompletionCreateParamsPluginWebTypedDict", - "ChatStreamCompletionCreateParamsPrompt", - "ChatStreamCompletionCreateParamsPromptTypedDict", - "ChatStreamCompletionCreateParamsProvider", - "ChatStreamCompletionCreateParamsProviderTypedDict", - "ChatStreamCompletionCreateParamsQuantization", - "ChatStreamCompletionCreateParamsReasoning", - "ChatStreamCompletionCreateParamsReasoningEffort", - "ChatStreamCompletionCreateParamsReasoningTypedDict", - "ChatStreamCompletionCreateParamsRequest", - "ChatStreamCompletionCreateParamsRequestTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatGrammar", - "ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatJSONObject", - "ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatJSONSchema", - "ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatPython", - "ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatText", - "ChatStreamCompletionCreateParamsResponseFormatTextTypedDict", - "ChatStreamCompletionCreateParamsResponseFormatUnion", - "ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict", - "ChatStreamCompletionCreateParamsSort", - "ChatStreamCompletionCreateParamsStop", - "ChatStreamCompletionCreateParamsStopTypedDict", - "ChatStreamCompletionCreateParamsStreamOptions", - "ChatStreamCompletionCreateParamsStreamOptionsTypedDict", - "ChatStreamCompletionCreateParamsTypeGrammar", - "ChatStreamCompletionCreateParamsTypeJSONObject", - "ChatStreamCompletionCreateParamsTypeJSONSchema", - "ChatStreamCompletionCreateParamsTypePython", - "ChatStreamCompletionCreateParamsTypeText", - "ChatStreamCompletionCreateParamsTypedDict", + "Completion", "CompletionTokensDetails", "CompletionTokensDetailsTypedDict", + "CompletionTypedDict", "CompletionUsage", "CompletionUsageTypedDict", "ContentImageURL", @@ -594,7 +387,12 @@ __all__ = [ "ContentTextTypedDict", "ContentTypeImageURL", "ContentTypeText", + "CreateChatCompletionResponse", + "CreateChatCompletionResponseTypedDict", + "DataCollection", "Detail", + "Effort", + "Engine", "Error", "ErrorTypedDict", "File", @@ -605,12 +403,50 @@ __all__ = [ "FileAnnotationDetailImageURLTypedDict", "FileAnnotationDetailTypedDict", "FileTypedDict", + "IDChainOfThought", + "IDFileParser", + "IDModeration", + "IDWeb", + "Ignore", + "IgnoreEnum", + "IgnoreTypedDict", + "Image", + "ImageTypedDict", "InputAudio", "InputAudioTypedDict", + "JSONSchema", + "JSONSchemaTypedDict", + "MaxPrice", + "MaxPriceTypedDict", + "Only", + "OnlyEnum", + "OnlyTypedDict", + "Order", + "OrderEnum", + "OrderTypedDict", "Parameters", "ParametersTypedDict", + "Pdf", + "PdfEngine", + "PdfTypedDict", + "Plugin", + "PluginChainOfThought", + "PluginChainOfThoughtTypedDict", + "PluginFileParser", + "PluginFileParserTypedDict", + "PluginModeration", + "PluginModerationTypedDict", + "PluginTypedDict", + "PluginWeb", + "PluginWebTypedDict", + "Prompt", "PromptTokensDetails", "PromptTokensDetailsTypedDict", + "PromptTypedDict", + "Provider", + "ProviderTypedDict", + "Quantization", + "Reasoning", "ReasoningDetail", "ReasoningDetailEncrypted", "ReasoningDetailEncryptedFormat", @@ -625,15 +461,38 @@ __all__ = [ "ReasoningDetailTextType", "ReasoningDetailTextTypedDict", "ReasoningDetailTypedDict", + "ReasoningEffort", + "ReasoningTypedDict", + "Request", + "RequestTypedDict", + "ResponseFormat", + "ResponseFormatGrammar", + "ResponseFormatGrammarTypedDict", + "ResponseFormatJSONObject", + "ResponseFormatJSONObjectTypedDict", + "ResponseFormatJSONSchema", "ResponseFormatJSONSchemaSchema", "ResponseFormatJSONSchemaSchemaTypedDict", + "ResponseFormatJSONSchemaTypedDict", + "ResponseFormatPython", + "ResponseFormatPythonTypedDict", + "ResponseFormatText", + "ResponseFormatTextTypedDict", + "ResponseFormatTypedDict", "Security", "SecurityTypedDict", - "StreamChatCompletionResponseBody", - "StreamChatCompletionResponseBodyTypedDict", + "Sort", + "Stop", + "StopTypedDict", + "StreamOptions", + "StreamOptionsTypedDict", "TopLogprob", "TopLogprobTypedDict", "TypeFile", + "TypeGrammar", + "TypeJSONObject", + "TypeJSONSchema", + "TypePython", "URLCitation", "URLCitationAnnotationDetail", "URLCitationAnnotationDetailType", @@ -669,6 +528,8 @@ _dynamic_imports: dict[str, str] = { "ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict": ".chatcompletionchunkchoicedeltatoolcall", "ChatCompletionChunkChoiceDeltaToolCallType": ".chatcompletionchunkchoicedeltatoolcall", "ChatCompletionChunkChoiceDeltaToolCallTypedDict": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionChunkWrapper": ".chatcompletionchunkwrapper", + "ChatCompletionChunkWrapperTypedDict": ".chatcompletionchunkwrapper", "ChatCompletionContentPart": ".chatcompletioncontentpart", "ChatCompletionContentPartTypedDict": ".chatcompletioncontentpart", "ChatCompletionContentPartAudio": ".chatcompletioncontentpartaudio", @@ -686,79 +547,79 @@ _dynamic_imports: dict[str, str] = { "ChatCompletionContentPartText": ".chatcompletioncontentparttext", "ChatCompletionContentPartTextType": ".chatcompletioncontentparttext", "ChatCompletionContentPartTextTypedDict": ".chatcompletioncontentparttext", + "Audio": ".chatcompletioncreateparams", + "AudioTypedDict": ".chatcompletioncreateparams", "ChatCompletionCreateParams": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsAudio": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsAudioTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsCompletion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsCompletionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsDataCollection": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsEffort": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsEngine": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIDChainOfThought": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIDFileParser": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIDModeration": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIDWeb": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIgnoreEnum": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIgnoreUnion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsIgnoreUnionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsImage": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsImageTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsJSONSchema": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsJSONSchemaTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsMaxPrice": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsMaxPriceTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOnlyEnum": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOnlyUnion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOnlyUnionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOrderEnum": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOrderUnion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsOrderUnionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPdf": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPdfEngine": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPdfTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginChainOfThought": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginChainOfThoughtTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginFileParser": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginFileParserTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginModeration": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginModerationTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginUnion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginUnionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginWeb": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPluginWebTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPrompt": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsPromptTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsProvider": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsProviderTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsQuantization": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsReasoning": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsReasoningEffort": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsReasoningTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsRequest": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsRequestTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatGrammar": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatGrammarTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatJSONObject": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatJSONSchema": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatPython": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatPythonTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatText": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatTextTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatUnion": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsResponseFormatUnionTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsSort": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsStop": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsStopTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsStreamOptions": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsStreamOptionsTypedDict": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsTypeGrammar": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsTypeJSONObject": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsTypeJSONSchema": ".chatcompletioncreateparams", - "ChatCompletionCreateParamsTypePython": ".chatcompletioncreateparams", "ChatCompletionCreateParamsTypeText": ".chatcompletioncreateparams", "ChatCompletionCreateParamsTypedDict": ".chatcompletioncreateparams", + "Completion": ".chatcompletioncreateparams", + "CompletionTypedDict": ".chatcompletioncreateparams", + "DataCollection": ".chatcompletioncreateparams", + "Effort": ".chatcompletioncreateparams", + "Engine": ".chatcompletioncreateparams", + "IDChainOfThought": ".chatcompletioncreateparams", + "IDFileParser": ".chatcompletioncreateparams", + "IDModeration": ".chatcompletioncreateparams", + "IDWeb": ".chatcompletioncreateparams", + "Ignore": ".chatcompletioncreateparams", + "IgnoreEnum": ".chatcompletioncreateparams", + "IgnoreTypedDict": ".chatcompletioncreateparams", + "Image": ".chatcompletioncreateparams", + "ImageTypedDict": ".chatcompletioncreateparams", + "JSONSchema": ".chatcompletioncreateparams", + "JSONSchemaTypedDict": ".chatcompletioncreateparams", + "MaxPrice": ".chatcompletioncreateparams", + "MaxPriceTypedDict": ".chatcompletioncreateparams", + "Only": ".chatcompletioncreateparams", + "OnlyEnum": ".chatcompletioncreateparams", + "OnlyTypedDict": ".chatcompletioncreateparams", + "Order": ".chatcompletioncreateparams", + "OrderEnum": ".chatcompletioncreateparams", + "OrderTypedDict": ".chatcompletioncreateparams", + "Pdf": ".chatcompletioncreateparams", + "PdfEngine": ".chatcompletioncreateparams", + "PdfTypedDict": ".chatcompletioncreateparams", + "Plugin": ".chatcompletioncreateparams", + "PluginChainOfThought": ".chatcompletioncreateparams", + "PluginChainOfThoughtTypedDict": ".chatcompletioncreateparams", + "PluginFileParser": ".chatcompletioncreateparams", + "PluginFileParserTypedDict": ".chatcompletioncreateparams", + "PluginModeration": ".chatcompletioncreateparams", + "PluginModerationTypedDict": ".chatcompletioncreateparams", + "PluginTypedDict": ".chatcompletioncreateparams", + "PluginWeb": ".chatcompletioncreateparams", + "PluginWebTypedDict": ".chatcompletioncreateparams", + "Prompt": ".chatcompletioncreateparams", + "PromptTypedDict": ".chatcompletioncreateparams", + "Provider": ".chatcompletioncreateparams", + "ProviderTypedDict": ".chatcompletioncreateparams", + "Quantization": ".chatcompletioncreateparams", + "Reasoning": ".chatcompletioncreateparams", + "ReasoningEffort": ".chatcompletioncreateparams", + "ReasoningTypedDict": ".chatcompletioncreateparams", + "Request": ".chatcompletioncreateparams", + "RequestTypedDict": ".chatcompletioncreateparams", + "ResponseFormat": ".chatcompletioncreateparams", + "ResponseFormatGrammar": ".chatcompletioncreateparams", + "ResponseFormatGrammarTypedDict": ".chatcompletioncreateparams", + "ResponseFormatJSONObject": ".chatcompletioncreateparams", + "ResponseFormatJSONObjectTypedDict": ".chatcompletioncreateparams", + "ResponseFormatJSONSchema": ".chatcompletioncreateparams", + "ResponseFormatJSONSchemaTypedDict": ".chatcompletioncreateparams", + "ResponseFormatPython": ".chatcompletioncreateparams", + "ResponseFormatPythonTypedDict": ".chatcompletioncreateparams", + "ResponseFormatText": ".chatcompletioncreateparams", + "ResponseFormatTextTypedDict": ".chatcompletioncreateparams", + "ResponseFormatTypedDict": ".chatcompletioncreateparams", + "Sort": ".chatcompletioncreateparams", + "Stop": ".chatcompletioncreateparams", + "StopTypedDict": ".chatcompletioncreateparams", + "StreamOptions": ".chatcompletioncreateparams", + "StreamOptionsTypedDict": ".chatcompletioncreateparams", + "TypeGrammar": ".chatcompletioncreateparams", + "TypeJSONObject": ".chatcompletioncreateparams", + "TypeJSONSchema": ".chatcompletioncreateparams", + "TypePython": ".chatcompletioncreateparams", "Error": ".chatcompletionerror", "ErrorTypedDict": ".chatcompletionerror", "ChatCompletionMessage": ".chatcompletionmessage", @@ -809,85 +670,14 @@ _dynamic_imports: dict[str, str] = { "ChatCompletionUserMessageParamContentTypedDict": ".chatcompletionusermessageparam", "ChatCompletionUserMessageParamRole": ".chatcompletionusermessageparam", "ChatCompletionUserMessageParamTypedDict": ".chatcompletionusermessageparam", - "ChatStreamCompletionCreateParams": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsAudio": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsAudioTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsCompletion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsCompletionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsDataCollection": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsEffort": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsEngine": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIDChainOfThought": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIDFileParser": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIDModeration": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIDWeb": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIgnoreEnum": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIgnoreUnion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsIgnoreUnionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsImage": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsImageTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsJSONSchema": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsJSONSchemaTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsMaxPrice": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsMaxPriceTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOnlyEnum": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOnlyUnion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOnlyUnionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOrderEnum": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOrderUnion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsOrderUnionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPdf": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPdfEngine": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPdfTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginChainOfThought": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginFileParser": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginFileParserTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginModeration": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginModerationTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginUnion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginUnionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginWeb": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPluginWebTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPrompt": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsPromptTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsProvider": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsProviderTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsQuantization": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsReasoning": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsReasoningEffort": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsReasoningTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsRequest": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsRequestTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatGrammar": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatJSONObject": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatJSONSchema": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatPython": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatText": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatTextTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatUnion": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsSort": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsStop": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsStopTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsStreamOptions": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsStreamOptionsTypedDict": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypeGrammar": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypeJSONObject": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypeJSONSchema": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypePython": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypeText": ".chatstreamcompletioncreateparams", - "ChatStreamCompletionCreateParamsTypedDict": ".chatstreamcompletioncreateparams", "CompletionTokensDetails": ".completionusage", "CompletionTokensDetailsTypedDict": ".completionusage", "CompletionUsage": ".completionusage", "CompletionUsageTypedDict": ".completionusage", "PromptTokensDetails": ".completionusage", "PromptTokensDetailsTypedDict": ".completionusage", + "CreateChatCompletionResponse": ".createchatcompletionop", + "CreateChatCompletionResponseTypedDict": ".createchatcompletionop", "ContentImageURL": ".fileannotationdetail", "ContentImageURLTypedDict": ".fileannotationdetail", "ContentText": ".fileannotationdetail", @@ -921,8 +711,6 @@ _dynamic_imports: dict[str, str] = { "ResponseFormatJSONSchemaSchemaTypedDict": ".responseformatjsonschemaschema", "Security": ".security", "SecurityTypedDict": ".security", - "StreamChatCompletionResponseBody": ".streamchatcompletionop", - "StreamChatCompletionResponseBodyTypedDict": ".streamchatcompletionop", "URLCitation": ".urlcitationannotationdetail", "URLCitationAnnotationDetail": ".urlcitationannotationdetail", "URLCitationAnnotationDetailType": ".urlcitationannotationdetail", @@ -931,6 +719,18 @@ _dynamic_imports: dict[str, str] = { } +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: @@ -939,7 +739,7 @@ def __getattr__(attr_name: str) -> object: ) try: - module = import_module(module_name, __package__) + module = dynamic_import(module_name) result = getattr(module, attr_name) return result except ImportError as e: diff --git a/src/openrouter/models/chatcompletion.py b/src/openrouter/models/chatcompletion.py index f4fd50c..e592b38 100644 --- a/src/openrouter/models/chatcompletion.py +++ b/src/openrouter/models/chatcompletion.py @@ -3,7 +3,6 @@ from __future__ import annotations from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceTypedDict from .completionusage import CompletionUsage, CompletionUsageTypedDict -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -12,12 +11,11 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionObject(str, Enum): - CHAT_COMPLETION = "chat.completion" +ChatCompletionObject = Literal["chat.completion"] class ChatCompletionTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionassistantmessageparam.py b/src/openrouter/models/chatcompletionassistantmessageparam.py index a698ee6..260f034 100644 --- a/src/openrouter/models/chatcompletionassistantmessageparam.py +++ b/src/openrouter/models/chatcompletionassistantmessageparam.py @@ -9,7 +9,6 @@ from .chatcompletionmessagetoolcall import ( ChatCompletionMessageToolCall, ChatCompletionMessageToolCallTypedDict, ) -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -18,13 +17,11 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import Any, List, Optional, Union +from typing import Any, List, Literal, Optional, Union from typing_extensions import NotRequired, TypeAliasType, TypedDict -class ChatCompletionAssistantMessageParamRole(str, Enum): - ASSISTANT = "assistant" - +ChatCompletionAssistantMessageParamRole = Literal["assistant"] ChatCompletionAssistantMessageParamContentTypedDict = TypeAliasType( "ChatCompletionAssistantMessageParamContentTypedDict", diff --git a/src/openrouter/models/chatcompletionchoice.py b/src/openrouter/models/chatcompletionchoice.py index cd7f7ae..f670b8a 100644 --- a/src/openrouter/models/chatcompletionchoice.py +++ b/src/openrouter/models/chatcompletionchoice.py @@ -6,7 +6,6 @@ from .chatcompletiontokenlogprobs import ( ChatCompletionTokenLogprobs, ChatCompletionTokenLogprobsTypedDict, ) -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -15,17 +14,14 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer +from typing import Literal from typing_extensions import NotRequired, TypedDict -class ChatCompletionChoiceFinishReason(str, Enum): - r"""Reason the completion finished""" - - TOOL_CALLS = "tool_calls" - STOP = "stop" - LENGTH = "length" - CONTENT_FILTER = "content_filter" - ERROR = "error" +ChatCompletionChoiceFinishReason = Literal[ + "tool_calls", "stop", "length", "content_filter", "error" +] +r"""Reason the completion finished""" class ChatCompletionChoiceTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionchunk.py b/src/openrouter/models/chatcompletionchunk.py index 54a0dec..0e1a44f 100644 --- a/src/openrouter/models/chatcompletionchunk.py +++ b/src/openrouter/models/chatcompletionchunk.py @@ -6,7 +6,6 @@ from .chatcompletionchunkchoice import ( ChatCompletionChunkChoiceTypedDict, ) from .completionusage import CompletionUsage, CompletionUsageTypedDict -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -15,12 +14,11 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionChunkObject(str, Enum): - CHAT_COMPLETION_CHUNK = "chat.completion.chunk" +ChatCompletionChunkObject = Literal["chat.completion.chunk"] class ChatCompletionChunkTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionchunkchoice.py b/src/openrouter/models/chatcompletionchunkchoice.py index 4ce6418..3e212e4 100644 --- a/src/openrouter/models/chatcompletionchunkchoice.py +++ b/src/openrouter/models/chatcompletionchunkchoice.py @@ -9,7 +9,6 @@ from .chatcompletiontokenlogprobs import ( ChatCompletionTokenLogprobs, ChatCompletionTokenLogprobsTypedDict, ) -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -18,15 +17,13 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer +from typing import Literal from typing_extensions import NotRequired, TypedDict -class ChatCompletionChunkChoiceFinishReason(str, Enum): - TOOL_CALLS = "tool_calls" - STOP = "stop" - LENGTH = "length" - CONTENT_FILTER = "content_filter" - ERROR = "error" +ChatCompletionChunkChoiceFinishReason = Literal[ + "tool_calls", "stop", "length", "content_filter", "error" +] class ChatCompletionChunkChoiceTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionchunkchoicedelta.py b/src/openrouter/models/chatcompletionchunkchoicedelta.py index 1aa2d5c..addd105 100644 --- a/src/openrouter/models/chatcompletionchunkchoicedelta.py +++ b/src/openrouter/models/chatcompletionchunkchoicedelta.py @@ -7,7 +7,6 @@ from .chatcompletionchunkchoicedeltatoolcall import ( ChatCompletionChunkChoiceDeltaToolCallTypedDict, ) from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -16,14 +15,12 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionChunkChoiceDeltaRole(str, Enum): - r"""The role of the message author""" - - ASSISTANT = "assistant" +ChatCompletionChunkChoiceDeltaRole = Literal["assistant"] +r"""The role of the message author""" class ChatCompletionChunkChoiceDeltaTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py b/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py index 0501977..e2fe9aa 100644 --- a/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py +++ b/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py @@ -1,16 +1,13 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel -from typing import Optional +from typing import Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionChunkChoiceDeltaToolCallType(str, Enum): - r"""Tool call type""" - - FUNCTION = "function" +ChatCompletionChunkChoiceDeltaToolCallType = Literal["function"] +r"""Tool call type""" class ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict(TypedDict): diff --git a/src/openrouter/models/streamchatcompletionop.py b/src/openrouter/models/chatcompletionchunkwrapper.py similarity index 67% rename from src/openrouter/models/streamchatcompletionop.py rename to src/openrouter/models/chatcompletionchunkwrapper.py index 289f952..129ad9e 100644 --- a/src/openrouter/models/streamchatcompletionop.py +++ b/src/openrouter/models/chatcompletionchunkwrapper.py @@ -6,15 +6,11 @@ from openrouter.types import BaseModel from typing_extensions import TypedDict -class StreamChatCompletionResponseBodyTypedDict(TypedDict): - r"""Successful chat completion response""" - +class ChatCompletionChunkWrapperTypedDict(TypedDict): data: ChatCompletionChunkTypedDict r"""Streaming chat completion chunk""" -class StreamChatCompletionResponseBody(BaseModel): - r"""Successful chat completion response""" - +class ChatCompletionChunkWrapper(BaseModel): data: ChatCompletionChunk r"""Streaming chat completion chunk""" diff --git a/src/openrouter/models/chatcompletioncontentpartaudio.py b/src/openrouter/models/chatcompletioncontentpartaudio.py index cc5abea..21bfb58 100644 --- a/src/openrouter/models/chatcompletioncontentpartaudio.py +++ b/src/openrouter/models/chatcompletioncontentpartaudio.py @@ -1,26 +1,18 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel import pydantic +from typing import Literal from typing_extensions import Annotated, TypedDict -class ChatCompletionContentPartAudioType(str, Enum): - INPUT_AUDIO = "input_audio" +ChatCompletionContentPartAudioType = Literal["input_audio"] - -class ChatCompletionContentPartAudioFormat(str, Enum): - r"""Audio format""" - - WAV = "wav" - MP3 = "mp3" - FLAC = "flac" - M4A = "m4a" - OGG = "ogg" - PCM16 = "pcm16" - PCM24 = "pcm24" +ChatCompletionContentPartAudioFormat = Literal[ + "wav", "mp3", "flac", "m4a", "ogg", "pcm16", "pcm24" +] +r"""Audio format""" class InputAudioTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletioncontentpartimage.py b/src/openrouter/models/chatcompletioncontentpartimage.py index 4469344..fde5e35 100644 --- a/src/openrouter/models/chatcompletioncontentpartimage.py +++ b/src/openrouter/models/chatcompletioncontentpartimage.py @@ -1,22 +1,15 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel -from typing import Optional +from typing import Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionContentPartImageType(str, Enum): - IMAGE_URL = "image_url" +ChatCompletionContentPartImageType = Literal["image_url"] - -class Detail(str, Enum): - r"""Image detail level for vision models""" - - AUTO = "auto" - LOW = "low" - HIGH = "high" +Detail = Literal["auto", "low", "high"] +r"""Image detail level for vision models""" class ChatCompletionContentPartImageImageURLTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletioncontentparttext.py b/src/openrouter/models/chatcompletioncontentparttext.py index db491d0..cbcf07c 100644 --- a/src/openrouter/models/chatcompletioncontentparttext.py +++ b/src/openrouter/models/chatcompletioncontentparttext.py @@ -1,13 +1,12 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel +from typing import Literal from typing_extensions import TypedDict -class ChatCompletionContentPartTextType(str, Enum): - TEXT = "text" +ChatCompletionContentPartTextType = Literal["text"] class ChatCompletionContentPartTextTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletioncreateparams.py b/src/openrouter/models/chatcompletioncreateparams.py index 0dcd4cd..d7ffef8 100644 --- a/src/openrouter/models/chatcompletioncreateparams.py +++ b/src/openrouter/models/chatcompletioncreateparams.py @@ -14,7 +14,6 @@ from .responseformatjsonschemaschema import ( ResponseFormatJSONSchemaSchema, ResponseFormatJSONSchemaSchemaTypedDict, ) -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -24,38 +23,33 @@ from openrouter.types import ( ) import pydantic from pydantic import model_serializer -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Union from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict -class ChatCompletionCreateParamsEffort(str, Enum): - r"""OpenAI-style reasoning effort setting""" - - HIGH = "high" - MEDIUM = "medium" - LOW = "low" - MINIMAL = "minimal" +Effort = Literal["high", "medium", "low", "minimal"] +r"""OpenAI-style reasoning effort setting""" -class ChatCompletionCreateParamsReasoningTypedDict(TypedDict): +class ReasoningTypedDict(TypedDict): r"""Reasoning configuration""" enabled: NotRequired[bool] r"""Enables reasoning with default settings. Only work for some models.""" - effort: NotRequired[Nullable[ChatCompletionCreateParamsEffort]] + effort: NotRequired[Nullable[Effort]] r"""OpenAI-style reasoning effort setting""" max_tokens: NotRequired[Nullable[float]] r"""non-OpenAI-style reasoning effort setting""" exclude: NotRequired[bool] -class ChatCompletionCreateParamsReasoning(BaseModel): +class Reasoning(BaseModel): r"""Reasoning configuration""" enabled: Optional[bool] = None r"""Enables reasoning with default settings. Only work for some models.""" - effort: OptionalNullable[ChatCompletionCreateParamsEffort] = UNSET + effort: OptionalNullable[Effort] = UNSET r"""OpenAI-style reasoning effort setting""" max_tokens: OptionalNullable[float] = UNSET @@ -94,48 +88,45 @@ class ChatCompletionCreateParamsReasoning(BaseModel): return m -class ChatCompletionCreateParamsTypePython(str, Enum): - PYTHON = "python" +TypePython = Literal["python"] -class ChatCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict): +class ResponseFormatPythonTypedDict(TypedDict): r"""Python code response format""" - type: ChatCompletionCreateParamsTypePython + type: TypePython -class ChatCompletionCreateParamsResponseFormatPython(BaseModel): +class ResponseFormatPython(BaseModel): r"""Python code response format""" - type: ChatCompletionCreateParamsTypePython + type: TypePython -class ChatCompletionCreateParamsTypeGrammar(str, Enum): - GRAMMAR = "grammar" +TypeGrammar = Literal["grammar"] -class ChatCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict): +class ResponseFormatGrammarTypedDict(TypedDict): r"""Custom grammar response format""" - type: ChatCompletionCreateParamsTypeGrammar + type: TypeGrammar grammar: str r"""Custom grammar for text generation""" -class ChatCompletionCreateParamsResponseFormatGrammar(BaseModel): +class ResponseFormatGrammar(BaseModel): r"""Custom grammar response format""" - type: ChatCompletionCreateParamsTypeGrammar + type: TypeGrammar grammar: str r"""Custom grammar for text generation""" -class ChatCompletionCreateParamsTypeJSONSchema(str, Enum): - JSON_SCHEMA = "json_schema" +TypeJSONSchema = Literal["json_schema"] -class ChatCompletionCreateParamsJSONSchemaTypedDict(TypedDict): +class JSONSchemaTypedDict(TypedDict): name: str r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" description: NotRequired[str] @@ -146,7 +137,7 @@ class ChatCompletionCreateParamsJSONSchemaTypedDict(TypedDict): r"""Enable strict schema adherence""" -class ChatCompletionCreateParamsJSONSchema(BaseModel): +class JSONSchema(BaseModel): name: str r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" @@ -192,499 +183,432 @@ class ChatCompletionCreateParamsJSONSchema(BaseModel): return m -class ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict(TypedDict): +class ResponseFormatJSONSchemaTypedDict(TypedDict): r"""JSON Schema response format for structured outputs""" - type: ChatCompletionCreateParamsTypeJSONSchema - json_schema: ChatCompletionCreateParamsJSONSchemaTypedDict + type: TypeJSONSchema + json_schema: JSONSchemaTypedDict -class ChatCompletionCreateParamsResponseFormatJSONSchema(BaseModel): +class ResponseFormatJSONSchema(BaseModel): r"""JSON Schema response format for structured outputs""" - type: ChatCompletionCreateParamsTypeJSONSchema + type: TypeJSONSchema - json_schema: ChatCompletionCreateParamsJSONSchema + json_schema: JSONSchema -class ChatCompletionCreateParamsTypeJSONObject(str, Enum): - JSON_OBJECT = "json_object" +TypeJSONObject = Literal["json_object"] -class ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict): +class ResponseFormatJSONObjectTypedDict(TypedDict): r"""JSON object response format""" - type: ChatCompletionCreateParamsTypeJSONObject + type: TypeJSONObject -class ChatCompletionCreateParamsResponseFormatJSONObject(BaseModel): +class ResponseFormatJSONObject(BaseModel): r"""JSON object response format""" - type: ChatCompletionCreateParamsTypeJSONObject + type: TypeJSONObject -class ChatCompletionCreateParamsTypeText(str, Enum): - TEXT = "text" +ChatCompletionCreateParamsTypeText = Literal["text"] -class ChatCompletionCreateParamsResponseFormatTextTypedDict(TypedDict): +class ResponseFormatTextTypedDict(TypedDict): r"""Default text response format""" type: ChatCompletionCreateParamsTypeText -class ChatCompletionCreateParamsResponseFormatText(BaseModel): +class ResponseFormatText(BaseModel): r"""Default text response format""" type: ChatCompletionCreateParamsTypeText -ChatCompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsResponseFormatUnionTypedDict", +ResponseFormatTypedDict = TypeAliasType( + "ResponseFormatTypedDict", Union[ - ChatCompletionCreateParamsResponseFormatTextTypedDict, - ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict, - ChatCompletionCreateParamsResponseFormatPythonTypedDict, - ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict, - ChatCompletionCreateParamsResponseFormatGrammarTypedDict, + ResponseFormatTextTypedDict, + ResponseFormatJSONObjectTypedDict, + ResponseFormatPythonTypedDict, + ResponseFormatJSONSchemaTypedDict, + ResponseFormatGrammarTypedDict, ], ) r"""Response format configuration""" -ChatCompletionCreateParamsResponseFormatUnion = TypeAliasType( - "ChatCompletionCreateParamsResponseFormatUnion", +ResponseFormat = TypeAliasType( + "ResponseFormat", Union[ - ChatCompletionCreateParamsResponseFormatText, - ChatCompletionCreateParamsResponseFormatJSONObject, - ChatCompletionCreateParamsResponseFormatPython, - ChatCompletionCreateParamsResponseFormatJSONSchema, - ChatCompletionCreateParamsResponseFormatGrammar, + ResponseFormatText, + ResponseFormatJSONObject, + ResponseFormatPython, + ResponseFormatJSONSchema, + ResponseFormatGrammar, ], ) r"""Response format configuration""" -ChatCompletionCreateParamsStopTypedDict = TypeAliasType( - "ChatCompletionCreateParamsStopTypedDict", Union[str, List[str], Any] -) +StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str], Any]) r"""Stop sequences (up to 4)""" -ChatCompletionCreateParamsStop = TypeAliasType( - "ChatCompletionCreateParamsStop", Union[str, List[str], Any] -) +Stop = TypeAliasType("Stop", Union[str, List[str], Any]) r"""Stop sequences (up to 4)""" -class ChatCompletionCreateParamsStreamOptionsTypedDict(TypedDict): +class StreamOptionsTypedDict(TypedDict): r"""Streaming configuration options""" include_usage: NotRequired[bool] r"""Include usage information in streaming response""" -class ChatCompletionCreateParamsStreamOptions(BaseModel): +class StreamOptions(BaseModel): r"""Streaming configuration options""" include_usage: Optional[bool] = None r"""Include usage information in streaming response""" -class ChatCompletionCreateParamsReasoningEffort(str, Enum): - r"""Reasoning effort""" +ReasoningEffort = Literal["high", "medium", "low", "minimal"] +r"""Reasoning effort""" - HIGH = "high" - MEDIUM = "medium" - LOW = "low" - MINIMAL = "minimal" +DataCollection = Literal["deny", "allow"] +r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. +- allow: (default) allow providers which store user data non-transiently and may train on it +- deny: use only providers which do not collect user data. + +""" + +OrderEnum = Literal[ + "AnyScale", + "Cent-ML", + "HuggingFace", + "Hyperbolic 2", + "Lepton", + "Lynn 2", + "Lynn", + "Mancer", + "Modal", + "OctoAI", + "Recursal", + "Reflection", + "Replicate", + "SambaNova 2", + "SF Compute", + "Together 2", + "01.AI", + "AI21", + "AionLabs", + "Alibaba", + "Amazon Bedrock", + "Anthropic", + "AtlasCloud", + "Atoma", + "Avian", + "Azure", + "BaseTen", + "Cerebras", + "Chutes", + "Cloudflare", + "Cohere", + "CrofAI", + "Crusoe", + "DeepInfra", + "DeepSeek", + "Enfer", + "Featherless", + "Fireworks", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "Hyperbolic", + "Inception", + "InferenceNet", + "Infermatic", + "Inflection", + "InoCloud", + "Kluster", + "Lambda", + "Liquid", + "Mancer 2", + "Meta", + "Minimax", + "Mistral", + "Moonshot AI", + "Morph", + "NCompass", + "Nebius", + "NextBit", + "Nineteen", + "Novita", + "OpenAI", + "OpenInference", + "Parasail", + "Perplexity", + "Phala", + "SambaNova", + "Stealth", + "Switchpoint", + "Targon", + "Together", + "Ubicloud", + "Venice", + "WandB", + "xAI", + "Z.AI", +] + +OrderTypedDict = TypeAliasType("OrderTypedDict", Union[OrderEnum, str]) -class ChatCompletionCreateParamsDataCollection(str, Enum): - r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - - allow: (default) allow providers which store user data non-transiently and may train on it - - deny: use only providers which do not collect user data. - - """ - - DENY = "deny" - ALLOW = "allow" +Order = TypeAliasType("Order", Union[OrderEnum, str]) -class ChatCompletionCreateParamsOrderEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" +OnlyEnum = Literal[ + "AnyScale", + "Cent-ML", + "HuggingFace", + "Hyperbolic 2", + "Lepton", + "Lynn 2", + "Lynn", + "Mancer", + "Modal", + "OctoAI", + "Recursal", + "Reflection", + "Replicate", + "SambaNova 2", + "SF Compute", + "Together 2", + "01.AI", + "AI21", + "AionLabs", + "Alibaba", + "Amazon Bedrock", + "Anthropic", + "AtlasCloud", + "Atoma", + "Avian", + "Azure", + "BaseTen", + "Cerebras", + "Chutes", + "Cloudflare", + "Cohere", + "CrofAI", + "Crusoe", + "DeepInfra", + "DeepSeek", + "Enfer", + "Featherless", + "Fireworks", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "Hyperbolic", + "Inception", + "InferenceNet", + "Infermatic", + "Inflection", + "InoCloud", + "Kluster", + "Lambda", + "Liquid", + "Mancer 2", + "Meta", + "Minimax", + "Mistral", + "Moonshot AI", + "Morph", + "NCompass", + "Nebius", + "NextBit", + "Nineteen", + "Novita", + "OpenAI", + "OpenInference", + "Parasail", + "Perplexity", + "Phala", + "SambaNova", + "Stealth", + "Switchpoint", + "Targon", + "Together", + "Ubicloud", + "Venice", + "WandB", + "xAI", + "Z.AI", +] + +OnlyTypedDict = TypeAliasType("OnlyTypedDict", Union[OnlyEnum, str]) -ChatCompletionCreateParamsOrderUnionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsOrderUnionTypedDict", - Union[ChatCompletionCreateParamsOrderEnum, str], -) +Only = TypeAliasType("Only", Union[OnlyEnum, str]) -ChatCompletionCreateParamsOrderUnion = TypeAliasType( - "ChatCompletionCreateParamsOrderUnion", - Union[ChatCompletionCreateParamsOrderEnum, str], -) +IgnoreEnum = Literal[ + "AnyScale", + "Cent-ML", + "HuggingFace", + "Hyperbolic 2", + "Lepton", + "Lynn 2", + "Lynn", + "Mancer", + "Modal", + "OctoAI", + "Recursal", + "Reflection", + "Replicate", + "SambaNova 2", + "SF Compute", + "Together 2", + "01.AI", + "AI21", + "AionLabs", + "Alibaba", + "Amazon Bedrock", + "Anthropic", + "AtlasCloud", + "Atoma", + "Avian", + "Azure", + "BaseTen", + "Cerebras", + "Chutes", + "Cloudflare", + "Cohere", + "CrofAI", + "Crusoe", + "DeepInfra", + "DeepSeek", + "Enfer", + "Featherless", + "Fireworks", + "Friendli", + "GMICloud", + "Google", + "Google AI Studio", + "Groq", + "Hyperbolic", + "Inception", + "InferenceNet", + "Infermatic", + "Inflection", + "InoCloud", + "Kluster", + "Lambda", + "Liquid", + "Mancer 2", + "Meta", + "Minimax", + "Mistral", + "Moonshot AI", + "Morph", + "NCompass", + "Nebius", + "NextBit", + "Nineteen", + "Novita", + "OpenAI", + "OpenInference", + "Parasail", + "Perplexity", + "Phala", + "SambaNova", + "Stealth", + "Switchpoint", + "Targon", + "Together", + "Ubicloud", + "Venice", + "WandB", + "xAI", + "Z.AI", +] + +IgnoreTypedDict = TypeAliasType("IgnoreTypedDict", Union[IgnoreEnum, str]) -class ChatCompletionCreateParamsOnlyEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" +Ignore = TypeAliasType("Ignore", Union[IgnoreEnum, str]) -ChatCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsOnlyUnionTypedDict", - Union[ChatCompletionCreateParamsOnlyEnum, str], -) +Quantization = Literal[ + "int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown" +] + +Sort = Literal["price", "throughput", "latency"] +r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" + +PromptTypedDict = TypeAliasType("PromptTypedDict", Union[float, str, Any]) -ChatCompletionCreateParamsOnlyUnion = TypeAliasType( - "ChatCompletionCreateParamsOnlyUnion", - Union[ChatCompletionCreateParamsOnlyEnum, str], -) +Prompt = TypeAliasType("Prompt", Union[float, str, Any]) -class ChatCompletionCreateParamsIgnoreEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" +CompletionTypedDict = TypeAliasType("CompletionTypedDict", Union[float, str, Any]) -ChatCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsIgnoreUnionTypedDict", - Union[ChatCompletionCreateParamsIgnoreEnum, str], -) +Completion = TypeAliasType("Completion", Union[float, str, Any]) -ChatCompletionCreateParamsIgnoreUnion = TypeAliasType( - "ChatCompletionCreateParamsIgnoreUnion", - Union[ChatCompletionCreateParamsIgnoreEnum, str], -) +ImageTypedDict = TypeAliasType("ImageTypedDict", Union[float, str, Any]) -class ChatCompletionCreateParamsQuantization(str, Enum): - INT4 = "int4" - INT8 = "int8" - FP4 = "fp4" - FP6 = "fp6" - FP8 = "fp8" - FP16 = "fp16" - BF16 = "bf16" - FP32 = "fp32" - UNKNOWN = "unknown" +Image = TypeAliasType("Image", Union[float, str, Any]) -class ChatCompletionCreateParamsSort(str, Enum): - r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - - PRICE = "price" - THROUGHPUT = "throughput" - LATENCY = "latency" +AudioTypedDict = TypeAliasType("AudioTypedDict", Union[float, str, Any]) -ChatCompletionCreateParamsPromptTypedDict = TypeAliasType( - "ChatCompletionCreateParamsPromptTypedDict", Union[float, str, Any] -) +Audio = TypeAliasType("Audio", Union[float, str, Any]) -ChatCompletionCreateParamsPrompt = TypeAliasType( - "ChatCompletionCreateParamsPrompt", Union[float, str, Any] -) +RequestTypedDict = TypeAliasType("RequestTypedDict", Union[float, str, Any]) -ChatCompletionCreateParamsCompletionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsCompletionTypedDict", Union[float, str, Any] -) +Request = TypeAliasType("Request", Union[float, str, Any]) -ChatCompletionCreateParamsCompletion = TypeAliasType( - "ChatCompletionCreateParamsCompletion", Union[float, str, Any] -) - - -ChatCompletionCreateParamsImageTypedDict = TypeAliasType( - "ChatCompletionCreateParamsImageTypedDict", Union[float, str, Any] -) - - -ChatCompletionCreateParamsImage = TypeAliasType( - "ChatCompletionCreateParamsImage", Union[float, str, Any] -) - - -ChatCompletionCreateParamsAudioTypedDict = TypeAliasType( - "ChatCompletionCreateParamsAudioTypedDict", Union[float, str, Any] -) - - -ChatCompletionCreateParamsAudio = TypeAliasType( - "ChatCompletionCreateParamsAudio", Union[float, str, Any] -) - - -ChatCompletionCreateParamsRequestTypedDict = TypeAliasType( - "ChatCompletionCreateParamsRequestTypedDict", Union[float, str, Any] -) - - -ChatCompletionCreateParamsRequest = TypeAliasType( - "ChatCompletionCreateParamsRequest", Union[float, str, Any] -) - - -class ChatCompletionCreateParamsMaxPriceTypedDict(TypedDict): +class MaxPriceTypedDict(TypedDict): r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - prompt: NotRequired[ChatCompletionCreateParamsPromptTypedDict] - completion: NotRequired[ChatCompletionCreateParamsCompletionTypedDict] - image: NotRequired[ChatCompletionCreateParamsImageTypedDict] - audio: NotRequired[ChatCompletionCreateParamsAudioTypedDict] - request: NotRequired[ChatCompletionCreateParamsRequestTypedDict] + prompt: NotRequired[PromptTypedDict] + completion: NotRequired[CompletionTypedDict] + image: NotRequired[ImageTypedDict] + audio: NotRequired[AudioTypedDict] + request: NotRequired[RequestTypedDict] -class ChatCompletionCreateParamsMaxPrice(BaseModel): +class MaxPrice(BaseModel): r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - prompt: Optional[ChatCompletionCreateParamsPrompt] = None + prompt: Optional[Prompt] = None - completion: Optional[ChatCompletionCreateParamsCompletion] = None + completion: Optional[Completion] = None - image: Optional[ChatCompletionCreateParamsImage] = None + image: Optional[Image] = None - audio: Optional[ChatCompletionCreateParamsAudio] = None + audio: Optional[Audio] = None - request: Optional[ChatCompletionCreateParamsRequest] = None + request: Optional[Request] = None -class ChatCompletionCreateParamsProviderTypedDict(TypedDict): +class ProviderTypedDict(TypedDict): r"""When multiple model providers are available, optionally indicate your routing preference.""" allow_fallbacks: NotRequired[Nullable[bool]] @@ -695,27 +619,27 @@ class ChatCompletionCreateParamsProviderTypedDict(TypedDict): """ require_parameters: NotRequired[Nullable[bool]] r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.""" - data_collection: NotRequired[Nullable[ChatCompletionCreateParamsDataCollection]] + data_collection: NotRequired[Nullable[DataCollection]] r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data. """ - order: NotRequired[Nullable[List[ChatCompletionCreateParamsOrderUnionTypedDict]]] + order: NotRequired[Nullable[List[OrderTypedDict]]] r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.""" - only: NotRequired[Nullable[List[ChatCompletionCreateParamsOnlyUnionTypedDict]]] + only: NotRequired[Nullable[List[OnlyTypedDict]]] r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.""" - ignore: NotRequired[Nullable[List[ChatCompletionCreateParamsIgnoreUnionTypedDict]]] + ignore: NotRequired[Nullable[List[IgnoreTypedDict]]] r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.""" - quantizations: NotRequired[Nullable[List[ChatCompletionCreateParamsQuantization]]] + quantizations: NotRequired[Nullable[List[Quantization]]] r"""A list of quantization levels to filter the provider by.""" - sort: NotRequired[Nullable[ChatCompletionCreateParamsSort]] + sort: NotRequired[Nullable[Sort]] r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - max_price: NotRequired[ChatCompletionCreateParamsMaxPriceTypedDict] + max_price: NotRequired[MaxPriceTypedDict] r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" -class ChatCompletionCreateParamsProvider(BaseModel): +class Provider(BaseModel): r"""When multiple model providers are available, optionally indicate your routing preference.""" allow_fallbacks: OptionalNullable[bool] = UNSET @@ -728,31 +652,29 @@ class ChatCompletionCreateParamsProvider(BaseModel): require_parameters: OptionalNullable[bool] = UNSET r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.""" - data_collection: OptionalNullable[ChatCompletionCreateParamsDataCollection] = UNSET + data_collection: OptionalNullable[DataCollection] = UNSET r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - allow: (default) allow providers which store user data non-transiently and may train on it - deny: use only providers which do not collect user data. """ - order: OptionalNullable[List[ChatCompletionCreateParamsOrderUnion]] = UNSET + order: OptionalNullable[List[Order]] = UNSET r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.""" - only: OptionalNullable[List[ChatCompletionCreateParamsOnlyUnion]] = UNSET + only: OptionalNullable[List[Only]] = UNSET r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.""" - ignore: OptionalNullable[List[ChatCompletionCreateParamsIgnoreUnion]] = UNSET + ignore: OptionalNullable[List[Ignore]] = UNSET r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.""" - quantizations: OptionalNullable[List[ChatCompletionCreateParamsQuantization]] = ( - UNSET - ) + quantizations: OptionalNullable[List[Quantization]] = UNSET r"""A list of quantization levels to filter the provider by.""" - sort: OptionalNullable[ChatCompletionCreateParamsSort] = UNSET + sort: OptionalNullable[Sort] = UNSET r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - max_price: Optional[ChatCompletionCreateParamsMaxPrice] = None + max_price: Optional[MaxPrice] = None r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" @model_serializer(mode="wrap") @@ -805,107 +727,90 @@ class ChatCompletionCreateParamsProvider(BaseModel): return m -class ChatCompletionCreateParamsIDFileParser(str, Enum): - FILE_PARSER = "file-parser" +IDFileParser = Literal["file-parser"] + +PdfEngine = Literal["mistral-ocr", "pdf-text", "native"] -class ChatCompletionCreateParamsPdfEngine(str, Enum): - MISTRAL_OCR = "mistral-ocr" - PDF_TEXT = "pdf-text" - NATIVE = "native" +class PdfTypedDict(TypedDict): + engine: NotRequired[PdfEngine] -class ChatCompletionCreateParamsPdfTypedDict(TypedDict): - engine: NotRequired[ChatCompletionCreateParamsPdfEngine] +class Pdf(BaseModel): + engine: Optional[PdfEngine] = None -class ChatCompletionCreateParamsPdf(BaseModel): - engine: Optional[ChatCompletionCreateParamsPdfEngine] = None - - -class ChatCompletionCreateParamsPluginFileParserTypedDict(TypedDict): - id: ChatCompletionCreateParamsIDFileParser +class PluginFileParserTypedDict(TypedDict): + id: IDFileParser max_files: NotRequired[float] - pdf: NotRequired[ChatCompletionCreateParamsPdfTypedDict] + pdf: NotRequired[PdfTypedDict] -class ChatCompletionCreateParamsPluginFileParser(BaseModel): - id: ChatCompletionCreateParamsIDFileParser +class PluginFileParser(BaseModel): + id: IDFileParser max_files: Optional[float] = None - pdf: Optional[ChatCompletionCreateParamsPdf] = None + pdf: Optional[Pdf] = None -class ChatCompletionCreateParamsIDChainOfThought(str, Enum): - CHAIN_OF_THOUGHT = "chain-of-thought" +IDChainOfThought = Literal["chain-of-thought"] -class ChatCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict): - id: ChatCompletionCreateParamsIDChainOfThought +class PluginChainOfThoughtTypedDict(TypedDict): + id: IDChainOfThought -class ChatCompletionCreateParamsPluginChainOfThought(BaseModel): - id: ChatCompletionCreateParamsIDChainOfThought +class PluginChainOfThought(BaseModel): + id: IDChainOfThought -class ChatCompletionCreateParamsIDWeb(str, Enum): - WEB = "web" +IDWeb = Literal["web"] + +Engine = Literal["native", "exa"] -class ChatCompletionCreateParamsEngine(str, Enum): - NATIVE = "native" - EXA = "exa" - - -class ChatCompletionCreateParamsPluginWebTypedDict(TypedDict): - id: ChatCompletionCreateParamsIDWeb +class PluginWebTypedDict(TypedDict): + id: IDWeb max_results: NotRequired[float] search_prompt: NotRequired[str] - engine: NotRequired[ChatCompletionCreateParamsEngine] + engine: NotRequired[Engine] -class ChatCompletionCreateParamsPluginWeb(BaseModel): - id: ChatCompletionCreateParamsIDWeb +class PluginWeb(BaseModel): + id: IDWeb max_results: Optional[float] = None search_prompt: Optional[str] = None - engine: Optional[ChatCompletionCreateParamsEngine] = None + engine: Optional[Engine] = None -class ChatCompletionCreateParamsIDModeration(str, Enum): - MODERATION = "moderation" +IDModeration = Literal["moderation"] -class ChatCompletionCreateParamsPluginModerationTypedDict(TypedDict): - id: ChatCompletionCreateParamsIDModeration +class PluginModerationTypedDict(TypedDict): + id: IDModeration -class ChatCompletionCreateParamsPluginModeration(BaseModel): - id: ChatCompletionCreateParamsIDModeration +class PluginModeration(BaseModel): + id: IDModeration -ChatCompletionCreateParamsPluginUnionTypedDict = TypeAliasType( - "ChatCompletionCreateParamsPluginUnionTypedDict", +PluginTypedDict = TypeAliasType( + "PluginTypedDict", Union[ - ChatCompletionCreateParamsPluginModerationTypedDict, - ChatCompletionCreateParamsPluginChainOfThoughtTypedDict, - ChatCompletionCreateParamsPluginFileParserTypedDict, - ChatCompletionCreateParamsPluginWebTypedDict, + PluginModerationTypedDict, + PluginChainOfThoughtTypedDict, + PluginFileParserTypedDict, + PluginWebTypedDict, ], ) -ChatCompletionCreateParamsPluginUnion = TypeAliasType( - "ChatCompletionCreateParamsPluginUnion", - Union[ - ChatCompletionCreateParamsPluginModeration, - ChatCompletionCreateParamsPluginChainOfThought, - ChatCompletionCreateParamsPluginFileParser, - ChatCompletionCreateParamsPluginWeb, - ], +Plugin = TypeAliasType( + "Plugin", Union[PluginModeration, PluginChainOfThought, PluginFileParser, PluginWeb] ) @@ -932,19 +837,17 @@ class ChatCompletionCreateParamsTypedDict(TypedDict): r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)""" presence_penalty: NotRequired[Nullable[float]] r"""Presence penalty (-2.0 to 2.0)""" - reasoning: NotRequired[Nullable[ChatCompletionCreateParamsReasoningTypedDict]] + reasoning: NotRequired[Nullable[ReasoningTypedDict]] r"""Reasoning configuration""" - response_format: NotRequired[ChatCompletionCreateParamsResponseFormatUnionTypedDict] + response_format: NotRequired[ResponseFormatTypedDict] r"""Response format configuration""" seed: NotRequired[Nullable[int]] r"""Random seed for deterministic outputs""" - stop: NotRequired[Nullable[ChatCompletionCreateParamsStopTypedDict]] + stop: NotRequired[Nullable[StopTypedDict]] r"""Stop sequences (up to 4)""" stream: NotRequired[Nullable[bool]] r"""Enable streaming response""" - stream_options: NotRequired[ - Nullable[ChatCompletionCreateParamsStreamOptionsTypedDict] - ] + stream_options: NotRequired[Nullable[StreamOptionsTypedDict]] temperature: NotRequired[Nullable[float]] r"""Sampling temperature (0-2)""" tool_choice: NotRequired[ChatCompletionToolChoiceOptionTypedDict] @@ -955,13 +858,13 @@ class ChatCompletionCreateParamsTypedDict(TypedDict): r"""Nucleus sampling parameter (0-1)""" user: NotRequired[str] r"""Unique user identifier""" - models_llm: NotRequired[Nullable[List[str]]] + model_list: NotRequired[Nullable[List[str]]] r"""Order of models to fallback to for this request""" - reasoning_effort: NotRequired[Nullable[ChatCompletionCreateParamsReasoningEffort]] + reasoning_effort: NotRequired[Nullable[ReasoningEffort]] r"""Reasoning effort""" - provider: NotRequired[Nullable[ChatCompletionCreateParamsProviderTypedDict]] + provider: NotRequired[Nullable[ProviderTypedDict]] r"""When multiple model providers are available, optionally indicate your routing preference.""" - plugins: NotRequired[List[ChatCompletionCreateParamsPluginUnionTypedDict]] + plugins: NotRequired[List[PluginTypedDict]] r"""Plugins you want to enable for this request, including their settings.""" @@ -998,22 +901,22 @@ class ChatCompletionCreateParams(BaseModel): presence_penalty: OptionalNullable[float] = UNSET r"""Presence penalty (-2.0 to 2.0)""" - reasoning: OptionalNullable[ChatCompletionCreateParamsReasoning] = UNSET + reasoning: OptionalNullable[Reasoning] = UNSET r"""Reasoning configuration""" - response_format: Optional[ChatCompletionCreateParamsResponseFormatUnion] = None + response_format: Optional[ResponseFormat] = None r"""Response format configuration""" seed: OptionalNullable[int] = UNSET r"""Random seed for deterministic outputs""" - stop: OptionalNullable[ChatCompletionCreateParamsStop] = UNSET + stop: OptionalNullable[Stop] = UNSET r"""Stop sequences (up to 4)""" stream: OptionalNullable[bool] = False r"""Enable streaming response""" - stream_options: OptionalNullable[ChatCompletionCreateParamsStreamOptions] = UNSET + stream_options: OptionalNullable[StreamOptions] = UNSET temperature: OptionalNullable[float] = 1 r"""Sampling temperature (0-2)""" @@ -1030,20 +933,18 @@ class ChatCompletionCreateParams(BaseModel): user: Optional[str] = None r"""Unique user identifier""" - models_llm: Annotated[ + model_list: Annotated[ OptionalNullable[List[str]], pydantic.Field(alias="models") ] = UNSET r"""Order of models to fallback to for this request""" - reasoning_effort: OptionalNullable[ChatCompletionCreateParamsReasoningEffort] = ( - UNSET - ) + reasoning_effort: OptionalNullable[ReasoningEffort] = UNSET r"""Reasoning effort""" - provider: OptionalNullable[ChatCompletionCreateParamsProvider] = UNSET + provider: OptionalNullable[Provider] = UNSET r"""When multiple model providers are available, optionally indicate your routing preference.""" - plugins: Optional[List[ChatCompletionCreateParamsPluginUnion]] = None + plugins: Optional[List[Plugin]] = None r"""Plugins you want to enable for this request, including their settings.""" @model_serializer(mode="wrap") @@ -1069,7 +970,7 @@ class ChatCompletionCreateParams(BaseModel): "tools", "top_p", "user", - "models_llm", + "model_list", "reasoning_effort", "provider", "plugins", @@ -1089,7 +990,7 @@ class ChatCompletionCreateParams(BaseModel): "stream_options", "temperature", "top_p", - "models_llm", + "model_list", "reasoning_effort", "provider", ] diff --git a/src/openrouter/models/chatcompletionerror.py b/src/openrouter/models/chatcompletionerror.py index 55a07b6..3896be8 100644 --- a/src/openrouter/models/chatcompletionerror.py +++ b/src/openrouter/models/chatcompletionerror.py @@ -1,34 +1,41 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) from pydantic import model_serializer -from typing_extensions import TypedDict +from typing import Optional +from typing_extensions import NotRequired, TypedDict class ErrorTypedDict(TypedDict): r"""Error object structure""" - code: Nullable[str] + code: Nullable[float] message: str - param: Nullable[str] - type: str + param: NotRequired[Nullable[str]] + type: NotRequired[str] class Error(BaseModel): r"""Error object structure""" - code: Nullable[str] + code: Nullable[float] message: str - param: Nullable[str] + param: OptionalNullable[str] = UNSET - type: str + type: Optional[str] = None @model_serializer(mode="wrap") def serialize_model(self, handler): - optional_fields = [] + optional_fields = ["param", "type"] nullable_fields = ["code", "param"] null_default_fields = [] diff --git a/src/openrouter/models/chatcompletionmessage.py b/src/openrouter/models/chatcompletionmessage.py index b4a0c08..18684ce 100644 --- a/src/openrouter/models/chatcompletionmessage.py +++ b/src/openrouter/models/chatcompletionmessage.py @@ -7,7 +7,6 @@ from .chatcompletionmessagetoolcall import ( ChatCompletionMessageToolCallTypedDict, ) from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -16,12 +15,11 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import List, Optional +from typing import List, Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionMessageRole(str, Enum): - ASSISTANT = "assistant" +ChatCompletionMessageRole = Literal["assistant"] class ChatCompletionMessageTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionmessagetoolcall.py b/src/openrouter/models/chatcompletionmessagetoolcall.py index cb94229..e34f429 100644 --- a/src/openrouter/models/chatcompletionmessagetoolcall.py +++ b/src/openrouter/models/chatcompletionmessagetoolcall.py @@ -1,13 +1,12 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel +from typing import Literal from typing_extensions import TypedDict -class ChatCompletionMessageToolCallType(str, Enum): - FUNCTION = "function" +ChatCompletionMessageToolCallType = Literal["function"] class ChatCompletionMessageToolCallFunctionTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionnamedtoolchoice.py b/src/openrouter/models/chatcompletionnamedtoolchoice.py index bf2b838..f1b9b70 100644 --- a/src/openrouter/models/chatcompletionnamedtoolchoice.py +++ b/src/openrouter/models/chatcompletionnamedtoolchoice.py @@ -1,13 +1,12 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel +from typing import Literal from typing_extensions import TypedDict -class ChatCompletionNamedToolChoiceType(str, Enum): - FUNCTION = "function" +ChatCompletionNamedToolChoiceType = Literal["function"] class ChatCompletionNamedToolChoiceFunctionTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletionsystemmessageparam.py b/src/openrouter/models/chatcompletionsystemmessageparam.py index a60f0a9..29201bb 100644 --- a/src/openrouter/models/chatcompletionsystemmessageparam.py +++ b/src/openrouter/models/chatcompletionsystemmessageparam.py @@ -5,15 +5,12 @@ from .chatcompletioncontentparttext import ( ChatCompletionContentPartText, ChatCompletionContentPartTextTypedDict, ) -from enum import Enum from openrouter.types import BaseModel -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypeAliasType, TypedDict -class ChatCompletionSystemMessageParamRole(str, Enum): - SYSTEM = "system" - +ChatCompletionSystemMessageParamRole = Literal["system"] ChatCompletionSystemMessageParamContentTypedDict = TypeAliasType( "ChatCompletionSystemMessageParamContentTypedDict", diff --git a/src/openrouter/models/chatcompletiontool.py b/src/openrouter/models/chatcompletiontool.py index 294f401..4ec43fb 100644 --- a/src/openrouter/models/chatcompletiontool.py +++ b/src/openrouter/models/chatcompletiontool.py @@ -1,7 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -10,12 +9,11 @@ from openrouter.types import ( UNSET_SENTINEL, ) from pydantic import model_serializer -from typing import Optional +from typing import Literal, Optional from typing_extensions import NotRequired, TypedDict -class ChatCompletionToolType(str, Enum): - FUNCTION = "function" +ChatCompletionToolType = Literal["function"] class ParametersTypedDict(TypedDict): diff --git a/src/openrouter/models/chatcompletiontoolchoiceoption.py b/src/openrouter/models/chatcompletiontoolchoiceoption.py index a8596ee..49b5d91 100644 --- a/src/openrouter/models/chatcompletiontoolchoiceoption.py +++ b/src/openrouter/models/chatcompletiontoolchoiceoption.py @@ -5,22 +5,15 @@ from .chatcompletionnamedtoolchoice import ( ChatCompletionNamedToolChoice, ChatCompletionNamedToolChoiceTypedDict, ) -from enum import Enum -from typing import Union +from typing import Literal, Union from typing_extensions import TypeAliasType -class ChatCompletionToolChoiceOptionRequired(str, Enum): - REQUIRED = "required" +ChatCompletionToolChoiceOptionRequired = Literal["required"] +ChatCompletionToolChoiceOptionAuto = Literal["auto"] -class ChatCompletionToolChoiceOptionAuto(str, Enum): - AUTO = "auto" - - -class ChatCompletionToolChoiceOptionNone(str, Enum): - NONE = "none" - +ChatCompletionToolChoiceOptionNone = Literal["none"] ChatCompletionToolChoiceOptionTypedDict = TypeAliasType( "ChatCompletionToolChoiceOptionTypedDict", diff --git a/src/openrouter/models/chatcompletiontoolmessageparam.py b/src/openrouter/models/chatcompletiontoolmessageparam.py index 0da1087..9345978 100644 --- a/src/openrouter/models/chatcompletiontoolmessageparam.py +++ b/src/openrouter/models/chatcompletiontoolmessageparam.py @@ -5,15 +5,12 @@ from .chatcompletioncontentpart import ( ChatCompletionContentPart, ChatCompletionContentPartTypedDict, ) -from enum import Enum from openrouter.types import BaseModel -from typing import List, Union +from typing import List, Literal, Union from typing_extensions import TypeAliasType, TypedDict -class ChatCompletionToolMessageParamRole(str, Enum): - TOOL = "tool" - +ChatCompletionToolMessageParamRole = Literal["tool"] ChatCompletionToolMessageParamContentTypedDict = TypeAliasType( "ChatCompletionToolMessageParamContentTypedDict", diff --git a/src/openrouter/models/chatcompletionusermessageparam.py b/src/openrouter/models/chatcompletionusermessageparam.py index b2dd0b0..ca292bd 100644 --- a/src/openrouter/models/chatcompletionusermessageparam.py +++ b/src/openrouter/models/chatcompletionusermessageparam.py @@ -5,15 +5,12 @@ from .chatcompletioncontentpart import ( ChatCompletionContentPart, ChatCompletionContentPartTypedDict, ) -from enum import Enum from openrouter.types import BaseModel -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypeAliasType, TypedDict -class ChatCompletionUserMessageParamRole(str, Enum): - USER = "user" - +ChatCompletionUserMessageParamRole = Literal["user"] ChatCompletionUserMessageParamContentTypedDict = TypeAliasType( "ChatCompletionUserMessageParamContentTypedDict", diff --git a/src/openrouter/models/chatstreamcompletioncreateparams.py b/src/openrouter/models/chatstreamcompletioncreateparams.py deleted file mode 100644 index 45f0faf..0000000 --- a/src/openrouter/models/chatstreamcompletioncreateparams.py +++ /dev/null @@ -1,1139 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" - -from __future__ import annotations -from .chatcompletionmessageparam import ( - ChatCompletionMessageParam, - ChatCompletionMessageParamTypedDict, -) -from .chatcompletiontool import ChatCompletionTool, ChatCompletionToolTypedDict -from .chatcompletiontoolchoiceoption import ( - ChatCompletionToolChoiceOption, - ChatCompletionToolChoiceOptionTypedDict, -) -from .responseformatjsonschemaschema import ( - ResponseFormatJSONSchemaSchema, - ResponseFormatJSONSchemaSchemaTypedDict, -) -from enum import Enum -from openrouter.types import ( - BaseModel, - Nullable, - OptionalNullable, - UNSET, - UNSET_SENTINEL, -) -import pydantic -from pydantic import model_serializer -from typing import Any, Dict, List, Optional, Union -from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict - - -class ChatStreamCompletionCreateParamsEffort(str, Enum): - r"""OpenAI-style reasoning effort setting""" - - HIGH = "high" - MEDIUM = "medium" - LOW = "low" - MINIMAL = "minimal" - - -class ChatStreamCompletionCreateParamsReasoningTypedDict(TypedDict): - r"""Reasoning configuration""" - - enabled: NotRequired[bool] - r"""Enables reasoning with default settings. Only work for some models.""" - effort: NotRequired[Nullable[ChatStreamCompletionCreateParamsEffort]] - r"""OpenAI-style reasoning effort setting""" - max_tokens: NotRequired[Nullable[float]] - r"""non-OpenAI-style reasoning effort setting""" - exclude: NotRequired[bool] - - -class ChatStreamCompletionCreateParamsReasoning(BaseModel): - r"""Reasoning configuration""" - - enabled: Optional[bool] = None - r"""Enables reasoning with default settings. Only work for some models.""" - - effort: OptionalNullable[ChatStreamCompletionCreateParamsEffort] = UNSET - r"""OpenAI-style reasoning effort setting""" - - max_tokens: OptionalNullable[float] = UNSET - r"""non-OpenAI-style reasoning effort setting""" - - exclude: Optional[bool] = False - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["enabled", "effort", "max_tokens", "exclude"] - nullable_fields = ["effort", "max_tokens"] - 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 - - -class ChatStreamCompletionCreateParamsTypePython(str, Enum): - PYTHON = "python" - - -class ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict): - r"""Python code response format""" - - type: ChatStreamCompletionCreateParamsTypePython - - -class ChatStreamCompletionCreateParamsResponseFormatPython(BaseModel): - r"""Python code response format""" - - type: ChatStreamCompletionCreateParamsTypePython - - -class ChatStreamCompletionCreateParamsTypeGrammar(str, Enum): - GRAMMAR = "grammar" - - -class ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict): - r"""Custom grammar response format""" - - type: ChatStreamCompletionCreateParamsTypeGrammar - grammar: str - r"""Custom grammar for text generation""" - - -class ChatStreamCompletionCreateParamsResponseFormatGrammar(BaseModel): - r"""Custom grammar response format""" - - type: ChatStreamCompletionCreateParamsTypeGrammar - - grammar: str - r"""Custom grammar for text generation""" - - -class ChatStreamCompletionCreateParamsTypeJSONSchema(str, Enum): - JSON_SCHEMA = "json_schema" - - -class ChatStreamCompletionCreateParamsJSONSchemaTypedDict(TypedDict): - name: str - r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" - description: NotRequired[str] - r"""Schema description for the model""" - schema_: NotRequired[ResponseFormatJSONSchemaSchemaTypedDict] - r"""The schema for the response format, described as a JSON Schema object""" - strict: NotRequired[Nullable[bool]] - r"""Enable strict schema adherence""" - - -class ChatStreamCompletionCreateParamsJSONSchema(BaseModel): - name: str - r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" - - description: Optional[str] = None - r"""Schema description for the model""" - - schema_: Annotated[ - Optional[ResponseFormatJSONSchemaSchema], pydantic.Field(alias="schema") - ] = None - r"""The schema for the response format, described as a JSON Schema object""" - - strict: OptionalNullable[bool] = UNSET - r"""Enable strict schema adherence""" - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = ["description", "schema", "strict"] - nullable_fields = ["strict"] - 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 - - -class ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict(TypedDict): - r"""JSON Schema response format for structured outputs""" - - type: ChatStreamCompletionCreateParamsTypeJSONSchema - json_schema: ChatStreamCompletionCreateParamsJSONSchemaTypedDict - - -class ChatStreamCompletionCreateParamsResponseFormatJSONSchema(BaseModel): - r"""JSON Schema response format for structured outputs""" - - type: ChatStreamCompletionCreateParamsTypeJSONSchema - - json_schema: ChatStreamCompletionCreateParamsJSONSchema - - -class ChatStreamCompletionCreateParamsTypeJSONObject(str, Enum): - JSON_OBJECT = "json_object" - - -class ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict): - r"""JSON object response format""" - - type: ChatStreamCompletionCreateParamsTypeJSONObject - - -class ChatStreamCompletionCreateParamsResponseFormatJSONObject(BaseModel): - r"""JSON object response format""" - - type: ChatStreamCompletionCreateParamsTypeJSONObject - - -class ChatStreamCompletionCreateParamsTypeText(str, Enum): - TEXT = "text" - - -class ChatStreamCompletionCreateParamsResponseFormatTextTypedDict(TypedDict): - r"""Default text response format""" - - type: ChatStreamCompletionCreateParamsTypeText - - -class ChatStreamCompletionCreateParamsResponseFormatText(BaseModel): - r"""Default text response format""" - - type: ChatStreamCompletionCreateParamsTypeText - - -ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict", - Union[ - ChatStreamCompletionCreateParamsResponseFormatTextTypedDict, - ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict, - ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict, - ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict, - ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict, - ], -) -r"""Response format configuration""" - - -ChatStreamCompletionCreateParamsResponseFormatUnion = TypeAliasType( - "ChatStreamCompletionCreateParamsResponseFormatUnion", - Union[ - ChatStreamCompletionCreateParamsResponseFormatText, - ChatStreamCompletionCreateParamsResponseFormatJSONObject, - ChatStreamCompletionCreateParamsResponseFormatPython, - ChatStreamCompletionCreateParamsResponseFormatJSONSchema, - ChatStreamCompletionCreateParamsResponseFormatGrammar, - ], -) -r"""Response format configuration""" - - -ChatStreamCompletionCreateParamsStopTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsStopTypedDict", Union[str, List[str], Any] -) -r"""Stop sequences (up to 4)""" - - -ChatStreamCompletionCreateParamsStop = TypeAliasType( - "ChatStreamCompletionCreateParamsStop", Union[str, List[str], Any] -) -r"""Stop sequences (up to 4)""" - - -class ChatStreamCompletionCreateParamsStreamOptionsTypedDict(TypedDict): - r"""Streaming configuration options""" - - include_usage: NotRequired[bool] - r"""Include usage information in streaming response""" - - -class ChatStreamCompletionCreateParamsStreamOptions(BaseModel): - r"""Streaming configuration options""" - - include_usage: Optional[bool] = None - r"""Include usage information in streaming response""" - - -class ChatStreamCompletionCreateParamsReasoningEffort(str, Enum): - r"""Reasoning effort""" - - HIGH = "high" - MEDIUM = "medium" - LOW = "low" - MINIMAL = "minimal" - - -class ChatStreamCompletionCreateParamsDataCollection(str, Enum): - r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - - allow: (default) allow providers which store user data non-transiently and may train on it - - deny: use only providers which do not collect user data. - - """ - - DENY = "deny" - ALLOW = "allow" - - -class ChatStreamCompletionCreateParamsOrderEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" - - -ChatStreamCompletionCreateParamsOrderUnionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsOrderUnionTypedDict", - Union[ChatStreamCompletionCreateParamsOrderEnum, str], -) - - -ChatStreamCompletionCreateParamsOrderUnion = TypeAliasType( - "ChatStreamCompletionCreateParamsOrderUnion", - Union[ChatStreamCompletionCreateParamsOrderEnum, str], -) - - -class ChatStreamCompletionCreateParamsOnlyEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" - - -ChatStreamCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsOnlyUnionTypedDict", - Union[ChatStreamCompletionCreateParamsOnlyEnum, str], -) - - -ChatStreamCompletionCreateParamsOnlyUnion = TypeAliasType( - "ChatStreamCompletionCreateParamsOnlyUnion", - Union[ChatStreamCompletionCreateParamsOnlyEnum, str], -) - - -class ChatStreamCompletionCreateParamsIgnoreEnum(str, Enum): - ANY_SCALE = "AnyScale" - CENT_ML = "Cent-ML" - HUGGING_FACE = "HuggingFace" - HYPERBOLIC_2 = "Hyperbolic 2" - LEPTON = "Lepton" - LYNN_2 = "Lynn 2" - LYNN = "Lynn" - MANCER = "Mancer" - MODAL = "Modal" - OCTO_AI = "OctoAI" - RECURSAL = "Recursal" - REFLECTION = "Reflection" - REPLICATE = "Replicate" - SAMBA_NOVA_2 = "SambaNova 2" - SF_COMPUTE = "SF Compute" - TOGETHER_2 = "Together 2" - ONE_DOT_AI = "01.AI" - AI21 = "AI21" - AION_LABS = "AionLabs" - ALIBABA = "Alibaba" - AMAZON_BEDROCK = "Amazon Bedrock" - ANTHROPIC = "Anthropic" - ATLAS_CLOUD = "AtlasCloud" - ATOMA = "Atoma" - AVIAN = "Avian" - AZURE = "Azure" - BASE_TEN = "BaseTen" - CEREBRAS = "Cerebras" - CHUTES = "Chutes" - CLOUDFLARE = "Cloudflare" - COHERE = "Cohere" - CROF_AI = "CrofAI" - CRUSOE = "Crusoe" - DEEP_INFRA = "DeepInfra" - DEEP_SEEK = "DeepSeek" - ENFER = "Enfer" - FEATHERLESS = "Featherless" - FIREWORKS = "Fireworks" - FRIENDLI = "Friendli" - GMI_CLOUD = "GMICloud" - GOOGLE = "Google" - GOOGLE_AI_STUDIO = "Google AI Studio" - GROQ = "Groq" - HYPERBOLIC = "Hyperbolic" - INCEPTION = "Inception" - INFERENCE_NET = "InferenceNet" - INFERMATIC = "Infermatic" - INFLECTION = "Inflection" - INO_CLOUD = "InoCloud" - KLUSTER = "Kluster" - LAMBDA = "Lambda" - LIQUID = "Liquid" - MANCER_2 = "Mancer 2" - META = "Meta" - MINIMAX = "Minimax" - MISTRAL = "Mistral" - MOONSHOT_AI = "Moonshot AI" - MORPH = "Morph" - N_COMPASS = "NCompass" - NEBIUS = "Nebius" - NEXT_BIT = "NextBit" - NINETEEN = "Nineteen" - NOVITA = "Novita" - OPEN_AI = "OpenAI" - OPEN_INFERENCE = "OpenInference" - PARASAIL = "Parasail" - PERPLEXITY = "Perplexity" - PHALA = "Phala" - SAMBA_NOVA = "SambaNova" - STEALTH = "Stealth" - SWITCHPOINT = "Switchpoint" - TARGON = "Targon" - TOGETHER = "Together" - UBICLOUD = "Ubicloud" - VENICE = "Venice" - WAND_B = "WandB" - X_AI = "xAI" - Z_AI = "Z.AI" - - -ChatStreamCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsIgnoreUnionTypedDict", - Union[ChatStreamCompletionCreateParamsIgnoreEnum, str], -) - - -ChatStreamCompletionCreateParamsIgnoreUnion = TypeAliasType( - "ChatStreamCompletionCreateParamsIgnoreUnion", - Union[ChatStreamCompletionCreateParamsIgnoreEnum, str], -) - - -class ChatStreamCompletionCreateParamsQuantization(str, Enum): - INT4 = "int4" - INT8 = "int8" - FP4 = "fp4" - FP6 = "fp6" - FP8 = "fp8" - FP16 = "fp16" - BF16 = "bf16" - FP32 = "fp32" - UNKNOWN = "unknown" - - -class ChatStreamCompletionCreateParamsSort(str, Enum): - r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - - PRICE = "price" - THROUGHPUT = "throughput" - LATENCY = "latency" - - -ChatStreamCompletionCreateParamsPromptTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsPromptTypedDict", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsPrompt = TypeAliasType( - "ChatStreamCompletionCreateParamsPrompt", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsCompletionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsCompletionTypedDict", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsCompletion = TypeAliasType( - "ChatStreamCompletionCreateParamsCompletion", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsImageTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsImageTypedDict", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsImage = TypeAliasType( - "ChatStreamCompletionCreateParamsImage", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsAudioTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsAudioTypedDict", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsAudio = TypeAliasType( - "ChatStreamCompletionCreateParamsAudio", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsRequestTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsRequestTypedDict", Union[float, str, Any] -) - - -ChatStreamCompletionCreateParamsRequest = TypeAliasType( - "ChatStreamCompletionCreateParamsRequest", Union[float, str, Any] -) - - -class ChatStreamCompletionCreateParamsMaxPriceTypedDict(TypedDict): - r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - - prompt: NotRequired[ChatStreamCompletionCreateParamsPromptTypedDict] - completion: NotRequired[ChatStreamCompletionCreateParamsCompletionTypedDict] - image: NotRequired[ChatStreamCompletionCreateParamsImageTypedDict] - audio: NotRequired[ChatStreamCompletionCreateParamsAudioTypedDict] - request: NotRequired[ChatStreamCompletionCreateParamsRequestTypedDict] - - -class ChatStreamCompletionCreateParamsMaxPrice(BaseModel): - r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - - prompt: Optional[ChatStreamCompletionCreateParamsPrompt] = None - - completion: Optional[ChatStreamCompletionCreateParamsCompletion] = None - - image: Optional[ChatStreamCompletionCreateParamsImage] = None - - audio: Optional[ChatStreamCompletionCreateParamsAudio] = None - - request: Optional[ChatStreamCompletionCreateParamsRequest] = None - - -class ChatStreamCompletionCreateParamsProviderTypedDict(TypedDict): - r"""When multiple model providers are available, optionally indicate your routing preference.""" - - allow_fallbacks: NotRequired[Nullable[bool]] - r"""Whether to allow backup providers to serve requests - - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider. - - false: use only the primary/custom provider, and return the upstream error if it's unavailable. - - """ - require_parameters: NotRequired[Nullable[bool]] - r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.""" - data_collection: NotRequired[ - Nullable[ChatStreamCompletionCreateParamsDataCollection] - ] - r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - - allow: (default) allow providers which store user data non-transiently and may train on it - - deny: use only providers which do not collect user data. - - """ - order: NotRequired[ - Nullable[List[ChatStreamCompletionCreateParamsOrderUnionTypedDict]] - ] - r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.""" - only: NotRequired[ - Nullable[List[ChatStreamCompletionCreateParamsOnlyUnionTypedDict]] - ] - r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.""" - ignore: NotRequired[ - Nullable[List[ChatStreamCompletionCreateParamsIgnoreUnionTypedDict]] - ] - r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.""" - quantizations: NotRequired[ - Nullable[List[ChatStreamCompletionCreateParamsQuantization]] - ] - r"""A list of quantization levels to filter the provider by.""" - sort: NotRequired[Nullable[ChatStreamCompletionCreateParamsSort]] - r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - max_price: NotRequired[ChatStreamCompletionCreateParamsMaxPriceTypedDict] - r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - - -class ChatStreamCompletionCreateParamsProvider(BaseModel): - r"""When multiple model providers are available, optionally indicate your routing preference.""" - - allow_fallbacks: OptionalNullable[bool] = UNSET - r"""Whether to allow backup providers to serve requests - - true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider. - - false: use only the primary/custom provider, and return the upstream error if it's unavailable. - - """ - - require_parameters: OptionalNullable[bool] = UNSET - r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest.""" - - data_collection: OptionalNullable[ - ChatStreamCompletionCreateParamsDataCollection - ] = UNSET - r"""Data collection setting. If no available model provider meets the requirement, your request will return an error. - - allow: (default) allow providers which store user data non-transiently and may train on it - - deny: use only providers which do not collect user data. - - """ - - order: OptionalNullable[List[ChatStreamCompletionCreateParamsOrderUnion]] = UNSET - r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message.""" - - only: OptionalNullable[List[ChatStreamCompletionCreateParamsOnlyUnion]] = UNSET - r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request.""" - - ignore: OptionalNullable[List[ChatStreamCompletionCreateParamsIgnoreUnion]] = UNSET - r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request.""" - - quantizations: OptionalNullable[ - List[ChatStreamCompletionCreateParamsQuantization] - ] = UNSET - r"""A list of quantization levels to filter the provider by.""" - - sort: OptionalNullable[ChatStreamCompletionCreateParamsSort] = UNSET - r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed.""" - - max_price: Optional[ChatStreamCompletionCreateParamsMaxPrice] = None - r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion.""" - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = [ - "allow_fallbacks", - "require_parameters", - "data_collection", - "order", - "only", - "ignore", - "quantizations", - "sort", - "max_price", - ] - nullable_fields = [ - "allow_fallbacks", - "require_parameters", - "data_collection", - "order", - "only", - "ignore", - "quantizations", - "sort", - ] - 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 - - -class ChatStreamCompletionCreateParamsIDFileParser(str, Enum): - FILE_PARSER = "file-parser" - - -class ChatStreamCompletionCreateParamsPdfEngine(str, Enum): - MISTRAL_OCR = "mistral-ocr" - PDF_TEXT = "pdf-text" - NATIVE = "native" - - -class ChatStreamCompletionCreateParamsPdfTypedDict(TypedDict): - engine: NotRequired[ChatStreamCompletionCreateParamsPdfEngine] - - -class ChatStreamCompletionCreateParamsPdf(BaseModel): - engine: Optional[ChatStreamCompletionCreateParamsPdfEngine] = None - - -class ChatStreamCompletionCreateParamsPluginFileParserTypedDict(TypedDict): - id: ChatStreamCompletionCreateParamsIDFileParser - max_files: NotRequired[float] - pdf: NotRequired[ChatStreamCompletionCreateParamsPdfTypedDict] - - -class ChatStreamCompletionCreateParamsPluginFileParser(BaseModel): - id: ChatStreamCompletionCreateParamsIDFileParser - - max_files: Optional[float] = None - - pdf: Optional[ChatStreamCompletionCreateParamsPdf] = None - - -class ChatStreamCompletionCreateParamsIDChainOfThought(str, Enum): - CHAIN_OF_THOUGHT = "chain-of-thought" - - -class ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict): - id: ChatStreamCompletionCreateParamsIDChainOfThought - - -class ChatStreamCompletionCreateParamsPluginChainOfThought(BaseModel): - id: ChatStreamCompletionCreateParamsIDChainOfThought - - -class ChatStreamCompletionCreateParamsIDWeb(str, Enum): - WEB = "web" - - -class ChatStreamCompletionCreateParamsEngine(str, Enum): - NATIVE = "native" - EXA = "exa" - - -class ChatStreamCompletionCreateParamsPluginWebTypedDict(TypedDict): - id: ChatStreamCompletionCreateParamsIDWeb - max_results: NotRequired[float] - search_prompt: NotRequired[str] - engine: NotRequired[ChatStreamCompletionCreateParamsEngine] - - -class ChatStreamCompletionCreateParamsPluginWeb(BaseModel): - id: ChatStreamCompletionCreateParamsIDWeb - - max_results: Optional[float] = None - - search_prompt: Optional[str] = None - - engine: Optional[ChatStreamCompletionCreateParamsEngine] = None - - -class ChatStreamCompletionCreateParamsIDModeration(str, Enum): - MODERATION = "moderation" - - -class ChatStreamCompletionCreateParamsPluginModerationTypedDict(TypedDict): - id: ChatStreamCompletionCreateParamsIDModeration - - -class ChatStreamCompletionCreateParamsPluginModeration(BaseModel): - id: ChatStreamCompletionCreateParamsIDModeration - - -ChatStreamCompletionCreateParamsPluginUnionTypedDict = TypeAliasType( - "ChatStreamCompletionCreateParamsPluginUnionTypedDict", - Union[ - ChatStreamCompletionCreateParamsPluginModerationTypedDict, - ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict, - ChatStreamCompletionCreateParamsPluginFileParserTypedDict, - ChatStreamCompletionCreateParamsPluginWebTypedDict, - ], -) - - -ChatStreamCompletionCreateParamsPluginUnion = TypeAliasType( - "ChatStreamCompletionCreateParamsPluginUnion", - Union[ - ChatStreamCompletionCreateParamsPluginModeration, - ChatStreamCompletionCreateParamsPluginChainOfThought, - ChatStreamCompletionCreateParamsPluginFileParser, - ChatStreamCompletionCreateParamsPluginWeb, - ], -) - - -class ChatStreamCompletionCreateParamsTypedDict(TypedDict): - r"""Chat completion request parameters""" - - messages: List[ChatCompletionMessageParamTypedDict] - r"""List of messages for the conversation""" - model: NotRequired[str] - r"""Model to use for completion""" - frequency_penalty: NotRequired[Nullable[float]] - r"""Frequency penalty (-2.0 to 2.0)""" - logit_bias: NotRequired[Nullable[Dict[str, float]]] - r"""Token logit bias adjustments""" - logprobs: NotRequired[Nullable[bool]] - r"""Return log probabilities""" - top_logprobs: NotRequired[Nullable[float]] - r"""Number of top log probabilities to return (0-20)""" - max_completion_tokens: NotRequired[Nullable[float]] - r"""Maximum tokens in completion""" - max_tokens: NotRequired[Nullable[float]] - r"""Maximum tokens (deprecated, use max_completion_tokens)""" - metadata: NotRequired[Dict[str, str]] - r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)""" - presence_penalty: NotRequired[Nullable[float]] - r"""Presence penalty (-2.0 to 2.0)""" - reasoning: NotRequired[Nullable[ChatStreamCompletionCreateParamsReasoningTypedDict]] - r"""Reasoning configuration""" - response_format: NotRequired[ - ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict - ] - r"""Response format configuration""" - seed: NotRequired[Nullable[int]] - r"""Random seed for deterministic outputs""" - stop: NotRequired[Nullable[ChatStreamCompletionCreateParamsStopTypedDict]] - r"""Stop sequences (up to 4)""" - stream: NotRequired[bool] - r"""Enable streaming response""" - stream_options: NotRequired[ - Nullable[ChatStreamCompletionCreateParamsStreamOptionsTypedDict] - ] - temperature: NotRequired[Nullable[float]] - r"""Sampling temperature (0-2)""" - tool_choice: NotRequired[ChatCompletionToolChoiceOptionTypedDict] - r"""Tool choice configuration""" - tools: NotRequired[List[ChatCompletionToolTypedDict]] - r"""Available tools for function calling""" - top_p: NotRequired[Nullable[float]] - r"""Nucleus sampling parameter (0-1)""" - user: NotRequired[str] - r"""Unique user identifier""" - models_llm: NotRequired[Nullable[List[str]]] - r"""Order of models to fallback to for this request""" - reasoning_effort: NotRequired[ - Nullable[ChatStreamCompletionCreateParamsReasoningEffort] - ] - r"""Reasoning effort""" - provider: NotRequired[Nullable[ChatStreamCompletionCreateParamsProviderTypedDict]] - r"""When multiple model providers are available, optionally indicate your routing preference.""" - plugins: NotRequired[List[ChatStreamCompletionCreateParamsPluginUnionTypedDict]] - r"""Plugins you want to enable for this request, including their settings.""" - - -class ChatStreamCompletionCreateParams(BaseModel): - r"""Chat completion request parameters""" - - messages: List[ChatCompletionMessageParam] - r"""List of messages for the conversation""" - - model: Optional[str] = None - r"""Model to use for completion""" - - frequency_penalty: OptionalNullable[float] = UNSET - r"""Frequency penalty (-2.0 to 2.0)""" - - logit_bias: OptionalNullable[Dict[str, float]] = UNSET - r"""Token logit bias adjustments""" - - logprobs: OptionalNullable[bool] = UNSET - r"""Return log probabilities""" - - top_logprobs: OptionalNullable[float] = UNSET - r"""Number of top log probabilities to return (0-20)""" - - max_completion_tokens: OptionalNullable[float] = UNSET - r"""Maximum tokens in completion""" - - max_tokens: OptionalNullable[float] = UNSET - r"""Maximum tokens (deprecated, use max_completion_tokens)""" - - metadata: Optional[Dict[str, str]] = None - r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)""" - - presence_penalty: OptionalNullable[float] = UNSET - r"""Presence penalty (-2.0 to 2.0)""" - - reasoning: OptionalNullable[ChatStreamCompletionCreateParamsReasoning] = UNSET - r"""Reasoning configuration""" - - response_format: Optional[ChatStreamCompletionCreateParamsResponseFormatUnion] = ( - None - ) - r"""Response format configuration""" - - seed: OptionalNullable[int] = UNSET - r"""Random seed for deterministic outputs""" - - stop: OptionalNullable[ChatStreamCompletionCreateParamsStop] = UNSET - r"""Stop sequences (up to 4)""" - - stream: Optional[bool] = True - r"""Enable streaming response""" - - stream_options: OptionalNullable[ChatStreamCompletionCreateParamsStreamOptions] = ( - UNSET - ) - - temperature: OptionalNullable[float] = 1 - r"""Sampling temperature (0-2)""" - - tool_choice: Optional[ChatCompletionToolChoiceOption] = None - r"""Tool choice configuration""" - - tools: Optional[List[ChatCompletionTool]] = None - r"""Available tools for function calling""" - - top_p: OptionalNullable[float] = 1 - r"""Nucleus sampling parameter (0-1)""" - - user: Optional[str] = None - r"""Unique user identifier""" - - models_llm: Annotated[ - OptionalNullable[List[str]], pydantic.Field(alias="models") - ] = UNSET - r"""Order of models to fallback to for this request""" - - reasoning_effort: OptionalNullable[ - ChatStreamCompletionCreateParamsReasoningEffort - ] = UNSET - r"""Reasoning effort""" - - provider: OptionalNullable[ChatStreamCompletionCreateParamsProvider] = UNSET - r"""When multiple model providers are available, optionally indicate your routing preference.""" - - plugins: Optional[List[ChatStreamCompletionCreateParamsPluginUnion]] = None - r"""Plugins you want to enable for this request, including their settings.""" - - @model_serializer(mode="wrap") - def serialize_model(self, handler): - optional_fields = [ - "model", - "frequency_penalty", - "logit_bias", - "logprobs", - "top_logprobs", - "max_completion_tokens", - "max_tokens", - "metadata", - "presence_penalty", - "reasoning", - "response_format", - "seed", - "stop", - "stream", - "stream_options", - "temperature", - "tool_choice", - "tools", - "top_p", - "user", - "models_llm", - "reasoning_effort", - "provider", - "plugins", - ] - nullable_fields = [ - "frequency_penalty", - "logit_bias", - "logprobs", - "top_logprobs", - "max_completion_tokens", - "max_tokens", - "presence_penalty", - "reasoning", - "seed", - "stop", - "stream_options", - "temperature", - "top_p", - "models_llm", - "reasoning_effort", - "provider", - ] - 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 diff --git a/src/openrouter/models/createchatcompletionop.py b/src/openrouter/models/createchatcompletionop.py new file mode 100644 index 0000000..4b81b7b --- /dev/null +++ b/src/openrouter/models/createchatcompletionop.py @@ -0,0 +1,35 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletion import ChatCompletion, ChatCompletionTypedDict +from .chatcompletionchunkwrapper import ( + ChatCompletionChunkWrapper, + ChatCompletionChunkWrapperTypedDict, +) +from openrouter.utils import eventstreaming +from typing import Union +from typing_extensions import TypeAliasType + + +CreateChatCompletionResponseTypedDict = TypeAliasType( + "CreateChatCompletionResponseTypedDict", + Union[ + ChatCompletionTypedDict, + Union[ + eventstreaming.EventStream[ChatCompletionChunkWrapperTypedDict], + eventstreaming.EventStreamAsync[ChatCompletionChunkWrapperTypedDict], + ], + ], +) + + +CreateChatCompletionResponse = TypeAliasType( + "CreateChatCompletionResponse", + Union[ + ChatCompletion, + Union[ + eventstreaming.EventStream[ChatCompletionChunkWrapper], + eventstreaming.EventStreamAsync[ChatCompletionChunkWrapper], + ], + ], +) diff --git a/src/openrouter/models/fileannotationdetail.py b/src/openrouter/models/fileannotationdetail.py index a255f7d..ea1660e 100644 --- a/src/openrouter/models/fileannotationdetail.py +++ b/src/openrouter/models/fileannotationdetail.py @@ -1,18 +1,14 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypeAliasType, TypedDict -class TypeFile(str, Enum): - FILE = "file" +TypeFile = Literal["file"] - -class ContentTypeImageURL(str, Enum): - IMAGE_URL = "image_url" +ContentTypeImageURL = Literal["image_url"] class FileAnnotationDetailImageURLTypedDict(TypedDict): @@ -34,8 +30,7 @@ class ContentImageURL(BaseModel): image_url: FileAnnotationDetailImageURL -class ContentTypeText(str, Enum): - TEXT = "text" +ContentTypeText = Literal["text"] class ContentTextTypedDict(TypedDict): diff --git a/src/openrouter/models/reasoningdetailencrypted.py b/src/openrouter/models/reasoningdetailencrypted.py index 4008622..d17bd47 100644 --- a/src/openrouter/models/reasoningdetailencrypted.py +++ b/src/openrouter/models/reasoningdetailencrypted.py @@ -1,7 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -11,18 +10,15 @@ from openrouter.types import ( ) import pydantic from pydantic import model_serializer -from typing import Optional +from typing import Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict -class ReasoningDetailEncryptedType(str, Enum): - REASONING_ENCRYPTED = "reasoning.encrypted" +ReasoningDetailEncryptedType = Literal["reasoning.encrypted"] - -class ReasoningDetailEncryptedFormat(str, Enum): - UNKNOWN = "unknown" - OPENAI_RESPONSES_V1 = "openai-responses-v1" - ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" +ReasoningDetailEncryptedFormat = Literal[ + "unknown", "openai-responses-v1", "anthropic-claude-v1" +] class ReasoningDetailEncryptedTypedDict(TypedDict): @@ -46,7 +42,7 @@ class ReasoningDetailEncrypted(BaseModel): format_: Annotated[ OptionalNullable[ReasoningDetailEncryptedFormat], pydantic.Field(alias="format") - ] = ReasoningDetailEncryptedFormat.ANTHROPIC_CLAUDE_V1 + ] = "anthropic-claude-v1" index: Optional[float] = None diff --git a/src/openrouter/models/reasoningdetailsummary.py b/src/openrouter/models/reasoningdetailsummary.py index 03faaaf..ac2c376 100644 --- a/src/openrouter/models/reasoningdetailsummary.py +++ b/src/openrouter/models/reasoningdetailsummary.py @@ -1,7 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -11,18 +10,15 @@ from openrouter.types import ( ) import pydantic from pydantic import model_serializer -from typing import Optional +from typing import Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict -class ReasoningDetailSummaryType(str, Enum): - REASONING_SUMMARY = "reasoning.summary" +ReasoningDetailSummaryType = Literal["reasoning.summary"] - -class ReasoningDetailSummaryFormat(str, Enum): - UNKNOWN = "unknown" - OPENAI_RESPONSES_V1 = "openai-responses-v1" - ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" +ReasoningDetailSummaryFormat = Literal[ + "unknown", "openai-responses-v1", "anthropic-claude-v1" +] class ReasoningDetailSummaryTypedDict(TypedDict): @@ -46,7 +42,7 @@ class ReasoningDetailSummary(BaseModel): format_: Annotated[ OptionalNullable[ReasoningDetailSummaryFormat], pydantic.Field(alias="format") - ] = ReasoningDetailSummaryFormat.ANTHROPIC_CLAUDE_V1 + ] = "anthropic-claude-v1" index: Optional[float] = None diff --git a/src/openrouter/models/reasoningdetailtext.py b/src/openrouter/models/reasoningdetailtext.py index acecee1..f1beee6 100644 --- a/src/openrouter/models/reasoningdetailtext.py +++ b/src/openrouter/models/reasoningdetailtext.py @@ -1,7 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import ( BaseModel, Nullable, @@ -11,18 +10,15 @@ from openrouter.types import ( ) import pydantic from pydantic import model_serializer -from typing import Optional +from typing import Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict -class ReasoningDetailTextType(str, Enum): - REASONING_TEXT = "reasoning.text" +ReasoningDetailTextType = Literal["reasoning.text"] - -class ReasoningDetailTextFormat(str, Enum): - UNKNOWN = "unknown" - OPENAI_RESPONSES_V1 = "openai-responses-v1" - ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" +ReasoningDetailTextFormat = Literal[ + "unknown", "openai-responses-v1", "anthropic-claude-v1" +] class ReasoningDetailTextTypedDict(TypedDict): @@ -49,7 +45,7 @@ class ReasoningDetailText(BaseModel): format_: Annotated[ OptionalNullable[ReasoningDetailTextFormat], pydantic.Field(alias="format") - ] = ReasoningDetailTextFormat.ANTHROPIC_CLAUDE_V1 + ] = "anthropic-claude-v1" index: Optional[float] = None diff --git a/src/openrouter/models/security.py b/src/openrouter/models/security.py index 6a22017..1870d08 100644 --- a/src/openrouter/models/security.py +++ b/src/openrouter/models/security.py @@ -8,11 +8,11 @@ from typing_extensions import Annotated, NotRequired, TypedDict class SecurityTypedDict(TypedDict): - bearer_auth: NotRequired[str] + api_key: NotRequired[str] class Security(BaseModel): - bearer_auth: Annotated[ + api_key: Annotated[ Optional[str], FieldMetadata( security=SecurityMetadata( diff --git a/src/openrouter/models/urlcitationannotationdetail.py b/src/openrouter/models/urlcitationannotationdetail.py index 76bd092..09d30f7 100644 --- a/src/openrouter/models/urlcitationannotationdetail.py +++ b/src/openrouter/models/urlcitationannotationdetail.py @@ -1,14 +1,12 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations -from enum import Enum from openrouter.types import BaseModel -from typing import Optional +from typing import Literal, Optional from typing_extensions import NotRequired, TypedDict -class URLCitationAnnotationDetailType(str, Enum): - URL_CITATION = "url_citation" +URLCitationAnnotationDetailType = Literal["url_citation"] class URLCitationTypedDict(TypedDict): diff --git a/src/openrouter/sdk.py b/src/openrouter/sdk.py index 0c3ad16..ab87f24 100644 --- a/src/openrouter/sdk.py +++ b/src/openrouter/sdk.py @@ -10,6 +10,7 @@ import importlib from openrouter import models, utils from openrouter._hooks import SDKHooks from openrouter.types import OptionalNullable, UNSET +import sys from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast import weakref @@ -23,14 +24,13 @@ class OpenRouter(BaseSDK): """ chat: "Chat" - r"""Chat completion operations""" _sub_sdk_map = { "chat": ("openrouter.chat", "Chat"), } def __init__( self, - bearer_auth: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None, + api_key: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None, provider_url: Optional[str] = None, server_idx: Optional[int] = None, server_url: Optional[str] = None, @@ -43,7 +43,7 @@ class OpenRouter(BaseSDK): ) -> None: r"""Instantiates the SDK configuring it with the provided parameters. - :param bearer_auth: The bearer_auth required for authentication + :param api_key: The api_key required for authentication :param provider_url: Allows setting the provider_url variable for url substitution :param server_idx: The index of the server to use for all methods :param server_url: The server URL to use for all methods @@ -75,11 +75,11 @@ class OpenRouter(BaseSDK): ), "The provided async_client must implement the AsyncHttpClient protocol." security: Any = None - if callable(bearer_auth): + if callable(api_key): # pylint: disable=unnecessary-lambda-assignment - security = lambda: models.Security(bearer_auth=bearer_auth()) + security = lambda: models.Security(api_key=api_key()) else: - security = models.Security(bearer_auth=bearer_auth) + security = models.Security(api_key=api_key) if server_url is not None: if url_params is not None: @@ -105,6 +105,7 @@ class OpenRouter(BaseSDK): timeout_ms=timeout_ms, debug_logger=debug_logger, ), + parent_ref=self, ) hooks = SDKHooks() @@ -124,13 +125,24 @@ class OpenRouter(BaseSDK): self.sdk_configuration.async_client_supplied, ) + def dynamic_import(self, modname, retries=3): + for attempt in range(retries): + try: + return importlib.import_module(modname) + 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__(self, name: str): if name in self._sub_sdk_map: module_path, class_name = self._sub_sdk_map[name] try: - module = importlib.import_module(module_path) + module = self.dynamic_import(module_path) klass = getattr(module, class_name) - instance = klass(self.sdk_configuration) + instance = klass(self.sdk_configuration, parent_ref=self) setattr(self, name, instance) return instance except ImportError as e: diff --git a/src/openrouter/utils/__init__.py b/src/openrouter/utils/__init__.py index 5c2c9c2..87192dd 100644 --- a/src/openrouter/utils/__init__.py +++ b/src/openrouter/utils/__init__.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING from importlib import import_module import builtins +import sys if TYPE_CHECKING: from .annotations import get_discriminator @@ -162,6 +163,18 @@ _dynamic_imports: dict[str, str] = { } +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: @@ -170,9 +183,8 @@ def __getattr__(attr_name: str) -> object: ) try: - module = import_module(module_name, __package__) - result = getattr(module, attr_name) - return result + module = dynamic_import(module_name) + return getattr(module, attr_name) except ImportError as e: raise ImportError( f"Failed to import {attr_name} from {module_name}: {e}" diff --git a/src/openrouter/utils/eventstreaming.py b/src/openrouter/utils/eventstreaming.py index 74a63f7..0969899 100644 --- a/src/openrouter/utils/eventstreaming.py +++ b/src/openrouter/utils/eventstreaming.py @@ -17,6 +17,9 @@ T = TypeVar("T") class EventStream(Generic[T]): + # Holds a reference to the SDK client to avoid it being garbage collected + # and cause termination of the underlying httpx client. + client_ref: Optional[object] response: httpx.Response generator: Generator[T, None, None] @@ -25,9 +28,11 @@ class EventStream(Generic[T]): response: httpx.Response, decoder: Callable[[str], T], sentinel: Optional[str] = None, + client_ref: Optional[object] = None, ): self.response = response self.generator = stream_events(response, decoder, sentinel) + self.client_ref = client_ref def __iter__(self): return self @@ -43,6 +48,9 @@ class EventStream(Generic[T]): class EventStreamAsync(Generic[T]): + # Holds a reference to the SDK client to avoid it being garbage collected + # and cause termination of the underlying httpx client. + client_ref: Optional[object] response: httpx.Response generator: AsyncGenerator[T, None] @@ -51,9 +59,11 @@ class EventStreamAsync(Generic[T]): response: httpx.Response, decoder: Callable[[str], T], sentinel: Optional[str] = None, + client_ref: Optional[object] = None, ): self.response = response self.generator = stream_events_async(response, decoder, sentinel) + self.client_ref = client_ref def __aiter__(self): return self diff --git a/src/openrouter/utils/security.py b/src/openrouter/utils/security.py index 8db6ee7..6996c79 100644 --- a/src/openrouter/utils/security.py +++ b/src/openrouter/utils/security.py @@ -64,8 +64,8 @@ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseMo security_dict: Any = {} - if os.getenv("OPENROUTER_BEARER_AUTH"): - security_dict["bearer_auth"] = os.getenv("OPENROUTER_BEARER_AUTH") + if os.getenv("OPENROUTER_API_KEY"): + security_dict["api_key"] = os.getenv("OPENROUTER_API_KEY") return security_class(**security_dict) if security_dict else None diff --git a/uv.lock b/uv.lock index 204557b..b914e47 100644 --- a/uv.lock +++ b/uv.lock @@ -201,7 +201,7 @@ wheels = [ [[package]] name = "openrouter" -version = "0.1.3" +version = "0.3.1" source = { editable = "." } dependencies = [ { name = "httpcore" },