commit ab530a160e68b419357eb146b1461b14ba3120ff Author: Sheldon Vaughn Date: Fri Aug 22 10:31:13 2025 -0500 first commit diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..396929a --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,30 @@ + +> **Remember to shutdown a GitHub Codespace when it is not in use!** + +# Dev Containers Quick Start + +The default location for usage snippets is the `samples` directory. + +## Running a Usage Sample + +A sample usage example has been provided in a `root.py` file. As you work with the SDK, it's expected that you will modify these samples to fit your needs. To execute this particular snippet, use the command below. + +``` +python root.py +``` + +## Generating Additional Usage Samples + +The speakeasy CLI allows you to generate more usage snippets. Here's how: + +- To generate a sample for a specific operation by providing an operation ID, use: + +``` +speakeasy generate usage -s .speakeasy/out.openapi.yaml -l python -i {INPUT_OPERATION_ID} -o ./samples +``` + +- To generate samples for an entire namespace (like a tag or group name), use: + +``` +speakeasy generate usage -s .speakeasy/out.openapi.yaml -l python -n {INPUT_TAG_NAME} -o ./samples +``` diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..75edff5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/images/tree/main/src/python +{ + "name": "Python", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/astral-sh/devcontainer-features/uv:latest": {} + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sudo chmod +x ./.devcontainer/setup.sh && ./.devcontainer/setup.sh", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "github.vscode-pull-request-github" + ], + "settings": { + "files.eol": "\n", + "editor.formatOnSave": true, + "python.formatting.provider": "black", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.linting.flake8Enabled": true, + "python.linting.banditEnabled": true, + "python.testing.pytestEnabled": true + } + }, + "codespaces": { + "openFiles": [ + ".devcontainer/README.md" + ] + } + } + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 0000000..b39c28c --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Install the speakeasy CLI +curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh + +# Setup samples directory +rmdir samples || true +mkdir samples + + +uv sync --dev + +# Generate starter usage sample with speakeasy +speakeasy generate usage -s .speakeasy/out.openapi.yaml -l python -o samples/root.py \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4d75d59 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.py linguist-generated=false \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aedee07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.venv/ +venv/ +src/*.egg-info/ +**/__pycache__/ +.pytest_cache/ +.python-version +.DS_Store +pyrightconfig.json +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.speakeasy/reports diff --git a/.speakeasy/OAS_files/chat-completions-openapi.yaml b/.speakeasy/OAS_files/chat-completions-openapi.yaml new file mode 100644 index 0000000..0a1ca40 --- /dev/null +++ b/.speakeasy/OAS_files/chat-completions-openapi.yaml @@ -0,0 +1,1548 @@ +openapi: 3.0.0 +info: + title: OpenRouter Chat Completions API + version: 1.0.0 + description: OpenAI-compatible Chat Completions API with additional OpenRouter features + contact: + name: OpenRouter Support + url: https://openrouter.ai/docs + email: support@openrouter.ai + license: + name: MIT + url: https://opensource.org/licenses/MIT +servers: + - url: https://{provider_url}/api/v1 + variables: + provider_url: + default: openrouter.ai + description: Production server +security: + - BearerAuth: [] +tags: + - name: Chat + description: Chat completion operations +externalDocs: + description: OpenRouter Documentation + url: https://openrouter.ai/docs +components: + securitySchemes: + BearerAuth: + type: http + scheme: bearer + description: API key as bearer token in Authorization header + schemas: + ChatCompletionMessageToolCall: + type: object + properties: + id: + type: string + description: Tool call identifier + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + description: Function name to call + arguments: + type: string + description: Function arguments as JSON string + required: + - name + - arguments + required: + - id + - type + - function + description: Tool call made by the assistant + ReasoningDetailSummary: + type: object + properties: + type: + type: string + enum: + - reasoning.summary + summary: + type: string + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + - summary + description: Reasoning summary detail + ReasoningDetailEncrypted: + type: object + properties: + type: + type: string + enum: + - reasoning.encrypted + data: + type: string + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + - data + description: Encrypted reasoning detail + ReasoningDetailText: + type: object + properties: + type: + type: string + enum: + - reasoning.text + text: + type: string + nullable: true + signature: + type: string + nullable: true + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + description: Text reasoning detail + ReasoningDetail: + oneOf: + - $ref: '#/components/schemas/ReasoningDetailSummary' + - $ref: '#/components/schemas/ReasoningDetailEncrypted' + - $ref: '#/components/schemas/ReasoningDetailText' + discriminator: + propertyName: type + mapping: + reasoning.summary: '#/components/schemas/ReasoningDetailSummary' + reasoning.encrypted: '#/components/schemas/ReasoningDetailEncrypted' + reasoning.text: '#/components/schemas/ReasoningDetailText' + description: Reasoning detail information + FileAnnotationDetail: + type: object + properties: + type: + type: string + enum: + - file + file: + type: object + properties: + hash: + type: string + name: + type: string + content: + type: array + items: + anyOf: + - type: object + properties: + type: + type: string + enum: + - text + text: + type: string + required: + - type + - text + - type: object + properties: + type: + type: string + enum: + - image_url + image_url: + type: object + properties: + url: + type: string + required: + - url + required: + - type + - image_url + required: + - hash + - content + required: + - type + - file + description: File annotation with content + URLCitationAnnotationDetail: + type: object + properties: + type: + type: string + enum: + - url_citation + url_citation: + type: object + properties: + end_index: + type: number + start_index: + type: number + title: + type: string + url: + type: string + content: + type: string + required: + - end_index + - start_index + - title + - url + required: + - type + - url_citation + description: URL citation annotation + AnnotationDetail: + oneOf: + - $ref: '#/components/schemas/FileAnnotationDetail' + - $ref: '#/components/schemas/URLCitationAnnotationDetail' + discriminator: + propertyName: type + mapping: + file: '#/components/schemas/FileAnnotationDetail' + url_citation: '#/components/schemas/URLCitationAnnotationDetail' + description: Annotation information + ChatCompletionMessage: + type: object + properties: + role: + type: string + enum: + - assistant + content: + type: string + nullable: true + description: Message content + reasoning: + type: string + nullable: true + description: Reasoning output + refusal: + type: string + nullable: true + description: Refusal message if content was refused + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageToolCall' + description: Tool calls made by the assistant + reasoning_details: + type: array + items: + $ref: '#/components/schemas/ReasoningDetail' + description: Reasoning details delta to send reasoning details back to upstream + annotations: + type: array + items: + $ref: '#/components/schemas/AnnotationDetail' + description: Annotations delta to send annotations back to upstream + required: + - role + - content + - refusal + description: Assistant message in completion response + ChatCompletionTokenLogprob: + type: object + properties: + token: + type: string + description: The token + logprob: + type: number + description: Log probability of the token + bytes: + type: array + nullable: true + items: + type: number + description: UTF-8 bytes of the token + top_logprobs: + type: array + items: + type: object + properties: + token: + type: string + logprob: + type: number + bytes: + type: array + nullable: true + items: + type: number + required: + - token + - logprob + - bytes + description: Top alternative tokens with probabilities + required: + - token + - logprob + - bytes + - top_logprobs + description: Token log probability information + ChatCompletionTokenLogprobs: + type: object + nullable: true + properties: + content: + type: array + nullable: true + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: Log probabilities for content tokens + refusal: + type: array + nullable: true + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: Log probabilities for refusal tokens + required: + - content + - refusal + description: Log probabilities for the completion + ChatCompletionChoice: + type: object + properties: + finish_reason: + type: string + nullable: true + enum: + - tool_calls + - stop + - length + - content_filter + - error + description: Reason the completion finished + index: + type: number + description: Choice index + message: + $ref: '#/components/schemas/ChatCompletionMessage' + logprobs: + $ref: '#/components/schemas/ChatCompletionTokenLogprobs' + required: + - finish_reason + - index + - message + description: Chat completion choice + CompletionUsage: + type: object + properties: + completion_tokens: + type: number + description: Number of tokens in the completion + prompt_tokens: + type: number + description: Number of tokens in the prompt + total_tokens: + type: number + description: Total number of tokens + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: number + description: Tokens used for reasoning + audio_tokens: + type: number + description: Tokens used for audio output + accepted_prediction_tokens: + type: number + description: Accepted prediction tokens + rejected_prediction_tokens: + type: number + description: Rejected prediction tokens + description: Detailed completion token usage + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: number + description: Cached prompt tokens + audio_tokens: + type: number + description: Audio input tokens + description: Detailed prompt token usage + required: + - completion_tokens + - prompt_tokens + - total_tokens + description: Token usage statistics + ChatCompletion: + type: object + properties: + id: + type: string + description: Unique completion identifier + choices: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChoice' + description: List of completion choices + created: + type: number + description: Unix timestamp of creation + model: + type: string + description: Model used for completion + object: + type: string + enum: + - chat.completion + system_fingerprint: + type: string + description: System fingerprint + usage: + $ref: '#/components/schemas/CompletionUsage' + required: + - id + - choices + - created + - model + - object + description: Chat completion response + ChatCompletionError: + type: object + properties: + error: + type: object + properties: + code: + type: string + nullable: true + message: + type: string + param: + type: string + nullable: true + type: + type: string + required: + - code + - message + - param + - type + description: Error object structure + required: + - error + description: Chat completion error response + ChatCompletionChunkChoiceDeltaToolCall: + type: object + properties: + index: + type: number + description: Tool call index in the array + id: + type: string + description: Tool call identifier + type: + type: string + enum: + - function + description: Tool call type + function: + type: object + properties: + name: + type: string + description: Function name + arguments: + type: string + description: Function arguments as JSON string + description: Function call details + required: + - index + description: Tool call delta for streaming responses + ChatCompletionChunkChoiceDelta: + type: object + properties: + role: + type: string + enum: + - assistant + description: The role of the message author + content: + type: string + nullable: true + description: Message content delta + reasoning: + type: string + nullable: true + description: Reasoning content delta + refusal: + type: string + nullable: true + description: Refusal message delta + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChunkChoiceDeltaToolCall' + description: Tool calls delta + reasoning_details: + type: array + items: + $ref: '#/components/schemas/ReasoningDetail' + description: Reasoning details delta to send reasoning details back to upstream + annotations: + type: array + items: + $ref: '#/components/schemas/AnnotationDetail' + description: Annotations delta to send annotations back to upstream + description: Delta changes in streaming response + ChatCompletionChunkChoice: + type: object + properties: + delta: + $ref: '#/components/schemas/ChatCompletionChunkChoiceDelta' + finish_reason: + type: string + nullable: true + enum: + - tool_calls + - stop + - length + - content_filter + - error + index: + type: number + logprobs: + $ref: '#/components/schemas/ChatCompletionTokenLogprobs' + required: + - delta + - finish_reason + - index + description: Streaming completion choice chunk + ChatCompletionChunk: + type: object + properties: + id: + type: string + choices: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChunkChoice' + created: + type: number + model: + type: string + object: + type: string + enum: + - chat.completion.chunk + system_fingerprint: + type: string + usage: + $ref: '#/components/schemas/CompletionUsage' + required: + - id + - choices + - created + - model + - object + description: Streaming chat completion chunk + ChatCompletionRole: + type: string + enum: + - system + - user + - assistant + - tool + - developer + description: The role of the message author + ChatCompletionContentPartText: + type: object + properties: + type: + type: string + enum: + - text + text: + type: string + required: + - type + - text + description: Text content part + ChatCompletionContentPartImage: + type: object + properties: + type: + type: string + enum: + - image_url + image_url: + type: object + properties: + url: + type: string + description: 'URL of the image (data: URLs supported)' + detail: + type: string + enum: + - auto + - low + - high + description: Image detail level for vision models + required: + - url + required: + - type + - image_url + description: Image content part for vision models + ChatCompletionContentPartAudio: + type: object + properties: + type: + type: string + enum: + - input_audio + input_audio: + type: object + properties: + data: + type: string + description: Base64 encoded audio data + format: + type: string + enum: + - wav + - mp3 + - flac + - m4a + - ogg + - pcm16 + - pcm24 + description: Audio format + required: + - data + - format + required: + - type + - input_audio + description: Audio input content part + ChatCompletionContentPart: + oneOf: + - $ref: '#/components/schemas/ChatCompletionContentPartText' + - $ref: '#/components/schemas/ChatCompletionContentPartImage' + - $ref: '#/components/schemas/ChatCompletionContentPartAudio' + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/ChatCompletionContentPartText' + image_url: '#/components/schemas/ChatCompletionContentPartImage' + input_audio: '#/components/schemas/ChatCompletionContentPartAudio' + description: Content part for chat completion messages + ChatCompletionSystemMessageParam: + type: object + properties: + role: + type: string + enum: + - system + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPartText' + description: System message content + name: + type: string + description: Optional name for the system message + required: + - role + - content + description: System message for setting behavior + ChatCompletionUserMessageParam: + type: object + properties: + role: + type: string + enum: + - user + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + description: User message content + name: + type: string + description: Optional name for the user + required: + - role + - content + description: User message + ChatCompletionAssistantMessageParam: + type: object + properties: + role: + type: string + enum: + - assistant + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + - nullable: true + description: Assistant message content + name: + type: string + description: Optional name for the assistant + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageToolCall' + description: Tool calls made by the assistant + refusal: + type: string + nullable: true + description: Refusal message if content was refused + required: + - role + description: Assistant message with tool calls and audio support + ChatCompletionToolMessageParam: + type: object + properties: + role: + type: string + enum: + - tool + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + description: Tool response content + tool_call_id: + type: string + description: ID of the tool call this message responds to + required: + - role + - content + - tool_call_id + description: Tool response message + ChatCompletionMessageParam: + oneOf: + - $ref: '#/components/schemas/ChatCompletionSystemMessageParam' + - $ref: '#/components/schemas/ChatCompletionUserMessageParam' + - $ref: '#/components/schemas/ChatCompletionAssistantMessageParam' + - $ref: '#/components/schemas/ChatCompletionToolMessageParam' + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/ChatCompletionSystemMessageParam' + user: '#/components/schemas/ChatCompletionUserMessageParam' + assistant: '#/components/schemas/ChatCompletionAssistantMessageParam' + tool: '#/components/schemas/ChatCompletionToolMessageParam' + description: Chat completion message with role-based discrimination + ChatCompletionTool: + type: object + properties: + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + maxLength: 64 + description: Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) + description: + type: string + description: Function description for the model + parameters: + type: object + properties: {} + description: Function parameters as JSON Schema object + strict: + type: boolean + nullable: true + description: Enable strict schema adherence + required: + - name + description: Function definition for tool calling + required: + - type + - function + description: Tool definition for function calling + ChatCompletionNamedToolChoice: + type: object + properties: + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + description: Function name to call + required: + - name + required: + - type + - function + description: Named tool choice for specific function + ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - type: string + enum: + - auto + - type: string + enum: + - required + - $ref: '#/components/schemas/ChatCompletionNamedToolChoice' + description: Tool choice configuration + ChatCompletionStreamOptions: + type: object + properties: + include_usage: + type: boolean + description: Include usage information in streaming response + description: Streaming configuration options + ResponseFormatJsonSchemaSchema: + type: object + properties: {} + description: The schema for the response format, described as a JSON Schema object + ChatCompletionCreateParams: + type: object + properties: + messages: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageParam' + minItems: 1 + description: List of messages for the conversation + example: + - role: user + content: Hello, how are you? + model: + type: string + description: Model to use for completion + frequency_penalty: + type: number + nullable: true + minimum: -2 + maximum: 2 + description: Frequency penalty (-2.0 to 2.0) + logit_bias: + type: object + nullable: true + additionalProperties: + type: number + description: Token logit bias adjustments + logprobs: + type: boolean + nullable: true + description: Return log probabilities + top_logprobs: + type: number + nullable: true + minimum: 0 + maximum: 20 + description: Number of top log probabilities to return (0-20) + max_completion_tokens: + type: number + nullable: true + minimum: 1 + description: Maximum tokens in completion + max_tokens: + type: number + nullable: true + minimum: 1 + description: Maximum tokens (deprecated, use max_completion_tokens) + metadata: + type: object + additionalProperties: + type: string + description: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) + presence_penalty: + type: number + nullable: true + minimum: -2 + maximum: 2 + description: Presence penalty (-2.0 to 2.0) + reasoning: + type: object + nullable: true + properties: + enabled: + type: boolean + description: Enables reasoning with default settings. Only work for some models. + effort: + type: string + nullable: true + enum: + - high + - medium + - low + - minimal + description: OpenAI-style reasoning effort setting + max_tokens: + type: number + nullable: true + description: non-OpenAI-style reasoning effort setting + exclude: + type: boolean + default: false + description: Reasoning configuration + response_format: + oneOf: + - type: object + properties: + type: + type: string + enum: + - text + required: + - type + description: Default text response format + - type: object + properties: + type: + type: string + enum: + - json_object + required: + - type + description: JSON object response format + - type: object + properties: + type: + type: string + enum: + - json_schema + json_schema: + type: object + properties: + name: + type: string + maxLength: 64 + description: Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) + description: + type: string + description: Schema description for the model + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Enable strict schema adherence + required: + - name + required: + - type + - json_schema + description: JSON Schema response format for structured outputs + - type: object + properties: + type: + type: string + enum: + - grammar + grammar: + type: string + description: Custom grammar for text generation + required: + - type + - grammar + description: Custom grammar response format + - type: object + properties: + type: + type: string + enum: + - python + required: + - type + description: Python code response format + description: Response format configuration + seed: + type: integer + nullable: true + description: Random seed for deterministic outputs + stop: + anyOf: + - type: string + - type: array + items: + type: string + maxItems: 4 + - nullable: true + description: Stop sequences (up to 4) + stream: + type: boolean + nullable: true + default: false + description: Enable streaming response + stream_options: + allOf: + - $ref: '#/components/schemas/ChatCompletionStreamOptions' + - nullable: true + temperature: + type: number + nullable: true + minimum: 0 + maximum: 2 + default: 1 + description: Sampling temperature (0-2) + tool_choice: + $ref: '#/components/schemas/ChatCompletionToolChoiceOption' + tools: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTool' + description: Available tools for function calling + top_p: + type: number + nullable: true + minimum: 0 + maximum: 1 + default: 1 + description: Nucleus sampling parameter (0-1) + user: + type: string + description: Unique user identifier + models: + x-speakeasy-name-override: models_llm + type: array + nullable: true + items: + type: string + description: Order of models to fallback to for this request + reasoning_effort: + type: string + nullable: true + enum: + - high + - medium + - low + - minimal + description: Reasoning effort + provider: + type: object + nullable: true + properties: + allow_fallbacks: + type: boolean + nullable: true + 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. + + - 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. + data_collection: + type: string + nullable: true + enum: + - deny + - allow + description: > + 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 + items: + anyOf: + - type: string + enum: + - 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 + - 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. + only: + type: array + nullable: true + items: + anyOf: + - type: string + enum: + - 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 + - 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. + ignore: + type: array + nullable: true + items: + anyOf: + - type: string + enum: + - 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 + - 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. + quantizations: + type: array + nullable: true + items: + type: string + enum: + - int4 + - int8 + - fp4 + - fp6 + - fp8 + - fp16 + - bf16 + - fp32 + - unknown + description: A list of quantization levels to filter the provider by. + sort: + type: string + nullable: true + enum: + - price + - throughput + - latency + description: >- + 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: + prompt: + anyOf: + - type: number + - type: string + - {} + completion: + anyOf: + - type: number + - type: string + - {} + image: + anyOf: + - type: number + - type: string + - {} + audio: + anyOf: + - type: number + - type: string + - {} + request: + anyOf: + - type: number + - type: string + - {} + 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. + additionalProperties: false + description: When multiple model providers are available, optionally indicate your routing preference. + plugins: + type: array + items: + oneOf: + - type: object + properties: + id: + type: string + enum: + - moderation + required: + - id + - type: object + properties: + id: + type: string + enum: + - web + max_results: + type: number + search_prompt: + type: string + engine: + type: string + enum: + - native + - exa + required: + - id + - type: object + properties: + id: + type: string + enum: + - chain-of-thought + required: + - id + - type: object + properties: + id: + type: string + enum: + - file-parser + max_files: + type: number + pdf: + type: object + properties: + engine: + type: string + enum: + - mistral-ocr + - pdf-text + - native + required: + - id + description: Plugins you want to enable for this request, including their settings. + required: + - messages + description: Chat completion request parameters + parameters: {} +paths: + /chat/completions: + post: + operationId: createChatCompletion + 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/ChatCompletionCreateParams' + responses: + '200': + description: Successful chat completion response + 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 + text/event-stream: + schema: + $ref: '#/components/schemas/ChatCompletionChunk' + '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' diff --git a/.speakeasy/OAS_files/overlay.yaml b/.speakeasy/OAS_files/overlay.yaml new file mode 100644 index 0000000..dce0ade --- /dev/null +++ b/.speakeasy/OAS_files/overlay.yaml @@ -0,0 +1,90 @@ +overlay: 1.0.0 +x-speakeasy-jsonpath: rfc9535 +info: + title: Overlay chat-completions-openapi.yaml => openapi.yaml + version: 0.0.0 +actions: + - target: $["components"]["schemas"]["ChatCompletion"]["properties"]["system_fingerprint"] + update: + type: string + nullable: true + description: System fingerprint + - target: $["components"]["schemas"]["ChatCompletionChunk"]["properties"]["system_fingerprint"] + update: + type: string + nullable: true + - target: $["components"]["schemas"] + update: + ChatStreamCompletionCreateParams: + allOf: + - $ref: "#/components/schemas/ChatCompletionCreateParams" + - type: object + properties: + stream: + type: boolean + enum: + - true + default: true + description: Enable streaming response + - target: $["paths"]["/chat/completions"]["post"]["responses"]["200"]["content"]["application/json"]["schema"] + update: + $ref: '#/components/schemas/ChatCompletion' + - target: $["paths"]["/chat/completions"]["post"]["responses"]["200"]["content"]["application/json"]["schema"] + update: + description: Non-streaming response when stream=false + - target: $["paths"]["/chat/completions"]["post"]["responses"]["200"]["content"]["application/json"]["schema"]["oneOf"] + remove: true + - target: $["paths"]["/chat/completions"]["post"]["responses"]["200"]["content"]["text/event-stream"] + remove: true + - target: $["paths"] + update: + /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' + '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' diff --git a/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml b/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml new file mode 100644 index 0000000..48c33da --- /dev/null +++ b/.speakeasy/OAS_files/speakeasy-modifications-overlay.yaml @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..e622013 --- /dev/null +++ b/.speakeasy/gen.lock @@ -0,0 +1,320 @@ +lockVersion: 2.0.0 +id: 232c6d4f-b0fd-4172-8f1b-e2421566e9b4 +management: + docChecksum: 003bbbc167e4db8bd3f147793a6648e1 + docVersion: 1.0.0 + speakeasyVersion: 1.606.2 + generationVersion: 2.687.1 + releaseVersion: 0.1.2 + configChecksum: b19ff6e8c7d11c27501834040fadf2a5 +features: + python: + additionalDependencies: 1.0.0 + constsAndDefaults: 1.0.5 + core: 5.19.9 + defaultEnabledRetries: 0.2.0 + devContainers: 3.0.0 + enumUnions: 0.1.0 + envVarSecurityUsage: 0.3.2 + flatRequests: 1.0.1 + globalSecurity: 3.0.3 + globalSecurityCallbacks: 1.0.0 + globalSecurityFlattening: 1.0.0 + globalServerURLs: 3.1.1 + 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 + serverEventsSentinels: 0.1.0 + unions: 3.0.4 +generatedFiles: + - .devcontainer/README.md + - .devcontainer/devcontainer.json + - .devcontainer/setup.sh + - .gitattributes + - .vscode/settings.json + - USAGE.md + - docs/errors/chatcompletionerror.md + - docs/models/annotationdetail.md + - docs/models/chatcompletion.md + - docs/models/chatcompletionassistantmessageparam.md + - docs/models/chatcompletionassistantmessageparamcontent.md + - docs/models/chatcompletionassistantmessageparamrole.md + - docs/models/chatcompletionchoice.md + - docs/models/chatcompletionchoicefinishreason.md + - docs/models/chatcompletionchunk.md + - docs/models/chatcompletionchunkchoice.md + - docs/models/chatcompletionchunkchoicedelta.md + - docs/models/chatcompletionchunkchoicedeltarole.md + - docs/models/chatcompletionchunkchoicedeltatoolcall.md + - docs/models/chatcompletionchunkchoicedeltatoolcallfunction.md + - docs/models/chatcompletionchunkchoicedeltatoolcalltype.md + - docs/models/chatcompletionchunkchoicefinishreason.md + - docs/models/chatcompletionchunkobject.md + - docs/models/chatcompletioncontentpart.md + - docs/models/chatcompletioncontentpartaudio.md + - docs/models/chatcompletioncontentpartaudioformat.md + - docs/models/chatcompletioncontentpartaudiotype.md + - docs/models/chatcompletioncontentpartimage.md + - docs/models/chatcompletioncontentpartimageimageurl.md + - docs/models/chatcompletioncontentpartimagetype.md + - 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 + - docs/models/chatcompletionmessagerole.md + - docs/models/chatcompletionmessagetoolcall.md + - docs/models/chatcompletionmessagetoolcallfunction.md + - docs/models/chatcompletionmessagetoolcalltype.md + - docs/models/chatcompletionnamedtoolchoice.md + - docs/models/chatcompletionnamedtoolchoicefunction.md + - docs/models/chatcompletionnamedtoolchoicetype.md + - docs/models/chatcompletionobject.md + - docs/models/chatcompletionsystemmessageparam.md + - docs/models/chatcompletionsystemmessageparamcontent.md + - docs/models/chatcompletionsystemmessageparamrole.md + - docs/models/chatcompletiontokenlogprob.md + - docs/models/chatcompletiontokenlogprobs.md + - docs/models/chatcompletiontool.md + - docs/models/chatcompletiontoolchoiceoption.md + - docs/models/chatcompletiontoolchoiceoptionauto.md + - docs/models/chatcompletiontoolchoiceoptionnone.md + - docs/models/chatcompletiontoolchoiceoptionrequired.md + - docs/models/chatcompletiontoolfunction.md + - docs/models/chatcompletiontoolmessageparam.md + - docs/models/chatcompletiontoolmessageparamcontent.md + - docs/models/chatcompletiontoolmessageparamrole.md + - docs/models/chatcompletiontooltype.md + - 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/completiontokensdetails.md + - docs/models/completionusage.md + - docs/models/contentimageurl.md + - docs/models/contenttext.md + - docs/models/contenttypeimageurl.md + - docs/models/contenttypetext.md + - docs/models/detail.md + - docs/models/error.md + - docs/models/file.md + - docs/models/fileannotationdetail.md + - docs/models/fileannotationdetailcontentunion.md + - docs/models/fileannotationdetailimageurl.md + - docs/models/inputaudio.md + - docs/models/parameters.md + - docs/models/prompttokensdetails.md + - docs/models/reasoningdetail.md + - docs/models/reasoningdetailencrypted.md + - docs/models/reasoningdetailencryptedformat.md + - docs/models/reasoningdetailencryptedtype.md + - docs/models/reasoningdetailsummary.md + - docs/models/reasoningdetailsummaryformat.md + - docs/models/reasoningdetailsummarytype.md + - docs/models/reasoningdetailtext.md + - docs/models/reasoningdetailtextformat.md + - docs/models/reasoningdetailtexttype.md + - docs/models/responseformatjsonschemaschema.md + - docs/models/security.md + - docs/models/streamchatcompletionresponsebody.md + - docs/models/toplogprob.md + - docs/models/typefile.md + - docs/models/urlcitation.md + - docs/models/urlcitationannotationdetail.md + - docs/models/urlcitationannotationdetailtype.md + - docs/models/utils/retryconfig.md + - docs/sdks/chat/README.md + - docs/sdks/openrouter/README.md + - py.typed + - pylintrc + - pyproject.toml + - scripts/publish.sh + - src/openrouter/__init__.py + - src/openrouter/_hooks/__init__.py + - src/openrouter/_hooks/sdkhooks.py + - src/openrouter/_hooks/types.py + - src/openrouter/_version.py + - src/openrouter/basesdk.py + - src/openrouter/chat.py + - src/openrouter/errors/__init__.py + - src/openrouter/errors/chatcompletionerror.py + - src/openrouter/errors/no_response_error.py + - src/openrouter/errors/openrouterdefaulterror.py + - src/openrouter/errors/openroutererror.py + - src/openrouter/errors/responsevalidationerror.py + - src/openrouter/httpclient.py + - src/openrouter/models/__init__.py + - src/openrouter/models/annotationdetail.py + - src/openrouter/models/chatcompletion.py + - src/openrouter/models/chatcompletionassistantmessageparam.py + - src/openrouter/models/chatcompletionchoice.py + - src/openrouter/models/chatcompletionchunk.py + - src/openrouter/models/chatcompletionchunkchoice.py + - src/openrouter/models/chatcompletionchunkchoicedelta.py + - src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py + - src/openrouter/models/chatcompletioncontentpart.py + - src/openrouter/models/chatcompletioncontentpartaudio.py + - src/openrouter/models/chatcompletioncontentpartimage.py + - src/openrouter/models/chatcompletioncontentparttext.py + - src/openrouter/models/chatcompletioncreateparams.py + - src/openrouter/models/chatcompletionerror.py + - src/openrouter/models/chatcompletionmessage.py + - src/openrouter/models/chatcompletionmessageparam.py + - src/openrouter/models/chatcompletionmessagetoolcall.py + - src/openrouter/models/chatcompletionnamedtoolchoice.py + - src/openrouter/models/chatcompletionsystemmessageparam.py + - src/openrouter/models/chatcompletiontokenlogprob.py + - src/openrouter/models/chatcompletiontokenlogprobs.py + - src/openrouter/models/chatcompletiontool.py + - 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/fileannotationdetail.py + - src/openrouter/models/reasoningdetail.py + - src/openrouter/models/reasoningdetailencrypted.py + - src/openrouter/models/reasoningdetailsummary.py + - 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 + - src/openrouter/sdkconfiguration.py + - src/openrouter/types/__init__.py + - src/openrouter/types/basemodel.py + - src/openrouter/utils/__init__.py + - src/openrouter/utils/annotations.py + - src/openrouter/utils/datetimes.py + - src/openrouter/utils/enums.py + - src/openrouter/utils/eventstreaming.py + - src/openrouter/utils/forms.py + - src/openrouter/utils/headers.py + - src/openrouter/utils/logger.py + - src/openrouter/utils/metadata.py + - src/openrouter/utils/queryparams.py + - src/openrouter/utils/requestbodies.py + - src/openrouter/utils/retries.py + - src/openrouter/utils/security.py + - src/openrouter/utils/serializers.py + - src/openrouter/utils/unmarshal_json_response.py + - src/openrouter/utils/url.py + - src/openrouter/utils/values.py +examples: + createChatCompletion: + speakeasy-default-create-chat-completion: + requestBody: + application/json: {"messages": [{"role": "user", "content": "Hello, how are you?"}], "stream": false, "temperature": 1, "top_p": 1} + responses: + "200": + application/json: {"id": "", "choices": [], "created": 6977.95, "model": "El Camino", "object": "chat.completion"} + "400": + application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} + "500": + application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} + streamChatCompletion: + speakeasy-default-stream-chat-completion: + requestBody: + application/json: {"messages": [{"role": "user", "content": "Hello, how are you?"}], "stream": true, "temperature": 1, "top_p": 1} + responses: + "400": + application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} + "500": + application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} +examplesVersion: 1.0.2 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml new file mode 100644 index 0000000..db04cdb --- /dev/null +++ b/.speakeasy/gen.yaml @@ -0,0 +1,64 @@ +configVersion: 2.0.0 +generation: + devContainers: + enabled: true + schemaPath: .speakeasy/out.openapi.yaml + sdkClassName: OpenRouter + maintainOpenAPIOrder: true + usageSnippets: + optionalPropertyRendering: withExample + sdkInitStyle: constructor + useClassNamesForArrayFields: true + fixes: + nameResolutionDec2023: true + nameResolutionFeb2025: true + parameterOrderingFeb2024: true + requestResponseComponentNamesFeb2024: true + securityFeb2025: true + sharedErrorComponentsApr2025: true + auth: + oAuth2ClientCredentialsEnabled: true + oAuth2PasswordEnabled: true + sdkHooksConfigAccess: true + tests: + generateTests: false + generateNewTests: true + skipResponseBodyAssertions: false +python: + version: 0.1.2 + additionalDependencies: + dev: {} + main: {} + authors: + - Speakeasy + baseErrorName: OpenRouterError + clientServerStatusCodesAsErrors: true + defaultErrorName: OpenRouterDefaultError + description: Python Client SDK Generated by Speakeasy. + enableCustomCodeRegions: false + enumFormat: enum + envVarPrefix: OPENROUTER + fixFlags: + responseRequiredSep2024: true + flattenGlobalSecurity: true + flattenRequests: true + flatteningOrder: parameters-first + imports: + option: openapi + paths: + callbacks: "" + errors: errors + operations: "" + shared: "" + webhooks: "" + inputModelSuffix: input + maxMethodParams: 999 + methodArguments: infer-optional-args + moduleName: "" + outputModelSuffix: output + packageManager: uv + packageName: openrouter + pytestFilterWarnings: [] + pytestTimeout: 0 + responseFormat: flat + templateVersion: v2 diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml new file mode 100644 index 0000000..3f27afd --- /dev/null +++ b/.speakeasy/out.openapi.yaml @@ -0,0 +1,1599 @@ +openapi: 3.0.0 +info: + title: OpenRouter Chat Completions API + version: 1.0.0 + description: OpenAI-compatible Chat Completions API with additional OpenRouter features + contact: + name: OpenRouter Support + url: https://openrouter.ai/docs + email: support@openrouter.ai + license: + name: MIT + url: https://opensource.org/licenses/MIT +servers: + - url: https://{provider_url}/api/v1 + variables: + provider_url: + default: openrouter.ai + description: Production server +security: + - BearerAuth: [] +tags: + - name: Chat + description: Chat completion operations +externalDocs: + description: OpenRouter Documentation + url: https://openrouter.ai/docs +components: + securitySchemes: + BearerAuth: + type: http + scheme: bearer + description: API key as bearer token in Authorization header + schemas: + ChatCompletionMessageToolCall: + type: object + properties: + id: + type: string + description: Tool call identifier + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + description: Function name to call + arguments: + type: string + description: Function arguments as JSON string + required: + - name + - arguments + required: + - id + - type + - function + description: Tool call made by the assistant + ReasoningDetailSummary: + type: object + properties: + type: + type: string + enum: + - reasoning.summary + summary: + type: string + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + - summary + description: Reasoning summary detail + ReasoningDetailEncrypted: + type: object + properties: + type: + type: string + enum: + - reasoning.encrypted + data: + type: string + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + - data + description: Encrypted reasoning detail + ReasoningDetailText: + type: object + properties: + type: + type: string + enum: + - reasoning.text + text: + type: string + nullable: true + signature: + type: string + nullable: true + id: + type: string + nullable: true + format: + type: string + nullable: true + enum: + - unknown + - openai-responses-v1 + - anthropic-claude-v1 + default: anthropic-claude-v1 + index: + type: number + required: + - type + description: Text reasoning detail + ReasoningDetail: + oneOf: + - $ref: '#/components/schemas/ReasoningDetailSummary' + - $ref: '#/components/schemas/ReasoningDetailEncrypted' + - $ref: '#/components/schemas/ReasoningDetailText' + discriminator: + propertyName: type + mapping: + reasoning.summary: '#/components/schemas/ReasoningDetailSummary' + reasoning.encrypted: '#/components/schemas/ReasoningDetailEncrypted' + reasoning.text: '#/components/schemas/ReasoningDetailText' + description: Reasoning detail information + FileAnnotationDetail: + type: object + properties: + type: + type: string + enum: + - file + file: + type: object + properties: + hash: + type: string + name: + type: string + content: + type: array + items: + anyOf: + - type: object + properties: + type: + type: string + enum: + - text + text: + type: string + required: + - type + - text + - type: object + properties: + type: + type: string + enum: + - image_url + image_url: + type: object + properties: + url: + type: string + required: + - url + required: + - type + - image_url + required: + - hash + - content + required: + - type + - file + description: File annotation with content + URLCitationAnnotationDetail: + type: object + properties: + type: + type: string + enum: + - url_citation + url_citation: + type: object + properties: + end_index: + type: number + start_index: + type: number + title: + type: string + url: + type: string + content: + type: string + required: + - end_index + - start_index + - title + - url + required: + - type + - url_citation + description: URL citation annotation + AnnotationDetail: + oneOf: + - $ref: '#/components/schemas/FileAnnotationDetail' + - $ref: '#/components/schemas/URLCitationAnnotationDetail' + discriminator: + propertyName: type + mapping: + file: '#/components/schemas/FileAnnotationDetail' + url_citation: '#/components/schemas/URLCitationAnnotationDetail' + description: Annotation information + ChatCompletionMessage: + type: object + properties: + role: + type: string + enum: + - assistant + content: + type: string + nullable: true + description: Message content + reasoning: + type: string + nullable: true + description: Reasoning output + refusal: + type: string + nullable: true + description: Refusal message if content was refused + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageToolCall' + description: Tool calls made by the assistant + reasoning_details: + type: array + items: + $ref: '#/components/schemas/ReasoningDetail' + description: Reasoning details delta to send reasoning details back to upstream + annotations: + type: array + items: + $ref: '#/components/schemas/AnnotationDetail' + description: Annotations delta to send annotations back to upstream + required: + - role + - content + - refusal + description: Assistant message in completion response + ChatCompletionTokenLogprob: + type: object + properties: + token: + type: string + description: The token + logprob: + type: number + description: Log probability of the token + bytes: + type: array + nullable: true + items: + type: number + description: UTF-8 bytes of the token + top_logprobs: + type: array + items: + type: object + properties: + token: + type: string + logprob: + type: number + bytes: + type: array + nullable: true + items: + type: number + required: + - token + - logprob + - bytes + description: Top alternative tokens with probabilities + required: + - token + - logprob + - bytes + - top_logprobs + description: Token log probability information + ChatCompletionTokenLogprobs: + type: object + nullable: true + properties: + content: + type: array + nullable: true + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: Log probabilities for content tokens + refusal: + type: array + nullable: true + items: + $ref: '#/components/schemas/ChatCompletionTokenLogprob' + description: Log probabilities for refusal tokens + required: + - content + - refusal + description: Log probabilities for the completion + ChatCompletionChoice: + type: object + properties: + finish_reason: + type: string + nullable: true + enum: + - tool_calls + - stop + - length + - content_filter + - error + description: Reason the completion finished + index: + type: number + description: Choice index + message: + $ref: '#/components/schemas/ChatCompletionMessage' + logprobs: + $ref: '#/components/schemas/ChatCompletionTokenLogprobs' + required: + - finish_reason + - index + - message + description: Chat completion choice + CompletionUsage: + type: object + properties: + completion_tokens: + type: number + description: Number of tokens in the completion + prompt_tokens: + type: number + description: Number of tokens in the prompt + total_tokens: + type: number + description: Total number of tokens + completion_tokens_details: + type: object + properties: + reasoning_tokens: + type: number + description: Tokens used for reasoning + audio_tokens: + type: number + description: Tokens used for audio output + accepted_prediction_tokens: + type: number + description: Accepted prediction tokens + rejected_prediction_tokens: + type: number + description: Rejected prediction tokens + description: Detailed completion token usage + prompt_tokens_details: + type: object + properties: + cached_tokens: + type: number + description: Cached prompt tokens + audio_tokens: + type: number + description: Audio input tokens + description: Detailed prompt token usage + required: + - completion_tokens + - prompt_tokens + - total_tokens + description: Token usage statistics + ChatCompletion: + type: object + properties: + id: + type: string + description: Unique completion identifier + choices: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChoice' + description: List of completion choices + created: + type: number + description: Unix timestamp of creation + model: + type: string + description: Model used for completion + object: + type: string + enum: + - chat.completion + system_fingerprint: + type: string + description: System fingerprint + nullable: true + usage: + $ref: '#/components/schemas/CompletionUsage' + required: + - id + - choices + - created + - model + - object + description: Chat completion response + ChatCompletionError: + type: object + properties: + error: + type: object + properties: + code: + type: string + nullable: true + message: + type: string + param: + type: string + nullable: true + type: + type: string + required: + - code + - message + - param + - type + description: Error object structure + required: + - error + description: Chat completion error response + ChatCompletionChunkChoiceDeltaToolCall: + type: object + properties: + index: + type: number + description: Tool call index in the array + id: + type: string + description: Tool call identifier + type: + type: string + enum: + - function + description: Tool call type + function: + type: object + properties: + name: + type: string + description: Function name + arguments: + type: string + description: Function arguments as JSON string + description: Function call details + required: + - index + description: Tool call delta for streaming responses + ChatCompletionChunkChoiceDelta: + type: object + properties: + role: + type: string + enum: + - assistant + description: The role of the message author + content: + type: string + nullable: true + description: Message content delta + reasoning: + type: string + nullable: true + description: Reasoning content delta + refusal: + type: string + nullable: true + description: Refusal message delta + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChunkChoiceDeltaToolCall' + description: Tool calls delta + reasoning_details: + type: array + items: + $ref: '#/components/schemas/ReasoningDetail' + description: Reasoning details delta to send reasoning details back to upstream + annotations: + type: array + items: + $ref: '#/components/schemas/AnnotationDetail' + description: Annotations delta to send annotations back to upstream + description: Delta changes in streaming response + ChatCompletionChunkChoice: + type: object + properties: + delta: + $ref: '#/components/schemas/ChatCompletionChunkChoiceDelta' + finish_reason: + type: string + nullable: true + enum: + - tool_calls + - stop + - length + - content_filter + - error + index: + type: number + logprobs: + $ref: '#/components/schemas/ChatCompletionTokenLogprobs' + required: + - delta + - finish_reason + - index + description: Streaming completion choice chunk + ChatCompletionChunk: + type: object + properties: + id: + type: string + choices: + type: array + items: + $ref: '#/components/schemas/ChatCompletionChunkChoice' + created: + type: number + model: + type: string + object: + type: string + enum: + - chat.completion.chunk + system_fingerprint: + type: string + nullable: true + usage: + $ref: '#/components/schemas/CompletionUsage' + required: + - id + - choices + - created + - model + - object + description: Streaming chat completion chunk + ChatCompletionRole: + type: string + enum: + - system + - user + - assistant + - tool + - developer + description: The role of the message author + ChatCompletionContentPartText: + type: object + properties: + type: + type: string + enum: + - text + text: + type: string + required: + - type + - text + description: Text content part + ChatCompletionContentPartImage: + type: object + properties: + type: + type: string + enum: + - image_url + image_url: + type: object + properties: + url: + type: string + description: 'URL of the image (data: URLs supported)' + detail: + type: string + enum: + - auto + - low + - high + description: Image detail level for vision models + required: + - url + required: + - type + - image_url + description: Image content part for vision models + ChatCompletionContentPartAudio: + type: object + properties: + type: + type: string + enum: + - input_audio + input_audio: + type: object + properties: + data: + type: string + description: Base64 encoded audio data + format: + type: string + enum: + - wav + - mp3 + - flac + - m4a + - ogg + - pcm16 + - pcm24 + description: Audio format + required: + - data + - format + required: + - type + - input_audio + description: Audio input content part + ChatCompletionContentPart: + oneOf: + - $ref: '#/components/schemas/ChatCompletionContentPartText' + - $ref: '#/components/schemas/ChatCompletionContentPartImage' + - $ref: '#/components/schemas/ChatCompletionContentPartAudio' + discriminator: + propertyName: type + mapping: + text: '#/components/schemas/ChatCompletionContentPartText' + image_url: '#/components/schemas/ChatCompletionContentPartImage' + input_audio: '#/components/schemas/ChatCompletionContentPartAudio' + description: Content part for chat completion messages + ChatCompletionSystemMessageParam: + type: object + properties: + role: + type: string + enum: + - system + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPartText' + description: System message content + name: + type: string + description: Optional name for the system message + required: + - role + - content + description: System message for setting behavior + ChatCompletionUserMessageParam: + type: object + properties: + role: + type: string + enum: + - user + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + description: User message content + name: + type: string + description: Optional name for the user + required: + - role + - content + description: User message + ChatCompletionAssistantMessageParam: + type: object + properties: + role: + type: string + enum: + - assistant + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + - nullable: true + description: Assistant message content + name: + type: string + description: Optional name for the assistant + tool_calls: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageToolCall' + description: Tool calls made by the assistant + refusal: + type: string + nullable: true + description: Refusal message if content was refused + required: + - role + description: Assistant message with tool calls and audio support + ChatCompletionToolMessageParam: + type: object + properties: + role: + type: string + enum: + - tool + content: + anyOf: + - type: string + - type: array + items: + $ref: '#/components/schemas/ChatCompletionContentPart' + description: Tool response content + tool_call_id: + type: string + description: ID of the tool call this message responds to + required: + - role + - content + - tool_call_id + description: Tool response message + ChatCompletionMessageParam: + oneOf: + - $ref: '#/components/schemas/ChatCompletionSystemMessageParam' + - $ref: '#/components/schemas/ChatCompletionUserMessageParam' + - $ref: '#/components/schemas/ChatCompletionAssistantMessageParam' + - $ref: '#/components/schemas/ChatCompletionToolMessageParam' + discriminator: + propertyName: role + mapping: + system: '#/components/schemas/ChatCompletionSystemMessageParam' + user: '#/components/schemas/ChatCompletionUserMessageParam' + assistant: '#/components/schemas/ChatCompletionAssistantMessageParam' + tool: '#/components/schemas/ChatCompletionToolMessageParam' + description: Chat completion message with role-based discrimination + ChatCompletionTool: + type: object + properties: + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + maxLength: 64 + description: Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) + description: + type: string + description: Function description for the model + parameters: + type: object + properties: {} + description: Function parameters as JSON Schema object + strict: + type: boolean + nullable: true + description: Enable strict schema adherence + required: + - name + description: Function definition for tool calling + required: + - type + - function + description: Tool definition for function calling + ChatCompletionNamedToolChoice: + type: object + properties: + type: + type: string + enum: + - function + function: + type: object + properties: + name: + type: string + description: Function name to call + required: + - name + required: + - type + - function + description: Named tool choice for specific function + ChatCompletionToolChoiceOption: + anyOf: + - type: string + enum: + - none + - type: string + enum: + - auto + - type: string + enum: + - required + - $ref: '#/components/schemas/ChatCompletionNamedToolChoice' + description: Tool choice configuration + ChatCompletionStreamOptions: + type: object + properties: + include_usage: + type: boolean + description: Include usage information in streaming response + description: Streaming configuration options + ResponseFormatJsonSchemaSchema: + type: object + properties: {} + description: The schema for the response format, described as a JSON Schema object + ChatCompletionCreateParams: + type: object + properties: + messages: + type: array + items: + $ref: '#/components/schemas/ChatCompletionMessageParam' + minItems: 1 + description: List of messages for the conversation + example: + - role: user + content: Hello, how are you? + model: + type: string + description: Model to use for completion + frequency_penalty: + type: number + nullable: true + minimum: -2 + maximum: 2 + description: Frequency penalty (-2.0 to 2.0) + logit_bias: + type: object + nullable: true + additionalProperties: + type: number + description: Token logit bias adjustments + logprobs: + type: boolean + nullable: true + description: Return log probabilities + top_logprobs: + type: number + nullable: true + minimum: 0 + maximum: 20 + description: Number of top log probabilities to return (0-20) + max_completion_tokens: + type: number + nullable: true + minimum: 1 + description: Maximum tokens in completion + max_tokens: + type: number + nullable: true + minimum: 1 + description: Maximum tokens (deprecated, use max_completion_tokens) + metadata: + type: object + additionalProperties: + type: string + description: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values) + presence_penalty: + type: number + nullable: true + minimum: -2 + maximum: 2 + description: Presence penalty (-2.0 to 2.0) + reasoning: + type: object + nullable: true + properties: + enabled: + type: boolean + description: Enables reasoning with default settings. Only work for some models. + effort: + type: string + nullable: true + enum: + - high + - medium + - low + - minimal + description: OpenAI-style reasoning effort setting + max_tokens: + type: number + nullable: true + description: non-OpenAI-style reasoning effort setting + exclude: + type: boolean + default: false + description: Reasoning configuration + response_format: + oneOf: + - type: object + properties: + type: + type: string + enum: + - text + required: + - type + description: Default text response format + - type: object + properties: + type: + type: string + enum: + - json_object + required: + - type + description: JSON object response format + - type: object + properties: + type: + type: string + enum: + - json_schema + json_schema: + type: object + properties: + name: + type: string + maxLength: 64 + description: Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) + description: + type: string + description: Schema description for the model + schema: + $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' + strict: + type: boolean + nullable: true + description: Enable strict schema adherence + required: + - name + required: + - type + - json_schema + description: JSON Schema response format for structured outputs + - type: object + properties: + type: + type: string + enum: + - grammar + grammar: + type: string + description: Custom grammar for text generation + required: + - type + - grammar + description: Custom grammar response format + - type: object + properties: + type: + type: string + enum: + - python + required: + - type + description: Python code response format + description: Response format configuration + seed: + type: integer + nullable: true + description: Random seed for deterministic outputs + stop: + anyOf: + - type: string + - type: array + items: + type: string + maxItems: 4 + - nullable: true + description: Stop sequences (up to 4) + stream: + type: boolean + nullable: true + default: false + description: Enable streaming response + stream_options: + allOf: + - $ref: '#/components/schemas/ChatCompletionStreamOptions' + - nullable: true + temperature: + type: number + nullable: true + minimum: 0 + maximum: 2 + default: 1 + description: Sampling temperature (0-2) + tool_choice: + $ref: '#/components/schemas/ChatCompletionToolChoiceOption' + tools: + type: array + items: + $ref: '#/components/schemas/ChatCompletionTool' + description: Available tools for function calling + top_p: + type: number + nullable: true + minimum: 0 + maximum: 1 + default: 1 + description: Nucleus sampling parameter (0-1) + user: + type: string + description: Unique user identifier + models: + x-speakeasy-name-override: models_llm + type: array + nullable: true + items: + type: string + description: Order of models to fallback to for this request + reasoning_effort: + type: string + nullable: true + enum: + - high + - medium + - low + - minimal + description: Reasoning effort + provider: + type: object + nullable: true + properties: + allow_fallbacks: + type: boolean + nullable: true + 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. + + - 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. + data_collection: + type: string + nullable: true + enum: + - deny + - allow + description: > + 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 + items: + anyOf: + - type: string + enum: + - 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 + - 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. + only: + type: array + nullable: true + items: + anyOf: + - type: string + enum: + - 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 + - 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. + ignore: + type: array + nullable: true + items: + anyOf: + - type: string + enum: + - 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 + - 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. + quantizations: + type: array + nullable: true + items: + type: string + enum: + - int4 + - int8 + - fp4 + - fp6 + - fp8 + - fp16 + - bf16 + - fp32 + - unknown + description: A list of quantization levels to filter the provider by. + sort: + type: string + nullable: true + enum: + - price + - throughput + - latency + description: >- + 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: + prompt: + anyOf: + - type: number + - type: string + - {} + completion: + anyOf: + - type: number + - type: string + - {} + image: + anyOf: + - type: number + - type: string + - {} + audio: + anyOf: + - type: number + - type: string + - {} + request: + anyOf: + - type: number + - type: string + - {} + 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. + additionalProperties: false + description: When multiple model providers are available, optionally indicate your routing preference. + plugins: + type: array + items: + oneOf: + - type: object + properties: + id: + type: string + enum: + - moderation + required: + - id + - type: object + properties: + id: + type: string + enum: + - web + max_results: + type: number + search_prompt: + type: string + engine: + type: string + enum: + - native + - exa + required: + - id + - type: object + properties: + id: + type: string + enum: + - chain-of-thought + required: + - id + - type: object + properties: + id: + type: string + enum: + - file-parser + max_files: + type: number + pdf: + type: object + properties: + engine: + type: string + enum: + - mistral-ocr + - pdf-text + - native + required: + - id + description: Plugins you want to enable for this request, including their settings. + 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 + 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/ChatCompletionCreateParams' + responses: + '200': + description: Successful chat completion response + content: + application/json: + 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' + '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: completeStream diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..0e31308 --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,40 @@ +speakeasyVersion: 1.606.2 +sources: + OpenRouter Chat Completions API: + sourceNamespace: open-router-chat-completions-api + sourceRevisionDigest: sha256:30b19a8759608792fb4d27f6bf28d5982d7e2a8cf5b3faf34ba3507a62f9f106 + sourceBlobDigest: sha256:454f1b880a0882a70f78eacccb2c33e3d9d19134a0738b0e21487984a7bf2e63 + tags: + - latest + - 1.0.0 +targets: + open-router: + source: OpenRouter Chat Completions API + sourceNamespace: open-router-chat-completions-api + sourceRevisionDigest: sha256:30b19a8759608792fb4d27f6bf28d5982d7e2a8cf5b3faf34ba3507a62f9f106 + sourceBlobDigest: sha256:454f1b880a0882a70f78eacccb2c33e3d9d19134a0738b0e21487984a7bf2e63 + codeSamplesNamespace: open-router-chat-completions-api-python-code-samples + codeSamplesRevisionDigest: sha256:3a91ac3dc92c4f41025bfbe2ab316844707268e93ea1947cd4fe8996f01620b5 +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + 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 + targets: + open-router: + target: python + source: OpenRouter Chat Completions API + codeSamples: + registry: + location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api-python-code-samples + labelOverride: + fixedValue: Python (SDK) + blocking: false diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml new file mode 100644 index 0000000..4069f05 --- /dev/null +++ b/.speakeasy/workflow.yaml @@ -0,0 +1,22 @@ +workflowVersion: 1.0.0 +speakeasyVersion: latest +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 +targets: + open-router: + target: python + source: OpenRouter Chat Completions API + codeSamples: + registry: + location: registry.speakeasyapi.dev/sheldon-vaughn-test/sandbox/open-router-chat-completions-api-python-code-samples + labelOverride: + fixedValue: Python (SDK) + blocking: false diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8d79f0a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "python.testing.pytestArgs": ["tests", "-vv"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "pylint.args": ["--rcfile=pylintrc"] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d585717 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/README.md b/README.md new file mode 100644 index 0000000..f08369f --- /dev/null +++ b/README.md @@ -0,0 +1,598 @@ +# open-router + +Developer-friendly & type-safe Python SDK specifically catered to leverage *open-router* API. + +
+ + + + +
+ + +

+> [!IMPORTANT] +> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/sheldon-vaughn-test/sandbox). Delete this section before > publishing to a package manager. + + +## Summary + +OpenRouter Chat Completions API: OpenAI-compatible Chat Completions API with additional OpenRouter features + +For more information about the API: [OpenRouter Documentation](https://openrouter.ai/docs) + + + +## Table of Contents + +* [open-router](#open-router) + * [SDK Installation](#sdk-installation) + * [IDE Support](#ide-support) + * [SDK Example Usage](#sdk-example-usage) + * [Authentication](#authentication) + * [Available Resources and Operations](#available-resources-and-operations) + * [Server-sent event streaming](#server-sent-event-streaming) + * [Retries](#retries) + * [Error Handling](#error-handling) + * [Server Selection](#server-selection) + * [Custom HTTP Client](#custom-http-client) + * [Resource Management](#resource-management) + * [Debugging](#debugging) +* [Development](#development) + * [Maturity](#maturity) + * [Contributions](#contributions) + + + + +## SDK Installation + +> [!TIP] +> To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide). + + +> [!NOTE] +> **Python version upgrade policy** +> +> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated. + +The SDK can be installed with *uv*, *pip*, or *poetry* package managers. + +### uv + +*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities. + +```bash +uv add git+.git +``` + +### PIP + +*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line. + +```bash +pip install git+.git +``` + +### Poetry + +*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies. + +```bash +poetry add git+.git +``` + +### Shell and script usage with `uv` + +You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so: + +```shell +uvx --from openrouter python +``` + +It's also possible to write a standalone Python script without needing to set up a whole project like so: + +```python +#!/usr/bin/env -S uv run --script +# /// script +# requires-python = ">=3.9" +# dependencies = [ +# "openrouter", +# ] +# /// + +from openrouter import OpenRouter + +sdk = OpenRouter( + # SDK arguments +) + +# Rest of script here... +``` + +Once that is saved to a file, you can run it with `uv run script.py` where +`script.py` can be replaced with the actual file name. + + + +## IDE Support + +### PyCharm + +Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin. + +- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/) + + + +## SDK Example Usage + +### Example + +```python +# Synchronous Example +from openrouter import OpenRouter, models +import os + + +with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) +``` + +
+ +The same SDK client can also be used to make asynchronous requests by importing asyncio. +```python +# Asynchronous Example +import asyncio +from openrouter import OpenRouter, models +import os + +async def main(): + + async with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + ) as open_router: + + res = await open_router.chat.complete_async(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +asyncio.run(main()) +``` + + + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security scheme globally: + +| Name | Type | Scheme | Environment Variable | +| ------------- | ---- | ----------- | ------------------------ | +| `bearer_auth` | http | HTTP Bearer | `OPENROUTER_BEARER_AUTH` | + +To authenticate with the API the `bearer_auth` parameter must be set when initializing the SDK client instance. For example: +```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(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +``` + + + +## Available Resources and Operations + +
+Available methods + +### [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 + + +
+ + + +## Server-sent event streaming + +[Server-sent events][mdn-sse] are used to stream content from certain +operations. These operations will expose the stream as [Generator][generator] that +can be consumed using a simple `for` loop. The loop will +terminate when the server no longer has any events to send and closes the +underlying connection. + +The stream is also a [Context Manager][context-manager] and can be used with the `with` statement and will close the +underlying connection when the context is exited. + +```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 + print(event, flush=True) + +``` + +[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events +[generator]: https://book.pythontips.com/en/latest/generators.html +[context-manager]: https://book.pythontips.com/en/latest/context_managers.html + + + +## Retries + +Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. + +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.utils import BackoffStrategy, RetryConfig +import os + + +with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.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) + +``` + +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.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", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +``` + + + +## Error Handling + +[`OpenRouterError`](./src/openrouter/errors/openroutererror.py) is the base class for all HTTP error responses. It has the following properties: + +| Property | Type | Description | +| ------------------ | ---------------- | --------------------------------------------------------------------------------------- | +| `err.message` | `str` | Error message | +| `err.status_code` | `int` | HTTP response status code eg `404` | +| `err.headers` | `httpx.Headers` | HTTP response headers | +| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. | +| `err.raw_response` | `httpx.Response` | Raw HTTP response | +| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). | + +### Example +```python +from openrouter import OpenRouter, errors, models +import os + + +with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + res = None + try: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + + + except errors.OpenRouterError as e: + # The base class for HTTP error responses + print(e.message) + print(e.status_code) + print(e.body) + print(e.headers) + print(e.raw_response) + + # Depending on the method different errors may be thrown + if isinstance(e, errors.ChatCompletionError): + print(e.data.error) # models.Error +``` + +### Error Classes +**Primary errors:** +* [`OpenRouterError`](./src/openrouter/errors/openroutererror.py): The base class for HTTP error responses. + * [`ChatCompletionError`](./src/openrouter/errors/chatcompletionerror.py): Chat completion error response. + +
Less common errors (5) + +
+ +**Network errors:** +* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors. + * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server. + * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out. + + +**Inherit from [`OpenRouterError`](./src/openrouter/errors/openroutererror.py)**: +* [`ResponseValidationError`](./src/openrouter/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute. + +
+ + + +## Server Selection + +### Server Variables + +The default server `https://{provider_url}/api/v1` contains variables and is set to `https://openrouter.ai/api/v1` by default. To override default values, the following parameters are available when initializing the SDK client instance: + +| Variable | Parameter | Default | Description | +| -------------- | ------------------- | ----------------- | ----------- | +| `provider_url` | `provider_url: str` | `"openrouter.ai"` | | + +#### Example + +```python +from openrouter import OpenRouter, models +import os + + +with OpenRouter( + provider_url="https://ruddy-guacamole.info/" + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +``` + +### Override Server URL Per-Client + +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 +import os + + +with OpenRouter( + server_url="https://openrouter.ai/api/v1", + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +``` + + + +## Custom HTTP Client + +The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance. +Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls. +This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly. + +For example, you could specify a header for every request that this sdk makes as follows: +```python +from openrouter import OpenRouter +import httpx + +http_client = httpx.Client(headers={"x-custom-header": "someValue"}) +s = OpenRouter(client=http_client) +``` + +or you could wrap the client with your own custom logic: +```python +from openrouter import OpenRouter +from openrouter.httpclient import AsyncHttpClient +import httpx + +class CustomClient(AsyncHttpClient): + client: AsyncHttpClient + + def __init__(self, client: AsyncHttpClient): + self.client = client + + async def send( + self, + request: httpx.Request, + *, + stream: bool = False, + auth: Union[ + httpx._types.AuthTypes, httpx._client.UseClientDefault, None + ] = httpx.USE_CLIENT_DEFAULT, + follow_redirects: Union[ + bool, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + ) -> httpx.Response: + request.headers["Client-Level-Header"] = "added by client" + + return await self.client.send( + request, stream=stream, auth=auth, follow_redirects=follow_redirects + ) + + def build_request( + self, + method: str, + url: httpx._types.URLTypes, + *, + content: Optional[httpx._types.RequestContent] = None, + data: Optional[httpx._types.RequestData] = None, + files: Optional[httpx._types.RequestFiles] = None, + json: Optional[Any] = None, + params: Optional[httpx._types.QueryParamTypes] = None, + headers: Optional[httpx._types.HeaderTypes] = None, + cookies: Optional[httpx._types.CookieTypes] = None, + timeout: Union[ + httpx._types.TimeoutTypes, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + extensions: Optional[httpx._types.RequestExtensions] = None, + ) -> httpx.Request: + return self.client.build_request( + method, + url, + content=content, + data=data, + files=files, + json=json, + params=params, + headers=headers, + cookies=cookies, + timeout=timeout, + extensions=extensions, + ) + +s = OpenRouter(async_client=CustomClient(httpx.AsyncClient())) +``` + + + +## Resource Management + +The `OpenRouter` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application. + +[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers + +```python +from openrouter import OpenRouter +import os +def main(): + + with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + ) as open_router: + # Rest of application here... + + +# Or when using async: +async def amain(): + + async with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + ) as open_router: + # Rest of application here... +``` + + + +## Debugging + +You can setup your SDK to emit debug logs for SDK requests and responses. + +You can pass your own logger class directly into your SDK. +```python +from openrouter import OpenRouter +import logging + +logging.basicConfig(level=logging.DEBUG) +s = OpenRouter(debug_logger=logging.getLogger("openrouter")) +``` + +You can also enable a default debug logger by setting an environment variable `OPENROUTER_DEBUG` to true. + + + + +# Development + +## Maturity + +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally +looking for the latest version. + +## Contributions + +While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. +We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. + +### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=open-router&utm_campaign=python) diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 0000000..4df956d --- /dev/null +++ b/USAGE.md @@ -0,0 +1,50 @@ + +```python +# Synchronous Example +from openrouter import OpenRouter, models +import os + + +with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), +) as open_router: + + res = open_router.chat.complete(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) +``` + +
+ +The same SDK client can also be used to make asynchronous requests by importing asyncio. +```python +# Asynchronous Example +import asyncio +from openrouter import OpenRouter, models +import os + +async def main(): + + async with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_BEARER_AUTH", ""), + ) as open_router: + + res = await open_router.chat.complete_async(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.USER, + "content": "Hello, how are you?", + }, + ], stream=False, temperature=1, top_p=1) + + # Handle response + print(res) + +asyncio.run(main()) +``` + \ No newline at end of file diff --git a/docs/errors/chatcompletionerror.md b/docs/errors/chatcompletionerror.md new file mode 100644 index 0000000..5442930 --- /dev/null +++ b/docs/errors/chatcompletionerror.md @@ -0,0 +1,10 @@ +# ChatCompletionError + +Chat completion error response + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------- | ---------------------------------- | ---------------------------------- | ---------------------------------- | +| `error` | [models.Error](../models/error.md) | :heavy_check_mark: | Error object structure | \ No newline at end of file diff --git a/docs/models/annotationdetail.md b/docs/models/annotationdetail.md new file mode 100644 index 0000000..69fcb02 --- /dev/null +++ b/docs/models/annotationdetail.md @@ -0,0 +1,19 @@ +# AnnotationDetail + +Annotation information + + +## Supported Types + +### `models.FileAnnotationDetail` + +```python +value: models.FileAnnotationDetail = /* values here */ +``` + +### `models.URLCitationAnnotationDetail` + +```python +value: models.URLCitationAnnotationDetail = /* values here */ +``` + diff --git a/docs/models/chatcompletion.md b/docs/models/chatcompletion.md new file mode 100644 index 0000000..7d6a58e --- /dev/null +++ b/docs/models/chatcompletion.md @@ -0,0 +1,16 @@ +# ChatCompletion + +Chat completion response + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `id` | *str* | :heavy_check_mark: | Unique completion identifier | +| `choices` | List[[models.ChatCompletionChoice](../models/chatcompletionchoice.md)] | :heavy_check_mark: | List of completion choices | +| `created` | *float* | :heavy_check_mark: | Unix timestamp of creation | +| `model` | *str* | :heavy_check_mark: | Model used for completion | +| `object` | [models.ChatCompletionObject](../models/chatcompletionobject.md) | :heavy_check_mark: | N/A | +| `system_fingerprint` | *OptionalNullable[str]* | :heavy_minus_sign: | System fingerprint | +| `usage` | [Optional[models.CompletionUsage]](../models/completionusage.md) | :heavy_minus_sign: | Token usage statistics | \ No newline at end of file diff --git a/docs/models/chatcompletionassistantmessageparam.md b/docs/models/chatcompletionassistantmessageparam.md new file mode 100644 index 0000000..f06e950 --- /dev/null +++ b/docs/models/chatcompletionassistantmessageparam.md @@ -0,0 +1,14 @@ +# ChatCompletionAssistantMessageParam + +Assistant message with tool calls and audio support + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | +| `role` | [models.ChatCompletionAssistantMessageParamRole](../models/chatcompletionassistantmessageparamrole.md) | :heavy_check_mark: | N/A | +| `content` | [OptionalNullable[models.ChatCompletionAssistantMessageParamContent]](../models/chatcompletionassistantmessageparamcontent.md) | :heavy_minus_sign: | Assistant message content | +| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the assistant | +| `tool_calls` | List[[models.ChatCompletionMessageToolCall](../models/chatcompletionmessagetoolcall.md)] | :heavy_minus_sign: | Tool calls made by the assistant | +| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | Refusal message if content was refused | \ No newline at end of file diff --git a/docs/models/chatcompletionassistantmessageparamcontent.md b/docs/models/chatcompletionassistantmessageparamcontent.md new file mode 100644 index 0000000..14be381 --- /dev/null +++ b/docs/models/chatcompletionassistantmessageparamcontent.md @@ -0,0 +1,25 @@ +# ChatCompletionAssistantMessageParamContent + +Assistant message content + + +## Supported Types + +### `str` + +```python +value: str = /* values here */ +``` + +### `List[models.ChatCompletionContentPart]` + +```python +value: List[models.ChatCompletionContentPart] = /* values here */ +``` + +### `Any` + +```python +value: Any = /* values here */ +``` + diff --git a/docs/models/chatcompletionassistantmessageparamrole.md b/docs/models/chatcompletionassistantmessageparamrole.md new file mode 100644 index 0000000..ef57fc0 --- /dev/null +++ b/docs/models/chatcompletionassistantmessageparamrole.md @@ -0,0 +1,8 @@ +# ChatCompletionAssistantMessageParamRole + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `ASSISTANT` | assistant | \ No newline at end of file diff --git a/docs/models/chatcompletionchoice.md b/docs/models/chatcompletionchoice.md new file mode 100644 index 0000000..50cc971 --- /dev/null +++ b/docs/models/chatcompletionchoice.md @@ -0,0 +1,13 @@ +# ChatCompletionChoice + +Chat completion choice + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `finish_reason` | [Nullable[models.ChatCompletionChoiceFinishReason]](../models/chatcompletionchoicefinishreason.md) | :heavy_check_mark: | Reason the completion finished | +| `index` | *float* | :heavy_check_mark: | Choice index | +| `message` | [models.ChatCompletionMessage](../models/chatcompletionmessage.md) | :heavy_check_mark: | Assistant message in completion response | +| `logprobs` | [OptionalNullable[models.ChatCompletionTokenLogprobs]](../models/chatcompletiontokenlogprobs.md) | :heavy_minus_sign: | Log probabilities for the completion | \ No newline at end of file diff --git a/docs/models/chatcompletionchoicefinishreason.md b/docs/models/chatcompletionchoicefinishreason.md new file mode 100644 index 0000000..faa6aea --- /dev/null +++ b/docs/models/chatcompletionchoicefinishreason.md @@ -0,0 +1,14 @@ +# ChatCompletionChoiceFinishReason + +Reason the completion finished + + +## Values + +| Name | Value | +| ---------------- | ---------------- | +| `TOOL_CALLS` | tool_calls | +| `STOP` | stop | +| `LENGTH` | length | +| `CONTENT_FILTER` | content_filter | +| `ERROR` | error | \ No newline at end of file diff --git a/docs/models/chatcompletionchunk.md b/docs/models/chatcompletionchunk.md new file mode 100644 index 0000000..2b3a311 --- /dev/null +++ b/docs/models/chatcompletionchunk.md @@ -0,0 +1,16 @@ +# ChatCompletionChunk + +Streaming chat completion chunk + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `id` | *str* | :heavy_check_mark: | N/A | +| `choices` | List[[models.ChatCompletionChunkChoice](../models/chatcompletionchunkchoice.md)] | :heavy_check_mark: | N/A | +| `created` | *float* | :heavy_check_mark: | N/A | +| `model` | *str* | :heavy_check_mark: | N/A | +| `object` | [models.ChatCompletionChunkObject](../models/chatcompletionchunkobject.md) | :heavy_check_mark: | N/A | +| `system_fingerprint` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `usage` | [Optional[models.CompletionUsage]](../models/completionusage.md) | :heavy_minus_sign: | Token usage statistics | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoice.md b/docs/models/chatcompletionchunkchoice.md new file mode 100644 index 0000000..5e78403 --- /dev/null +++ b/docs/models/chatcompletionchunkchoice.md @@ -0,0 +1,13 @@ +# ChatCompletionChunkChoice + +Streaming completion choice chunk + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `delta` | [models.ChatCompletionChunkChoiceDelta](../models/chatcompletionchunkchoicedelta.md) | :heavy_check_mark: | Delta changes in streaming response | +| `finish_reason` | [Nullable[models.ChatCompletionChunkChoiceFinishReason]](../models/chatcompletionchunkchoicefinishreason.md) | :heavy_check_mark: | N/A | +| `index` | *float* | :heavy_check_mark: | N/A | +| `logprobs` | [OptionalNullable[models.ChatCompletionTokenLogprobs]](../models/chatcompletiontokenlogprobs.md) | :heavy_minus_sign: | Log probabilities for the completion | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicedelta.md b/docs/models/chatcompletionchunkchoicedelta.md new file mode 100644 index 0000000..cc61fce --- /dev/null +++ b/docs/models/chatcompletionchunkchoicedelta.md @@ -0,0 +1,16 @@ +# ChatCompletionChunkChoiceDelta + +Delta changes in streaming response + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| `role` | [Optional[models.ChatCompletionChunkChoiceDeltaRole]](../models/chatcompletionchunkchoicedeltarole.md) | :heavy_minus_sign: | The role of the message author | +| `content` | *OptionalNullable[str]* | :heavy_minus_sign: | Message content delta | +| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | Reasoning content delta | +| `refusal` | *OptionalNullable[str]* | :heavy_minus_sign: | Refusal message delta | +| `tool_calls` | List[[models.ChatCompletionChunkChoiceDeltaToolCall](../models/chatcompletionchunkchoicedeltatoolcall.md)] | :heavy_minus_sign: | Tool calls delta | +| `reasoning_details` | List[[models.ReasoningDetail](../models/reasoningdetail.md)] | :heavy_minus_sign: | Reasoning details delta to send reasoning details back to upstream | +| `annotations` | List[[models.AnnotationDetail](../models/annotationdetail.md)] | :heavy_minus_sign: | Annotations delta to send annotations back to upstream | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicedeltarole.md b/docs/models/chatcompletionchunkchoicedeltarole.md new file mode 100644 index 0000000..cdd171a --- /dev/null +++ b/docs/models/chatcompletionchunkchoicedeltarole.md @@ -0,0 +1,10 @@ +# ChatCompletionChunkChoiceDeltaRole + +The role of the message author + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `ASSISTANT` | assistant | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicedeltatoolcall.md b/docs/models/chatcompletionchunkchoicedeltatoolcall.md new file mode 100644 index 0000000..831b2f3 --- /dev/null +++ b/docs/models/chatcompletionchunkchoicedeltatoolcall.md @@ -0,0 +1,13 @@ +# ChatCompletionChunkChoiceDeltaToolCall + +Tool call delta for streaming responses + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | +| `index` | *float* | :heavy_check_mark: | Tool call index in the array | +| `id` | *Optional[str]* | :heavy_minus_sign: | Tool call identifier | +| `type` | [Optional[models.ChatCompletionChunkChoiceDeltaToolCallType]](../models/chatcompletionchunkchoicedeltatoolcalltype.md) | :heavy_minus_sign: | Tool call type | +| `function` | [Optional[models.ChatCompletionChunkChoiceDeltaToolCallFunction]](../models/chatcompletionchunkchoicedeltatoolcallfunction.md) | :heavy_minus_sign: | Function call details | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicedeltatoolcallfunction.md b/docs/models/chatcompletionchunkchoicedeltatoolcallfunction.md new file mode 100644 index 0000000..d02d71b --- /dev/null +++ b/docs/models/chatcompletionchunkchoicedeltatoolcallfunction.md @@ -0,0 +1,11 @@ +# ChatCompletionChunkChoiceDeltaToolCallFunction + +Function call details + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- | +| `name` | *Optional[str]* | :heavy_minus_sign: | Function name | +| `arguments` | *Optional[str]* | :heavy_minus_sign: | Function arguments as JSON string | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicedeltatoolcalltype.md b/docs/models/chatcompletionchunkchoicedeltatoolcalltype.md new file mode 100644 index 0000000..238532c --- /dev/null +++ b/docs/models/chatcompletionchunkchoicedeltatoolcalltype.md @@ -0,0 +1,10 @@ +# ChatCompletionChunkChoiceDeltaToolCallType + +Tool call type + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `FUNCTION` | function | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkchoicefinishreason.md b/docs/models/chatcompletionchunkchoicefinishreason.md new file mode 100644 index 0000000..1a676c4 --- /dev/null +++ b/docs/models/chatcompletionchunkchoicefinishreason.md @@ -0,0 +1,12 @@ +# ChatCompletionChunkChoiceFinishReason + + +## Values + +| Name | Value | +| ---------------- | ---------------- | +| `TOOL_CALLS` | tool_calls | +| `STOP` | stop | +| `LENGTH` | length | +| `CONTENT_FILTER` | content_filter | +| `ERROR` | error | \ No newline at end of file diff --git a/docs/models/chatcompletionchunkobject.md b/docs/models/chatcompletionchunkobject.md new file mode 100644 index 0000000..cb5bfd4 --- /dev/null +++ b/docs/models/chatcompletionchunkobject.md @@ -0,0 +1,8 @@ +# ChatCompletionChunkObject + + +## Values + +| Name | Value | +| ----------------------- | ----------------------- | +| `CHAT_COMPLETION_CHUNK` | chat.completion.chunk | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpart.md b/docs/models/chatcompletioncontentpart.md new file mode 100644 index 0000000..114dfe4 --- /dev/null +++ b/docs/models/chatcompletioncontentpart.md @@ -0,0 +1,25 @@ +# ChatCompletionContentPart + +Content part for chat completion messages + + +## Supported Types + +### `models.ChatCompletionContentPartText` + +```python +value: models.ChatCompletionContentPartText = /* values here */ +``` + +### `models.ChatCompletionContentPartImage` + +```python +value: models.ChatCompletionContentPartImage = /* values here */ +``` + +### `models.ChatCompletionContentPartAudio` + +```python +value: models.ChatCompletionContentPartAudio = /* values here */ +``` + diff --git a/docs/models/chatcompletioncontentpartaudio.md b/docs/models/chatcompletioncontentpartaudio.md new file mode 100644 index 0000000..370d942 --- /dev/null +++ b/docs/models/chatcompletioncontentpartaudio.md @@ -0,0 +1,11 @@ +# ChatCompletionContentPartAudio + +Audio input content part + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `type` | [models.ChatCompletionContentPartAudioType](../models/chatcompletioncontentpartaudiotype.md) | :heavy_check_mark: | N/A | +| `input_audio` | [models.InputAudio](../models/inputaudio.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpartaudioformat.md b/docs/models/chatcompletioncontentpartaudioformat.md new file mode 100644 index 0000000..839d83f --- /dev/null +++ b/docs/models/chatcompletioncontentpartaudioformat.md @@ -0,0 +1,16 @@ +# ChatCompletionContentPartAudioFormat + +Audio format + + +## Values + +| Name | Value | +| ------- | ------- | +| `WAV` | wav | +| `MP3` | mp3 | +| `FLAC` | flac | +| `M4A` | m4a | +| `OGG` | ogg | +| `PCM16` | pcm16 | +| `PCM24` | pcm24 | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpartaudiotype.md b/docs/models/chatcompletioncontentpartaudiotype.md new file mode 100644 index 0000000..d6d1ded --- /dev/null +++ b/docs/models/chatcompletioncontentpartaudiotype.md @@ -0,0 +1,8 @@ +# ChatCompletionContentPartAudioType + + +## Values + +| Name | Value | +| ------------- | ------------- | +| `INPUT_AUDIO` | input_audio | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpartimage.md b/docs/models/chatcompletioncontentpartimage.md new file mode 100644 index 0000000..2d2e0ed --- /dev/null +++ b/docs/models/chatcompletioncontentpartimage.md @@ -0,0 +1,11 @@ +# ChatCompletionContentPartImage + +Image content part for vision models + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `type` | [models.ChatCompletionContentPartImageType](../models/chatcompletioncontentpartimagetype.md) | :heavy_check_mark: | N/A | +| `image_url` | [models.ChatCompletionContentPartImageImageURL](../models/chatcompletioncontentpartimageimageurl.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpartimageimageurl.md b/docs/models/chatcompletioncontentpartimageimageurl.md new file mode 100644 index 0000000..9a97c0c --- /dev/null +++ b/docs/models/chatcompletioncontentpartimageimageurl.md @@ -0,0 +1,9 @@ +# ChatCompletionContentPartImageImageURL + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | +| `url` | *str* | :heavy_check_mark: | URL of the image (data: URLs supported) | +| `detail` | [Optional[models.Detail]](../models/detail.md) | :heavy_minus_sign: | Image detail level for vision models | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentpartimagetype.md b/docs/models/chatcompletioncontentpartimagetype.md new file mode 100644 index 0000000..a4bf809 --- /dev/null +++ b/docs/models/chatcompletioncontentpartimagetype.md @@ -0,0 +1,8 @@ +# ChatCompletionContentPartImageType + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `IMAGE_URL` | image_url | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentparttext.md b/docs/models/chatcompletioncontentparttext.md new file mode 100644 index 0000000..8d399e3 --- /dev/null +++ b/docs/models/chatcompletioncontentparttext.md @@ -0,0 +1,11 @@ +# ChatCompletionContentPartText + +Text content part + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `type` | [models.ChatCompletionContentPartTextType](../models/chatcompletioncontentparttexttype.md) | :heavy_check_mark: | N/A | +| `text` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncontentparttexttype.md b/docs/models/chatcompletioncontentparttexttype.md new file mode 100644 index 0000000..7a8499d --- /dev/null +++ b/docs/models/chatcompletioncontentparttexttype.md @@ -0,0 +1,8 @@ +# ChatCompletionContentPartTextType + + +## Values + +| Name | Value | +| ------ | ------ | +| `TEXT` | text | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparams.md b/docs/models/chatcompletioncreateparams.md new file mode 100644 index 0000000..e06608e --- /dev/null +++ b/docs/models/chatcompletioncreateparams.md @@ -0,0 +1,34 @@ +# ChatCompletionCreateParams + +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 diff --git a/docs/models/chatcompletioncreateparamsaudio.md b/docs/models/chatcompletioncreateparamsaudio.md new file mode 100644 index 0000000..e60d0c8 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsaudio.md @@ -0,0 +1,23 @@ +# ChatCompletionCreateParamsAudio + + +## 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/chatcompletioncreateparamscompletion.md b/docs/models/chatcompletioncreateparamscompletion.md new file mode 100644 index 0000000..0718ff0 --- /dev/null +++ b/docs/models/chatcompletioncreateparamscompletion.md @@ -0,0 +1,23 @@ +# 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/chatcompletioncreateparamsdatacollection.md b/docs/models/chatcompletioncreateparamsdatacollection.md new file mode 100644 index 0000000..0f05804 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsdatacollection.md @@ -0,0 +1,14 @@ +# ChatCompletionCreateParamsDataCollection + +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/chatcompletioncreateparamseffort.md b/docs/models/chatcompletioncreateparamseffort.md new file mode 100644 index 0000000..15adb4b --- /dev/null +++ b/docs/models/chatcompletioncreateparamseffort.md @@ -0,0 +1,13 @@ +# ChatCompletionCreateParamsEffort + +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/chatcompletioncreateparamsengine.md b/docs/models/chatcompletioncreateparamsengine.md new file mode 100644 index 0000000..5f1bb21 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsengine.md @@ -0,0 +1,9 @@ +# ChatCompletionCreateParamsEngine + + +## Values + +| Name | Value | +| -------- | -------- | +| `NATIVE` | native | +| `EXA` | exa | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsidchainofthought.md b/docs/models/chatcompletioncreateparamsidchainofthought.md new file mode 100644 index 0000000..e13847b --- /dev/null +++ b/docs/models/chatcompletioncreateparamsidchainofthought.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsIDChainOfThought + + +## Values + +| Name | Value | +| ------------------ | ------------------ | +| `CHAIN_OF_THOUGHT` | chain-of-thought | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsidfileparser.md b/docs/models/chatcompletioncreateparamsidfileparser.md new file mode 100644 index 0000000..7d664f1 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsidfileparser.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsIDFileParser + + +## Values + +| Name | Value | +| ------------- | ------------- | +| `FILE_PARSER` | file-parser | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsidmoderation.md b/docs/models/chatcompletioncreateparamsidmoderation.md new file mode 100644 index 0000000..a605649 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsidmoderation.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsIDModeration + + +## Values + +| Name | Value | +| ------------ | ------------ | +| `MODERATION` | moderation | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsidweb.md b/docs/models/chatcompletioncreateparamsidweb.md new file mode 100644 index 0000000..62d1f02 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsidweb.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsIDWeb + + +## Values + +| Name | Value | +| ----- | ----- | +| `WEB` | web | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsignoreenum.md b/docs/models/chatcompletioncreateparamsignoreenum.md new file mode 100644 index 0000000..39a3791 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsignoreenum.md @@ -0,0 +1,85 @@ +# ChatCompletionCreateParamsIgnoreEnum + + +## 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/chatcompletioncreateparamsignoreunion.md b/docs/models/chatcompletioncreateparamsignoreunion.md new file mode 100644 index 0000000..96cc708 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsignoreunion.md @@ -0,0 +1,17 @@ +# ChatCompletionCreateParamsIgnoreUnion + + +## Supported Types + +### `models.ChatCompletionCreateParamsIgnoreEnum` + +```python +value: models.ChatCompletionCreateParamsIgnoreEnum = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsimage.md b/docs/models/chatcompletioncreateparamsimage.md new file mode 100644 index 0000000..c61f30d --- /dev/null +++ b/docs/models/chatcompletioncreateparamsimage.md @@ -0,0 +1,23 @@ +# ChatCompletionCreateParamsImage + + +## 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/chatcompletioncreateparamsjsonschema.md b/docs/models/chatcompletioncreateparamsjsonschema.md new file mode 100644 index 0000000..f7b77cc --- /dev/null +++ b/docs/models/chatcompletioncreateparamsjsonschema.md @@ -0,0 +1,11 @@ +# ChatCompletionCreateParamsJSONSchema + + +## 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/chatcompletioncreateparamsmaxprice.md b/docs/models/chatcompletioncreateparamsmaxprice.md new file mode 100644 index 0000000..21a9f9d --- /dev/null +++ b/docs/models/chatcompletioncreateparamsmaxprice.md @@ -0,0 +1,14 @@ +# 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/chatcompletioncreateparamsonlyenum.md b/docs/models/chatcompletioncreateparamsonlyenum.md new file mode 100644 index 0000000..ac7e092 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsonlyenum.md @@ -0,0 +1,85 @@ +# ChatCompletionCreateParamsOnlyEnum + + +## 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/chatcompletioncreateparamsonlyunion.md b/docs/models/chatcompletioncreateparamsonlyunion.md new file mode 100644 index 0000000..190e394 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsonlyunion.md @@ -0,0 +1,17 @@ +# ChatCompletionCreateParamsOnlyUnion + + +## Supported Types + +### `models.ChatCompletionCreateParamsOnlyEnum` + +```python +value: models.ChatCompletionCreateParamsOnlyEnum = /* values here */ +``` + +### `str` + +```python +value: str = /* values here */ +``` + diff --git a/docs/models/chatcompletioncreateparamsorderenum.md b/docs/models/chatcompletioncreateparamsorderenum.md new file mode 100644 index 0000000..a83b3e5 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsorderenum.md @@ -0,0 +1,85 @@ +# ChatCompletionCreateParamsOrderEnum + + +## 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/chatcompletioncreateparamsorderunion.md b/docs/models/chatcompletioncreateparamsorderunion.md new file mode 100644 index 0000000..5b1429e --- /dev/null +++ b/docs/models/chatcompletioncreateparamsorderunion.md @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 0000000..e95b198 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspdf.md @@ -0,0 +1,8 @@ +# 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/chatcompletioncreateparamspdfengine.md b/docs/models/chatcompletioncreateparamspdfengine.md new file mode 100644 index 0000000..1330e18 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspdfengine.md @@ -0,0 +1,10 @@ +# ChatCompletionCreateParamsPdfEngine + + +## Values + +| Name | Value | +| ------------- | ------------- | +| `MISTRAL_OCR` | mistral-ocr | +| `PDF_TEXT` | pdf-text | +| `NATIVE` | native | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamspluginchainofthought.md b/docs/models/chatcompletioncreateparamspluginchainofthought.md new file mode 100644 index 0000000..98d012b --- /dev/null +++ b/docs/models/chatcompletioncreateparamspluginchainofthought.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..6d060a6 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspluginfileparser.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..a213ea0 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspluginmoderation.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..f326c21 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspluginunion.md @@ -0,0 +1,29 @@ +# 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 new file mode 100644 index 0000000..9796a17 --- /dev/null +++ b/docs/models/chatcompletioncreateparamspluginweb.md @@ -0,0 +1,11 @@ +# 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/chatcompletioncreateparamsprompt.md b/docs/models/chatcompletioncreateparamsprompt.md new file mode 100644 index 0000000..12c0a17 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsprompt.md @@ -0,0 +1,23 @@ +# ChatCompletionCreateParamsPrompt + + +## 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/chatcompletioncreateparamsprovider.md b/docs/models/chatcompletioncreateparamsprovider.md new file mode 100644 index 0000000..e217d53 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsprovider.md @@ -0,0 +1,18 @@ +# ChatCompletionCreateParamsProvider + +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.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 diff --git a/docs/models/chatcompletioncreateparamsquantization.md b/docs/models/chatcompletioncreateparamsquantization.md new file mode 100644 index 0000000..2c6c357 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsquantization.md @@ -0,0 +1,16 @@ +# ChatCompletionCreateParamsQuantization + + +## 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/chatcompletioncreateparamsreasoning.md b/docs/models/chatcompletioncreateparamsreasoning.md new file mode 100644 index 0000000..d2374f7 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsreasoning.md @@ -0,0 +1,13 @@ +# 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/chatcompletioncreateparamsreasoningeffort.md b/docs/models/chatcompletioncreateparamsreasoningeffort.md new file mode 100644 index 0000000..771aab3 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsreasoningeffort.md @@ -0,0 +1,13 @@ +# ChatCompletionCreateParamsReasoningEffort + +Reasoning effort + + +## Values + +| Name | Value | +| --------- | --------- | +| `HIGH` | high | +| `MEDIUM` | medium | +| `LOW` | low | +| `MINIMAL` | minimal | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsrequest.md b/docs/models/chatcompletioncreateparamsrequest.md new file mode 100644 index 0000000..05c8a09 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsrequest.md @@ -0,0 +1,23 @@ +# ChatCompletionCreateParamsRequest + + +## 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/chatcompletioncreateparamsresponseformatgrammar.md b/docs/models/chatcompletioncreateparamsresponseformatgrammar.md new file mode 100644 index 0000000..4b4275a --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformatgrammar.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..0de86bb --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformatjsonobject.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..9bd34e0 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformatjsonschema.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..770b61a --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformatpython.md @@ -0,0 +1,10 @@ +# 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/chatcompletioncreateparamsresponseformattext.md b/docs/models/chatcompletioncreateparamsresponseformattext.md new file mode 100644 index 0000000..0eadf11 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformattext.md @@ -0,0 +1,10 @@ +# ChatCompletionCreateParamsResponseFormatText + +Default text response format + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `type` | [models.ChatCompletionCreateParamsTypeText](../models/chatcompletioncreateparamstypetext.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamsresponseformatunion.md b/docs/models/chatcompletioncreateparamsresponseformatunion.md new file mode 100644 index 0000000..5b66aef --- /dev/null +++ b/docs/models/chatcompletioncreateparamsresponseformatunion.md @@ -0,0 +1,37 @@ +# 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/chatcompletioncreateparamssort.md b/docs/models/chatcompletioncreateparamssort.md new file mode 100644 index 0000000..a11c83a --- /dev/null +++ b/docs/models/chatcompletioncreateparamssort.md @@ -0,0 +1,12 @@ +# ChatCompletionCreateParamsSort + +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/chatcompletioncreateparamsstop.md b/docs/models/chatcompletioncreateparamsstop.md new file mode 100644 index 0000000..5b4be00 --- /dev/null +++ b/docs/models/chatcompletioncreateparamsstop.md @@ -0,0 +1,25 @@ +# ChatCompletionCreateParamsStop + +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/chatcompletioncreateparamsstreamoptions.md b/docs/models/chatcompletioncreateparamsstreamoptions.md new file mode 100644 index 0000000..9f75def --- /dev/null +++ b/docs/models/chatcompletioncreateparamsstreamoptions.md @@ -0,0 +1,10 @@ +# ChatCompletionCreateParamsStreamOptions + +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/chatcompletioncreateparamstypegrammar.md b/docs/models/chatcompletioncreateparamstypegrammar.md new file mode 100644 index 0000000..c3cf87f --- /dev/null +++ b/docs/models/chatcompletioncreateparamstypegrammar.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsTypeGrammar + + +## Values + +| Name | Value | +| --------- | --------- | +| `GRAMMAR` | grammar | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamstypejsonobject.md b/docs/models/chatcompletioncreateparamstypejsonobject.md new file mode 100644 index 0000000..b3724f9 --- /dev/null +++ b/docs/models/chatcompletioncreateparamstypejsonobject.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsTypeJSONObject + + +## Values + +| Name | Value | +| ------------- | ------------- | +| `JSON_OBJECT` | json_object | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamstypejsonschema.md b/docs/models/chatcompletioncreateparamstypejsonschema.md new file mode 100644 index 0000000..9f307a4 --- /dev/null +++ b/docs/models/chatcompletioncreateparamstypejsonschema.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsTypeJSONSchema + + +## Values + +| Name | Value | +| ------------- | ------------- | +| `JSON_SCHEMA` | json_schema | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamstypepython.md b/docs/models/chatcompletioncreateparamstypepython.md new file mode 100644 index 0000000..991e9ac --- /dev/null +++ b/docs/models/chatcompletioncreateparamstypepython.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsTypePython + + +## Values + +| Name | Value | +| -------- | -------- | +| `PYTHON` | python | \ No newline at end of file diff --git a/docs/models/chatcompletioncreateparamstypetext.md b/docs/models/chatcompletioncreateparamstypetext.md new file mode 100644 index 0000000..cd805c8 --- /dev/null +++ b/docs/models/chatcompletioncreateparamstypetext.md @@ -0,0 +1,8 @@ +# ChatCompletionCreateParamsTypeText + + +## Values + +| Name | Value | +| ------ | ------ | +| `TEXT` | text | \ No newline at end of file diff --git a/docs/models/chatcompletionmessage.md b/docs/models/chatcompletionmessage.md new file mode 100644 index 0000000..549573d --- /dev/null +++ b/docs/models/chatcompletionmessage.md @@ -0,0 +1,16 @@ +# ChatCompletionMessage + +Assistant message in completion response + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `role` | [models.ChatCompletionMessageRole](../models/chatcompletionmessagerole.md) | :heavy_check_mark: | N/A | +| `content` | *Nullable[str]* | :heavy_check_mark: | Message content | +| `reasoning` | *OptionalNullable[str]* | :heavy_minus_sign: | Reasoning output | +| `refusal` | *Nullable[str]* | :heavy_check_mark: | Refusal message if content was refused | +| `tool_calls` | List[[models.ChatCompletionMessageToolCall](../models/chatcompletionmessagetoolcall.md)] | :heavy_minus_sign: | Tool calls made by the assistant | +| `reasoning_details` | List[[models.ReasoningDetail](../models/reasoningdetail.md)] | :heavy_minus_sign: | Reasoning details delta to send reasoning details back to upstream | +| `annotations` | List[[models.AnnotationDetail](../models/annotationdetail.md)] | :heavy_minus_sign: | Annotations delta to send annotations back to upstream | \ No newline at end of file diff --git a/docs/models/chatcompletionmessageparam.md b/docs/models/chatcompletionmessageparam.md new file mode 100644 index 0000000..de89710 --- /dev/null +++ b/docs/models/chatcompletionmessageparam.md @@ -0,0 +1,31 @@ +# ChatCompletionMessageParam + +Chat completion message with role-based discrimination + + +## Supported Types + +### `models.ChatCompletionSystemMessageParam` + +```python +value: models.ChatCompletionSystemMessageParam = /* values here */ +``` + +### `models.ChatCompletionUserMessageParam` + +```python +value: models.ChatCompletionUserMessageParam = /* values here */ +``` + +### `models.ChatCompletionAssistantMessageParam` + +```python +value: models.ChatCompletionAssistantMessageParam = /* values here */ +``` + +### `models.ChatCompletionToolMessageParam` + +```python +value: models.ChatCompletionToolMessageParam = /* values here */ +``` + diff --git a/docs/models/chatcompletionmessagerole.md b/docs/models/chatcompletionmessagerole.md new file mode 100644 index 0000000..9eabb6b --- /dev/null +++ b/docs/models/chatcompletionmessagerole.md @@ -0,0 +1,8 @@ +# ChatCompletionMessageRole + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `ASSISTANT` | assistant | \ No newline at end of file diff --git a/docs/models/chatcompletionmessagetoolcall.md b/docs/models/chatcompletionmessagetoolcall.md new file mode 100644 index 0000000..f9994b1 --- /dev/null +++ b/docs/models/chatcompletionmessagetoolcall.md @@ -0,0 +1,12 @@ +# ChatCompletionMessageToolCall + +Tool call made by the assistant + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `id` | *str* | :heavy_check_mark: | Tool call identifier | +| `type` | [models.ChatCompletionMessageToolCallType](../models/chatcompletionmessagetoolcalltype.md) | :heavy_check_mark: | N/A | +| `function` | [models.ChatCompletionMessageToolCallFunction](../models/chatcompletionmessagetoolcallfunction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletionmessagetoolcallfunction.md b/docs/models/chatcompletionmessagetoolcallfunction.md new file mode 100644 index 0000000..b5fb57f --- /dev/null +++ b/docs/models/chatcompletionmessagetoolcallfunction.md @@ -0,0 +1,9 @@ +# ChatCompletionMessageToolCallFunction + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- | +| `name` | *str* | :heavy_check_mark: | Function name to call | +| `arguments` | *str* | :heavy_check_mark: | Function arguments as JSON string | \ No newline at end of file diff --git a/docs/models/chatcompletionmessagetoolcalltype.md b/docs/models/chatcompletionmessagetoolcalltype.md new file mode 100644 index 0000000..0fbb7ea --- /dev/null +++ b/docs/models/chatcompletionmessagetoolcalltype.md @@ -0,0 +1,8 @@ +# ChatCompletionMessageToolCallType + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `FUNCTION` | function | \ No newline at end of file diff --git a/docs/models/chatcompletionnamedtoolchoice.md b/docs/models/chatcompletionnamedtoolchoice.md new file mode 100644 index 0000000..cbce276 --- /dev/null +++ b/docs/models/chatcompletionnamedtoolchoice.md @@ -0,0 +1,11 @@ +# ChatCompletionNamedToolChoice + +Named tool choice for specific function + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `type` | [models.ChatCompletionNamedToolChoiceType](../models/chatcompletionnamedtoolchoicetype.md) | :heavy_check_mark: | N/A | +| `function` | [models.ChatCompletionNamedToolChoiceFunction](../models/chatcompletionnamedtoolchoicefunction.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/chatcompletionnamedtoolchoicefunction.md b/docs/models/chatcompletionnamedtoolchoicefunction.md new file mode 100644 index 0000000..e52e2b8 --- /dev/null +++ b/docs/models/chatcompletionnamedtoolchoicefunction.md @@ -0,0 +1,8 @@ +# ChatCompletionNamedToolChoiceFunction + + +## Fields + +| Field | Type | Required | Description | +| --------------------- | --------------------- | --------------------- | --------------------- | +| `name` | *str* | :heavy_check_mark: | Function name to call | \ No newline at end of file diff --git a/docs/models/chatcompletionnamedtoolchoicetype.md b/docs/models/chatcompletionnamedtoolchoicetype.md new file mode 100644 index 0000000..6dfc5bd --- /dev/null +++ b/docs/models/chatcompletionnamedtoolchoicetype.md @@ -0,0 +1,8 @@ +# ChatCompletionNamedToolChoiceType + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `FUNCTION` | function | \ No newline at end of file diff --git a/docs/models/chatcompletionobject.md b/docs/models/chatcompletionobject.md new file mode 100644 index 0000000..fcef9f7 --- /dev/null +++ b/docs/models/chatcompletionobject.md @@ -0,0 +1,8 @@ +# ChatCompletionObject + + +## Values + +| Name | Value | +| ----------------- | ----------------- | +| `CHAT_COMPLETION` | chat.completion | \ No newline at end of file diff --git a/docs/models/chatcompletionsystemmessageparam.md b/docs/models/chatcompletionsystemmessageparam.md new file mode 100644 index 0000000..3953f44 --- /dev/null +++ b/docs/models/chatcompletionsystemmessageparam.md @@ -0,0 +1,12 @@ +# ChatCompletionSystemMessageParam + +System message for setting behavior + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `role` | [models.ChatCompletionSystemMessageParamRole](../models/chatcompletionsystemmessageparamrole.md) | :heavy_check_mark: | N/A | +| `content` | [models.ChatCompletionSystemMessageParamContent](../models/chatcompletionsystemmessageparamcontent.md) | :heavy_check_mark: | System message content | +| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the system message | \ No newline at end of file diff --git a/docs/models/chatcompletionsystemmessageparamcontent.md b/docs/models/chatcompletionsystemmessageparamcontent.md new file mode 100644 index 0000000..12b5c76 --- /dev/null +++ b/docs/models/chatcompletionsystemmessageparamcontent.md @@ -0,0 +1,19 @@ +# ChatCompletionSystemMessageParamContent + +System message content + + +## Supported Types + +### `str` + +```python +value: str = /* values here */ +``` + +### `List[models.ChatCompletionContentPartText]` + +```python +value: List[models.ChatCompletionContentPartText] = /* values here */ +``` + diff --git a/docs/models/chatcompletionsystemmessageparamrole.md b/docs/models/chatcompletionsystemmessageparamrole.md new file mode 100644 index 0000000..52c79f6 --- /dev/null +++ b/docs/models/chatcompletionsystemmessageparamrole.md @@ -0,0 +1,8 @@ +# ChatCompletionSystemMessageParamRole + + +## Values + +| Name | Value | +| -------- | -------- | +| `SYSTEM` | system | \ No newline at end of file diff --git a/docs/models/chatcompletiontokenlogprob.md b/docs/models/chatcompletiontokenlogprob.md new file mode 100644 index 0000000..a0a9b27 --- /dev/null +++ b/docs/models/chatcompletiontokenlogprob.md @@ -0,0 +1,13 @@ +# ChatCompletionTokenLogprob + +Token log probability information + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | +| `token` | *str* | :heavy_check_mark: | The token | +| `logprob` | *float* | :heavy_check_mark: | Log probability of the token | +| `bytes_` | List[*float*] | :heavy_check_mark: | UTF-8 bytes of the token | +| `top_logprobs` | List[[models.TopLogprob](../models/toplogprob.md)] | :heavy_check_mark: | Top alternative tokens with probabilities | \ No newline at end of file diff --git a/docs/models/chatcompletiontokenlogprobs.md b/docs/models/chatcompletiontokenlogprobs.md new file mode 100644 index 0000000..d11fc25 --- /dev/null +++ b/docs/models/chatcompletiontokenlogprobs.md @@ -0,0 +1,11 @@ +# ChatCompletionTokenLogprobs + +Log probabilities for the completion + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `content` | List[[models.ChatCompletionTokenLogprob](../models/chatcompletiontokenlogprob.md)] | :heavy_check_mark: | Log probabilities for content tokens | +| `refusal` | List[[models.ChatCompletionTokenLogprob](../models/chatcompletiontokenlogprob.md)] | :heavy_check_mark: | Log probabilities for refusal tokens | \ No newline at end of file diff --git a/docs/models/chatcompletiontool.md b/docs/models/chatcompletiontool.md new file mode 100644 index 0000000..582aa1a --- /dev/null +++ b/docs/models/chatcompletiontool.md @@ -0,0 +1,11 @@ +# ChatCompletionTool + +Tool definition for function calling + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `type` | [models.ChatCompletionToolType](../models/chatcompletiontooltype.md) | :heavy_check_mark: | N/A | +| `function` | [models.ChatCompletionToolFunction](../models/chatcompletiontoolfunction.md) | :heavy_check_mark: | Function definition for tool calling | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolchoiceoption.md b/docs/models/chatcompletiontoolchoiceoption.md new file mode 100644 index 0000000..af7d9c3 --- /dev/null +++ b/docs/models/chatcompletiontoolchoiceoption.md @@ -0,0 +1,31 @@ +# ChatCompletionToolChoiceOption + +Tool choice configuration + + +## Supported Types + +### `models.ChatCompletionToolChoiceOptionNone` + +```python +value: models.ChatCompletionToolChoiceOptionNone = /* values here */ +``` + +### `models.ChatCompletionToolChoiceOptionAuto` + +```python +value: models.ChatCompletionToolChoiceOptionAuto = /* values here */ +``` + +### `models.ChatCompletionToolChoiceOptionRequired` + +```python +value: models.ChatCompletionToolChoiceOptionRequired = /* values here */ +``` + +### `models.ChatCompletionNamedToolChoice` + +```python +value: models.ChatCompletionNamedToolChoice = /* values here */ +``` + diff --git a/docs/models/chatcompletiontoolchoiceoptionauto.md b/docs/models/chatcompletiontoolchoiceoptionauto.md new file mode 100644 index 0000000..db457e8 --- /dev/null +++ b/docs/models/chatcompletiontoolchoiceoptionauto.md @@ -0,0 +1,8 @@ +# ChatCompletionToolChoiceOptionAuto + + +## Values + +| Name | Value | +| ------ | ------ | +| `AUTO` | auto | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolchoiceoptionnone.md b/docs/models/chatcompletiontoolchoiceoptionnone.md new file mode 100644 index 0000000..ab21478 --- /dev/null +++ b/docs/models/chatcompletiontoolchoiceoptionnone.md @@ -0,0 +1,8 @@ +# ChatCompletionToolChoiceOptionNone + + +## Values + +| Name | Value | +| ------ | ------ | +| `NONE` | none | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolchoiceoptionrequired.md b/docs/models/chatcompletiontoolchoiceoptionrequired.md new file mode 100644 index 0000000..9adea3c --- /dev/null +++ b/docs/models/chatcompletiontoolchoiceoptionrequired.md @@ -0,0 +1,8 @@ +# ChatCompletionToolChoiceOptionRequired + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `REQUIRED` | required | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolfunction.md b/docs/models/chatcompletiontoolfunction.md new file mode 100644 index 0000000..07503d8 --- /dev/null +++ b/docs/models/chatcompletiontoolfunction.md @@ -0,0 +1,13 @@ +# ChatCompletionToolFunction + +Function definition for tool calling + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `name` | *str* | :heavy_check_mark: | Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars) | +| `description` | *Optional[str]* | :heavy_minus_sign: | Function description for the model | +| `parameters` | [Optional[models.Parameters]](../models/parameters.md) | :heavy_minus_sign: | Function parameters as JSON Schema object | +| `strict` | *OptionalNullable[bool]* | :heavy_minus_sign: | Enable strict schema adherence | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolmessageparam.md b/docs/models/chatcompletiontoolmessageparam.md new file mode 100644 index 0000000..0f6aa44 --- /dev/null +++ b/docs/models/chatcompletiontoolmessageparam.md @@ -0,0 +1,12 @@ +# ChatCompletionToolMessageParam + +Tool response message + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `role` | [models.ChatCompletionToolMessageParamRole](../models/chatcompletiontoolmessageparamrole.md) | :heavy_check_mark: | N/A | +| `content` | [models.ChatCompletionToolMessageParamContent](../models/chatcompletiontoolmessageparamcontent.md) | :heavy_check_mark: | Tool response content | +| `tool_call_id` | *str* | :heavy_check_mark: | ID of the tool call this message responds to | \ No newline at end of file diff --git a/docs/models/chatcompletiontoolmessageparamcontent.md b/docs/models/chatcompletiontoolmessageparamcontent.md new file mode 100644 index 0000000..0c3cea2 --- /dev/null +++ b/docs/models/chatcompletiontoolmessageparamcontent.md @@ -0,0 +1,19 @@ +# ChatCompletionToolMessageParamContent + +Tool response content + + +## Supported Types + +### `str` + +```python +value: str = /* values here */ +``` + +### `List[models.ChatCompletionContentPart]` + +```python +value: List[models.ChatCompletionContentPart] = /* values here */ +``` + diff --git a/docs/models/chatcompletiontoolmessageparamrole.md b/docs/models/chatcompletiontoolmessageparamrole.md new file mode 100644 index 0000000..154255c --- /dev/null +++ b/docs/models/chatcompletiontoolmessageparamrole.md @@ -0,0 +1,8 @@ +# ChatCompletionToolMessageParamRole + + +## Values + +| Name | Value | +| ------ | ------ | +| `TOOL` | tool | \ No newline at end of file diff --git a/docs/models/chatcompletiontooltype.md b/docs/models/chatcompletiontooltype.md new file mode 100644 index 0000000..50a06b1 --- /dev/null +++ b/docs/models/chatcompletiontooltype.md @@ -0,0 +1,8 @@ +# ChatCompletionToolType + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `FUNCTION` | function | \ No newline at end of file diff --git a/docs/models/chatcompletionusermessageparam.md b/docs/models/chatcompletionusermessageparam.md new file mode 100644 index 0000000..b25e2d8 --- /dev/null +++ b/docs/models/chatcompletionusermessageparam.md @@ -0,0 +1,12 @@ +# ChatCompletionUserMessageParam + +User message + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `role` | [models.ChatCompletionUserMessageParamRole](../models/chatcompletionusermessageparamrole.md) | :heavy_check_mark: | N/A | +| `content` | [models.ChatCompletionUserMessageParamContent](../models/chatcompletionusermessageparamcontent.md) | :heavy_check_mark: | User message content | +| `name` | *Optional[str]* | :heavy_minus_sign: | Optional name for the user | \ No newline at end of file diff --git a/docs/models/chatcompletionusermessageparamcontent.md b/docs/models/chatcompletionusermessageparamcontent.md new file mode 100644 index 0000000..d5f2e54 --- /dev/null +++ b/docs/models/chatcompletionusermessageparamcontent.md @@ -0,0 +1,19 @@ +# ChatCompletionUserMessageParamContent + +User message content + + +## Supported Types + +### `str` + +```python +value: str = /* values here */ +``` + +### `List[models.ChatCompletionContentPart]` + +```python +value: List[models.ChatCompletionContentPart] = /* values here */ +``` + diff --git a/docs/models/chatcompletionusermessageparamrole.md b/docs/models/chatcompletionusermessageparamrole.md new file mode 100644 index 0000000..3b99641 --- /dev/null +++ b/docs/models/chatcompletionusermessageparamrole.md @@ -0,0 +1,8 @@ +# ChatCompletionUserMessageParamRole + + +## Values + +| Name | Value | +| ------ | ------ | +| `USER` | user | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparams.md b/docs/models/chatstreamcompletioncreateparams.md new file mode 100644 index 0000000..951d638 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparams.md @@ -0,0 +1,34 @@ +# 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 new file mode 100644 index 0000000..af8432b --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsaudio.md @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 0000000..ce56e0b --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamscompletion.md @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 0000000..9972e0c --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsdatacollection.md @@ -0,0 +1,14 @@ +# 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 new file mode 100644 index 0000000..3a250fe --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamseffort.md @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 0000000..eab43e0 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsengine.md @@ -0,0 +1,9 @@ +# 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 new file mode 100644 index 0000000..b27f206 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsidchainofthought.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..1f968ce --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsidfileparser.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..3d87f7f --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsidmoderation.md @@ -0,0 +1,8 @@ +# ChatStreamCompletionCreateParamsIDModeration + + +## Values + +| Name | Value | +| ------------ | ------------ | +| `MODERATION` | moderation | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsidweb.md b/docs/models/chatstreamcompletioncreateparamsidweb.md new file mode 100644 index 0000000..19e697e --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsidweb.md @@ -0,0 +1,8 @@ +# ChatStreamCompletionCreateParamsIDWeb + + +## Values + +| Name | Value | +| ----- | ----- | +| `WEB` | web | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamsignoreenum.md b/docs/models/chatstreamcompletioncreateparamsignoreenum.md new file mode 100644 index 0000000..e46f946 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsignoreenum.md @@ -0,0 +1,85 @@ +# 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 new file mode 100644 index 0000000..46fc295 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsignoreunion.md @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 0000000..29e9b4b --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsimage.md @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 0000000..8a7dc08 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsjsonschema.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..a631f50 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsmaxprice.md @@ -0,0 +1,14 @@ +# 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 new file mode 100644 index 0000000..e038932 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsonlyenum.md @@ -0,0 +1,85 @@ +# 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 new file mode 100644 index 0000000..18f6d13 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsonlyunion.md @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 0000000..2b1105c --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsorderenum.md @@ -0,0 +1,85 @@ +# 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 new file mode 100644 index 0000000..ff57c40 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsorderunion.md @@ -0,0 +1,17 @@ +# 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 new file mode 100644 index 0000000..60c51a2 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspdf.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..709c8f0 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspdfengine.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..6f31a2d --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspluginchainofthought.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..37e3b19 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspluginfileparser.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..16e8729 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspluginmoderation.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..47101cc --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspluginunion.md @@ -0,0 +1,29 @@ +# 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 new file mode 100644 index 0000000..28d113d --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamspluginweb.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..dbb7049 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsprompt.md @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 0000000..69bc3d2 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsprovider.md @@ -0,0 +1,18 @@ +# 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 new file mode 100644 index 0000000..180a43e --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsquantization.md @@ -0,0 +1,16 @@ +# 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 new file mode 100644 index 0000000..1d001f6 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsreasoning.md @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 0000000..8d4800a --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsreasoningeffort.md @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 0000000..ef75853 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsrequest.md @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 0000000..d6fb376 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformatgrammar.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..30c9be5 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformatjsonobject.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..63068dd --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformatjsonschema.md @@ -0,0 +1,11 @@ +# 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 new file mode 100644 index 0000000..7aa985c --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformatpython.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..ba4bcc4 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformattext.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..f6ba15b --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsresponseformatunion.md @@ -0,0 +1,37 @@ +# 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 new file mode 100644 index 0000000..e2f845a --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamssort.md @@ -0,0 +1,12 @@ +# 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 new file mode 100644 index 0000000..d3cd163 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsstop.md @@ -0,0 +1,25 @@ +# 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 new file mode 100644 index 0000000..c70a614 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamsstreamoptions.md @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..8e64f10 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamstypegrammar.md @@ -0,0 +1,8 @@ +# ChatStreamCompletionCreateParamsTypeGrammar + + +## Values + +| Name | Value | +| --------- | --------- | +| `GRAMMAR` | grammar | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypejsonobject.md b/docs/models/chatstreamcompletioncreateparamstypejsonobject.md new file mode 100644 index 0000000..bb9c748 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamstypejsonobject.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..172f379 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamstypejsonschema.md @@ -0,0 +1,8 @@ +# 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 new file mode 100644 index 0000000..4c2a41e --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamstypepython.md @@ -0,0 +1,8 @@ +# ChatStreamCompletionCreateParamsTypePython + + +## Values + +| Name | Value | +| -------- | -------- | +| `PYTHON` | python | \ No newline at end of file diff --git a/docs/models/chatstreamcompletioncreateparamstypetext.md b/docs/models/chatstreamcompletioncreateparamstypetext.md new file mode 100644 index 0000000..2a5cd35 --- /dev/null +++ b/docs/models/chatstreamcompletioncreateparamstypetext.md @@ -0,0 +1,8 @@ +# ChatStreamCompletionCreateParamsTypeText + + +## Values + +| Name | Value | +| ------ | ------ | +| `TEXT` | text | \ No newline at end of file diff --git a/docs/models/completiontokensdetails.md b/docs/models/completiontokensdetails.md new file mode 100644 index 0000000..5373314 --- /dev/null +++ b/docs/models/completiontokensdetails.md @@ -0,0 +1,13 @@ +# CompletionTokensDetails + +Detailed completion token usage + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | +| `reasoning_tokens` | *Optional[float]* | :heavy_minus_sign: | Tokens used for reasoning | +| `audio_tokens` | *Optional[float]* | :heavy_minus_sign: | Tokens used for audio output | +| `accepted_prediction_tokens` | *Optional[float]* | :heavy_minus_sign: | Accepted prediction tokens | +| `rejected_prediction_tokens` | *Optional[float]* | :heavy_minus_sign: | Rejected prediction tokens | \ No newline at end of file diff --git a/docs/models/completionusage.md b/docs/models/completionusage.md new file mode 100644 index 0000000..d17099e --- /dev/null +++ b/docs/models/completionusage.md @@ -0,0 +1,14 @@ +# CompletionUsage + +Token usage statistics + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `completion_tokens` | *float* | :heavy_check_mark: | Number of tokens in the completion | +| `prompt_tokens` | *float* | :heavy_check_mark: | Number of tokens in the prompt | +| `total_tokens` | *float* | :heavy_check_mark: | Total number of tokens | +| `completion_tokens_details` | [Optional[models.CompletionTokensDetails]](../models/completiontokensdetails.md) | :heavy_minus_sign: | Detailed completion token usage | +| `prompt_tokens_details` | [Optional[models.PromptTokensDetails]](../models/prompttokensdetails.md) | :heavy_minus_sign: | Detailed prompt token usage | \ No newline at end of file diff --git a/docs/models/contentimageurl.md b/docs/models/contentimageurl.md new file mode 100644 index 0000000..c880462 --- /dev/null +++ b/docs/models/contentimageurl.md @@ -0,0 +1,9 @@ +# ContentImageURL + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `type` | [models.ContentTypeImageURL](../models/contenttypeimageurl.md) | :heavy_check_mark: | N/A | +| `image_url` | [models.FileAnnotationDetailImageURL](../models/fileannotationdetailimageurl.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/contenttext.md b/docs/models/contenttext.md new file mode 100644 index 0000000..8b4caf5 --- /dev/null +++ b/docs/models/contenttext.md @@ -0,0 +1,9 @@ +# ContentText + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `type` | [models.ContentTypeText](../models/contenttypetext.md) | :heavy_check_mark: | N/A | +| `text` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/contenttypeimageurl.md b/docs/models/contenttypeimageurl.md new file mode 100644 index 0000000..ae8e63a --- /dev/null +++ b/docs/models/contenttypeimageurl.md @@ -0,0 +1,8 @@ +# ContentTypeImageURL + + +## Values + +| Name | Value | +| ----------- | ----------- | +| `IMAGE_URL` | image_url | \ No newline at end of file diff --git a/docs/models/contenttypetext.md b/docs/models/contenttypetext.md new file mode 100644 index 0000000..a8aaa96 --- /dev/null +++ b/docs/models/contenttypetext.md @@ -0,0 +1,8 @@ +# ContentTypeText + + +## Values + +| Name | Value | +| ------ | ------ | +| `TEXT` | text | \ No newline at end of file diff --git a/docs/models/detail.md b/docs/models/detail.md new file mode 100644 index 0000000..9ba0b10 --- /dev/null +++ b/docs/models/detail.md @@ -0,0 +1,12 @@ +# Detail + +Image detail level for vision models + + +## Values + +| Name | Value | +| ------ | ------ | +| `AUTO` | auto | +| `LOW` | low | +| `HIGH` | high | \ No newline at end of file diff --git a/docs/models/error.md b/docs/models/error.md new file mode 100644 index 0000000..72bc8b6 --- /dev/null +++ b/docs/models/error.md @@ -0,0 +1,13 @@ +# Error + +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 diff --git a/docs/models/file.md b/docs/models/file.md new file mode 100644 index 0000000..e94247d --- /dev/null +++ b/docs/models/file.md @@ -0,0 +1,10 @@ +# File + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `hash` | *str* | :heavy_check_mark: | N/A | +| `name` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `content` | List[[models.FileAnnotationDetailContentUnion](../models/fileannotationdetailcontentunion.md)] | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/fileannotationdetail.md b/docs/models/fileannotationdetail.md new file mode 100644 index 0000000..e2e9b30 --- /dev/null +++ b/docs/models/fileannotationdetail.md @@ -0,0 +1,11 @@ +# FileAnnotationDetail + +File annotation with content + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| `type` | [models.TypeFile](../models/typefile.md) | :heavy_check_mark: | N/A | +| `file` | [models.File](../models/file.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/fileannotationdetailcontentunion.md b/docs/models/fileannotationdetailcontentunion.md new file mode 100644 index 0000000..1694d38 --- /dev/null +++ b/docs/models/fileannotationdetailcontentunion.md @@ -0,0 +1,17 @@ +# FileAnnotationDetailContentUnion + + +## Supported Types + +### `models.ContentText` + +```python +value: models.ContentText = /* values here */ +``` + +### `models.ContentImageURL` + +```python +value: models.ContentImageURL = /* values here */ +``` + diff --git a/docs/models/fileannotationdetailimageurl.md b/docs/models/fileannotationdetailimageurl.md new file mode 100644 index 0000000..e3e889d --- /dev/null +++ b/docs/models/fileannotationdetailimageurl.md @@ -0,0 +1,8 @@ +# FileAnnotationDetailImageURL + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `url` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/inputaudio.md b/docs/models/inputaudio.md new file mode 100644 index 0000000..d7187b3 --- /dev/null +++ b/docs/models/inputaudio.md @@ -0,0 +1,9 @@ +# InputAudio + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | +| `data` | *str* | :heavy_check_mark: | Base64 encoded audio data | +| `format_` | [models.ChatCompletionContentPartAudioFormat](../models/chatcompletioncontentpartaudioformat.md) | :heavy_check_mark: | Audio format | \ No newline at end of file diff --git a/docs/models/parameters.md b/docs/models/parameters.md new file mode 100644 index 0000000..ed2aca3 --- /dev/null +++ b/docs/models/parameters.md @@ -0,0 +1,9 @@ +# Parameters + +Function parameters as JSON Schema object + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/docs/models/prompttokensdetails.md b/docs/models/prompttokensdetails.md new file mode 100644 index 0000000..e81acf0 --- /dev/null +++ b/docs/models/prompttokensdetails.md @@ -0,0 +1,11 @@ +# PromptTokensDetails + +Detailed prompt token usage + + +## Fields + +| Field | Type | Required | Description | +| -------------------- | -------------------- | -------------------- | -------------------- | +| `cached_tokens` | *Optional[float]* | :heavy_minus_sign: | Cached prompt tokens | +| `audio_tokens` | *Optional[float]* | :heavy_minus_sign: | Audio input tokens | \ No newline at end of file diff --git a/docs/models/reasoningdetail.md b/docs/models/reasoningdetail.md new file mode 100644 index 0000000..736d5fe --- /dev/null +++ b/docs/models/reasoningdetail.md @@ -0,0 +1,25 @@ +# ReasoningDetail + +Reasoning detail information + + +## Supported Types + +### `models.ReasoningDetailSummary` + +```python +value: models.ReasoningDetailSummary = /* values here */ +``` + +### `models.ReasoningDetailEncrypted` + +```python +value: models.ReasoningDetailEncrypted = /* values here */ +``` + +### `models.ReasoningDetailText` + +```python +value: models.ReasoningDetailText = /* values here */ +``` + diff --git a/docs/models/reasoningdetailencrypted.md b/docs/models/reasoningdetailencrypted.md new file mode 100644 index 0000000..bef434d --- /dev/null +++ b/docs/models/reasoningdetailencrypted.md @@ -0,0 +1,14 @@ +# ReasoningDetailEncrypted + +Encrypted reasoning detail + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `type` | [models.ReasoningDetailEncryptedType](../models/reasoningdetailencryptedtype.md) | :heavy_check_mark: | N/A | +| `data` | *str* | :heavy_check_mark: | N/A | +| `id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `format_` | [OptionalNullable[models.ReasoningDetailEncryptedFormat]](../models/reasoningdetailencryptedformat.md) | :heavy_minus_sign: | N/A | +| `index` | *Optional[float]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/reasoningdetailencryptedformat.md b/docs/models/reasoningdetailencryptedformat.md new file mode 100644 index 0000000..4e45f83 --- /dev/null +++ b/docs/models/reasoningdetailencryptedformat.md @@ -0,0 +1,10 @@ +# ReasoningDetailEncryptedFormat + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `UNKNOWN` | unknown | +| `OPENAI_RESPONSES_V1` | openai-responses-v1 | +| `ANTHROPIC_CLAUDE_V1` | anthropic-claude-v1 | \ No newline at end of file diff --git a/docs/models/reasoningdetailencryptedtype.md b/docs/models/reasoningdetailencryptedtype.md new file mode 100644 index 0000000..c574453 --- /dev/null +++ b/docs/models/reasoningdetailencryptedtype.md @@ -0,0 +1,8 @@ +# ReasoningDetailEncryptedType + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `REASONING_ENCRYPTED` | reasoning.encrypted | \ No newline at end of file diff --git a/docs/models/reasoningdetailsummary.md b/docs/models/reasoningdetailsummary.md new file mode 100644 index 0000000..e277e74 --- /dev/null +++ b/docs/models/reasoningdetailsummary.md @@ -0,0 +1,14 @@ +# ReasoningDetailSummary + +Reasoning summary detail + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `type` | [models.ReasoningDetailSummaryType](../models/reasoningdetailsummarytype.md) | :heavy_check_mark: | N/A | +| `summary` | *str* | :heavy_check_mark: | N/A | +| `id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `format_` | [OptionalNullable[models.ReasoningDetailSummaryFormat]](../models/reasoningdetailsummaryformat.md) | :heavy_minus_sign: | N/A | +| `index` | *Optional[float]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/reasoningdetailsummaryformat.md b/docs/models/reasoningdetailsummaryformat.md new file mode 100644 index 0000000..c6d9f9d --- /dev/null +++ b/docs/models/reasoningdetailsummaryformat.md @@ -0,0 +1,10 @@ +# ReasoningDetailSummaryFormat + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `UNKNOWN` | unknown | +| `OPENAI_RESPONSES_V1` | openai-responses-v1 | +| `ANTHROPIC_CLAUDE_V1` | anthropic-claude-v1 | \ No newline at end of file diff --git a/docs/models/reasoningdetailsummarytype.md b/docs/models/reasoningdetailsummarytype.md new file mode 100644 index 0000000..6de96b9 --- /dev/null +++ b/docs/models/reasoningdetailsummarytype.md @@ -0,0 +1,8 @@ +# ReasoningDetailSummaryType + + +## Values + +| Name | Value | +| ------------------- | ------------------- | +| `REASONING_SUMMARY` | reasoning.summary | \ No newline at end of file diff --git a/docs/models/reasoningdetailtext.md b/docs/models/reasoningdetailtext.md new file mode 100644 index 0000000..0635471 --- /dev/null +++ b/docs/models/reasoningdetailtext.md @@ -0,0 +1,15 @@ +# ReasoningDetailText + +Text reasoning detail + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `type` | [models.ReasoningDetailTextType](../models/reasoningdetailtexttype.md) | :heavy_check_mark: | N/A | +| `text` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `signature` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `id` | *OptionalNullable[str]* | :heavy_minus_sign: | N/A | +| `format_` | [OptionalNullable[models.ReasoningDetailTextFormat]](../models/reasoningdetailtextformat.md) | :heavy_minus_sign: | N/A | +| `index` | *Optional[float]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/reasoningdetailtextformat.md b/docs/models/reasoningdetailtextformat.md new file mode 100644 index 0000000..7fadd88 --- /dev/null +++ b/docs/models/reasoningdetailtextformat.md @@ -0,0 +1,10 @@ +# ReasoningDetailTextFormat + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `UNKNOWN` | unknown | +| `OPENAI_RESPONSES_V1` | openai-responses-v1 | +| `ANTHROPIC_CLAUDE_V1` | anthropic-claude-v1 | \ No newline at end of file diff --git a/docs/models/reasoningdetailtexttype.md b/docs/models/reasoningdetailtexttype.md new file mode 100644 index 0000000..2a56e42 --- /dev/null +++ b/docs/models/reasoningdetailtexttype.md @@ -0,0 +1,8 @@ +# ReasoningDetailTextType + + +## Values + +| Name | Value | +| ---------------- | ---------------- | +| `REASONING_TEXT` | reasoning.text | \ No newline at end of file diff --git a/docs/models/responseformatjsonschemaschema.md b/docs/models/responseformatjsonschemaschema.md new file mode 100644 index 0000000..2801b0e --- /dev/null +++ b/docs/models/responseformatjsonschemaschema.md @@ -0,0 +1,9 @@ +# ResponseFormatJSONSchemaSchema + +The schema for the response format, described as a JSON Schema object + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/docs/models/security.md b/docs/models/security.md new file mode 100644 index 0000000..8ca6325 --- /dev/null +++ b/docs/models/security.md @@ -0,0 +1,8 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `bearer_auth` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/streamchatcompletionresponsebody.md b/docs/models/streamchatcompletionresponsebody.md new file mode 100644 index 0000000..a0cca72 --- /dev/null +++ b/docs/models/streamchatcompletionresponsebody.md @@ -0,0 +1,10 @@ +# StreamChatCompletionResponseBody + +Successful chat completion response + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `data` | [models.ChatCompletionChunk](../models/chatcompletionchunk.md) | :heavy_check_mark: | Streaming chat completion chunk | \ No newline at end of file diff --git a/docs/models/toplogprob.md b/docs/models/toplogprob.md new file mode 100644 index 0000000..a3eddcf --- /dev/null +++ b/docs/models/toplogprob.md @@ -0,0 +1,10 @@ +# TopLogprob + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `token` | *str* | :heavy_check_mark: | N/A | +| `logprob` | *float* | :heavy_check_mark: | N/A | +| `bytes_` | List[*float*] | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/typefile.md b/docs/models/typefile.md new file mode 100644 index 0000000..53830bb --- /dev/null +++ b/docs/models/typefile.md @@ -0,0 +1,8 @@ +# TypeFile + + +## Values + +| Name | Value | +| ------ | ------ | +| `FILE` | file | \ No newline at end of file diff --git a/docs/models/urlcitation.md b/docs/models/urlcitation.md new file mode 100644 index 0000000..c27ba7b --- /dev/null +++ b/docs/models/urlcitation.md @@ -0,0 +1,12 @@ +# URLCitation + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `end_index` | *float* | :heavy_check_mark: | N/A | +| `start_index` | *float* | :heavy_check_mark: | N/A | +| `title` | *str* | :heavy_check_mark: | N/A | +| `url` | *str* | :heavy_check_mark: | N/A | +| `content` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/urlcitationannotationdetail.md b/docs/models/urlcitationannotationdetail.md new file mode 100644 index 0000000..d97dba5 --- /dev/null +++ b/docs/models/urlcitationannotationdetail.md @@ -0,0 +1,11 @@ +# URLCitationAnnotationDetail + +URL citation annotation + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `type` | [models.URLCitationAnnotationDetailType](../models/urlcitationannotationdetailtype.md) | :heavy_check_mark: | N/A | +| `url_citation` | [models.URLCitation](../models/urlcitation.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/urlcitationannotationdetailtype.md b/docs/models/urlcitationannotationdetailtype.md new file mode 100644 index 0000000..51224c1 --- /dev/null +++ b/docs/models/urlcitationannotationdetailtype.md @@ -0,0 +1,8 @@ +# URLCitationAnnotationDetailType + + +## Values + +| Name | Value | +| -------------- | -------------- | +| `URL_CITATION` | url_citation | \ No newline at end of file diff --git a/docs/models/utils/retryconfig.md b/docs/models/utils/retryconfig.md new file mode 100644 index 0000000..69dd549 --- /dev/null +++ b/docs/models/utils/retryconfig.md @@ -0,0 +1,24 @@ +# RetryConfig + +Allows customizing the default retry configuration. Only usable with methods that mention they support retries. + +## Fields + +| Name | Type | Description | Example | +| ------------------------- | ----------------------------------- | --------------------------------------- | --------- | +| `strategy` | `*str*` | The retry strategy to use. | `backoff` | +| `backoff` | [BackoffStrategy](#backoffstrategy) | Configuration for the backoff strategy. | | +| `retry_connection_errors` | `*bool*` | Whether to retry on connection errors. | `true` | + +## BackoffStrategy + +The backoff strategy allows retrying a request with an exponential backoff between each retry. + +### Fields + +| Name | Type | Description | Example | +| ------------------ | --------- | ----------------------------------------- | -------- | +| `initial_interval` | `*int*` | The initial interval in milliseconds. | `500` | +| `max_interval` | `*int*` | The maximum interval in milliseconds. | `60000` | +| `exponent` | `*float*` | The exponent to use for the backoff. | `1.5` | +| `max_elapsed_time` | `*int*` | The maximum elapsed time in milliseconds. | `300000` | \ No newline at end of file diff --git a/docs/sdks/chat/README.md b/docs/sdks/chat/README.md new file mode 100644 index 0000000..343d180 --- /dev/null +++ b/docs/sdks/chat/README.md @@ -0,0 +1,155 @@ +# Chat +(*chat*) + +## Overview + +Chat completion operations + +### Available Operations + +* [complete](#complete) - Create a chat completion +* [complete_stream](#complete_stream) - Create a chat completion + +## complete + +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(messages=[ + { + "role": models.ChatCompletionUserMessageParamRole.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 + print(event, flush=True) + +``` + +### 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. | | + +### Response + +**[Union[eventstreaming.EventStream[models.StreamChatCompletionResponseBody], eventstreaming.EventStreamAsync[models.StreamChatCompletionResponseBody]]](../../models/.md)** + +### Errors + +| Error Type | Status Code | Content Type | +| ----------------------------- | ----------------------------- | ----------------------------- | +| errors.ChatCompletionError | 400, 401, 429 | application/json | +| errors.ChatCompletionError | 500 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/openrouter/README.md b/docs/sdks/openrouter/README.md new file mode 100644 index 0000000..93727ce --- /dev/null +++ b/docs/sdks/openrouter/README.md @@ -0,0 +1,10 @@ +# OpenRouter SDK + +## Overview + +OpenRouter Chat Completions API: OpenAI-compatible Chat Completions API with additional OpenRouter features + +OpenRouter Documentation + + +### Available Operations diff --git a/examples/.env b/examples/.env new file mode 100644 index 0000000..85d3b39 --- /dev/null +++ b/examples/.env @@ -0,0 +1 @@ +OPENROUTER_API_KEY="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" \ No newline at end of file diff --git a/examples/.env.template b/examples/.env.template new file mode 100644 index 0000000..34456e9 --- /dev/null +++ b/examples/.env.template @@ -0,0 +1 @@ +OPENROUTER_API_KEY="" \ No newline at end of file diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..9098da8 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,25 @@ +# Run SDK examples with uv + +This guide explains how to create and activate a Python virtual environment on macOS, install necessary dependencies, and run the `.py` scripts. + +## Steps to Set Up and Run the Script + +### Prerequisites + +- [Install uv](https://docs.astral.sh/uv/getting-started/installation/#pypi) + + +### Configure auth + +- Rename .env.template to .env and populate the .env file with your client ID and secret + +```bash +OPENROUTER_API_KEY="" +``` + +### Run the script with the .env values + +```bash + cd examples/ + uv run --env-file=.env script.py +``` diff --git a/examples/chatCompletion.py b/examples/chatCompletion.py new file mode 100644 index 0000000..b422014 --- /dev/null +++ b/examples/chatCompletion.py @@ -0,0 +1,20 @@ + +dependencies = [ + "openrouter", + "os", +] + +import os +from openrouter import OpenRouter + +with OpenRouter( + bearer_auth=os.getenv("OPENROUTER_API_KEY"), +) as sdk: + result = sdk.chat.complete( + model="openai/gpt-3.5-turbo", + messages=[ + {"role": "user", "content": "Hello, world!"}, + ], + ) + +print(result) \ No newline at end of file diff --git a/examples/sseChatCompletion.py b/examples/sseChatCompletion.py new file mode 100644 index 0000000..6b16dfc --- /dev/null +++ b/examples/sseChatCompletion.py @@ -0,0 +1,26 @@ + +dependencies = [ + "openrouter", + "os", +] + +import os +from openrouter import OpenRouter, models + +with OpenRouter( + bearer_auth=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) + + 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 diff --git a/py.typed b/py.typed new file mode 100644 index 0000000..3e38f1a --- /dev/null +++ b/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. The package enables type hints. diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..e8cd3e8 --- /dev/null +++ b/pylintrc @@ -0,0 +1,662 @@ +[MAIN] + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Clear in-memory caches upon conclusion of linting. Useful if running pylint +# in a server-like mode. +clear-cache-post-run=no + +# Load and enable all available extensions. Use --list-extensions to see a list +# all available extensions. +#enable-all-extensions= + +# In error mode, messages with a category besides ERROR or FATAL are +# suppressed, and no reports are done by default. Error mode is compatible with +# disabling specific errors. +#errors-only= + +# Always return a 0 (non-error) status code, even if lint errors are found. +# This is primarily useful in continuous integration scripts. +#exit-zero= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-allow-list= + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. (This is an alternative name to extension-pkg-allow-list +# for backward compatibility.) +extension-pkg-whitelist= + +# Return non-zero exit code if any of these messages/categories are detected, +# even if score is above --fail-under value. Syntax same as enable. Messages +# specified are enabled, while categories only check already-enabled messages. +fail-on= + +# Specify a score threshold under which the program will exit with error. +fail-under=10 + +# Interpret the stdin as a python script, whose filename needs to be passed as +# the module_or_package argument. +#from-stdin= + +# Files or directories to be skipped. They should be base names, not paths. +ignore=CVS + +# Add files or directories matching the regular expressions patterns to the +# ignore-list. The regex matches against paths and can be in Posix or Windows +# format. Because '\\' represents the directory delimiter on Windows systems, +# it can't be used as an escape character. +ignore-paths= + +# Files or directories matching the regular expression patterns are skipped. +# The regex matches against base names, not paths. The default value ignores +# Emacs file locks +ignore-patterns=^\.# + +# List of module names for which member attributes should not be checked and +# will not be imported (useful for modules/projects where namespaces are +# manipulated during runtime and thus existing member attributes cannot be +# deduced by static analysis). It supports qualified module names, as well as +# Unix pattern matching. +ignored-modules= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use, and will cap the count on Windows to +# avoid hangs. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Minimum Python version to use for version dependent checks. Will default to +# the version used to run pylint. +py-version=3.9 + +# Discover python modules and packages in the file system subtree. +recursive=no + +# Add paths to the list of the source roots. Supports globbing patterns. The +# source root is an absolute path or a path relative to the current working +# directory used to determine a package namespace for modules located under the +# source root. +source-roots=src + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# In verbose mode, extra non-checker-related info will be displayed. +#verbose= + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. If left empty, argument names will be checked with the set +# naming style. +#argument-rgx= + +# Naming style matching correct attribute names. +#attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. If left empty, attribute names will be checked with the set naming +# style. +attr-rgx=[^\W\d][^\W]*|__.*__$ + +# Bad variable names which should always be refused, separated by a comma. +bad-names= + +# Bad variable names regexes, separated by a comma. If names match any regex, +# they will always be refused +bad-names-rgxs= + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. If left empty, class attribute names will be checked +# with the set naming style. +#class-attribute-rgx= + +# Naming style matching correct class constant names. +class-const-naming-style=UPPER_CASE + +# Regular expression matching correct class constant names. Overrides class- +# const-naming-style. If left empty, class constant names will be checked with +# the set naming style. +#class-const-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. If left empty, class names will be checked with the set naming style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. If left empty, constant names will be checked with the set naming +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. If left empty, function names will be checked with the set +# naming style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _, + e, + id + +# Good variable names regexes, separated by a comma. If names match any regex, +# they will always be accepted +good-names-rgxs= + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. If left empty, inline iteration names will be checked +# with the set naming style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. If left empty, method names will be checked with the set naming style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. If left empty, module names will be checked with the set naming style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Regular expression matching correct type alias names. If left empty, type +# alias names will be checked with the set naming style. +typealias-rgx=.* + +# Regular expression matching correct type variable names. If left empty, type +# variable names will be checked with the set naming style. +#typevar-rgx= + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. If left empty, variable names will be checked with the set +# naming style. +#variable-rgx= + + +[CLASSES] + +# Warn about protected attribute access inside special methods +check-protected-access-in-special-methods=no + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + asyncSetUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[DESIGN] + +# List of regular expressions of class ancestor names to ignore when counting +# public methods (see R0903) +exclude-too-few-public-methods= + +# List of qualified class names to ignore when counting class parents (see +# R0901) +ignored-parents= + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=25 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when caught. +overgeneral-exceptions=builtins.BaseException,builtins.Exception + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow explicit reexports by alias from a package __init__. +allow-reexport-from-package=no + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules= + +# Output a graph (.gv or any supported image format) of external dependencies +# to the given file (report RP0402 must not be disabled). +ext-import-graph= + +# Output a graph (.gv or any supported image format) of all (i.e. internal and +# external) dependencies to the given file (report RP0402 must not be +# disabled). +import-graph= + +# Output a graph (.gv or any supported image format) of internal dependencies +# to the given file (report RP0402 must not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[LOGGING] + +# The type of string formatting that logging methods do. `old` means using % +# formatting, `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, +# UNDEFINED. +confidence=HIGH, + CONTROL_FLOW, + INFERENCE, + INFERENCE_FAILURE, + UNDEFINED + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then re-enable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-implicit-booleaness-not-comparison-to-string, + use-implicit-booleaness-not-comparison-to-zero, + use-symbolic-message-instead, + trailing-whitespace, + line-too-long, + missing-class-docstring, + missing-module-docstring, + missing-function-docstring, + too-many-instance-attributes, + wrong-import-order, + too-many-arguments, + broad-exception-raised, + too-few-public-methods, + too-many-branches, + duplicate-code, + trailing-newlines, + too-many-public-methods, + too-many-locals, + too-many-lines, + using-constant-test, + too-many-statements, + cyclic-import, + too-many-nested-blocks, + too-many-boolean-expressions, + no-else-raise, + bare-except, + broad-exception-caught, + fixme, + relative-beyond-top-level, + consider-using-with, + wildcard-import, + unused-wildcard-import, + too-many-return-statements + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable= + + +[METHOD_ARGS] + +# List of qualified names (i.e., library.method) which require a timeout +# parameter e.g. 'requests.api.get,requests.api.post' +timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.api.options,requests.api.patch,requests.api.post,requests.api.put,requests.api.request + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + +# Regular expression of note tags to take in consideration. +notes-rgx= + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit,argparse.parse_error + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'fatal', 'error', 'warning', 'refactor', +# 'convention', and 'info' which contain the number of messages in each +# category, as well as 'statement' which is the total number of statements +# analyzed. This score is used by the global evaluation report (RP0004). +evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +msg-template= + +# Set the output format. Available formats are: text, parseable, colorized, +# json2 (improved json format), json (old json format) and msvs (visual +# studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +#output-format= + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[SIMILARITIES] + +# Comments are removed from the similarity computation +ignore-comments=yes + +# Docstrings are removed from the similarity computation +ignore-docstrings=yes + +# Imports are removed from the similarity computation +ignore-imports=yes + +# Signatures are removed from the similarity computation +ignore-signatures=yes + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. No available dictionaries : You need to install +# both the python package and the system dependency for enchant to work. +spelling-dict= + +# List of comma separated words that should be considered directives if they +# appear at the beginning of a comment and should not be checked. +spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=no + +# This flag controls whether the implicit-str-concat should generate a warning +# on implicit string concatenation in sequences defined over several lines. +check-str-concat-over-line-jumps=no + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of symbolic message names to ignore for Mixin members. +ignored-checks-for-mixins=no-member, + not-async-context-manager, + not-context-manager, + attribute-defined-outside-init + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# Regex pattern to define which classes are considered mixins. +mixin-class-rgx=.*[Mm]ixin + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of names allowed to shadow builtins +allowed-redefined-builtins=id,object + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5f2eeec --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[project] +name = "openrouter" +version = "0.1.2" +description = "Python Client SDK Generated by Speakeasy." +authors = [{ name = "Speakeasy" },] +readme = "README.md" +requires-python = ">=3.9.2" +dependencies = [ + "httpcore >=1.0.9", + "httpx >=0.28.1", + "pydantic >=2.11.2", +] + +[dependency-groups] +dev = [ + "mypy ==1.15.0", + "pylint ==3.2.3", +] + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +"*" = ["py.typed"] + +[build-system] +requires = ["setuptools>=80", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "function" +pythonpath = ["src"] + +[tool.mypy] +disable_error_code = "misc" +explicit_package_bases = true +mypy_path = "src" + +[[tool.mypy.overrides]] +module = "typing_inspect" +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = "jsonpath" +ignore_missing_imports = true + +[tool.pyright] +venvPath = "." +venv = ".venv" + + diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 0000000..ef28dc1 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +uv build +uv publish --token $PYPI_TOKEN diff --git a/src/open_router/_hooks/registration.py b/src/open_router/_hooks/registration.py new file mode 100644 index 0000000..cab4778 --- /dev/null +++ b/src/open_router/_hooks/registration.py @@ -0,0 +1,13 @@ +from .types import Hooks + + +# This file is only ever generated once on the first generation and then is free to be modified. +# Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them +# in this file or in separate files in the hooks folder. + + +def init_hooks(hooks: Hooks): + # pylint: disable=unused-argument + """Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook + with an instance of a hook that implements that specific Hook interface + Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance""" diff --git a/src/openrouter/__init__.py b/src/openrouter/__init__.py new file mode 100644 index 0000000..833c68c --- /dev/null +++ b/src/openrouter/__init__.py @@ -0,0 +1,17 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from ._version import ( + __title__, + __version__, + __openapi_doc_version__, + __gen_version__, + __user_agent__, +) +from .sdk import * +from .sdkconfiguration import * + + +VERSION: str = __version__ +OPENAPI_DOC_VERSION = __openapi_doc_version__ +SPEAKEASY_GENERATOR_VERSION = __gen_version__ +USER_AGENT = __user_agent__ diff --git a/src/openrouter/_hooks/__init__.py b/src/openrouter/_hooks/__init__.py new file mode 100644 index 0000000..2ee66cd --- /dev/null +++ b/src/openrouter/_hooks/__init__.py @@ -0,0 +1,5 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from .sdkhooks import * +from .types import * +from .registration import * diff --git a/src/openrouter/_hooks/registration.py b/src/openrouter/_hooks/registration.py new file mode 100644 index 0000000..cab4778 --- /dev/null +++ b/src/openrouter/_hooks/registration.py @@ -0,0 +1,13 @@ +from .types import Hooks + + +# This file is only ever generated once on the first generation and then is free to be modified. +# Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them +# in this file or in separate files in the hooks folder. + + +def init_hooks(hooks: Hooks): + # pylint: disable=unused-argument + """Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook + with an instance of a hook that implements that specific Hook interface + Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance""" diff --git a/src/openrouter/_hooks/sdkhooks.py b/src/openrouter/_hooks/sdkhooks.py new file mode 100644 index 0000000..bea18a5 --- /dev/null +++ b/src/openrouter/_hooks/sdkhooks.py @@ -0,0 +1,76 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from .types import ( + SDKInitHook, + BeforeRequestContext, + BeforeRequestHook, + AfterSuccessContext, + AfterSuccessHook, + AfterErrorContext, + AfterErrorHook, + Hooks, +) +from .registration import init_hooks +from typing import List, Optional, Tuple +from openrouter.sdkconfiguration import SDKConfiguration + + +class SDKHooks(Hooks): + def __init__(self) -> None: + self.sdk_init_hooks: List[SDKInitHook] = [] + self.before_request_hooks: List[BeforeRequestHook] = [] + self.after_success_hooks: List[AfterSuccessHook] = [] + self.after_error_hooks: List[AfterErrorHook] = [] + init_hooks(self) + + def register_sdk_init_hook(self, hook: SDKInitHook) -> None: + self.sdk_init_hooks.append(hook) + + def register_before_request_hook(self, hook: BeforeRequestHook) -> None: + self.before_request_hooks.append(hook) + + def register_after_success_hook(self, hook: AfterSuccessHook) -> None: + self.after_success_hooks.append(hook) + + def register_after_error_hook(self, hook: AfterErrorHook) -> None: + self.after_error_hooks.append(hook) + + def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration: + for hook in self.sdk_init_hooks: + config = hook.sdk_init(config) + return config + + def before_request( + self, hook_ctx: BeforeRequestContext, request: httpx.Request + ) -> httpx.Request: + for hook in self.before_request_hooks: + out = hook.before_request(hook_ctx, request) + if isinstance(out, Exception): + raise out + request = out + + return request + + def after_success( + self, hook_ctx: AfterSuccessContext, response: httpx.Response + ) -> httpx.Response: + for hook in self.after_success_hooks: + out = hook.after_success(hook_ctx, response) + if isinstance(out, Exception): + raise out + response = out + return response + + def after_error( + self, + hook_ctx: AfterErrorContext, + response: Optional[httpx.Response], + error: Optional[Exception], + ) -> Tuple[Optional[httpx.Response], Optional[Exception]]: + for hook in self.after_error_hooks: + result = hook.after_error(hook_ctx, response, error) + if isinstance(result, Exception): + raise result + response, error = result + return response, error diff --git a/src/openrouter/_hooks/types.py b/src/openrouter/_hooks/types.py new file mode 100644 index 0000000..07ace03 --- /dev/null +++ b/src/openrouter/_hooks/types.py @@ -0,0 +1,112 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from abc import ABC, abstractmethod +import httpx +from openrouter.sdkconfiguration import SDKConfiguration +from typing import Any, Callable, List, Optional, Tuple, Union + + +class HookContext: + config: SDKConfiguration + base_url: str + operation_id: str + oauth2_scopes: Optional[List[str]] = None + security_source: Optional[Union[Any, Callable[[], Any]]] = None + + def __init__( + self, + config: SDKConfiguration, + base_url: str, + operation_id: str, + oauth2_scopes: Optional[List[str]], + security_source: Optional[Union[Any, Callable[[], Any]]], + ): + self.config = config + self.base_url = base_url + self.operation_id = operation_id + self.oauth2_scopes = oauth2_scopes + self.security_source = security_source + + +class BeforeRequestContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__( + hook_ctx.config, + hook_ctx.base_url, + hook_ctx.operation_id, + hook_ctx.oauth2_scopes, + hook_ctx.security_source, + ) + + +class AfterSuccessContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__( + hook_ctx.config, + hook_ctx.base_url, + hook_ctx.operation_id, + hook_ctx.oauth2_scopes, + hook_ctx.security_source, + ) + + +class AfterErrorContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__( + hook_ctx.config, + hook_ctx.base_url, + hook_ctx.operation_id, + hook_ctx.oauth2_scopes, + hook_ctx.security_source, + ) + + +class SDKInitHook(ABC): + @abstractmethod + def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration: + pass + + +class BeforeRequestHook(ABC): + @abstractmethod + def before_request( + self, hook_ctx: BeforeRequestContext, request: httpx.Request + ) -> Union[httpx.Request, Exception]: + pass + + +class AfterSuccessHook(ABC): + @abstractmethod + def after_success( + self, hook_ctx: AfterSuccessContext, response: httpx.Response + ) -> Union[httpx.Response, Exception]: + pass + + +class AfterErrorHook(ABC): + @abstractmethod + def after_error( + self, + hook_ctx: AfterErrorContext, + response: Optional[httpx.Response], + error: Optional[Exception], + ) -> Union[Tuple[Optional[httpx.Response], Optional[Exception]], Exception]: + pass + + +class Hooks(ABC): + @abstractmethod + def register_sdk_init_hook(self, hook: SDKInitHook): + pass + + @abstractmethod + def register_before_request_hook(self, hook: BeforeRequestHook): + pass + + @abstractmethod + def register_after_success_hook(self, hook: AfterSuccessHook): + pass + + @abstractmethod + def register_after_error_hook(self, hook: AfterErrorHook): + pass diff --git a/src/openrouter/_version.py b/src/openrouter/_version.py new file mode 100644 index 0000000..8c275f4 --- /dev/null +++ b/src/openrouter/_version.py @@ -0,0 +1,15 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import importlib.metadata + +__title__: str = "openrouter" +__version__: str = "0.1.2" +__openapi_doc_version__: str = "1.0.0" +__gen_version__: str = "2.687.1" +__user_agent__: str = "speakeasy-sdk/python 0.1.2 2.687.1 1.0.0 openrouter" + +try: + if __package__ is not None: + __version__ = importlib.metadata.version(__package__) +except importlib.metadata.PackageNotFoundError: + pass diff --git a/src/openrouter/basesdk.py b/src/openrouter/basesdk.py new file mode 100644 index 0000000..de6dfd0 --- /dev/null +++ b/src/openrouter/basesdk.py @@ -0,0 +1,358 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from .sdkconfiguration import SDKConfiguration +import httpx +from openrouter import errors, models, utils +from openrouter._hooks import ( + AfterErrorContext, + AfterSuccessContext, + BeforeRequestContext, +) +from openrouter.utils import RetryConfig, SerializedRequestBody, get_body_content +from typing import Callable, List, Mapping, Optional, Tuple +from urllib.parse import parse_qs, urlparse + + +class BaseSDK: + sdk_configuration: SDKConfiguration + + def __init__(self, sdk_config: SDKConfiguration) -> None: + self.sdk_configuration = sdk_config + + def _get_url(self, base_url, url_variables): + sdk_url, sdk_variables = self.sdk_configuration.get_server_details() + + if base_url is None: + base_url = sdk_url + + if url_variables is None: + url_variables = sdk_variables + + return utils.template_url(base_url, url_variables) + + def _build_request_async( + self, + method, + path, + base_url, + url_variables, + request, + request_body_required, + request_has_path_params, + request_has_query_params, + user_agent_header, + accept_header_value, + _globals=None, + security=None, + timeout_ms: Optional[int] = None, + get_serialized_body: Optional[ + Callable[[], Optional[SerializedRequestBody]] + ] = None, + url_override: Optional[str] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> httpx.Request: + client = self.sdk_configuration.async_client + return self._build_request_with_client( + client, + method, + path, + base_url, + url_variables, + request, + request_body_required, + request_has_path_params, + request_has_query_params, + user_agent_header, + accept_header_value, + _globals, + security, + timeout_ms, + get_serialized_body, + url_override, + http_headers, + ) + + def _build_request( + self, + method, + path, + base_url, + url_variables, + request, + request_body_required, + request_has_path_params, + request_has_query_params, + user_agent_header, + accept_header_value, + _globals=None, + security=None, + timeout_ms: Optional[int] = None, + get_serialized_body: Optional[ + Callable[[], Optional[SerializedRequestBody]] + ] = None, + url_override: Optional[str] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> httpx.Request: + client = self.sdk_configuration.client + return self._build_request_with_client( + client, + method, + path, + base_url, + url_variables, + request, + request_body_required, + request_has_path_params, + request_has_query_params, + user_agent_header, + accept_header_value, + _globals, + security, + timeout_ms, + get_serialized_body, + url_override, + http_headers, + ) + + def _build_request_with_client( + self, + client, + method, + path, + base_url, + url_variables, + request, + request_body_required, + request_has_path_params, + request_has_query_params, + user_agent_header, + accept_header_value, + _globals=None, + security=None, + timeout_ms: Optional[int] = None, + get_serialized_body: Optional[ + Callable[[], Optional[SerializedRequestBody]] + ] = None, + url_override: Optional[str] = None, + http_headers: Optional[Mapping[str, str]] = None, + ) -> httpx.Request: + query_params = {} + + url = url_override + if url is None: + url = utils.generate_url( + self._get_url(base_url, url_variables), + path, + request if request_has_path_params else None, + _globals if request_has_path_params else None, + ) + + query_params = utils.get_query_params( + request if request_has_query_params else None, + _globals if request_has_query_params else None, + ) + else: + # Pick up the query parameter from the override so they can be + # preserved when building the request later on (necessary as of + # httpx 0.28). + parsed_override = urlparse(str(url_override)) + query_params = parse_qs(parsed_override.query, keep_blank_values=True) + + headers = utils.get_headers(request, _globals) + headers["Accept"] = accept_header_value + headers[user_agent_header] = self.sdk_configuration.user_agent + + if security is not None: + if callable(security): + security = security() + security = utils.get_security_from_env(security, models.Security) + if security is not None: + security_headers, security_query_params = utils.get_security(security) + headers = {**headers, **security_headers} + query_params = {**query_params, **security_query_params} + + serialized_request_body = SerializedRequestBody() + if get_serialized_body is not None: + rb = get_serialized_body() + if request_body_required and rb is None: + raise ValueError("request body is required") + + if rb is not None: + serialized_request_body = rb + + if ( + serialized_request_body.media_type is not None + and serialized_request_body.media_type + not in ( + "multipart/form-data", + "multipart/mixed", + ) + ): + headers["content-type"] = serialized_request_body.media_type + + if http_headers is not None: + for header, value in http_headers.items(): + headers[header] = value + + timeout = timeout_ms / 1000 if timeout_ms is not None else None + + return client.build_request( + method, + url, + params=query_params, + content=serialized_request_body.content, + data=serialized_request_body.data, + files=serialized_request_body.files, + headers=headers, + timeout=timeout, + ) + + def do_request( + self, + hook_ctx, + request, + error_status_codes, + stream=False, + retry_config: Optional[Tuple[RetryConfig, List[str]]] = None, + ) -> httpx.Response: + client = self.sdk_configuration.client + logger = self.sdk_configuration.debug_logger + + hooks = self.sdk_configuration.__dict__["_hooks"] + + def do(): + http_res = None + try: + req = hooks.before_request(BeforeRequestContext(hook_ctx), request) + logger.debug( + "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s", + req.method, + req.url, + req.headers, + get_body_content(req), + ) + + if client is None: + raise ValueError("client is required") + + http_res = client.send(req, stream=stream) + except Exception as e: + _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + logger.debug("Request Exception", exc_info=True) + raise e + + if http_res is None: + logger.debug("Raising no response SDK error") + raise errors.NoResponseError("No response received") + + logger.debug( + "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s", + http_res.status_code, + http_res.url, + http_res.headers, + "" if stream else http_res.text, + ) + + if utils.match_status_codes(error_status_codes, http_res.status_code): + result, err = hooks.after_error( + AfterErrorContext(hook_ctx), http_res, None + ) + if err is not None: + logger.debug("Request Exception", exc_info=True) + raise err + if result is not None: + http_res = result + else: + logger.debug("Raising unexpected SDK error") + raise errors.OpenRouterDefaultError( + "Unexpected error occurred", http_res + ) + + return http_res + + if retry_config is not None: + http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1])) + else: + http_res = do() + + if not utils.match_status_codes(error_status_codes, http_res.status_code): + http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res) + + return http_res + + async def do_request_async( + self, + hook_ctx, + request, + error_status_codes, + stream=False, + retry_config: Optional[Tuple[RetryConfig, List[str]]] = None, + ) -> httpx.Response: + client = self.sdk_configuration.async_client + logger = self.sdk_configuration.debug_logger + + hooks = self.sdk_configuration.__dict__["_hooks"] + + async def do(): + http_res = None + try: + req = hooks.before_request(BeforeRequestContext(hook_ctx), request) + logger.debug( + "Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s", + req.method, + req.url, + req.headers, + get_body_content(req), + ) + + if client is None: + raise ValueError("client is required") + + http_res = await client.send(req, stream=stream) + except Exception as e: + _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + logger.debug("Request Exception", exc_info=True) + raise e + + if http_res is None: + logger.debug("Raising no response SDK error") + raise errors.NoResponseError("No response received") + + logger.debug( + "Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s", + http_res.status_code, + http_res.url, + http_res.headers, + "" if stream else http_res.text, + ) + + if utils.match_status_codes(error_status_codes, http_res.status_code): + result, err = hooks.after_error( + AfterErrorContext(hook_ctx), http_res, None + ) + if err is not None: + logger.debug("Request Exception", exc_info=True) + raise err + if result is not None: + http_res = result + else: + logger.debug("Raising unexpected SDK error") + raise errors.OpenRouterDefaultError( + "Unexpected error occurred", http_res + ) + + return http_res + + if retry_config is not None: + http_res = await utils.retry_async( + do, utils.Retries(retry_config[0], retry_config[1]) + ) + else: + http_res = await do() + + if not utils.match_status_codes(error_status_codes, http_res.status_code): + http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res) + + return http_res diff --git a/src/openrouter/chat.py b/src/openrouter/chat.py new file mode 100644 index 0000000..0b8f344 --- /dev/null +++ b/src/openrouter/chat.py @@ -0,0 +1,987 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from .basesdk import BaseSDK +from openrouter import errors, models, utils +from openrouter._hooks import HookContext +from openrouter.types import OptionalNullable, UNSET +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 + + +class Chat(BaseSDK): + r"""Chat completion operations""" + + 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.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( + 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 = self.do_request( + 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 = 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", "text/event-stream"): + return eventstreaming.EventStream( + http_res, + lambda raw: utils.unmarshal_json( + raw, models.StreamChatCompletionResponseBody + ), + sentinel="[DONE]", + ) + if utils.match_response(http_res, ["400", "401", "429"], "application/json"): + http_res_text = utils.stream_to_text(http_res) + response_data = unmarshal_json_response( + errors.ChatCompletionErrorData, http_res, http_res_text + ) + raise errors.ChatCompletionError(response_data, http_res, http_res_text) + if utils.match_response(http_res, "500", "application/json"): + http_res_text = utils.stream_to_text(http_res) + response_data = unmarshal_json_response( + errors.ChatCompletionErrorData, http_res, http_res_text + ) + raise errors.ChatCompletionError(response_data, http_res, http_res_text) + 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 + ) + + http_res_text = utils.stream_to_text(http_res) + raise errors.OpenRouterDefaultError( + "Unexpected response received", http_res, http_res_text + ) + + async def complete_stream_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.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.EventStreamAsync[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_async( + 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 = await self.do_request_async( + 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", "text/event-stream"): + return eventstreaming.EventStreamAsync( + http_res, + lambda raw: utils.unmarshal_json( + raw, models.StreamChatCompletionResponseBody + ), + sentinel="[DONE]", + ) + if utils.match_response(http_res, ["400", "401", "429"], "application/json"): + http_res_text = await utils.stream_to_text_async(http_res) + response_data = unmarshal_json_response( + errors.ChatCompletionErrorData, http_res, http_res_text + ) + raise errors.ChatCompletionError(response_data, http_res, http_res_text) + if utils.match_response(http_res, "500", "application/json"): + http_res_text = await utils.stream_to_text_async(http_res) + response_data = unmarshal_json_response( + errors.ChatCompletionErrorData, http_res, http_res_text + ) + raise errors.ChatCompletionError(response_data, http_res, http_res_text) + 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 + ) + + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.OpenRouterDefaultError( + "Unexpected response received", http_res, http_res_text + ) diff --git a/src/openrouter/errors/__init__.py b/src/openrouter/errors/__init__.py new file mode 100644 index 0000000..5cf95f1 --- /dev/null +++ b/src/openrouter/errors/__init__.py @@ -0,0 +1,56 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import TYPE_CHECKING +from importlib import import_module +import builtins + +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__ = [ + "ChatCompletionError", + "ChatCompletionErrorData", + "NoResponseError", + "OpenRouterDefaultError", + "OpenRouterError", + "ResponseValidationError", +] + +_dynamic_imports: dict[str, str] = { + "ChatCompletionError": ".chatcompletionerror", + "ChatCompletionErrorData": ".chatcompletionerror", + "NoResponseError": ".no_response_error", + "OpenRouterDefaultError": ".openrouterdefaulterror", + "OpenRouterError": ".openroutererror", + "ResponseValidationError": ".responsevalidationerror", +} + + +def __getattr__(attr_name: str) -> object: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError( + f"No {attr_name} found in _dynamic_imports for module name -> {__name__} " + ) + + try: + module = import_module(module_name, __package__) + result = getattr(module, attr_name) + return result + except ImportError as e: + raise ImportError( + f"Failed to import {attr_name} from {module_name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to get {attr_name} from {module_name}: {e}" + ) from e + + +def __dir__(): + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/openrouter/errors/chatcompletionerror.py b/src/openrouter/errors/chatcompletionerror.py new file mode 100644 index 0000000..eafcbec --- /dev/null +++ b/src/openrouter/errors/chatcompletionerror.py @@ -0,0 +1,30 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +import httpx +from openrouter.errors import OpenRouterError +from openrouter.models import chatcompletionerror as models_chatcompletionerror +from openrouter.types import BaseModel +from typing import Optional + + +class ChatCompletionErrorData(BaseModel): + error: models_chatcompletionerror.Error + r"""Error object structure""" + + +class ChatCompletionError(OpenRouterError): + r"""Chat completion error response""" + + data: ChatCompletionErrorData + + def __init__( + self, + data: ChatCompletionErrorData, + raw_response: httpx.Response, + body: Optional[str] = None, + ): + fallback = body or raw_response.text + message = str(data.error.message) or fallback + super().__init__(message, raw_response, body) + self.data = data diff --git a/src/openrouter/errors/no_response_error.py b/src/openrouter/errors/no_response_error.py new file mode 100644 index 0000000..f98beea --- /dev/null +++ b/src/openrouter/errors/no_response_error.py @@ -0,0 +1,13 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +class NoResponseError(Exception): + """Error raised when no HTTP response is received from the server.""" + + message: str + + def __init__(self, message: str = "No response received"): + self.message = message + super().__init__(message) + + def __str__(self): + return self.message diff --git a/src/openrouter/errors/openrouterdefaulterror.py b/src/openrouter/errors/openrouterdefaulterror.py new file mode 100644 index 0000000..0d87bd2 --- /dev/null +++ b/src/openrouter/errors/openrouterdefaulterror.py @@ -0,0 +1,38 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from typing import Optional + +from openrouter.errors import OpenRouterError + +MAX_MESSAGE_LEN = 10_000 + + +class OpenRouterDefaultError(OpenRouterError): + """The fallback error class if no more specific error class is matched.""" + + def __init__( + self, message: str, raw_response: httpx.Response, body: Optional[str] = None + ): + body_display = body or raw_response.text or '""' + + if message: + message += ": " + message += f"Status {raw_response.status_code}" + + headers = raw_response.headers + content_type = headers.get("content-type", '""') + if content_type != "application/json": + if " " in content_type: + content_type = f'"{content_type}"' + message += f" Content-Type {content_type}" + + if len(body_display) > MAX_MESSAGE_LEN: + truncated = body_display[:MAX_MESSAGE_LEN] + remaining = len(body_display) - MAX_MESSAGE_LEN + body_display = f"{truncated}...and {remaining} more chars" + + message += f". Body: {body_display}" + message = message.strip() + + super().__init__(message, raw_response, body) diff --git a/src/openrouter/errors/openroutererror.py b/src/openrouter/errors/openroutererror.py new file mode 100644 index 0000000..fddb83a --- /dev/null +++ b/src/openrouter/errors/openroutererror.py @@ -0,0 +1,26 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from typing import Optional + + +class OpenRouterError(Exception): + """The base class for all HTTP error responses.""" + + message: str + status_code: int + body: str + headers: httpx.Headers + raw_response: httpx.Response + + def __init__( + self, message: str, raw_response: httpx.Response, body: Optional[str] = None + ): + self.message = message + self.status_code = raw_response.status_code + self.body = body if body is not None else raw_response.text + self.headers = raw_response.headers + self.raw_response = raw_response + + def __str__(self): + return self.message diff --git a/src/openrouter/errors/responsevalidationerror.py b/src/openrouter/errors/responsevalidationerror.py new file mode 100644 index 0000000..9fa5f63 --- /dev/null +++ b/src/openrouter/errors/responsevalidationerror.py @@ -0,0 +1,25 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +from typing import Optional + +from openrouter.errors import OpenRouterError + + +class ResponseValidationError(OpenRouterError): + """Error raised when there is a type mismatch between the response data and the expected Pydantic model.""" + + def __init__( + self, + message: str, + raw_response: httpx.Response, + cause: Exception, + body: Optional[str] = None, + ): + message = f"{message}: {cause}" + super().__init__(message, raw_response, body) + + @property + def cause(self): + """Normally the Pydantic ValidationError""" + return self.__cause__ diff --git a/src/openrouter/httpclient.py b/src/openrouter/httpclient.py new file mode 100644 index 0000000..47b052c --- /dev/null +++ b/src/openrouter/httpclient.py @@ -0,0 +1,126 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +# pyright: reportReturnType = false +import asyncio +from typing_extensions import Protocol, runtime_checkable +import httpx +from typing import Any, Optional, Union + + +@runtime_checkable +class HttpClient(Protocol): + def send( + self, + request: httpx.Request, + *, + stream: bool = False, + auth: Union[ + httpx._types.AuthTypes, httpx._client.UseClientDefault, None + ] = httpx.USE_CLIENT_DEFAULT, + follow_redirects: Union[ + bool, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + ) -> httpx.Response: + pass + + def build_request( + self, + method: str, + url: httpx._types.URLTypes, + *, + content: Optional[httpx._types.RequestContent] = None, + data: Optional[httpx._types.RequestData] = None, + files: Optional[httpx._types.RequestFiles] = None, + json: Optional[Any] = None, + params: Optional[httpx._types.QueryParamTypes] = None, + headers: Optional[httpx._types.HeaderTypes] = None, + cookies: Optional[httpx._types.CookieTypes] = None, + timeout: Union[ + httpx._types.TimeoutTypes, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + extensions: Optional[httpx._types.RequestExtensions] = None, + ) -> httpx.Request: + pass + + def close(self) -> None: + pass + + +@runtime_checkable +class AsyncHttpClient(Protocol): + async def send( + self, + request: httpx.Request, + *, + stream: bool = False, + auth: Union[ + httpx._types.AuthTypes, httpx._client.UseClientDefault, None + ] = httpx.USE_CLIENT_DEFAULT, + follow_redirects: Union[ + bool, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + ) -> httpx.Response: + pass + + def build_request( + self, + method: str, + url: httpx._types.URLTypes, + *, + content: Optional[httpx._types.RequestContent] = None, + data: Optional[httpx._types.RequestData] = None, + files: Optional[httpx._types.RequestFiles] = None, + json: Optional[Any] = None, + params: Optional[httpx._types.QueryParamTypes] = None, + headers: Optional[httpx._types.HeaderTypes] = None, + cookies: Optional[httpx._types.CookieTypes] = None, + timeout: Union[ + httpx._types.TimeoutTypes, httpx._client.UseClientDefault + ] = httpx.USE_CLIENT_DEFAULT, + extensions: Optional[httpx._types.RequestExtensions] = None, + ) -> httpx.Request: + pass + + async def aclose(self) -> None: + pass + + +class ClientOwner(Protocol): + client: Union[HttpClient, None] + async_client: Union[AsyncHttpClient, None] + + +def close_clients( + owner: ClientOwner, + sync_client: Union[HttpClient, None], + sync_client_supplied: bool, + async_client: Union[AsyncHttpClient, None], + async_client_supplied: bool, +) -> None: + """ + A finalizer function that is meant to be used with weakref.finalize to close + httpx clients used by an SDK so that underlying resources can be garbage + collected. + """ + + # Unset the client/async_client properties so there are no more references + # to them from the owning SDK instance and they can be reaped. + owner.client = None + owner.async_client = None + + if sync_client is not None and not sync_client_supplied: + try: + sync_client.close() + except Exception: + pass + + if async_client is not None and not async_client_supplied: + try: + loop = asyncio.get_running_loop() + asyncio.run_coroutine_threadsafe(async_client.aclose(), loop) + except RuntimeError: + try: + asyncio.run(async_client.aclose()) + except RuntimeError: + # best effort + pass diff --git a/src/openrouter/models/__init__.py b/src/openrouter/models/__init__.py new file mode 100644 index 0000000..59080c2 --- /dev/null +++ b/src/openrouter/models/__init__.py @@ -0,0 +1,957 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import TYPE_CHECKING +from importlib import import_module +import builtins + +if TYPE_CHECKING: + from .annotationdetail import AnnotationDetail, AnnotationDetailTypedDict + from .chatcompletion import ( + ChatCompletion, + ChatCompletionObject, + ChatCompletionTypedDict, + ) + from .chatcompletionassistantmessageparam import ( + ChatCompletionAssistantMessageParam, + ChatCompletionAssistantMessageParamContent, + ChatCompletionAssistantMessageParamContentTypedDict, + ChatCompletionAssistantMessageParamRole, + ChatCompletionAssistantMessageParamTypedDict, + ) + from .chatcompletionchoice import ( + ChatCompletionChoice, + ChatCompletionChoiceFinishReason, + ChatCompletionChoiceTypedDict, + ) + from .chatcompletionchunk import ( + ChatCompletionChunk, + ChatCompletionChunkObject, + ChatCompletionChunkTypedDict, + ) + from .chatcompletionchunkchoice import ( + ChatCompletionChunkChoice, + ChatCompletionChunkChoiceFinishReason, + ChatCompletionChunkChoiceTypedDict, + ) + from .chatcompletionchunkchoicedelta import ( + ChatCompletionChunkChoiceDelta, + ChatCompletionChunkChoiceDeltaRole, + ChatCompletionChunkChoiceDeltaTypedDict, + ) + from .chatcompletionchunkchoicedeltatoolcall import ( + ChatCompletionChunkChoiceDeltaToolCall, + ChatCompletionChunkChoiceDeltaToolCallFunction, + ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict, + ChatCompletionChunkChoiceDeltaToolCallType, + ChatCompletionChunkChoiceDeltaToolCallTypedDict, + ) + from .chatcompletioncontentpart import ( + ChatCompletionContentPart, + ChatCompletionContentPartTypedDict, + ) + from .chatcompletioncontentpartaudio import ( + ChatCompletionContentPartAudio, + ChatCompletionContentPartAudioFormat, + ChatCompletionContentPartAudioType, + ChatCompletionContentPartAudioTypedDict, + InputAudio, + InputAudioTypedDict, + ) + from .chatcompletioncontentpartimage import ( + ChatCompletionContentPartImage, + ChatCompletionContentPartImageImageURL, + ChatCompletionContentPartImageImageURLTypedDict, + ChatCompletionContentPartImageType, + ChatCompletionContentPartImageTypedDict, + Detail, + ) + from .chatcompletioncontentparttext import ( + ChatCompletionContentPartText, + ChatCompletionContentPartTextType, + ChatCompletionContentPartTextTypedDict, + ) + from .chatcompletioncreateparams import ( + 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, + ) + from .chatcompletionerror import Error, ErrorTypedDict + from .chatcompletionmessage import ( + ChatCompletionMessage, + ChatCompletionMessageRole, + ChatCompletionMessageTypedDict, + ) + from .chatcompletionmessageparam import ( + ChatCompletionMessageParam, + ChatCompletionMessageParamTypedDict, + ) + from .chatcompletionmessagetoolcall import ( + ChatCompletionMessageToolCall, + ChatCompletionMessageToolCallFunction, + ChatCompletionMessageToolCallFunctionTypedDict, + ChatCompletionMessageToolCallType, + ChatCompletionMessageToolCallTypedDict, + ) + from .chatcompletionnamedtoolchoice import ( + ChatCompletionNamedToolChoice, + ChatCompletionNamedToolChoiceFunction, + ChatCompletionNamedToolChoiceFunctionTypedDict, + ChatCompletionNamedToolChoiceType, + ChatCompletionNamedToolChoiceTypedDict, + ) + from .chatcompletionsystemmessageparam import ( + ChatCompletionSystemMessageParam, + ChatCompletionSystemMessageParamContent, + ChatCompletionSystemMessageParamContentTypedDict, + ChatCompletionSystemMessageParamRole, + ChatCompletionSystemMessageParamTypedDict, + ) + from .chatcompletiontokenlogprob import ( + ChatCompletionTokenLogprob, + ChatCompletionTokenLogprobTypedDict, + TopLogprob, + TopLogprobTypedDict, + ) + from .chatcompletiontokenlogprobs import ( + ChatCompletionTokenLogprobs, + ChatCompletionTokenLogprobsTypedDict, + ) + from .chatcompletiontool import ( + ChatCompletionTool, + ChatCompletionToolFunction, + ChatCompletionToolFunctionTypedDict, + ChatCompletionToolType, + ChatCompletionToolTypedDict, + Parameters, + ParametersTypedDict, + ) + from .chatcompletiontoolchoiceoption import ( + ChatCompletionToolChoiceOption, + ChatCompletionToolChoiceOptionAuto, + ChatCompletionToolChoiceOptionNone, + ChatCompletionToolChoiceOptionRequired, + ChatCompletionToolChoiceOptionTypedDict, + ) + from .chatcompletiontoolmessageparam import ( + ChatCompletionToolMessageParam, + ChatCompletionToolMessageParamContent, + ChatCompletionToolMessageParamContentTypedDict, + ChatCompletionToolMessageParamRole, + ChatCompletionToolMessageParamTypedDict, + ) + from .chatcompletionusermessageparam import ( + ChatCompletionUserMessageParam, + ChatCompletionUserMessageParamContent, + ChatCompletionUserMessageParamContentTypedDict, + 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, + CompletionUsage, + CompletionUsageTypedDict, + PromptTokensDetails, + PromptTokensDetailsTypedDict, + ) + from .fileannotationdetail import ( + ContentImageURL, + ContentImageURLTypedDict, + ContentText, + ContentTextTypedDict, + ContentTypeImageURL, + ContentTypeText, + File, + FileAnnotationDetail, + FileAnnotationDetailContentUnion, + FileAnnotationDetailContentUnionTypedDict, + FileAnnotationDetailImageURL, + FileAnnotationDetailImageURLTypedDict, + FileAnnotationDetailTypedDict, + FileTypedDict, + TypeFile, + ) + from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict + from .reasoningdetailencrypted import ( + ReasoningDetailEncrypted, + ReasoningDetailEncryptedFormat, + ReasoningDetailEncryptedType, + ReasoningDetailEncryptedTypedDict, + ) + from .reasoningdetailsummary import ( + ReasoningDetailSummary, + ReasoningDetailSummaryFormat, + ReasoningDetailSummaryType, + ReasoningDetailSummaryTypedDict, + ) + from .reasoningdetailtext import ( + ReasoningDetailText, + ReasoningDetailTextFormat, + ReasoningDetailTextType, + ReasoningDetailTextTypedDict, + ) + from .responseformatjsonschemaschema import ( + ResponseFormatJSONSchemaSchema, + ResponseFormatJSONSchemaSchemaTypedDict, + ) + from .security import Security, SecurityTypedDict + from .streamchatcompletionop import ( + StreamChatCompletionResponseBody, + StreamChatCompletionResponseBodyTypedDict, + ) + from .urlcitationannotationdetail import ( + URLCitation, + URLCitationAnnotationDetail, + URLCitationAnnotationDetailType, + URLCitationAnnotationDetailTypedDict, + URLCitationTypedDict, + ) + +__all__ = [ + "AnnotationDetail", + "AnnotationDetailTypedDict", + "ChatCompletion", + "ChatCompletionAssistantMessageParam", + "ChatCompletionAssistantMessageParamContent", + "ChatCompletionAssistantMessageParamContentTypedDict", + "ChatCompletionAssistantMessageParamRole", + "ChatCompletionAssistantMessageParamTypedDict", + "ChatCompletionChoice", + "ChatCompletionChoiceFinishReason", + "ChatCompletionChoiceTypedDict", + "ChatCompletionChunk", + "ChatCompletionChunkChoice", + "ChatCompletionChunkChoiceDelta", + "ChatCompletionChunkChoiceDeltaRole", + "ChatCompletionChunkChoiceDeltaToolCall", + "ChatCompletionChunkChoiceDeltaToolCallFunction", + "ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict", + "ChatCompletionChunkChoiceDeltaToolCallType", + "ChatCompletionChunkChoiceDeltaToolCallTypedDict", + "ChatCompletionChunkChoiceDeltaTypedDict", + "ChatCompletionChunkChoiceFinishReason", + "ChatCompletionChunkChoiceTypedDict", + "ChatCompletionChunkObject", + "ChatCompletionChunkTypedDict", + "ChatCompletionContentPart", + "ChatCompletionContentPartAudio", + "ChatCompletionContentPartAudioFormat", + "ChatCompletionContentPartAudioType", + "ChatCompletionContentPartAudioTypedDict", + "ChatCompletionContentPartImage", + "ChatCompletionContentPartImageImageURL", + "ChatCompletionContentPartImageImageURLTypedDict", + "ChatCompletionContentPartImageType", + "ChatCompletionContentPartImageTypedDict", + "ChatCompletionContentPartText", + "ChatCompletionContentPartTextType", + "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", + "ChatCompletionMessageParam", + "ChatCompletionMessageParamTypedDict", + "ChatCompletionMessageRole", + "ChatCompletionMessageToolCall", + "ChatCompletionMessageToolCallFunction", + "ChatCompletionMessageToolCallFunctionTypedDict", + "ChatCompletionMessageToolCallType", + "ChatCompletionMessageToolCallTypedDict", + "ChatCompletionMessageTypedDict", + "ChatCompletionNamedToolChoice", + "ChatCompletionNamedToolChoiceFunction", + "ChatCompletionNamedToolChoiceFunctionTypedDict", + "ChatCompletionNamedToolChoiceType", + "ChatCompletionNamedToolChoiceTypedDict", + "ChatCompletionObject", + "ChatCompletionSystemMessageParam", + "ChatCompletionSystemMessageParamContent", + "ChatCompletionSystemMessageParamContentTypedDict", + "ChatCompletionSystemMessageParamRole", + "ChatCompletionSystemMessageParamTypedDict", + "ChatCompletionTokenLogprob", + "ChatCompletionTokenLogprobTypedDict", + "ChatCompletionTokenLogprobs", + "ChatCompletionTokenLogprobsTypedDict", + "ChatCompletionTool", + "ChatCompletionToolChoiceOption", + "ChatCompletionToolChoiceOptionAuto", + "ChatCompletionToolChoiceOptionNone", + "ChatCompletionToolChoiceOptionRequired", + "ChatCompletionToolChoiceOptionTypedDict", + "ChatCompletionToolFunction", + "ChatCompletionToolFunctionTypedDict", + "ChatCompletionToolMessageParam", + "ChatCompletionToolMessageParamContent", + "ChatCompletionToolMessageParamContentTypedDict", + "ChatCompletionToolMessageParamRole", + "ChatCompletionToolMessageParamTypedDict", + "ChatCompletionToolType", + "ChatCompletionToolTypedDict", + "ChatCompletionTypedDict", + "ChatCompletionUserMessageParam", + "ChatCompletionUserMessageParamContent", + "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", + "CompletionTokensDetails", + "CompletionTokensDetailsTypedDict", + "CompletionUsage", + "CompletionUsageTypedDict", + "ContentImageURL", + "ContentImageURLTypedDict", + "ContentText", + "ContentTextTypedDict", + "ContentTypeImageURL", + "ContentTypeText", + "Detail", + "Error", + "ErrorTypedDict", + "File", + "FileAnnotationDetail", + "FileAnnotationDetailContentUnion", + "FileAnnotationDetailContentUnionTypedDict", + "FileAnnotationDetailImageURL", + "FileAnnotationDetailImageURLTypedDict", + "FileAnnotationDetailTypedDict", + "FileTypedDict", + "InputAudio", + "InputAudioTypedDict", + "Parameters", + "ParametersTypedDict", + "PromptTokensDetails", + "PromptTokensDetailsTypedDict", + "ReasoningDetail", + "ReasoningDetailEncrypted", + "ReasoningDetailEncryptedFormat", + "ReasoningDetailEncryptedType", + "ReasoningDetailEncryptedTypedDict", + "ReasoningDetailSummary", + "ReasoningDetailSummaryFormat", + "ReasoningDetailSummaryType", + "ReasoningDetailSummaryTypedDict", + "ReasoningDetailText", + "ReasoningDetailTextFormat", + "ReasoningDetailTextType", + "ReasoningDetailTextTypedDict", + "ReasoningDetailTypedDict", + "ResponseFormatJSONSchemaSchema", + "ResponseFormatJSONSchemaSchemaTypedDict", + "Security", + "SecurityTypedDict", + "StreamChatCompletionResponseBody", + "StreamChatCompletionResponseBodyTypedDict", + "TopLogprob", + "TopLogprobTypedDict", + "TypeFile", + "URLCitation", + "URLCitationAnnotationDetail", + "URLCitationAnnotationDetailType", + "URLCitationAnnotationDetailTypedDict", + "URLCitationTypedDict", +] + +_dynamic_imports: dict[str, str] = { + "AnnotationDetail": ".annotationdetail", + "AnnotationDetailTypedDict": ".annotationdetail", + "ChatCompletion": ".chatcompletion", + "ChatCompletionObject": ".chatcompletion", + "ChatCompletionTypedDict": ".chatcompletion", + "ChatCompletionAssistantMessageParam": ".chatcompletionassistantmessageparam", + "ChatCompletionAssistantMessageParamContent": ".chatcompletionassistantmessageparam", + "ChatCompletionAssistantMessageParamContentTypedDict": ".chatcompletionassistantmessageparam", + "ChatCompletionAssistantMessageParamRole": ".chatcompletionassistantmessageparam", + "ChatCompletionAssistantMessageParamTypedDict": ".chatcompletionassistantmessageparam", + "ChatCompletionChoice": ".chatcompletionchoice", + "ChatCompletionChoiceFinishReason": ".chatcompletionchoice", + "ChatCompletionChoiceTypedDict": ".chatcompletionchoice", + "ChatCompletionChunk": ".chatcompletionchunk", + "ChatCompletionChunkObject": ".chatcompletionchunk", + "ChatCompletionChunkTypedDict": ".chatcompletionchunk", + "ChatCompletionChunkChoice": ".chatcompletionchunkchoice", + "ChatCompletionChunkChoiceFinishReason": ".chatcompletionchunkchoice", + "ChatCompletionChunkChoiceTypedDict": ".chatcompletionchunkchoice", + "ChatCompletionChunkChoiceDelta": ".chatcompletionchunkchoicedelta", + "ChatCompletionChunkChoiceDeltaRole": ".chatcompletionchunkchoicedelta", + "ChatCompletionChunkChoiceDeltaTypedDict": ".chatcompletionchunkchoicedelta", + "ChatCompletionChunkChoiceDeltaToolCall": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionChunkChoiceDeltaToolCallFunction": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionChunkChoiceDeltaToolCallType": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionChunkChoiceDeltaToolCallTypedDict": ".chatcompletionchunkchoicedeltatoolcall", + "ChatCompletionContentPart": ".chatcompletioncontentpart", + "ChatCompletionContentPartTypedDict": ".chatcompletioncontentpart", + "ChatCompletionContentPartAudio": ".chatcompletioncontentpartaudio", + "ChatCompletionContentPartAudioFormat": ".chatcompletioncontentpartaudio", + "ChatCompletionContentPartAudioType": ".chatcompletioncontentpartaudio", + "ChatCompletionContentPartAudioTypedDict": ".chatcompletioncontentpartaudio", + "InputAudio": ".chatcompletioncontentpartaudio", + "InputAudioTypedDict": ".chatcompletioncontentpartaudio", + "ChatCompletionContentPartImage": ".chatcompletioncontentpartimage", + "ChatCompletionContentPartImageImageURL": ".chatcompletioncontentpartimage", + "ChatCompletionContentPartImageImageURLTypedDict": ".chatcompletioncontentpartimage", + "ChatCompletionContentPartImageType": ".chatcompletioncontentpartimage", + "ChatCompletionContentPartImageTypedDict": ".chatcompletioncontentpartimage", + "Detail": ".chatcompletioncontentpartimage", + "ChatCompletionContentPartText": ".chatcompletioncontentparttext", + "ChatCompletionContentPartTextType": ".chatcompletioncontentparttext", + "ChatCompletionContentPartTextTypedDict": ".chatcompletioncontentparttext", + "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", + "Error": ".chatcompletionerror", + "ErrorTypedDict": ".chatcompletionerror", + "ChatCompletionMessage": ".chatcompletionmessage", + "ChatCompletionMessageRole": ".chatcompletionmessage", + "ChatCompletionMessageTypedDict": ".chatcompletionmessage", + "ChatCompletionMessageParam": ".chatcompletionmessageparam", + "ChatCompletionMessageParamTypedDict": ".chatcompletionmessageparam", + "ChatCompletionMessageToolCall": ".chatcompletionmessagetoolcall", + "ChatCompletionMessageToolCallFunction": ".chatcompletionmessagetoolcall", + "ChatCompletionMessageToolCallFunctionTypedDict": ".chatcompletionmessagetoolcall", + "ChatCompletionMessageToolCallType": ".chatcompletionmessagetoolcall", + "ChatCompletionMessageToolCallTypedDict": ".chatcompletionmessagetoolcall", + "ChatCompletionNamedToolChoice": ".chatcompletionnamedtoolchoice", + "ChatCompletionNamedToolChoiceFunction": ".chatcompletionnamedtoolchoice", + "ChatCompletionNamedToolChoiceFunctionTypedDict": ".chatcompletionnamedtoolchoice", + "ChatCompletionNamedToolChoiceType": ".chatcompletionnamedtoolchoice", + "ChatCompletionNamedToolChoiceTypedDict": ".chatcompletionnamedtoolchoice", + "ChatCompletionSystemMessageParam": ".chatcompletionsystemmessageparam", + "ChatCompletionSystemMessageParamContent": ".chatcompletionsystemmessageparam", + "ChatCompletionSystemMessageParamContentTypedDict": ".chatcompletionsystemmessageparam", + "ChatCompletionSystemMessageParamRole": ".chatcompletionsystemmessageparam", + "ChatCompletionSystemMessageParamTypedDict": ".chatcompletionsystemmessageparam", + "ChatCompletionTokenLogprob": ".chatcompletiontokenlogprob", + "ChatCompletionTokenLogprobTypedDict": ".chatcompletiontokenlogprob", + "TopLogprob": ".chatcompletiontokenlogprob", + "TopLogprobTypedDict": ".chatcompletiontokenlogprob", + "ChatCompletionTokenLogprobs": ".chatcompletiontokenlogprobs", + "ChatCompletionTokenLogprobsTypedDict": ".chatcompletiontokenlogprobs", + "ChatCompletionTool": ".chatcompletiontool", + "ChatCompletionToolFunction": ".chatcompletiontool", + "ChatCompletionToolFunctionTypedDict": ".chatcompletiontool", + "ChatCompletionToolType": ".chatcompletiontool", + "ChatCompletionToolTypedDict": ".chatcompletiontool", + "Parameters": ".chatcompletiontool", + "ParametersTypedDict": ".chatcompletiontool", + "ChatCompletionToolChoiceOption": ".chatcompletiontoolchoiceoption", + "ChatCompletionToolChoiceOptionAuto": ".chatcompletiontoolchoiceoption", + "ChatCompletionToolChoiceOptionNone": ".chatcompletiontoolchoiceoption", + "ChatCompletionToolChoiceOptionRequired": ".chatcompletiontoolchoiceoption", + "ChatCompletionToolChoiceOptionTypedDict": ".chatcompletiontoolchoiceoption", + "ChatCompletionToolMessageParam": ".chatcompletiontoolmessageparam", + "ChatCompletionToolMessageParamContent": ".chatcompletiontoolmessageparam", + "ChatCompletionToolMessageParamContentTypedDict": ".chatcompletiontoolmessageparam", + "ChatCompletionToolMessageParamRole": ".chatcompletiontoolmessageparam", + "ChatCompletionToolMessageParamTypedDict": ".chatcompletiontoolmessageparam", + "ChatCompletionUserMessageParam": ".chatcompletionusermessageparam", + "ChatCompletionUserMessageParamContent": ".chatcompletionusermessageparam", + "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", + "ContentImageURL": ".fileannotationdetail", + "ContentImageURLTypedDict": ".fileannotationdetail", + "ContentText": ".fileannotationdetail", + "ContentTextTypedDict": ".fileannotationdetail", + "ContentTypeImageURL": ".fileannotationdetail", + "ContentTypeText": ".fileannotationdetail", + "File": ".fileannotationdetail", + "FileAnnotationDetail": ".fileannotationdetail", + "FileAnnotationDetailContentUnion": ".fileannotationdetail", + "FileAnnotationDetailContentUnionTypedDict": ".fileannotationdetail", + "FileAnnotationDetailImageURL": ".fileannotationdetail", + "FileAnnotationDetailImageURLTypedDict": ".fileannotationdetail", + "FileAnnotationDetailTypedDict": ".fileannotationdetail", + "FileTypedDict": ".fileannotationdetail", + "TypeFile": ".fileannotationdetail", + "ReasoningDetail": ".reasoningdetail", + "ReasoningDetailTypedDict": ".reasoningdetail", + "ReasoningDetailEncrypted": ".reasoningdetailencrypted", + "ReasoningDetailEncryptedFormat": ".reasoningdetailencrypted", + "ReasoningDetailEncryptedType": ".reasoningdetailencrypted", + "ReasoningDetailEncryptedTypedDict": ".reasoningdetailencrypted", + "ReasoningDetailSummary": ".reasoningdetailsummary", + "ReasoningDetailSummaryFormat": ".reasoningdetailsummary", + "ReasoningDetailSummaryType": ".reasoningdetailsummary", + "ReasoningDetailSummaryTypedDict": ".reasoningdetailsummary", + "ReasoningDetailText": ".reasoningdetailtext", + "ReasoningDetailTextFormat": ".reasoningdetailtext", + "ReasoningDetailTextType": ".reasoningdetailtext", + "ReasoningDetailTextTypedDict": ".reasoningdetailtext", + "ResponseFormatJSONSchemaSchema": ".responseformatjsonschemaschema", + "ResponseFormatJSONSchemaSchemaTypedDict": ".responseformatjsonschemaschema", + "Security": ".security", + "SecurityTypedDict": ".security", + "StreamChatCompletionResponseBody": ".streamchatcompletionop", + "StreamChatCompletionResponseBodyTypedDict": ".streamchatcompletionop", + "URLCitation": ".urlcitationannotationdetail", + "URLCitationAnnotationDetail": ".urlcitationannotationdetail", + "URLCitationAnnotationDetailType": ".urlcitationannotationdetail", + "URLCitationAnnotationDetailTypedDict": ".urlcitationannotationdetail", + "URLCitationTypedDict": ".urlcitationannotationdetail", +} + + +def __getattr__(attr_name: str) -> object: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError( + f"No {attr_name} found in _dynamic_imports for module name -> {__name__} " + ) + + try: + module = import_module(module_name, __package__) + result = getattr(module, attr_name) + return result + except ImportError as e: + raise ImportError( + f"Failed to import {attr_name} from {module_name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to get {attr_name} from {module_name}: {e}" + ) from e + + +def __dir__(): + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/openrouter/models/annotationdetail.py b/src/openrouter/models/annotationdetail.py new file mode 100644 index 0000000..320bc64 --- /dev/null +++ b/src/openrouter/models/annotationdetail.py @@ -0,0 +1,29 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .fileannotationdetail import FileAnnotationDetail, FileAnnotationDetailTypedDict +from .urlcitationannotationdetail import ( + URLCitationAnnotationDetail, + URLCitationAnnotationDetailTypedDict, +) +from openrouter.utils import get_discriminator +from pydantic import Discriminator, Tag +from typing import Union +from typing_extensions import Annotated, TypeAliasType + + +AnnotationDetailTypedDict = TypeAliasType( + "AnnotationDetailTypedDict", + Union[FileAnnotationDetailTypedDict, URLCitationAnnotationDetailTypedDict], +) +r"""Annotation information""" + + +AnnotationDetail = Annotated[ + Union[ + Annotated[FileAnnotationDetail, Tag("file")], + Annotated[URLCitationAnnotationDetail, Tag("url_citation")], + ], + Discriminator(lambda m: get_discriminator(m, "type", "type")), +] +r"""Annotation information""" diff --git a/src/openrouter/models/chatcompletion.py b/src/openrouter/models/chatcompletion.py new file mode 100644 index 0000000..f4fd50c --- /dev/null +++ b/src/openrouter/models/chatcompletion.py @@ -0,0 +1,92 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceTypedDict +from .completionusage import CompletionUsage, CompletionUsageTypedDict +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionObject(str, Enum): + CHAT_COMPLETION = "chat.completion" + + +class ChatCompletionTypedDict(TypedDict): + r"""Chat completion response""" + + id: str + r"""Unique completion identifier""" + choices: List[ChatCompletionChoiceTypedDict] + r"""List of completion choices""" + created: float + r"""Unix timestamp of creation""" + model: str + r"""Model used for completion""" + object: ChatCompletionObject + system_fingerprint: NotRequired[Nullable[str]] + r"""System fingerprint""" + usage: NotRequired[CompletionUsageTypedDict] + r"""Token usage statistics""" + + +class ChatCompletion(BaseModel): + r"""Chat completion response""" + + id: str + r"""Unique completion identifier""" + + choices: List[ChatCompletionChoice] + r"""List of completion choices""" + + created: float + r"""Unix timestamp of creation""" + + model: str + r"""Model used for completion""" + + object: ChatCompletionObject + + system_fingerprint: OptionalNullable[str] = UNSET + r"""System fingerprint""" + + usage: Optional[CompletionUsage] = None + r"""Token usage statistics""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["system_fingerprint", "usage"] + nullable_fields = ["system_fingerprint"] + 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/chatcompletionassistantmessageparam.py b/src/openrouter/models/chatcompletionassistantmessageparam.py new file mode 100644 index 0000000..a698ee6 --- /dev/null +++ b/src/openrouter/models/chatcompletionassistantmessageparam.py @@ -0,0 +1,102 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletioncontentpart import ( + ChatCompletionContentPart, + ChatCompletionContentPartTypedDict, +) +from .chatcompletionmessagetoolcall import ( + ChatCompletionMessageToolCall, + ChatCompletionMessageToolCallTypedDict, +) +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import Any, List, Optional, Union +from typing_extensions import NotRequired, TypeAliasType, TypedDict + + +class ChatCompletionAssistantMessageParamRole(str, Enum): + ASSISTANT = "assistant" + + +ChatCompletionAssistantMessageParamContentTypedDict = TypeAliasType( + "ChatCompletionAssistantMessageParamContentTypedDict", + Union[str, List[ChatCompletionContentPartTypedDict], Any], +) +r"""Assistant message content""" + + +ChatCompletionAssistantMessageParamContent = TypeAliasType( + "ChatCompletionAssistantMessageParamContent", + Union[str, List[ChatCompletionContentPart], Any], +) +r"""Assistant message content""" + + +class ChatCompletionAssistantMessageParamTypedDict(TypedDict): + r"""Assistant message with tool calls and audio support""" + + role: ChatCompletionAssistantMessageParamRole + content: NotRequired[Nullable[ChatCompletionAssistantMessageParamContentTypedDict]] + r"""Assistant message content""" + name: NotRequired[str] + r"""Optional name for the assistant""" + tool_calls: NotRequired[List[ChatCompletionMessageToolCallTypedDict]] + r"""Tool calls made by the assistant""" + refusal: NotRequired[Nullable[str]] + r"""Refusal message if content was refused""" + + +class ChatCompletionAssistantMessageParam(BaseModel): + r"""Assistant message with tool calls and audio support""" + + role: ChatCompletionAssistantMessageParamRole + + content: OptionalNullable[ChatCompletionAssistantMessageParamContent] = UNSET + r"""Assistant message content""" + + name: Optional[str] = None + r"""Optional name for the assistant""" + + tool_calls: Optional[List[ChatCompletionMessageToolCall]] = None + r"""Tool calls made by the assistant""" + + refusal: OptionalNullable[str] = UNSET + r"""Refusal message if content was refused""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["content", "name", "tool_calls", "refusal"] + nullable_fields = ["content", "refusal"] + 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/chatcompletionchoice.py b/src/openrouter/models/chatcompletionchoice.py new file mode 100644 index 0000000..cd7f7ae --- /dev/null +++ b/src/openrouter/models/chatcompletionchoice.py @@ -0,0 +1,87 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionmessage import ChatCompletionMessage, ChatCompletionMessageTypedDict +from .chatcompletiontokenlogprobs import ( + ChatCompletionTokenLogprobs, + ChatCompletionTokenLogprobsTypedDict, +) +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +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" + + +class ChatCompletionChoiceTypedDict(TypedDict): + r"""Chat completion choice""" + + finish_reason: Nullable[ChatCompletionChoiceFinishReason] + r"""Reason the completion finished""" + index: float + r"""Choice index""" + message: ChatCompletionMessageTypedDict + r"""Assistant message in completion response""" + logprobs: NotRequired[Nullable[ChatCompletionTokenLogprobsTypedDict]] + r"""Log probabilities for the completion""" + + +class ChatCompletionChoice(BaseModel): + r"""Chat completion choice""" + + finish_reason: Nullable[ChatCompletionChoiceFinishReason] + r"""Reason the completion finished""" + + index: float + r"""Choice index""" + + message: ChatCompletionMessage + r"""Assistant message in completion response""" + + logprobs: OptionalNullable[ChatCompletionTokenLogprobs] = UNSET + r"""Log probabilities for the completion""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["logprobs"] + nullable_fields = ["finish_reason", "logprobs"] + null_default_fields = [] + + serialized = handler(self) + + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k) + serialized.pop(k, None) + + optional_nullable = k in optional_fields and k in nullable_fields + is_set = ( + self.__pydantic_fields_set__.intersection({n}) + or k in null_default_fields + ) # pylint: disable=no-member + + if val is not None and val != UNSET_SENTINEL: + m[k] = val + elif val != UNSET_SENTINEL and ( + not k in optional_fields or (optional_nullable and is_set) + ): + m[k] = val + + return m diff --git a/src/openrouter/models/chatcompletionchunk.py b/src/openrouter/models/chatcompletionchunk.py new file mode 100644 index 0000000..54a0dec --- /dev/null +++ b/src/openrouter/models/chatcompletionchunk.py @@ -0,0 +1,85 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionchunkchoice import ( + ChatCompletionChunkChoice, + ChatCompletionChunkChoiceTypedDict, +) +from .completionusage import CompletionUsage, CompletionUsageTypedDict +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionChunkObject(str, Enum): + CHAT_COMPLETION_CHUNK = "chat.completion.chunk" + + +class ChatCompletionChunkTypedDict(TypedDict): + r"""Streaming chat completion chunk""" + + id: str + choices: List[ChatCompletionChunkChoiceTypedDict] + created: float + model: str + object: ChatCompletionChunkObject + system_fingerprint: NotRequired[Nullable[str]] + usage: NotRequired[CompletionUsageTypedDict] + r"""Token usage statistics""" + + +class ChatCompletionChunk(BaseModel): + r"""Streaming chat completion chunk""" + + id: str + + choices: List[ChatCompletionChunkChoice] + + created: float + + model: str + + object: ChatCompletionChunkObject + + system_fingerprint: OptionalNullable[str] = UNSET + + usage: Optional[CompletionUsage] = None + r"""Token usage statistics""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["system_fingerprint", "usage"] + nullable_fields = ["system_fingerprint"] + 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/chatcompletionchunkchoice.py b/src/openrouter/models/chatcompletionchunkchoice.py new file mode 100644 index 0000000..4ce6418 --- /dev/null +++ b/src/openrouter/models/chatcompletionchunkchoice.py @@ -0,0 +1,84 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionchunkchoicedelta import ( + ChatCompletionChunkChoiceDelta, + ChatCompletionChunkChoiceDeltaTypedDict, +) +from .chatcompletiontokenlogprobs import ( + ChatCompletionTokenLogprobs, + ChatCompletionTokenLogprobsTypedDict, +) +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionChunkChoiceFinishReason(str, Enum): + TOOL_CALLS = "tool_calls" + STOP = "stop" + LENGTH = "length" + CONTENT_FILTER = "content_filter" + ERROR = "error" + + +class ChatCompletionChunkChoiceTypedDict(TypedDict): + r"""Streaming completion choice chunk""" + + delta: ChatCompletionChunkChoiceDeltaTypedDict + r"""Delta changes in streaming response""" + finish_reason: Nullable[ChatCompletionChunkChoiceFinishReason] + index: float + logprobs: NotRequired[Nullable[ChatCompletionTokenLogprobsTypedDict]] + r"""Log probabilities for the completion""" + + +class ChatCompletionChunkChoice(BaseModel): + r"""Streaming completion choice chunk""" + + delta: ChatCompletionChunkChoiceDelta + r"""Delta changes in streaming response""" + + finish_reason: Nullable[ChatCompletionChunkChoiceFinishReason] + + index: float + + logprobs: OptionalNullable[ChatCompletionTokenLogprobs] = UNSET + r"""Log probabilities for the completion""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["logprobs"] + nullable_fields = ["finish_reason", "logprobs"] + null_default_fields = [] + + serialized = handler(self) + + m = {} + + for n, f in type(self).model_fields.items(): + k = f.alias or n + val = serialized.get(k) + serialized.pop(k, None) + + optional_nullable = k in optional_fields and k in nullable_fields + is_set = ( + self.__pydantic_fields_set__.intersection({n}) + or k in null_default_fields + ) # pylint: disable=no-member + + if val is not None and val != UNSET_SENTINEL: + m[k] = val + elif val != UNSET_SENTINEL and ( + not k in optional_fields or (optional_nullable and is_set) + ): + m[k] = val + + return m diff --git a/src/openrouter/models/chatcompletionchunkchoicedelta.py b/src/openrouter/models/chatcompletionchunkchoicedelta.py new file mode 100644 index 0000000..1aa2d5c --- /dev/null +++ b/src/openrouter/models/chatcompletionchunkchoicedelta.py @@ -0,0 +1,108 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .annotationdetail import AnnotationDetail, AnnotationDetailTypedDict +from .chatcompletionchunkchoicedeltatoolcall import ( + ChatCompletionChunkChoiceDeltaToolCall, + ChatCompletionChunkChoiceDeltaToolCallTypedDict, +) +from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionChunkChoiceDeltaRole(str, Enum): + r"""The role of the message author""" + + ASSISTANT = "assistant" + + +class ChatCompletionChunkChoiceDeltaTypedDict(TypedDict): + r"""Delta changes in streaming response""" + + role: NotRequired[ChatCompletionChunkChoiceDeltaRole] + r"""The role of the message author""" + content: NotRequired[Nullable[str]] + r"""Message content delta""" + reasoning: NotRequired[Nullable[str]] + r"""Reasoning content delta""" + refusal: NotRequired[Nullable[str]] + r"""Refusal message delta""" + tool_calls: NotRequired[List[ChatCompletionChunkChoiceDeltaToolCallTypedDict]] + r"""Tool calls delta""" + reasoning_details: NotRequired[List[ReasoningDetailTypedDict]] + r"""Reasoning details delta to send reasoning details back to upstream""" + annotations: NotRequired[List[AnnotationDetailTypedDict]] + r"""Annotations delta to send annotations back to upstream""" + + +class ChatCompletionChunkChoiceDelta(BaseModel): + r"""Delta changes in streaming response""" + + role: Optional[ChatCompletionChunkChoiceDeltaRole] = None + r"""The role of the message author""" + + content: OptionalNullable[str] = UNSET + r"""Message content delta""" + + reasoning: OptionalNullable[str] = UNSET + r"""Reasoning content delta""" + + refusal: OptionalNullable[str] = UNSET + r"""Refusal message delta""" + + tool_calls: Optional[List[ChatCompletionChunkChoiceDeltaToolCall]] = None + r"""Tool calls delta""" + + reasoning_details: Optional[List[ReasoningDetail]] = None + r"""Reasoning details delta to send reasoning details back to upstream""" + + annotations: Optional[List[AnnotationDetail]] = None + r"""Annotations delta to send annotations back to upstream""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [ + "role", + "content", + "reasoning", + "refusal", + "tool_calls", + "reasoning_details", + "annotations", + ] + nullable_fields = ["content", "reasoning", "refusal"] + 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/chatcompletionchunkchoicedeltatoolcall.py b/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py new file mode 100644 index 0000000..0501977 --- /dev/null +++ b/src/openrouter/models/chatcompletionchunkchoicedeltatoolcall.py @@ -0,0 +1,61 @@ +"""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_extensions import NotRequired, TypedDict + + +class ChatCompletionChunkChoiceDeltaToolCallType(str, Enum): + r"""Tool call type""" + + FUNCTION = "function" + + +class ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict(TypedDict): + r"""Function call details""" + + name: NotRequired[str] + r"""Function name""" + arguments: NotRequired[str] + r"""Function arguments as JSON string""" + + +class ChatCompletionChunkChoiceDeltaToolCallFunction(BaseModel): + r"""Function call details""" + + name: Optional[str] = None + r"""Function name""" + + arguments: Optional[str] = None + r"""Function arguments as JSON string""" + + +class ChatCompletionChunkChoiceDeltaToolCallTypedDict(TypedDict): + r"""Tool call delta for streaming responses""" + + index: float + r"""Tool call index in the array""" + id: NotRequired[str] + r"""Tool call identifier""" + type: NotRequired[ChatCompletionChunkChoiceDeltaToolCallType] + r"""Tool call type""" + function: NotRequired[ChatCompletionChunkChoiceDeltaToolCallFunctionTypedDict] + r"""Function call details""" + + +class ChatCompletionChunkChoiceDeltaToolCall(BaseModel): + r"""Tool call delta for streaming responses""" + + index: float + r"""Tool call index in the array""" + + id: Optional[str] = None + r"""Tool call identifier""" + + type: Optional[ChatCompletionChunkChoiceDeltaToolCallType] = None + r"""Tool call type""" + + function: Optional[ChatCompletionChunkChoiceDeltaToolCallFunction] = None + r"""Function call details""" diff --git a/src/openrouter/models/chatcompletioncontentpart.py b/src/openrouter/models/chatcompletioncontentpart.py new file mode 100644 index 0000000..8c4cf14 --- /dev/null +++ b/src/openrouter/models/chatcompletioncontentpart.py @@ -0,0 +1,41 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletioncontentpartaudio import ( + ChatCompletionContentPartAudio, + ChatCompletionContentPartAudioTypedDict, +) +from .chatcompletioncontentpartimage import ( + ChatCompletionContentPartImage, + ChatCompletionContentPartImageTypedDict, +) +from .chatcompletioncontentparttext import ( + ChatCompletionContentPartText, + ChatCompletionContentPartTextTypedDict, +) +from openrouter.utils import get_discriminator +from pydantic import Discriminator, Tag +from typing import Union +from typing_extensions import Annotated, TypeAliasType + + +ChatCompletionContentPartTypedDict = TypeAliasType( + "ChatCompletionContentPartTypedDict", + Union[ + ChatCompletionContentPartTextTypedDict, + ChatCompletionContentPartImageTypedDict, + ChatCompletionContentPartAudioTypedDict, + ], +) +r"""Content part for chat completion messages""" + + +ChatCompletionContentPart = Annotated[ + Union[ + Annotated[ChatCompletionContentPartText, Tag("text")], + Annotated[ChatCompletionContentPartImage, Tag("image_url")], + Annotated[ChatCompletionContentPartAudio, Tag("input_audio")], + ], + Discriminator(lambda m: get_discriminator(m, "type", "type")), +] +r"""Content part for chat completion messages""" diff --git a/src/openrouter/models/chatcompletioncontentpartaudio.py b/src/openrouter/models/chatcompletioncontentpartaudio.py new file mode 100644 index 0000000..cc5abea --- /dev/null +++ b/src/openrouter/models/chatcompletioncontentpartaudio.py @@ -0,0 +1,55 @@ +"""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_extensions import Annotated, TypedDict + + +class ChatCompletionContentPartAudioType(str, Enum): + INPUT_AUDIO = "input_audio" + + +class ChatCompletionContentPartAudioFormat(str, Enum): + r"""Audio format""" + + WAV = "wav" + MP3 = "mp3" + FLAC = "flac" + M4A = "m4a" + OGG = "ogg" + PCM16 = "pcm16" + PCM24 = "pcm24" + + +class InputAudioTypedDict(TypedDict): + data: str + r"""Base64 encoded audio data""" + format_: ChatCompletionContentPartAudioFormat + r"""Audio format""" + + +class InputAudio(BaseModel): + data: str + r"""Base64 encoded audio data""" + + format_: Annotated[ + ChatCompletionContentPartAudioFormat, pydantic.Field(alias="format") + ] + r"""Audio format""" + + +class ChatCompletionContentPartAudioTypedDict(TypedDict): + r"""Audio input content part""" + + type: ChatCompletionContentPartAudioType + input_audio: InputAudioTypedDict + + +class ChatCompletionContentPartAudio(BaseModel): + r"""Audio input content part""" + + type: ChatCompletionContentPartAudioType + + input_audio: InputAudio diff --git a/src/openrouter/models/chatcompletioncontentpartimage.py b/src/openrouter/models/chatcompletioncontentpartimage.py new file mode 100644 index 0000000..4469344 --- /dev/null +++ b/src/openrouter/models/chatcompletioncontentpartimage.py @@ -0,0 +1,49 @@ +"""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_extensions import NotRequired, TypedDict + + +class ChatCompletionContentPartImageType(str, Enum): + IMAGE_URL = "image_url" + + +class Detail(str, Enum): + r"""Image detail level for vision models""" + + AUTO = "auto" + LOW = "low" + HIGH = "high" + + +class ChatCompletionContentPartImageImageURLTypedDict(TypedDict): + url: str + r"""URL of the image (data: URLs supported)""" + detail: NotRequired[Detail] + r"""Image detail level for vision models""" + + +class ChatCompletionContentPartImageImageURL(BaseModel): + url: str + r"""URL of the image (data: URLs supported)""" + + detail: Optional[Detail] = None + r"""Image detail level for vision models""" + + +class ChatCompletionContentPartImageTypedDict(TypedDict): + r"""Image content part for vision models""" + + type: ChatCompletionContentPartImageType + image_url: ChatCompletionContentPartImageImageURLTypedDict + + +class ChatCompletionContentPartImage(BaseModel): + r"""Image content part for vision models""" + + type: ChatCompletionContentPartImageType + + image_url: ChatCompletionContentPartImageImageURL diff --git a/src/openrouter/models/chatcompletioncontentparttext.py b/src/openrouter/models/chatcompletioncontentparttext.py new file mode 100644 index 0000000..db491d0 --- /dev/null +++ b/src/openrouter/models/chatcompletioncontentparttext.py @@ -0,0 +1,25 @@ +"""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_extensions import TypedDict + + +class ChatCompletionContentPartTextType(str, Enum): + TEXT = "text" + + +class ChatCompletionContentPartTextTypedDict(TypedDict): + r"""Text content part""" + + type: ChatCompletionContentPartTextType + text: str + + +class ChatCompletionContentPartText(BaseModel): + r"""Text content part""" + + type: ChatCompletionContentPartTextType + + text: str diff --git a/src/openrouter/models/chatcompletioncreateparams.py b/src/openrouter/models/chatcompletioncreateparams.py new file mode 100644 index 0000000..0dcd4cd --- /dev/null +++ b/src/openrouter/models/chatcompletioncreateparams.py @@ -0,0 +1,1120 @@ +"""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 ChatCompletionCreateParamsEffort(str, Enum): + r"""OpenAI-style reasoning effort setting""" + + HIGH = "high" + MEDIUM = "medium" + LOW = "low" + MINIMAL = "minimal" + + +class ChatCompletionCreateParamsReasoningTypedDict(TypedDict): + r"""Reasoning configuration""" + + enabled: NotRequired[bool] + r"""Enables reasoning with default settings. Only work for some models.""" + effort: NotRequired[Nullable[ChatCompletionCreateParamsEffort]] + r"""OpenAI-style reasoning effort setting""" + max_tokens: NotRequired[Nullable[float]] + r"""non-OpenAI-style reasoning effort setting""" + exclude: NotRequired[bool] + + +class ChatCompletionCreateParamsReasoning(BaseModel): + r"""Reasoning configuration""" + + enabled: Optional[bool] = None + r"""Enables reasoning with default settings. Only work for some models.""" + + effort: OptionalNullable[ChatCompletionCreateParamsEffort] = 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 ChatCompletionCreateParamsTypePython(str, Enum): + PYTHON = "python" + + +class ChatCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict): + r"""Python code response format""" + + type: ChatCompletionCreateParamsTypePython + + +class ChatCompletionCreateParamsResponseFormatPython(BaseModel): + r"""Python code response format""" + + type: ChatCompletionCreateParamsTypePython + + +class ChatCompletionCreateParamsTypeGrammar(str, Enum): + GRAMMAR = "grammar" + + +class ChatCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict): + r"""Custom grammar response format""" + + type: ChatCompletionCreateParamsTypeGrammar + grammar: str + r"""Custom grammar for text generation""" + + +class ChatCompletionCreateParamsResponseFormatGrammar(BaseModel): + r"""Custom grammar response format""" + + type: ChatCompletionCreateParamsTypeGrammar + + grammar: str + r"""Custom grammar for text generation""" + + +class ChatCompletionCreateParamsTypeJSONSchema(str, Enum): + JSON_SCHEMA = "json_schema" + + +class ChatCompletionCreateParamsJSONSchemaTypedDict(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 ChatCompletionCreateParamsJSONSchema(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 ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict(TypedDict): + r"""JSON Schema response format for structured outputs""" + + type: ChatCompletionCreateParamsTypeJSONSchema + json_schema: ChatCompletionCreateParamsJSONSchemaTypedDict + + +class ChatCompletionCreateParamsResponseFormatJSONSchema(BaseModel): + r"""JSON Schema response format for structured outputs""" + + type: ChatCompletionCreateParamsTypeJSONSchema + + json_schema: ChatCompletionCreateParamsJSONSchema + + +class ChatCompletionCreateParamsTypeJSONObject(str, Enum): + JSON_OBJECT = "json_object" + + +class ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict): + r"""JSON object response format""" + + type: ChatCompletionCreateParamsTypeJSONObject + + +class ChatCompletionCreateParamsResponseFormatJSONObject(BaseModel): + r"""JSON object response format""" + + type: ChatCompletionCreateParamsTypeJSONObject + + +class ChatCompletionCreateParamsTypeText(str, Enum): + TEXT = "text" + + +class ChatCompletionCreateParamsResponseFormatTextTypedDict(TypedDict): + r"""Default text response format""" + + type: ChatCompletionCreateParamsTypeText + + +class ChatCompletionCreateParamsResponseFormatText(BaseModel): + r"""Default text response format""" + + type: ChatCompletionCreateParamsTypeText + + +ChatCompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsResponseFormatUnionTypedDict", + Union[ + ChatCompletionCreateParamsResponseFormatTextTypedDict, + ChatCompletionCreateParamsResponseFormatJSONObjectTypedDict, + ChatCompletionCreateParamsResponseFormatPythonTypedDict, + ChatCompletionCreateParamsResponseFormatJSONSchemaTypedDict, + ChatCompletionCreateParamsResponseFormatGrammarTypedDict, + ], +) +r"""Response format configuration""" + + +ChatCompletionCreateParamsResponseFormatUnion = TypeAliasType( + "ChatCompletionCreateParamsResponseFormatUnion", + Union[ + ChatCompletionCreateParamsResponseFormatText, + ChatCompletionCreateParamsResponseFormatJSONObject, + ChatCompletionCreateParamsResponseFormatPython, + ChatCompletionCreateParamsResponseFormatJSONSchema, + ChatCompletionCreateParamsResponseFormatGrammar, + ], +) +r"""Response format configuration""" + + +ChatCompletionCreateParamsStopTypedDict = TypeAliasType( + "ChatCompletionCreateParamsStopTypedDict", Union[str, List[str], Any] +) +r"""Stop sequences (up to 4)""" + + +ChatCompletionCreateParamsStop = TypeAliasType( + "ChatCompletionCreateParamsStop", Union[str, List[str], Any] +) +r"""Stop sequences (up to 4)""" + + +class ChatCompletionCreateParamsStreamOptionsTypedDict(TypedDict): + r"""Streaming configuration options""" + + include_usage: NotRequired[bool] + r"""Include usage information in streaming response""" + + +class ChatCompletionCreateParamsStreamOptions(BaseModel): + r"""Streaming configuration options""" + + include_usage: Optional[bool] = None + r"""Include usage information in streaming response""" + + +class ChatCompletionCreateParamsReasoningEffort(str, Enum): + r"""Reasoning effort""" + + HIGH = "high" + MEDIUM = "medium" + LOW = "low" + MINIMAL = "minimal" + + +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" + + +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" + + +ChatCompletionCreateParamsOrderUnionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsOrderUnionTypedDict", + Union[ChatCompletionCreateParamsOrderEnum, str], +) + + +ChatCompletionCreateParamsOrderUnion = TypeAliasType( + "ChatCompletionCreateParamsOrderUnion", + Union[ChatCompletionCreateParamsOrderEnum, 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" + + +ChatCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsOnlyUnionTypedDict", + Union[ChatCompletionCreateParamsOnlyEnum, str], +) + + +ChatCompletionCreateParamsOnlyUnion = TypeAliasType( + "ChatCompletionCreateParamsOnlyUnion", + Union[ChatCompletionCreateParamsOnlyEnum, str], +) + + +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" + + +ChatCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsIgnoreUnionTypedDict", + Union[ChatCompletionCreateParamsIgnoreEnum, str], +) + + +ChatCompletionCreateParamsIgnoreUnion = TypeAliasType( + "ChatCompletionCreateParamsIgnoreUnion", + Union[ChatCompletionCreateParamsIgnoreEnum, str], +) + + +class ChatCompletionCreateParamsQuantization(str, Enum): + INT4 = "int4" + INT8 = "int8" + FP4 = "fp4" + FP6 = "fp6" + FP8 = "fp8" + FP16 = "fp16" + BF16 = "bf16" + FP32 = "fp32" + UNKNOWN = "unknown" + + +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" + + +ChatCompletionCreateParamsPromptTypedDict = TypeAliasType( + "ChatCompletionCreateParamsPromptTypedDict", Union[float, str, Any] +) + + +ChatCompletionCreateParamsPrompt = TypeAliasType( + "ChatCompletionCreateParamsPrompt", Union[float, str, Any] +) + + +ChatCompletionCreateParamsCompletionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsCompletionTypedDict", 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): + 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] + + +class ChatCompletionCreateParamsMaxPrice(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 + + completion: Optional[ChatCompletionCreateParamsCompletion] = None + + image: Optional[ChatCompletionCreateParamsImage] = None + + audio: Optional[ChatCompletionCreateParamsAudio] = None + + request: Optional[ChatCompletionCreateParamsRequest] = None + + +class ChatCompletionCreateParamsProviderTypedDict(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[ChatCompletionCreateParamsDataCollection]] + 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]]] + 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]]] + 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]]] + 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]]] + r"""A list of quantization levels to filter the provider by.""" + sort: NotRequired[Nullable[ChatCompletionCreateParamsSort]] + 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] + 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): + 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[ChatCompletionCreateParamsDataCollection] = 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 + 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 + 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 + 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 + ) + r"""A list of quantization levels to filter the provider by.""" + + sort: OptionalNullable[ChatCompletionCreateParamsSort] = 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 + 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 ChatCompletionCreateParamsIDFileParser(str, Enum): + FILE_PARSER = "file-parser" + + +class ChatCompletionCreateParamsPdfEngine(str, Enum): + MISTRAL_OCR = "mistral-ocr" + PDF_TEXT = "pdf-text" + NATIVE = "native" + + +class ChatCompletionCreateParamsPdfTypedDict(TypedDict): + engine: NotRequired[ChatCompletionCreateParamsPdfEngine] + + +class ChatCompletionCreateParamsPdf(BaseModel): + engine: Optional[ChatCompletionCreateParamsPdfEngine] = None + + +class ChatCompletionCreateParamsPluginFileParserTypedDict(TypedDict): + id: ChatCompletionCreateParamsIDFileParser + max_files: NotRequired[float] + pdf: NotRequired[ChatCompletionCreateParamsPdfTypedDict] + + +class ChatCompletionCreateParamsPluginFileParser(BaseModel): + id: ChatCompletionCreateParamsIDFileParser + + max_files: Optional[float] = None + + pdf: Optional[ChatCompletionCreateParamsPdf] = None + + +class ChatCompletionCreateParamsIDChainOfThought(str, Enum): + CHAIN_OF_THOUGHT = "chain-of-thought" + + +class ChatCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict): + id: ChatCompletionCreateParamsIDChainOfThought + + +class ChatCompletionCreateParamsPluginChainOfThought(BaseModel): + id: ChatCompletionCreateParamsIDChainOfThought + + +class ChatCompletionCreateParamsIDWeb(str, Enum): + WEB = "web" + + +class ChatCompletionCreateParamsEngine(str, Enum): + NATIVE = "native" + EXA = "exa" + + +class ChatCompletionCreateParamsPluginWebTypedDict(TypedDict): + id: ChatCompletionCreateParamsIDWeb + max_results: NotRequired[float] + search_prompt: NotRequired[str] + engine: NotRequired[ChatCompletionCreateParamsEngine] + + +class ChatCompletionCreateParamsPluginWeb(BaseModel): + id: ChatCompletionCreateParamsIDWeb + + max_results: Optional[float] = None + + search_prompt: Optional[str] = None + + engine: Optional[ChatCompletionCreateParamsEngine] = None + + +class ChatCompletionCreateParamsIDModeration(str, Enum): + MODERATION = "moderation" + + +class ChatCompletionCreateParamsPluginModerationTypedDict(TypedDict): + id: ChatCompletionCreateParamsIDModeration + + +class ChatCompletionCreateParamsPluginModeration(BaseModel): + id: ChatCompletionCreateParamsIDModeration + + +ChatCompletionCreateParamsPluginUnionTypedDict = TypeAliasType( + "ChatCompletionCreateParamsPluginUnionTypedDict", + Union[ + ChatCompletionCreateParamsPluginModerationTypedDict, + ChatCompletionCreateParamsPluginChainOfThoughtTypedDict, + ChatCompletionCreateParamsPluginFileParserTypedDict, + ChatCompletionCreateParamsPluginWebTypedDict, + ], +) + + +ChatCompletionCreateParamsPluginUnion = TypeAliasType( + "ChatCompletionCreateParamsPluginUnion", + Union[ + ChatCompletionCreateParamsPluginModeration, + ChatCompletionCreateParamsPluginChainOfThought, + ChatCompletionCreateParamsPluginFileParser, + ChatCompletionCreateParamsPluginWeb, + ], +) + + +class ChatCompletionCreateParamsTypedDict(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[ChatCompletionCreateParamsReasoningTypedDict]] + r"""Reasoning configuration""" + response_format: NotRequired[ChatCompletionCreateParamsResponseFormatUnionTypedDict] + r"""Response format configuration""" + seed: NotRequired[Nullable[int]] + r"""Random seed for deterministic outputs""" + stop: NotRequired[Nullable[ChatCompletionCreateParamsStopTypedDict]] + r"""Stop sequences (up to 4)""" + stream: NotRequired[Nullable[bool]] + r"""Enable streaming response""" + stream_options: NotRequired[ + Nullable[ChatCompletionCreateParamsStreamOptionsTypedDict] + ] + 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[ChatCompletionCreateParamsReasoningEffort]] + r"""Reasoning effort""" + provider: NotRequired[Nullable[ChatCompletionCreateParamsProviderTypedDict]] + r"""When multiple model providers are available, optionally indicate your routing preference.""" + plugins: NotRequired[List[ChatCompletionCreateParamsPluginUnionTypedDict]] + r"""Plugins you want to enable for this request, including their settings.""" + + +class ChatCompletionCreateParams(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[ChatCompletionCreateParamsReasoning] = UNSET + r"""Reasoning configuration""" + + response_format: Optional[ChatCompletionCreateParamsResponseFormatUnion] = None + r"""Response format configuration""" + + seed: OptionalNullable[int] = UNSET + r"""Random seed for deterministic outputs""" + + stop: OptionalNullable[ChatCompletionCreateParamsStop] = UNSET + r"""Stop sequences (up to 4)""" + + stream: OptionalNullable[bool] = False + r"""Enable streaming response""" + + stream_options: OptionalNullable[ChatCompletionCreateParamsStreamOptions] = 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[ChatCompletionCreateParamsReasoningEffort] = ( + UNSET + ) + r"""Reasoning effort""" + + provider: OptionalNullable[ChatCompletionCreateParamsProvider] = UNSET + r"""When multiple model providers are available, optionally indicate your routing preference.""" + + plugins: Optional[List[ChatCompletionCreateParamsPluginUnion]] = 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", + "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/chatcompletionerror.py b/src/openrouter/models/chatcompletionerror.py new file mode 100644 index 0000000..55a07b6 --- /dev/null +++ b/src/openrouter/models/chatcompletionerror.py @@ -0,0 +1,57 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL +from pydantic import model_serializer +from typing_extensions import TypedDict + + +class ErrorTypedDict(TypedDict): + r"""Error object structure""" + + code: Nullable[str] + message: str + param: Nullable[str] + type: str + + +class Error(BaseModel): + r"""Error object structure""" + + code: Nullable[str] + + message: str + + param: Nullable[str] + + type: str + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [] + nullable_fields = ["code", "param"] + 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/chatcompletionmessage.py b/src/openrouter/models/chatcompletionmessage.py new file mode 100644 index 0000000..b4a0c08 --- /dev/null +++ b/src/openrouter/models/chatcompletionmessage.py @@ -0,0 +1,101 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .annotationdetail import AnnotationDetail, AnnotationDetailTypedDict +from .chatcompletionmessagetoolcall import ( + ChatCompletionMessageToolCall, + ChatCompletionMessageToolCallTypedDict, +) +from .reasoningdetail import ReasoningDetail, ReasoningDetailTypedDict +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import List, Optional +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionMessageRole(str, Enum): + ASSISTANT = "assistant" + + +class ChatCompletionMessageTypedDict(TypedDict): + r"""Assistant message in completion response""" + + role: ChatCompletionMessageRole + content: Nullable[str] + r"""Message content""" + refusal: Nullable[str] + r"""Refusal message if content was refused""" + reasoning: NotRequired[Nullable[str]] + r"""Reasoning output""" + tool_calls: NotRequired[List[ChatCompletionMessageToolCallTypedDict]] + r"""Tool calls made by the assistant""" + reasoning_details: NotRequired[List[ReasoningDetailTypedDict]] + r"""Reasoning details delta to send reasoning details back to upstream""" + annotations: NotRequired[List[AnnotationDetailTypedDict]] + r"""Annotations delta to send annotations back to upstream""" + + +class ChatCompletionMessage(BaseModel): + r"""Assistant message in completion response""" + + role: ChatCompletionMessageRole + + content: Nullable[str] + r"""Message content""" + + refusal: Nullable[str] + r"""Refusal message if content was refused""" + + reasoning: OptionalNullable[str] = UNSET + r"""Reasoning output""" + + tool_calls: Optional[List[ChatCompletionMessageToolCall]] = None + r"""Tool calls made by the assistant""" + + reasoning_details: Optional[List[ReasoningDetail]] = None + r"""Reasoning details delta to send reasoning details back to upstream""" + + annotations: Optional[List[AnnotationDetail]] = None + r"""Annotations delta to send annotations back to upstream""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [ + "reasoning", + "tool_calls", + "reasoning_details", + "annotations", + ] + nullable_fields = ["content", "reasoning", "refusal"] + 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/chatcompletionmessageparam.py b/src/openrouter/models/chatcompletionmessageparam.py new file mode 100644 index 0000000..27eb870 --- /dev/null +++ b/src/openrouter/models/chatcompletionmessageparam.py @@ -0,0 +1,47 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionassistantmessageparam import ( + ChatCompletionAssistantMessageParam, + ChatCompletionAssistantMessageParamTypedDict, +) +from .chatcompletionsystemmessageparam import ( + ChatCompletionSystemMessageParam, + ChatCompletionSystemMessageParamTypedDict, +) +from .chatcompletiontoolmessageparam import ( + ChatCompletionToolMessageParam, + ChatCompletionToolMessageParamTypedDict, +) +from .chatcompletionusermessageparam import ( + ChatCompletionUserMessageParam, + ChatCompletionUserMessageParamTypedDict, +) +from openrouter.utils import get_discriminator +from pydantic import Discriminator, Tag +from typing import Union +from typing_extensions import Annotated, TypeAliasType + + +ChatCompletionMessageParamTypedDict = TypeAliasType( + "ChatCompletionMessageParamTypedDict", + Union[ + ChatCompletionSystemMessageParamTypedDict, + ChatCompletionUserMessageParamTypedDict, + ChatCompletionToolMessageParamTypedDict, + ChatCompletionAssistantMessageParamTypedDict, + ], +) +r"""Chat completion message with role-based discrimination""" + + +ChatCompletionMessageParam = Annotated[ + Union[ + Annotated[ChatCompletionSystemMessageParam, Tag("system")], + Annotated[ChatCompletionUserMessageParam, Tag("user")], + Annotated[ChatCompletionAssistantMessageParam, Tag("assistant")], + Annotated[ChatCompletionToolMessageParam, Tag("tool")], + ], + Discriminator(lambda m: get_discriminator(m, "role", "role")), +] +r"""Chat completion message with role-based discrimination""" diff --git a/src/openrouter/models/chatcompletionmessagetoolcall.py b/src/openrouter/models/chatcompletionmessagetoolcall.py new file mode 100644 index 0000000..cb94229 --- /dev/null +++ b/src/openrouter/models/chatcompletionmessagetoolcall.py @@ -0,0 +1,45 @@ +"""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_extensions import TypedDict + + +class ChatCompletionMessageToolCallType(str, Enum): + FUNCTION = "function" + + +class ChatCompletionMessageToolCallFunctionTypedDict(TypedDict): + name: str + r"""Function name to call""" + arguments: str + r"""Function arguments as JSON string""" + + +class ChatCompletionMessageToolCallFunction(BaseModel): + name: str + r"""Function name to call""" + + arguments: str + r"""Function arguments as JSON string""" + + +class ChatCompletionMessageToolCallTypedDict(TypedDict): + r"""Tool call made by the assistant""" + + id: str + r"""Tool call identifier""" + type: ChatCompletionMessageToolCallType + function: ChatCompletionMessageToolCallFunctionTypedDict + + +class ChatCompletionMessageToolCall(BaseModel): + r"""Tool call made by the assistant""" + + id: str + r"""Tool call identifier""" + + type: ChatCompletionMessageToolCallType + + function: ChatCompletionMessageToolCallFunction diff --git a/src/openrouter/models/chatcompletionnamedtoolchoice.py b/src/openrouter/models/chatcompletionnamedtoolchoice.py new file mode 100644 index 0000000..bf2b838 --- /dev/null +++ b/src/openrouter/models/chatcompletionnamedtoolchoice.py @@ -0,0 +1,35 @@ +"""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_extensions import TypedDict + + +class ChatCompletionNamedToolChoiceType(str, Enum): + FUNCTION = "function" + + +class ChatCompletionNamedToolChoiceFunctionTypedDict(TypedDict): + name: str + r"""Function name to call""" + + +class ChatCompletionNamedToolChoiceFunction(BaseModel): + name: str + r"""Function name to call""" + + +class ChatCompletionNamedToolChoiceTypedDict(TypedDict): + r"""Named tool choice for specific function""" + + type: ChatCompletionNamedToolChoiceType + function: ChatCompletionNamedToolChoiceFunctionTypedDict + + +class ChatCompletionNamedToolChoice(BaseModel): + r"""Named tool choice for specific function""" + + type: ChatCompletionNamedToolChoiceType + + function: ChatCompletionNamedToolChoiceFunction diff --git a/src/openrouter/models/chatcompletionsystemmessageparam.py b/src/openrouter/models/chatcompletionsystemmessageparam.py new file mode 100644 index 0000000..a60f0a9 --- /dev/null +++ b/src/openrouter/models/chatcompletionsystemmessageparam.py @@ -0,0 +1,51 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletioncontentparttext import ( + ChatCompletionContentPartText, + ChatCompletionContentPartTextTypedDict, +) +from enum import Enum +from openrouter.types import BaseModel +from typing import List, Optional, Union +from typing_extensions import NotRequired, TypeAliasType, TypedDict + + +class ChatCompletionSystemMessageParamRole(str, Enum): + SYSTEM = "system" + + +ChatCompletionSystemMessageParamContentTypedDict = TypeAliasType( + "ChatCompletionSystemMessageParamContentTypedDict", + Union[str, List[ChatCompletionContentPartTextTypedDict]], +) +r"""System message content""" + + +ChatCompletionSystemMessageParamContent = TypeAliasType( + "ChatCompletionSystemMessageParamContent", + Union[str, List[ChatCompletionContentPartText]], +) +r"""System message content""" + + +class ChatCompletionSystemMessageParamTypedDict(TypedDict): + r"""System message for setting behavior""" + + role: ChatCompletionSystemMessageParamRole + content: ChatCompletionSystemMessageParamContentTypedDict + r"""System message content""" + name: NotRequired[str] + r"""Optional name for the system message""" + + +class ChatCompletionSystemMessageParam(BaseModel): + r"""System message for setting behavior""" + + role: ChatCompletionSystemMessageParamRole + + content: ChatCompletionSystemMessageParamContent + r"""System message content""" + + name: Optional[str] = None + r"""Optional name for the system message""" diff --git a/src/openrouter/models/chatcompletiontokenlogprob.py b/src/openrouter/models/chatcompletiontokenlogprob.py new file mode 100644 index 0000000..eaea44f --- /dev/null +++ b/src/openrouter/models/chatcompletiontokenlogprob.py @@ -0,0 +1,111 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL +import pydantic +from pydantic import model_serializer +from typing import List +from typing_extensions import Annotated, TypedDict + + +class TopLogprobTypedDict(TypedDict): + token: str + logprob: float + bytes_: Nullable[List[float]] + + +class TopLogprob(BaseModel): + token: str + + logprob: float + + bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")] + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [] + nullable_fields = ["bytes"] + 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 ChatCompletionTokenLogprobTypedDict(TypedDict): + r"""Token log probability information""" + + token: str + r"""The token""" + logprob: float + r"""Log probability of the token""" + bytes_: Nullable[List[float]] + r"""UTF-8 bytes of the token""" + top_logprobs: List[TopLogprobTypedDict] + r"""Top alternative tokens with probabilities""" + + +class ChatCompletionTokenLogprob(BaseModel): + r"""Token log probability information""" + + token: str + r"""The token""" + + logprob: float + r"""Log probability of the token""" + + bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")] + r"""UTF-8 bytes of the token""" + + top_logprobs: List[TopLogprob] + r"""Top alternative tokens with probabilities""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [] + nullable_fields = ["bytes"] + 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/chatcompletiontokenlogprobs.py b/src/openrouter/models/chatcompletiontokenlogprobs.py new file mode 100644 index 0000000..3642450 --- /dev/null +++ b/src/openrouter/models/chatcompletiontokenlogprobs.py @@ -0,0 +1,60 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletiontokenlogprob import ( + ChatCompletionTokenLogprob, + ChatCompletionTokenLogprobTypedDict, +) +from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL +from pydantic import model_serializer +from typing import List +from typing_extensions import TypedDict + + +class ChatCompletionTokenLogprobsTypedDict(TypedDict): + r"""Log probabilities for the completion""" + + content: Nullable[List[ChatCompletionTokenLogprobTypedDict]] + r"""Log probabilities for content tokens""" + refusal: Nullable[List[ChatCompletionTokenLogprobTypedDict]] + r"""Log probabilities for refusal tokens""" + + +class ChatCompletionTokenLogprobs(BaseModel): + r"""Log probabilities for the completion""" + + content: Nullable[List[ChatCompletionTokenLogprob]] + r"""Log probabilities for content tokens""" + + refusal: Nullable[List[ChatCompletionTokenLogprob]] + r"""Log probabilities for refusal tokens""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = [] + nullable_fields = ["content", "refusal"] + 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/chatcompletiontool.py b/src/openrouter/models/chatcompletiontool.py new file mode 100644 index 0000000..294f401 --- /dev/null +++ b/src/openrouter/models/chatcompletiontool.py @@ -0,0 +1,102 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +from pydantic import model_serializer +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class ChatCompletionToolType(str, Enum): + FUNCTION = "function" + + +class ParametersTypedDict(TypedDict): + r"""Function parameters as JSON Schema object""" + + +class Parameters(BaseModel): + r"""Function parameters as JSON Schema object""" + + +class ChatCompletionToolFunctionTypedDict(TypedDict): + r"""Function definition for tool calling""" + + name: str + r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" + description: NotRequired[str] + r"""Function description for the model""" + parameters: NotRequired[ParametersTypedDict] + r"""Function parameters as JSON Schema object""" + strict: NotRequired[Nullable[bool]] + r"""Enable strict schema adherence""" + + +class ChatCompletionToolFunction(BaseModel): + r"""Function definition for tool calling""" + + name: str + r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)""" + + description: Optional[str] = None + r"""Function description for the model""" + + parameters: Optional[Parameters] = None + r"""Function parameters as JSON Schema object""" + + strict: OptionalNullable[bool] = UNSET + r"""Enable strict schema adherence""" + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["description", "parameters", "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 ChatCompletionToolTypedDict(TypedDict): + r"""Tool definition for function calling""" + + type: ChatCompletionToolType + function: ChatCompletionToolFunctionTypedDict + r"""Function definition for tool calling""" + + +class ChatCompletionTool(BaseModel): + r"""Tool definition for function calling""" + + type: ChatCompletionToolType + + function: ChatCompletionToolFunction + r"""Function definition for tool calling""" diff --git a/src/openrouter/models/chatcompletiontoolchoiceoption.py b/src/openrouter/models/chatcompletiontoolchoiceoption.py new file mode 100644 index 0000000..a8596ee --- /dev/null +++ b/src/openrouter/models/chatcompletiontoolchoiceoption.py @@ -0,0 +1,46 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionnamedtoolchoice import ( + ChatCompletionNamedToolChoice, + ChatCompletionNamedToolChoiceTypedDict, +) +from enum import Enum +from typing import Union +from typing_extensions import TypeAliasType + + +class ChatCompletionToolChoiceOptionRequired(str, Enum): + REQUIRED = "required" + + +class ChatCompletionToolChoiceOptionAuto(str, Enum): + AUTO = "auto" + + +class ChatCompletionToolChoiceOptionNone(str, Enum): + NONE = "none" + + +ChatCompletionToolChoiceOptionTypedDict = TypeAliasType( + "ChatCompletionToolChoiceOptionTypedDict", + Union[ + ChatCompletionNamedToolChoiceTypedDict, + ChatCompletionToolChoiceOptionNone, + ChatCompletionToolChoiceOptionAuto, + ChatCompletionToolChoiceOptionRequired, + ], +) +r"""Tool choice configuration""" + + +ChatCompletionToolChoiceOption = TypeAliasType( + "ChatCompletionToolChoiceOption", + Union[ + ChatCompletionNamedToolChoice, + ChatCompletionToolChoiceOptionNone, + ChatCompletionToolChoiceOptionAuto, + ChatCompletionToolChoiceOptionRequired, + ], +) +r"""Tool choice configuration""" diff --git a/src/openrouter/models/chatcompletiontoolmessageparam.py b/src/openrouter/models/chatcompletiontoolmessageparam.py new file mode 100644 index 0000000..0da1087 --- /dev/null +++ b/src/openrouter/models/chatcompletiontoolmessageparam.py @@ -0,0 +1,50 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletioncontentpart import ( + ChatCompletionContentPart, + ChatCompletionContentPartTypedDict, +) +from enum import Enum +from openrouter.types import BaseModel +from typing import List, Union +from typing_extensions import TypeAliasType, TypedDict + + +class ChatCompletionToolMessageParamRole(str, Enum): + TOOL = "tool" + + +ChatCompletionToolMessageParamContentTypedDict = TypeAliasType( + "ChatCompletionToolMessageParamContentTypedDict", + Union[str, List[ChatCompletionContentPartTypedDict]], +) +r"""Tool response content""" + + +ChatCompletionToolMessageParamContent = TypeAliasType( + "ChatCompletionToolMessageParamContent", Union[str, List[ChatCompletionContentPart]] +) +r"""Tool response content""" + + +class ChatCompletionToolMessageParamTypedDict(TypedDict): + r"""Tool response message""" + + role: ChatCompletionToolMessageParamRole + content: ChatCompletionToolMessageParamContentTypedDict + r"""Tool response content""" + tool_call_id: str + r"""ID of the tool call this message responds to""" + + +class ChatCompletionToolMessageParam(BaseModel): + r"""Tool response message""" + + role: ChatCompletionToolMessageParamRole + + content: ChatCompletionToolMessageParamContent + r"""Tool response content""" + + tool_call_id: str + r"""ID of the tool call this message responds to""" diff --git a/src/openrouter/models/chatcompletionusermessageparam.py b/src/openrouter/models/chatcompletionusermessageparam.py new file mode 100644 index 0000000..b2dd0b0 --- /dev/null +++ b/src/openrouter/models/chatcompletionusermessageparam.py @@ -0,0 +1,50 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletioncontentpart import ( + ChatCompletionContentPart, + ChatCompletionContentPartTypedDict, +) +from enum import Enum +from openrouter.types import BaseModel +from typing import List, Optional, Union +from typing_extensions import NotRequired, TypeAliasType, TypedDict + + +class ChatCompletionUserMessageParamRole(str, Enum): + USER = "user" + + +ChatCompletionUserMessageParamContentTypedDict = TypeAliasType( + "ChatCompletionUserMessageParamContentTypedDict", + Union[str, List[ChatCompletionContentPartTypedDict]], +) +r"""User message content""" + + +ChatCompletionUserMessageParamContent = TypeAliasType( + "ChatCompletionUserMessageParamContent", Union[str, List[ChatCompletionContentPart]] +) +r"""User message content""" + + +class ChatCompletionUserMessageParamTypedDict(TypedDict): + r"""User message""" + + role: ChatCompletionUserMessageParamRole + content: ChatCompletionUserMessageParamContentTypedDict + r"""User message content""" + name: NotRequired[str] + r"""Optional name for the user""" + + +class ChatCompletionUserMessageParam(BaseModel): + r"""User message""" + + role: ChatCompletionUserMessageParamRole + + content: ChatCompletionUserMessageParamContent + r"""User message content""" + + name: Optional[str] = None + r"""Optional name for the user""" diff --git a/src/openrouter/models/chatstreamcompletioncreateparams.py b/src/openrouter/models/chatstreamcompletioncreateparams.py new file mode 100644 index 0000000..45f0faf --- /dev/null +++ b/src/openrouter/models/chatstreamcompletioncreateparams.py @@ -0,0 +1,1139 @@ +"""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/completionusage.py b/src/openrouter/models/completionusage.py new file mode 100644 index 0000000..74ce8bd --- /dev/null +++ b/src/openrouter/models/completionusage.py @@ -0,0 +1,88 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel +from typing import Optional +from typing_extensions import NotRequired, TypedDict + + +class CompletionTokensDetailsTypedDict(TypedDict): + r"""Detailed completion token usage""" + + reasoning_tokens: NotRequired[float] + r"""Tokens used for reasoning""" + audio_tokens: NotRequired[float] + r"""Tokens used for audio output""" + accepted_prediction_tokens: NotRequired[float] + r"""Accepted prediction tokens""" + rejected_prediction_tokens: NotRequired[float] + r"""Rejected prediction tokens""" + + +class CompletionTokensDetails(BaseModel): + r"""Detailed completion token usage""" + + reasoning_tokens: Optional[float] = None + r"""Tokens used for reasoning""" + + audio_tokens: Optional[float] = None + r"""Tokens used for audio output""" + + accepted_prediction_tokens: Optional[float] = None + r"""Accepted prediction tokens""" + + rejected_prediction_tokens: Optional[float] = None + r"""Rejected prediction tokens""" + + +class PromptTokensDetailsTypedDict(TypedDict): + r"""Detailed prompt token usage""" + + cached_tokens: NotRequired[float] + r"""Cached prompt tokens""" + audio_tokens: NotRequired[float] + r"""Audio input tokens""" + + +class PromptTokensDetails(BaseModel): + r"""Detailed prompt token usage""" + + cached_tokens: Optional[float] = None + r"""Cached prompt tokens""" + + audio_tokens: Optional[float] = None + r"""Audio input tokens""" + + +class CompletionUsageTypedDict(TypedDict): + r"""Token usage statistics""" + + completion_tokens: float + r"""Number of tokens in the completion""" + prompt_tokens: float + r"""Number of tokens in the prompt""" + total_tokens: float + r"""Total number of tokens""" + completion_tokens_details: NotRequired[CompletionTokensDetailsTypedDict] + r"""Detailed completion token usage""" + prompt_tokens_details: NotRequired[PromptTokensDetailsTypedDict] + r"""Detailed prompt token usage""" + + +class CompletionUsage(BaseModel): + r"""Token usage statistics""" + + completion_tokens: float + r"""Number of tokens in the completion""" + + prompt_tokens: float + r"""Number of tokens in the prompt""" + + total_tokens: float + r"""Total number of tokens""" + + completion_tokens_details: Optional[CompletionTokensDetails] = None + r"""Detailed completion token usage""" + + prompt_tokens_details: Optional[PromptTokensDetails] = None + r"""Detailed prompt token usage""" diff --git a/src/openrouter/models/fileannotationdetail.py b/src/openrouter/models/fileannotationdetail.py new file mode 100644 index 0000000..a255f7d --- /dev/null +++ b/src/openrouter/models/fileannotationdetail.py @@ -0,0 +1,89 @@ +"""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_extensions import NotRequired, TypeAliasType, TypedDict + + +class TypeFile(str, Enum): + FILE = "file" + + +class ContentTypeImageURL(str, Enum): + IMAGE_URL = "image_url" + + +class FileAnnotationDetailImageURLTypedDict(TypedDict): + url: str + + +class FileAnnotationDetailImageURL(BaseModel): + url: str + + +class ContentImageURLTypedDict(TypedDict): + type: ContentTypeImageURL + image_url: FileAnnotationDetailImageURLTypedDict + + +class ContentImageURL(BaseModel): + type: ContentTypeImageURL + + image_url: FileAnnotationDetailImageURL + + +class ContentTypeText(str, Enum): + TEXT = "text" + + +class ContentTextTypedDict(TypedDict): + type: ContentTypeText + text: str + + +class ContentText(BaseModel): + type: ContentTypeText + + text: str + + +FileAnnotationDetailContentUnionTypedDict = TypeAliasType( + "FileAnnotationDetailContentUnionTypedDict", + Union[ContentTextTypedDict, ContentImageURLTypedDict], +) + + +FileAnnotationDetailContentUnion = TypeAliasType( + "FileAnnotationDetailContentUnion", Union[ContentText, ContentImageURL] +) + + +class FileTypedDict(TypedDict): + hash: str + content: List[FileAnnotationDetailContentUnionTypedDict] + name: NotRequired[str] + + +class File(BaseModel): + hash: str + + content: List[FileAnnotationDetailContentUnion] + + name: Optional[str] = None + + +class FileAnnotationDetailTypedDict(TypedDict): + r"""File annotation with content""" + + type: TypeFile + file: FileTypedDict + + +class FileAnnotationDetail(BaseModel): + r"""File annotation with content""" + + type: TypeFile + + file: File diff --git a/src/openrouter/models/reasoningdetail.py b/src/openrouter/models/reasoningdetail.py new file mode 100644 index 0000000..645ac0c --- /dev/null +++ b/src/openrouter/models/reasoningdetail.py @@ -0,0 +1,38 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .reasoningdetailencrypted import ( + ReasoningDetailEncrypted, + ReasoningDetailEncryptedTypedDict, +) +from .reasoningdetailsummary import ( + ReasoningDetailSummary, + ReasoningDetailSummaryTypedDict, +) +from .reasoningdetailtext import ReasoningDetailText, ReasoningDetailTextTypedDict +from openrouter.utils import get_discriminator +from pydantic import Discriminator, Tag +from typing import Union +from typing_extensions import Annotated, TypeAliasType + + +ReasoningDetailTypedDict = TypeAliasType( + "ReasoningDetailTypedDict", + Union[ + ReasoningDetailSummaryTypedDict, + ReasoningDetailEncryptedTypedDict, + ReasoningDetailTextTypedDict, + ], +) +r"""Reasoning detail information""" + + +ReasoningDetail = Annotated[ + Union[ + Annotated[ReasoningDetailSummary, Tag("reasoning.summary")], + Annotated[ReasoningDetailEncrypted, Tag("reasoning.encrypted")], + Annotated[ReasoningDetailText, Tag("reasoning.text")], + ], + Discriminator(lambda m: get_discriminator(m, "type", "type")), +] +r"""Reasoning detail information""" diff --git a/src/openrouter/models/reasoningdetailencrypted.py b/src/openrouter/models/reasoningdetailencrypted.py new file mode 100644 index 0000000..4008622 --- /dev/null +++ b/src/openrouter/models/reasoningdetailencrypted.py @@ -0,0 +1,81 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class ReasoningDetailEncryptedType(str, Enum): + REASONING_ENCRYPTED = "reasoning.encrypted" + + +class ReasoningDetailEncryptedFormat(str, Enum): + UNKNOWN = "unknown" + OPENAI_RESPONSES_V1 = "openai-responses-v1" + ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" + + +class ReasoningDetailEncryptedTypedDict(TypedDict): + r"""Encrypted reasoning detail""" + + type: ReasoningDetailEncryptedType + data: str + id: NotRequired[Nullable[str]] + format_: NotRequired[Nullable[ReasoningDetailEncryptedFormat]] + index: NotRequired[float] + + +class ReasoningDetailEncrypted(BaseModel): + r"""Encrypted reasoning detail""" + + type: ReasoningDetailEncryptedType + + data: str + + id: OptionalNullable[str] = UNSET + + format_: Annotated[ + OptionalNullable[ReasoningDetailEncryptedFormat], pydantic.Field(alias="format") + ] = ReasoningDetailEncryptedFormat.ANTHROPIC_CLAUDE_V1 + + index: Optional[float] = None + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["id", "format", "index"] + nullable_fields = ["id", "format"] + 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/reasoningdetailsummary.py b/src/openrouter/models/reasoningdetailsummary.py new file mode 100644 index 0000000..03faaaf --- /dev/null +++ b/src/openrouter/models/reasoningdetailsummary.py @@ -0,0 +1,81 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class ReasoningDetailSummaryType(str, Enum): + REASONING_SUMMARY = "reasoning.summary" + + +class ReasoningDetailSummaryFormat(str, Enum): + UNKNOWN = "unknown" + OPENAI_RESPONSES_V1 = "openai-responses-v1" + ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" + + +class ReasoningDetailSummaryTypedDict(TypedDict): + r"""Reasoning summary detail""" + + type: ReasoningDetailSummaryType + summary: str + id: NotRequired[Nullable[str]] + format_: NotRequired[Nullable[ReasoningDetailSummaryFormat]] + index: NotRequired[float] + + +class ReasoningDetailSummary(BaseModel): + r"""Reasoning summary detail""" + + type: ReasoningDetailSummaryType + + summary: str + + id: OptionalNullable[str] = UNSET + + format_: Annotated[ + OptionalNullable[ReasoningDetailSummaryFormat], pydantic.Field(alias="format") + ] = ReasoningDetailSummaryFormat.ANTHROPIC_CLAUDE_V1 + + index: Optional[float] = None + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["id", "format", "index"] + nullable_fields = ["id", "format"] + 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/reasoningdetailtext.py b/src/openrouter/models/reasoningdetailtext.py new file mode 100644 index 0000000..acecee1 --- /dev/null +++ b/src/openrouter/models/reasoningdetailtext.py @@ -0,0 +1,84 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from enum import Enum +from openrouter.types import ( + BaseModel, + Nullable, + OptionalNullable, + UNSET, + UNSET_SENTINEL, +) +import pydantic +from pydantic import model_serializer +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class ReasoningDetailTextType(str, Enum): + REASONING_TEXT = "reasoning.text" + + +class ReasoningDetailTextFormat(str, Enum): + UNKNOWN = "unknown" + OPENAI_RESPONSES_V1 = "openai-responses-v1" + ANTHROPIC_CLAUDE_V1 = "anthropic-claude-v1" + + +class ReasoningDetailTextTypedDict(TypedDict): + r"""Text reasoning detail""" + + type: ReasoningDetailTextType + text: NotRequired[Nullable[str]] + signature: NotRequired[Nullable[str]] + id: NotRequired[Nullable[str]] + format_: NotRequired[Nullable[ReasoningDetailTextFormat]] + index: NotRequired[float] + + +class ReasoningDetailText(BaseModel): + r"""Text reasoning detail""" + + type: ReasoningDetailTextType + + text: OptionalNullable[str] = UNSET + + signature: OptionalNullable[str] = UNSET + + id: OptionalNullable[str] = UNSET + + format_: Annotated[ + OptionalNullable[ReasoningDetailTextFormat], pydantic.Field(alias="format") + ] = ReasoningDetailTextFormat.ANTHROPIC_CLAUDE_V1 + + index: Optional[float] = None + + @model_serializer(mode="wrap") + def serialize_model(self, handler): + optional_fields = ["text", "signature", "id", "format", "index"] + nullable_fields = ["text", "signature", "id", "format"] + 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/responseformatjsonschemaschema.py b/src/openrouter/models/responseformatjsonschemaschema.py new file mode 100644 index 0000000..0857feb --- /dev/null +++ b/src/openrouter/models/responseformatjsonschemaschema.py @@ -0,0 +1,13 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel +from typing_extensions import TypedDict + + +class ResponseFormatJSONSchemaSchemaTypedDict(TypedDict): + r"""The schema for the response format, described as a JSON Schema object""" + + +class ResponseFormatJSONSchemaSchema(BaseModel): + r"""The schema for the response format, described as a JSON Schema object""" diff --git a/src/openrouter/models/security.py b/src/openrouter/models/security.py new file mode 100644 index 0000000..6a22017 --- /dev/null +++ b/src/openrouter/models/security.py @@ -0,0 +1,25 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from openrouter.types import BaseModel +from openrouter.utils import FieldMetadata, SecurityMetadata +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class SecurityTypedDict(TypedDict): + bearer_auth: NotRequired[str] + + +class Security(BaseModel): + bearer_auth: Annotated[ + Optional[str], + FieldMetadata( + security=SecurityMetadata( + scheme=True, + scheme_type="http", + sub_type="bearer", + field_name="Authorization", + ) + ), + ] = None diff --git a/src/openrouter/models/streamchatcompletionop.py b/src/openrouter/models/streamchatcompletionop.py new file mode 100644 index 0000000..289f952 --- /dev/null +++ b/src/openrouter/models/streamchatcompletionop.py @@ -0,0 +1,20 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from .chatcompletionchunk import ChatCompletionChunk, ChatCompletionChunkTypedDict +from openrouter.types import BaseModel +from typing_extensions import TypedDict + + +class StreamChatCompletionResponseBodyTypedDict(TypedDict): + r"""Successful chat completion response""" + + data: ChatCompletionChunkTypedDict + r"""Streaming chat completion chunk""" + + +class StreamChatCompletionResponseBody(BaseModel): + r"""Successful chat completion response""" + + data: ChatCompletionChunk + r"""Streaming chat completion chunk""" diff --git a/src/openrouter/models/urlcitationannotationdetail.py b/src/openrouter/models/urlcitationannotationdetail.py new file mode 100644 index 0000000..76bd092 --- /dev/null +++ b/src/openrouter/models/urlcitationannotationdetail.py @@ -0,0 +1,46 @@ +"""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_extensions import NotRequired, TypedDict + + +class URLCitationAnnotationDetailType(str, Enum): + URL_CITATION = "url_citation" + + +class URLCitationTypedDict(TypedDict): + end_index: float + start_index: float + title: str + url: str + content: NotRequired[str] + + +class URLCitation(BaseModel): + end_index: float + + start_index: float + + title: str + + url: str + + content: Optional[str] = None + + +class URLCitationAnnotationDetailTypedDict(TypedDict): + r"""URL citation annotation""" + + type: URLCitationAnnotationDetailType + url_citation: URLCitationTypedDict + + +class URLCitationAnnotationDetail(BaseModel): + r"""URL citation annotation""" + + type: URLCitationAnnotationDetailType + + url_citation: URLCitation diff --git a/src/openrouter/py.typed b/src/openrouter/py.typed new file mode 100644 index 0000000..3e38f1a --- /dev/null +++ b/src/openrouter/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. The package enables type hints. diff --git a/src/openrouter/sdk.py b/src/openrouter/sdk.py new file mode 100644 index 0000000..0c3ad16 --- /dev/null +++ b/src/openrouter/sdk.py @@ -0,0 +1,174 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from .basesdk import BaseSDK +from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients +from .sdkconfiguration import SDKConfiguration +from .utils.logger import Logger, get_default_logger +from .utils.retries import RetryConfig +import httpx +import importlib +from openrouter import models, utils +from openrouter._hooks import SDKHooks +from openrouter.types import OptionalNullable, UNSET +from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union, cast +import weakref + +if TYPE_CHECKING: + from openrouter.chat import Chat + + +class OpenRouter(BaseSDK): + r"""OpenRouter Chat Completions API: OpenAI-compatible Chat Completions API with additional OpenRouter features + https://openrouter.ai/docs - OpenRouter Documentation + """ + + 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, + provider_url: Optional[str] = None, + server_idx: Optional[int] = None, + server_url: Optional[str] = None, + url_params: Optional[Dict[str, str]] = None, + client: Optional[HttpClient] = None, + async_client: Optional[AsyncHttpClient] = None, + retry_config: OptionalNullable[RetryConfig] = UNSET, + timeout_ms: Optional[int] = None, + debug_logger: Optional[Logger] = None, + ) -> None: + r"""Instantiates the SDK configuring it with the provided parameters. + + :param bearer_auth: The bearer_auth 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 + :param url_params: Parameters to optionally template the server URL with + :param client: The HTTP client to use for all synchronous methods + :param async_client: The Async HTTP client to use for all asynchronous methods + :param retry_config: The retry configuration to use for all supported methods + :param timeout_ms: Optional request timeout applied to each operation in milliseconds + """ + client_supplied = True + if client is None: + client = httpx.Client() + client_supplied = False + + assert issubclass( + type(client), HttpClient + ), "The provided client must implement the HttpClient protocol." + + async_client_supplied = True + if async_client is None: + async_client = httpx.AsyncClient() + async_client_supplied = False + + if debug_logger is None: + debug_logger = get_default_logger() + + assert issubclass( + type(async_client), AsyncHttpClient + ), "The provided async_client must implement the AsyncHttpClient protocol." + + security: Any = None + if callable(bearer_auth): + # pylint: disable=unnecessary-lambda-assignment + security = lambda: models.Security(bearer_auth=bearer_auth()) + else: + security = models.Security(bearer_auth=bearer_auth) + + if server_url is not None: + if url_params is not None: + server_url = utils.template_url(server_url, url_params) + server_defaults: List[Dict[str, str]] = [ + { + "provider_url": provider_url or "openrouter.ai", + }, + ] + + BaseSDK.__init__( + self, + SDKConfiguration( + client=client, + client_supplied=client_supplied, + async_client=async_client, + async_client_supplied=async_client_supplied, + security=security, + server_url=server_url, + server_idx=server_idx, + server_defaults=server_defaults, + retry_config=retry_config, + timeout_ms=timeout_ms, + debug_logger=debug_logger, + ), + ) + + hooks = SDKHooks() + + # pylint: disable=protected-access + self.sdk_configuration.__dict__["_hooks"] = hooks + + self.sdk_configuration = hooks.sdk_init(self.sdk_configuration) + + weakref.finalize( + self, + close_clients, + cast(ClientOwner, self.sdk_configuration), + self.sdk_configuration.client, + self.sdk_configuration.client_supplied, + self.sdk_configuration.async_client, + self.sdk_configuration.async_client_supplied, + ) + + 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) + klass = getattr(module, class_name) + instance = klass(self.sdk_configuration) + setattr(self, name, instance) + return instance + except ImportError as e: + raise AttributeError( + f"Failed to import module {module_path} for attribute {name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to find class {class_name} in module {module_path} for attribute {name}: {e}" + ) from e + + raise AttributeError( + f"'{type(self).__name__}' object has no attribute '{name}'" + ) + + def __dir__(self): + default_attrs = list(super().__dir__()) + lazy_attrs = list(self._sub_sdk_map.keys()) + return sorted(list(set(default_attrs + lazy_attrs))) + + def __enter__(self): + return self + + async def __aenter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + if ( + self.sdk_configuration.client is not None + and not self.sdk_configuration.client_supplied + ): + self.sdk_configuration.client.close() + self.sdk_configuration.client = None + + async def __aexit__(self, exc_type, exc_val, exc_tb): + if ( + self.sdk_configuration.async_client is not None + and not self.sdk_configuration.async_client_supplied + ): + await self.sdk_configuration.async_client.aclose() + self.sdk_configuration.async_client = None diff --git a/src/openrouter/sdkconfiguration.py b/src/openrouter/sdkconfiguration.py new file mode 100644 index 0000000..ba1e868 --- /dev/null +++ b/src/openrouter/sdkconfiguration.py @@ -0,0 +1,50 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from ._version import ( + __gen_version__, + __openapi_doc_version__, + __user_agent__, + __version__, +) +from .httpclient import AsyncHttpClient, HttpClient +from .utils import Logger, RetryConfig, remove_suffix +from dataclasses import dataclass, field +from openrouter import models +from openrouter.types import OptionalNullable, UNSET +from pydantic import Field +from typing import Callable, Dict, List, Optional, Tuple, Union + + +SERVERS = [ + "https://{provider_url}/api/v1", + # Production server +] +"""Contains the list of servers available to the SDK""" + + +@dataclass +class SDKConfiguration: + client: Union[HttpClient, None] + client_supplied: bool + async_client: Union[AsyncHttpClient, None] + async_client_supplied: bool + debug_logger: Logger + security: Optional[Union[models.Security, Callable[[], models.Security]]] = None + server_url: Optional[str] = "" + server_idx: Optional[int] = 0 + server_defaults: List[Dict[str, str]] = field(default_factory=List) + language: str = "python" + openapi_doc_version: str = __openapi_doc_version__ + sdk_version: str = __version__ + gen_version: str = __gen_version__ + user_agent: str = __user_agent__ + retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET) + timeout_ms: Optional[int] = None + + def get_server_details(self) -> Tuple[str, Dict[str, str]]: + if self.server_url is not None and self.server_url: + return remove_suffix(self.server_url, "/"), {} + if self.server_idx is None: + self.server_idx = 0 + + return SERVERS[self.server_idx], self.server_defaults[self.server_idx] diff --git a/src/openrouter/types/__init__.py b/src/openrouter/types/__init__.py new file mode 100644 index 0000000..fc76fe0 --- /dev/null +++ b/src/openrouter/types/__init__.py @@ -0,0 +1,21 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from .basemodel import ( + BaseModel, + Nullable, + OptionalNullable, + UnrecognizedInt, + UnrecognizedStr, + UNSET, + UNSET_SENTINEL, +) + +__all__ = [ + "BaseModel", + "Nullable", + "OptionalNullable", + "UnrecognizedInt", + "UnrecognizedStr", + "UNSET", + "UNSET_SENTINEL", +] diff --git a/src/openrouter/types/basemodel.py b/src/openrouter/types/basemodel.py new file mode 100644 index 0000000..231c2e3 --- /dev/null +++ b/src/openrouter/types/basemodel.py @@ -0,0 +1,39 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from pydantic import ConfigDict, model_serializer +from pydantic import BaseModel as PydanticBaseModel +from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union +from typing_extensions import TypeAliasType, TypeAlias + + +class BaseModel(PydanticBaseModel): + model_config = ConfigDict( + populate_by_name=True, arbitrary_types_allowed=True, protected_namespaces=() + ) + + +class Unset(BaseModel): + @model_serializer(mode="plain") + def serialize_model(self): + return UNSET_SENTINEL + + def __bool__(self) -> Literal[False]: + return False + + +UNSET = Unset() +UNSET_SENTINEL = "~?~unset~?~sentinel~?~" + + +T = TypeVar("T") +if TYPE_CHECKING: + Nullable: TypeAlias = Union[T, None] + OptionalNullable: TypeAlias = Union[Optional[Nullable[T]], Unset] +else: + Nullable = TypeAliasType("Nullable", Union[T, None], type_params=(T,)) + OptionalNullable = TypeAliasType( + "OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,) + ) + +UnrecognizedInt: TypeAlias = int +UnrecognizedStr: TypeAlias = str diff --git a/src/openrouter/utils/__init__.py b/src/openrouter/utils/__init__.py new file mode 100644 index 0000000..5c2c9c2 --- /dev/null +++ b/src/openrouter/utils/__init__.py @@ -0,0 +1,188 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import TYPE_CHECKING +from importlib import import_module +import builtins + +if TYPE_CHECKING: + from .annotations import get_discriminator + from .datetimes import parse_datetime + from .enums import OpenEnumMeta + from .headers import get_headers, get_response_headers + from .metadata import ( + FieldMetadata, + find_metadata, + FormMetadata, + HeaderMetadata, + MultipartFormMetadata, + PathParamMetadata, + QueryParamMetadata, + RequestMetadata, + SecurityMetadata, + ) + from .queryparams import get_query_params + from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig + from .requestbodies import serialize_request_body, SerializedRequestBody + from .security import get_security, get_security_from_env + + from .serializers import ( + get_pydantic_model, + marshal_json, + unmarshal, + unmarshal_json, + serialize_decimal, + serialize_float, + serialize_int, + stream_to_text, + stream_to_text_async, + stream_to_bytes, + stream_to_bytes_async, + validate_const, + validate_decimal, + validate_float, + validate_int, + validate_open_enum, + ) + from .url import generate_url, template_url, remove_suffix + from .values import ( + get_global_from_env, + match_content_type, + match_status_codes, + match_response, + cast_partial, + ) + from .logger import Logger, get_body_content, get_default_logger + +__all__ = [ + "BackoffStrategy", + "FieldMetadata", + "find_metadata", + "FormMetadata", + "generate_url", + "get_body_content", + "get_default_logger", + "get_discriminator", + "parse_datetime", + "get_global_from_env", + "get_headers", + "get_pydantic_model", + "get_query_params", + "get_response_headers", + "get_security", + "get_security_from_env", + "HeaderMetadata", + "Logger", + "marshal_json", + "match_content_type", + "match_status_codes", + "match_response", + "MultipartFormMetadata", + "OpenEnumMeta", + "PathParamMetadata", + "QueryParamMetadata", + "remove_suffix", + "Retries", + "retry", + "retry_async", + "RetryConfig", + "RequestMetadata", + "SecurityMetadata", + "serialize_decimal", + "serialize_float", + "serialize_int", + "serialize_request_body", + "SerializedRequestBody", + "stream_to_text", + "stream_to_text_async", + "stream_to_bytes", + "stream_to_bytes_async", + "template_url", + "unmarshal", + "unmarshal_json", + "validate_decimal", + "validate_const", + "validate_float", + "validate_int", + "validate_open_enum", + "cast_partial", +] + +_dynamic_imports: dict[str, str] = { + "BackoffStrategy": ".retries", + "FieldMetadata": ".metadata", + "find_metadata": ".metadata", + "FormMetadata": ".metadata", + "generate_url": ".url", + "get_body_content": ".logger", + "get_default_logger": ".logger", + "get_discriminator": ".annotations", + "parse_datetime": ".datetimes", + "get_global_from_env": ".values", + "get_headers": ".headers", + "get_pydantic_model": ".serializers", + "get_query_params": ".queryparams", + "get_response_headers": ".headers", + "get_security": ".security", + "get_security_from_env": ".security", + "HeaderMetadata": ".metadata", + "Logger": ".logger", + "marshal_json": ".serializers", + "match_content_type": ".values", + "match_status_codes": ".values", + "match_response": ".values", + "MultipartFormMetadata": ".metadata", + "OpenEnumMeta": ".enums", + "PathParamMetadata": ".metadata", + "QueryParamMetadata": ".metadata", + "remove_suffix": ".url", + "Retries": ".retries", + "retry": ".retries", + "retry_async": ".retries", + "RetryConfig": ".retries", + "RequestMetadata": ".metadata", + "SecurityMetadata": ".metadata", + "serialize_decimal": ".serializers", + "serialize_float": ".serializers", + "serialize_int": ".serializers", + "serialize_request_body": ".requestbodies", + "SerializedRequestBody": ".requestbodies", + "stream_to_text": ".serializers", + "stream_to_text_async": ".serializers", + "stream_to_bytes": ".serializers", + "stream_to_bytes_async": ".serializers", + "template_url": ".url", + "unmarshal": ".serializers", + "unmarshal_json": ".serializers", + "validate_decimal": ".serializers", + "validate_const": ".serializers", + "validate_float": ".serializers", + "validate_int": ".serializers", + "validate_open_enum": ".serializers", + "cast_partial": ".values", +} + + +def __getattr__(attr_name: str) -> object: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError( + f"no {attr_name} found in _dynamic_imports, module name -> {__name__} " + ) + + try: + module = import_module(module_name, __package__) + result = getattr(module, attr_name) + return result + except ImportError as e: + raise ImportError( + f"Failed to import {attr_name} from {module_name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to get {attr_name} from {module_name}: {e}" + ) from e + + +def __dir__(): + lazy_attrs = builtins.list(_dynamic_imports.keys()) + return builtins.sorted(lazy_attrs) diff --git a/src/openrouter/utils/annotations.py b/src/openrouter/utils/annotations.py new file mode 100644 index 0000000..387874e --- /dev/null +++ b/src/openrouter/utils/annotations.py @@ -0,0 +1,55 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from enum import Enum +from typing import Any, Optional + +def get_discriminator(model: Any, fieldname: str, key: str) -> str: + """ + Recursively search for the discriminator attribute in a model. + + Args: + model (Any): The model to search within. + fieldname (str): The name of the field to search for. + key (str): The key to search for in dictionaries. + + Returns: + str: The name of the discriminator attribute. + + Raises: + ValueError: If the discriminator attribute is not found. + """ + upper_fieldname = fieldname.upper() + + def get_field_discriminator(field: Any) -> Optional[str]: + """Search for the discriminator attribute in a given field.""" + + if isinstance(field, dict): + if key in field: + return f'{field[key]}' + + if hasattr(field, fieldname): + attr = getattr(field, fieldname) + if isinstance(attr, Enum): + return f'{attr.value}' + return f'{attr}' + + if hasattr(field, upper_fieldname): + attr = getattr(field, upper_fieldname) + if isinstance(attr, Enum): + return f'{attr.value}' + return f'{attr}' + + return None + + + if isinstance(model, list): + for field in model: + discriminator = get_field_discriminator(field) + if discriminator is not None: + return discriminator + + discriminator = get_field_discriminator(model) + if discriminator is not None: + return discriminator + + raise ValueError(f'Could not find discriminator field {fieldname} in {model}') diff --git a/src/openrouter/utils/datetimes.py b/src/openrouter/utils/datetimes.py new file mode 100644 index 0000000..a6c52cd --- /dev/null +++ b/src/openrouter/utils/datetimes.py @@ -0,0 +1,23 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from datetime import datetime +import sys + + +def parse_datetime(datetime_string: str) -> datetime: + """ + Convert a RFC 3339 / ISO 8601 formatted string into a datetime object. + Python versions 3.11 and later support parsing RFC 3339 directly with + datetime.fromisoformat(), but for earlier versions, this function + encapsulates the necessary extra logic. + """ + # Python 3.11 and later can parse RFC 3339 directly + if sys.version_info >= (3, 11): + return datetime.fromisoformat(datetime_string) + + # For Python 3.10 and earlier, a common ValueError is trailing 'Z' suffix, + # so fix that upfront. + if datetime_string.endswith("Z"): + datetime_string = datetime_string[:-1] + "+00:00" + + return datetime.fromisoformat(datetime_string) diff --git a/src/openrouter/utils/enums.py b/src/openrouter/utils/enums.py new file mode 100644 index 0000000..c3bc13c --- /dev/null +++ b/src/openrouter/utils/enums.py @@ -0,0 +1,74 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import enum +import sys + +class OpenEnumMeta(enum.EnumMeta): + # The __call__ method `boundary` kwarg was added in 3.11 and must be present + # for pyright. Refer also: https://github.com/pylint-dev/pylint/issues/9622 + # pylint: disable=unexpected-keyword-arg + # The __call__ method `values` varg must be named for pyright. + # pylint: disable=keyword-arg-before-vararg + + if sys.version_info >= (3, 11): + def __call__( + cls, value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None + ): + # The `type` kwarg also happens to be a built-in that pylint flags as + # redeclared. Safe to ignore this lint rule with this scope. + # pylint: disable=redefined-builtin + + if names is not None: + return super().__call__( + value, + names=names, + *values, + module=module, + qualname=qualname, + type=type, + start=start, + boundary=boundary, + ) + + try: + return super().__call__( + value, + names=names, # pyright: ignore[reportArgumentType] + *values, + module=module, + qualname=qualname, + type=type, + start=start, + boundary=boundary, + ) + except ValueError: + return value + else: + def __call__( + cls, value, names=None, *, module=None, qualname=None, type=None, start=1 + ): + # The `type` kwarg also happens to be a built-in that pylint flags as + # redeclared. Safe to ignore this lint rule with this scope. + # pylint: disable=redefined-builtin + + if names is not None: + return super().__call__( + value, + names=names, + module=module, + qualname=qualname, + type=type, + start=start, + ) + + try: + return super().__call__( + value, + names=names, # pyright: ignore[reportArgumentType] + module=module, + qualname=qualname, + type=type, + start=start, + ) + except ValueError: + return value diff --git a/src/openrouter/utils/eventstreaming.py b/src/openrouter/utils/eventstreaming.py new file mode 100644 index 0000000..74a63f7 --- /dev/null +++ b/src/openrouter/utils/eventstreaming.py @@ -0,0 +1,238 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import re +import json +from typing import ( + Callable, + Generic, + TypeVar, + Optional, + Generator, + AsyncGenerator, + Tuple, +) +import httpx + +T = TypeVar("T") + + +class EventStream(Generic[T]): + response: httpx.Response + generator: Generator[T, None, None] + + def __init__( + self, + response: httpx.Response, + decoder: Callable[[str], T], + sentinel: Optional[str] = None, + ): + self.response = response + self.generator = stream_events(response, decoder, sentinel) + + def __iter__(self): + return self + + def __next__(self): + return next(self.generator) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.response.close() + + +class EventStreamAsync(Generic[T]): + response: httpx.Response + generator: AsyncGenerator[T, None] + + def __init__( + self, + response: httpx.Response, + decoder: Callable[[str], T], + sentinel: Optional[str] = None, + ): + self.response = response + self.generator = stream_events_async(response, decoder, sentinel) + + def __aiter__(self): + return self + + async def __anext__(self): + return await self.generator.__anext__() + + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + await self.response.aclose() + + +class ServerEvent: + id: Optional[str] = None + event: Optional[str] = None + data: Optional[str] = None + retry: Optional[int] = None + + +MESSAGE_BOUNDARIES = [ + b"\r\n\r\n", + b"\n\n", + b"\r\r", +] + + +async def stream_events_async( + response: httpx.Response, + decoder: Callable[[str], T], + sentinel: Optional[str] = None, +) -> AsyncGenerator[T, None]: + buffer = bytearray() + position = 0 + discard = False + async for chunk in response.aiter_bytes(): + # We've encountered the sentinel value and should no longer process + # incoming data. Instead we throw new data away until the server closes + # the connection. + if discard: + continue + + buffer += chunk + for i in range(position, len(buffer)): + char = buffer[i : i + 1] + seq: Optional[bytes] = None + if char in [b"\r", b"\n"]: + for boundary in MESSAGE_BOUNDARIES: + seq = _peek_sequence(i, buffer, boundary) + if seq is not None: + break + if seq is None: + continue + + block = buffer[position:i] + position = i + len(seq) + event, discard = _parse_event(block, decoder, sentinel) + if event is not None: + yield event + + if position > 0: + buffer = buffer[position:] + position = 0 + + event, discard = _parse_event(buffer, decoder, sentinel) + if event is not None: + yield event + + +def stream_events( + response: httpx.Response, + decoder: Callable[[str], T], + sentinel: Optional[str] = None, +) -> Generator[T, None, None]: + buffer = bytearray() + position = 0 + discard = False + for chunk in response.iter_bytes(): + # We've encountered the sentinel value and should no longer process + # incoming data. Instead we throw new data away until the server closes + # the connection. + if discard: + continue + + buffer += chunk + for i in range(position, len(buffer)): + char = buffer[i : i + 1] + seq: Optional[bytes] = None + if char in [b"\r", b"\n"]: + for boundary in MESSAGE_BOUNDARIES: + seq = _peek_sequence(i, buffer, boundary) + if seq is not None: + break + if seq is None: + continue + + block = buffer[position:i] + position = i + len(seq) + event, discard = _parse_event(block, decoder, sentinel) + if event is not None: + yield event + + if position > 0: + buffer = buffer[position:] + position = 0 + + event, discard = _parse_event(buffer, decoder, sentinel) + if event is not None: + yield event + + +def _parse_event( + raw: bytearray, decoder: Callable[[str], T], sentinel: Optional[str] = None +) -> Tuple[Optional[T], bool]: + block = raw.decode() + lines = re.split(r"\r?\n|\r", block) + publish = False + event = ServerEvent() + data = "" + for line in lines: + if not line: + continue + + delim = line.find(":") + if delim <= 0: + continue + + field = line[0:delim] + value = line[delim + 1 :] if delim < len(line) - 1 else "" + if len(value) and value[0] == " ": + value = value[1:] + + if field == "event": + event.event = value + publish = True + elif field == "data": + data += value + "\n" + publish = True + elif field == "id": + event.id = value + publish = True + elif field == "retry": + event.retry = int(value) if value.isdigit() else None + publish = True + + if sentinel and data == f"{sentinel}\n": + return None, True + + if data: + data = data[:-1] + event.data = data + + data_is_primitive = ( + data.isnumeric() or data == "true" or data == "false" or data == "null" + ) + data_is_json = ( + data.startswith("{") or data.startswith("[") or data.startswith('"') + ) + + if data_is_primitive or data_is_json: + try: + event.data = json.loads(data) + except Exception: + pass + + out = None + if publish: + out = decoder(json.dumps(event.__dict__)) + + return out, False + + +def _peek_sequence(position: int, buffer: bytearray, sequence: bytes): + if len(sequence) > (len(buffer) - position): + return None + + for i, seq in enumerate(sequence): + if buffer[position + i] != seq: + return None + + return sequence diff --git a/src/openrouter/utils/forms.py b/src/openrouter/utils/forms.py new file mode 100644 index 0000000..e873495 --- /dev/null +++ b/src/openrouter/utils/forms.py @@ -0,0 +1,223 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import ( + Any, + Dict, + get_type_hints, + List, + Tuple, +) +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from .serializers import marshal_json + +from .metadata import ( + FormMetadata, + MultipartFormMetadata, + find_field_metadata, +) +from .values import _is_set, _val_to_string + + +def _populate_form( + field_name: str, + explode: bool, + obj: Any, + delimiter: str, + form: Dict[str, List[str]], +): + if not _is_set(obj): + return form + + if isinstance(obj, BaseModel): + items = [] + + obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields + for name in obj_fields: + obj_field = obj_fields[name] + obj_field_name = obj_field.alias if obj_field.alias is not None else name + if obj_field_name == "": + continue + + val = getattr(obj, name) + if not _is_set(val): + continue + + if explode: + form[obj_field_name] = [_val_to_string(val)] + else: + items.append(f"{obj_field_name}{delimiter}{_val_to_string(val)}") + + if len(items) > 0: + form[field_name] = [delimiter.join(items)] + elif isinstance(obj, Dict): + items = [] + for key, value in obj.items(): + if not _is_set(value): + continue + + if explode: + form[key] = [_val_to_string(value)] + else: + items.append(f"{key}{delimiter}{_val_to_string(value)}") + + if len(items) > 0: + form[field_name] = [delimiter.join(items)] + elif isinstance(obj, List): + items = [] + + for value in obj: + if not _is_set(value): + continue + + if explode: + if not field_name in form: + form[field_name] = [] + form[field_name].append(_val_to_string(value)) + else: + items.append(_val_to_string(value)) + + if len(items) > 0: + form[field_name] = [delimiter.join([str(item) for item in items])] + else: + form[field_name] = [_val_to_string(obj)] + + return form + + +def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]: + """Extract file name, content, and content type from a file object.""" + file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields + + file_name = "" + content = None + content_type = None + + for file_field_name in file_fields: + file_field = file_fields[file_field_name] + + file_metadata = find_field_metadata(file_field, MultipartFormMetadata) + if file_metadata is None: + continue + + if file_metadata.content: + content = getattr(file_obj, file_field_name, None) + elif file_field_name == "content_type": + content_type = getattr(file_obj, file_field_name, None) + else: + file_name = getattr(file_obj, file_field_name) + + if file_name == "" or content is None: + raise ValueError("invalid multipart/form-data file") + + return file_name, content, content_type + + +def serialize_multipart_form( + media_type: str, request: Any +) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]: + form: Dict[str, Any] = {} + files: List[Tuple[str, Any]] = [] + + if not isinstance(request, BaseModel): + raise TypeError("invalid request body type") + + request_fields: Dict[str, FieldInfo] = request.__class__.model_fields + request_field_types = get_type_hints(request.__class__) + + for name in request_fields: + field = request_fields[name] + + val = getattr(request, name) + if not _is_set(val): + continue + + field_metadata = find_field_metadata(field, MultipartFormMetadata) + if not field_metadata: + continue + + f_name = field.alias if field.alias else name + + if field_metadata.file: + if isinstance(val, List): + # Handle array of files + for file_obj in val: + if not _is_set(file_obj): + continue + + file_name, content, content_type = _extract_file_properties(file_obj) + + if content_type is not None: + files.append((f_name + "[]", (file_name, content, content_type))) + else: + files.append((f_name + "[]", (file_name, content))) + else: + # Handle single file + file_name, content, content_type = _extract_file_properties(val) + + if content_type is not None: + files.append((f_name, (file_name, content, content_type))) + else: + files.append((f_name, (file_name, content))) + elif field_metadata.json: + files.append((f_name, ( + None, + marshal_json(val, request_field_types[name]), + "application/json", + ))) + else: + if isinstance(val, List): + values = [] + + for value in val: + if not _is_set(value): + continue + values.append(_val_to_string(value)) + + form[f_name + "[]"] = values + else: + form[f_name] = _val_to_string(val) + return media_type, form, files + + +def serialize_form_data(data: Any) -> Dict[str, Any]: + form: Dict[str, List[str]] = {} + + if isinstance(data, BaseModel): + data_fields: Dict[str, FieldInfo] = data.__class__.model_fields + data_field_types = get_type_hints(data.__class__) + for name in data_fields: + field = data_fields[name] + + val = getattr(data, name) + if not _is_set(val): + continue + + metadata = find_field_metadata(field, FormMetadata) + if metadata is None: + continue + + f_name = field.alias if field.alias is not None else name + + if metadata.json: + form[f_name] = [marshal_json(val, data_field_types[name])] + else: + if metadata.style == "form": + _populate_form( + f_name, + metadata.explode, + val, + ",", + form, + ) + else: + raise ValueError(f"Invalid form style for field {name}") + elif isinstance(data, Dict): + for key, value in data.items(): + if _is_set(value): + form[key] = [_val_to_string(value)] + else: + raise TypeError(f"Invalid request body type {type(data)} for form data") + + return form diff --git a/src/openrouter/utils/headers.py b/src/openrouter/utils/headers.py new file mode 100644 index 0000000..37864cb --- /dev/null +++ b/src/openrouter/utils/headers.py @@ -0,0 +1,136 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import ( + Any, + Dict, + List, + Optional, +) +from httpx import Headers +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from .metadata import ( + HeaderMetadata, + find_field_metadata, +) + +from .values import _is_set, _populate_from_globals, _val_to_string + + +def get_headers(headers_params: Any, gbls: Optional[Any] = None) -> Dict[str, str]: + headers: Dict[str, str] = {} + + globals_already_populated = [] + if _is_set(headers_params): + globals_already_populated = _populate_headers(headers_params, gbls, headers, []) + if _is_set(gbls): + _populate_headers(gbls, None, headers, globals_already_populated) + + return headers + + +def _populate_headers( + headers_params: Any, + gbls: Any, + header_values: Dict[str, str], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] + + if not isinstance(headers_params, BaseModel): + return globals_already_populated + + param_fields: Dict[str, FieldInfo] = headers_params.__class__.model_fields + for name in param_fields: + if name in skip_fields: + continue + + field = param_fields[name] + f_name = field.alias if field.alias is not None else name + + metadata = find_field_metadata(field, HeaderMetadata) + if metadata is None: + continue + + value, global_found = _populate_from_globals( + name, getattr(headers_params, name), HeaderMetadata, gbls + ) + if global_found: + globals_already_populated.append(name) + value = _serialize_header(metadata.explode, value) + + if value != "": + header_values[f_name] = value + + return globals_already_populated + + +def _serialize_header(explode: bool, obj: Any) -> str: + if not _is_set(obj): + return "" + + if isinstance(obj, BaseModel): + items = [] + obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields + for name in obj_fields: + obj_field = obj_fields[name] + obj_param_metadata = find_field_metadata(obj_field, HeaderMetadata) + + if not obj_param_metadata: + continue + + f_name = obj_field.alias if obj_field.alias is not None else name + + val = getattr(obj, name) + if not _is_set(val): + continue + + if explode: + items.append(f"{f_name}={_val_to_string(val)}") + else: + items.append(f_name) + items.append(_val_to_string(val)) + + if len(items) > 0: + return ",".join(items) + elif isinstance(obj, Dict): + items = [] + + for key, value in obj.items(): + if not _is_set(value): + continue + + if explode: + items.append(f"{key}={_val_to_string(value)}") + else: + items.append(key) + items.append(_val_to_string(value)) + + if len(items) > 0: + return ",".join([str(item) for item in items]) + elif isinstance(obj, List): + items = [] + + for value in obj: + if not _is_set(value): + continue + + items.append(_val_to_string(value)) + + if len(items) > 0: + return ",".join(items) + elif _is_set(obj): + return f"{_val_to_string(obj)}" + + return "" + + +def get_response_headers(headers: Headers) -> Dict[str, List[str]]: + res: Dict[str, List[str]] = {} + for k, v in headers.items(): + if not k in res: + res[k] = [] + + res[k].append(v) + return res diff --git a/src/openrouter/utils/logger.py b/src/openrouter/utils/logger.py new file mode 100644 index 0000000..db55cd3 --- /dev/null +++ b/src/openrouter/utils/logger.py @@ -0,0 +1,27 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import httpx +import logging +import os +from typing import Any, Protocol + + +class Logger(Protocol): + def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: + pass + + +class NoOpLogger: + def debug(self, msg: str, *args: Any, **kwargs: Any) -> None: + pass + + +def get_body_content(req: httpx.Request) -> str: + return "" if not hasattr(req, "_content") else str(req.content) + + +def get_default_logger() -> Logger: + if os.getenv("OPENROUTER_DEBUG"): + logging.basicConfig(level=logging.DEBUG) + return logging.getLogger("openrouter") + return NoOpLogger() diff --git a/src/openrouter/utils/metadata.py b/src/openrouter/utils/metadata.py new file mode 100644 index 0000000..173b3e5 --- /dev/null +++ b/src/openrouter/utils/metadata.py @@ -0,0 +1,118 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import Optional, Type, TypeVar, Union +from dataclasses import dataclass +from pydantic.fields import FieldInfo + + +T = TypeVar("T") + + +@dataclass +class SecurityMetadata: + option: bool = False + scheme: bool = False + scheme_type: Optional[str] = None + sub_type: Optional[str] = None + field_name: Optional[str] = None + + def get_field_name(self, default: str) -> str: + return self.field_name or default + + +@dataclass +class ParamMetadata: + serialization: Optional[str] = None + style: str = "simple" + explode: bool = False + + +@dataclass +class PathParamMetadata(ParamMetadata): + pass + + +@dataclass +class QueryParamMetadata(ParamMetadata): + style: str = "form" + explode: bool = True + + +@dataclass +class HeaderMetadata(ParamMetadata): + pass + + +@dataclass +class RequestMetadata: + media_type: str = "application/octet-stream" + + +@dataclass +class MultipartFormMetadata: + file: bool = False + content: bool = False + json: bool = False + + +@dataclass +class FormMetadata: + json: bool = False + style: str = "form" + explode: bool = True + + +class FieldMetadata: + security: Optional[SecurityMetadata] = None + path: Optional[PathParamMetadata] = None + query: Optional[QueryParamMetadata] = None + header: Optional[HeaderMetadata] = None + request: Optional[RequestMetadata] = None + form: Optional[FormMetadata] = None + multipart: Optional[MultipartFormMetadata] = None + + def __init__( + self, + security: Optional[SecurityMetadata] = None, + path: Optional[Union[PathParamMetadata, bool]] = None, + query: Optional[Union[QueryParamMetadata, bool]] = None, + header: Optional[Union[HeaderMetadata, bool]] = None, + request: Optional[Union[RequestMetadata, bool]] = None, + form: Optional[Union[FormMetadata, bool]] = None, + multipart: Optional[Union[MultipartFormMetadata, bool]] = None, + ): + self.security = security + self.path = PathParamMetadata() if isinstance(path, bool) else path + self.query = QueryParamMetadata() if isinstance(query, bool) else query + self.header = HeaderMetadata() if isinstance(header, bool) else header + self.request = RequestMetadata() if isinstance(request, bool) else request + self.form = FormMetadata() if isinstance(form, bool) else form + self.multipart = ( + MultipartFormMetadata() if isinstance(multipart, bool) else multipart + ) + + +def find_field_metadata(field_info: FieldInfo, metadata_type: Type[T]) -> Optional[T]: + metadata = find_metadata(field_info, FieldMetadata) + if not metadata: + return None + + fields = metadata.__dict__ + + for field in fields: + if isinstance(fields[field], metadata_type): + return fields[field] + + return None + + +def find_metadata(field_info: FieldInfo, metadata_type: Type[T]) -> Optional[T]: + metadata = field_info.metadata + if not metadata: + return None + + for md in metadata: + if isinstance(md, metadata_type): + return md + + return None diff --git a/src/openrouter/utils/queryparams.py b/src/openrouter/utils/queryparams.py new file mode 100644 index 0000000..37a6e7f --- /dev/null +++ b/src/openrouter/utils/queryparams.py @@ -0,0 +1,205 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import ( + Any, + Dict, + get_type_hints, + List, + Optional, +) + +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from .metadata import ( + QueryParamMetadata, + find_field_metadata, +) +from .values import ( + _get_serialized_params, + _is_set, + _populate_from_globals, + _val_to_string, +) +from .forms import _populate_form + + +def get_query_params( + query_params: Any, + gbls: Optional[Any] = None, +) -> Dict[str, List[str]]: + params: Dict[str, List[str]] = {} + + globals_already_populated = _populate_query_params(query_params, gbls, params, []) + if _is_set(gbls): + _populate_query_params(gbls, None, params, globals_already_populated) + + return params + + +def _populate_query_params( + query_params: Any, + gbls: Any, + query_param_values: Dict[str, List[str]], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] + + if not isinstance(query_params, BaseModel): + return globals_already_populated + + param_fields: Dict[str, FieldInfo] = query_params.__class__.model_fields + param_field_types = get_type_hints(query_params.__class__) + for name in param_fields: + if name in skip_fields: + continue + + field = param_fields[name] + + metadata = find_field_metadata(field, QueryParamMetadata) + if not metadata: + continue + + value = getattr(query_params, name) if _is_set(query_params) else None + + value, global_found = _populate_from_globals( + name, value, QueryParamMetadata, gbls + ) + if global_found: + globals_already_populated.append(name) + + f_name = field.alias if field.alias is not None else name + serialization = metadata.serialization + if serialization is not None: + serialized_parms = _get_serialized_params( + metadata, f_name, value, param_field_types[name] + ) + for key, value in serialized_parms.items(): + if key in query_param_values: + query_param_values[key].extend(value) + else: + query_param_values[key] = [value] + else: + style = metadata.style + if style == "deepObject": + _populate_deep_object_query_params(f_name, value, query_param_values) + elif style == "form": + _populate_delimited_query_params( + metadata, f_name, value, ",", query_param_values + ) + elif style == "pipeDelimited": + _populate_delimited_query_params( + metadata, f_name, value, "|", query_param_values + ) + else: + raise NotImplementedError( + f"query param style {style} not yet supported" + ) + + return globals_already_populated + + +def _populate_deep_object_query_params( + field_name: str, + obj: Any, + params: Dict[str, List[str]], +): + if not _is_set(obj): + return + + if isinstance(obj, BaseModel): + _populate_deep_object_query_params_basemodel(field_name, obj, params) + elif isinstance(obj, Dict): + _populate_deep_object_query_params_dict(field_name, obj, params) + + +def _populate_deep_object_query_params_basemodel( + prior_params_key: str, + obj: Any, + params: Dict[str, List[str]], +): + if not _is_set(obj) or not isinstance(obj, BaseModel): + return + + obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields + for name in obj_fields: + obj_field = obj_fields[name] + + f_name = obj_field.alias if obj_field.alias is not None else name + + params_key = f"{prior_params_key}[{f_name}]" + + obj_param_metadata = find_field_metadata(obj_field, QueryParamMetadata) + if not _is_set(obj_param_metadata): + continue + + obj_val = getattr(obj, name) + if not _is_set(obj_val): + continue + + if isinstance(obj_val, BaseModel): + _populate_deep_object_query_params_basemodel(params_key, obj_val, params) + elif isinstance(obj_val, Dict): + _populate_deep_object_query_params_dict(params_key, obj_val, params) + elif isinstance(obj_val, List): + _populate_deep_object_query_params_list(params_key, obj_val, params) + else: + params[params_key] = [_val_to_string(obj_val)] + + +def _populate_deep_object_query_params_dict( + prior_params_key: str, + value: Dict, + params: Dict[str, List[str]], +): + if not _is_set(value): + return + + for key, val in value.items(): + if not _is_set(val): + continue + + params_key = f"{prior_params_key}[{key}]" + + if isinstance(val, BaseModel): + _populate_deep_object_query_params_basemodel(params_key, val, params) + elif isinstance(val, Dict): + _populate_deep_object_query_params_dict(params_key, val, params) + elif isinstance(val, List): + _populate_deep_object_query_params_list(params_key, val, params) + else: + params[params_key] = [_val_to_string(val)] + + +def _populate_deep_object_query_params_list( + params_key: str, + value: List, + params: Dict[str, List[str]], +): + if not _is_set(value): + return + + for val in value: + if not _is_set(val): + continue + + if params.get(params_key) is None: + params[params_key] = [] + + params[params_key].append(_val_to_string(val)) + + +def _populate_delimited_query_params( + metadata: QueryParamMetadata, + field_name: str, + obj: Any, + delimiter: str, + query_param_values: Dict[str, List[str]], +): + _populate_form( + field_name, + metadata.explode, + obj, + delimiter, + query_param_values, + ) diff --git a/src/openrouter/utils/requestbodies.py b/src/openrouter/utils/requestbodies.py new file mode 100644 index 0000000..d5240dd --- /dev/null +++ b/src/openrouter/utils/requestbodies.py @@ -0,0 +1,66 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import io +from dataclasses import dataclass +import re +from typing import ( + Any, + Optional, +) + +from .forms import serialize_form_data, serialize_multipart_form + +from .serializers import marshal_json + +SERIALIZATION_METHOD_TO_CONTENT_TYPE = { + "json": "application/json", + "form": "application/x-www-form-urlencoded", + "multipart": "multipart/form-data", + "raw": "application/octet-stream", + "string": "text/plain", +} + + +@dataclass +class SerializedRequestBody: + media_type: Optional[str] = None + content: Optional[Any] = None + data: Optional[Any] = None + files: Optional[Any] = None + + +def serialize_request_body( + request_body: Any, + nullable: bool, + optional: bool, + serialization_method: str, + request_body_type, +) -> Optional[SerializedRequestBody]: + if request_body is None: + if not nullable and optional: + return None + + media_type = SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method] + + serialized_request_body = SerializedRequestBody(media_type) + + if re.match(r"(application|text)\/.*?\+*json.*", media_type) is not None: + serialized_request_body.content = marshal_json(request_body, request_body_type) + elif re.match(r"multipart\/.*", media_type) is not None: + ( + serialized_request_body.media_type, + serialized_request_body.data, + serialized_request_body.files, + ) = serialize_multipart_form(media_type, request_body) + elif re.match(r"application\/x-www-form-urlencoded.*", media_type) is not None: + serialized_request_body.data = serialize_form_data(request_body) + elif isinstance(request_body, (bytes, bytearray, io.BytesIO, io.BufferedReader)): + serialized_request_body.content = request_body + elif isinstance(request_body, str): + serialized_request_body.content = request_body + else: + raise TypeError( + f"invalid request body type {type(request_body)} for mediaType {media_type}" + ) + + return serialized_request_body diff --git a/src/openrouter/utils/retries.py b/src/openrouter/utils/retries.py new file mode 100644 index 0000000..4d60867 --- /dev/null +++ b/src/openrouter/utils/retries.py @@ -0,0 +1,217 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import asyncio +import random +import time +from typing import List + +import httpx + + +class BackoffStrategy: + initial_interval: int + max_interval: int + exponent: float + max_elapsed_time: int + + def __init__( + self, + initial_interval: int, + max_interval: int, + exponent: float, + max_elapsed_time: int, + ): + self.initial_interval = initial_interval + self.max_interval = max_interval + self.exponent = exponent + self.max_elapsed_time = max_elapsed_time + + +class RetryConfig: + strategy: str + backoff: BackoffStrategy + retry_connection_errors: bool + + def __init__( + self, strategy: str, backoff: BackoffStrategy, retry_connection_errors: bool + ): + self.strategy = strategy + self.backoff = backoff + self.retry_connection_errors = retry_connection_errors + + +class Retries: + config: RetryConfig + status_codes: List[str] + + def __init__(self, config: RetryConfig, status_codes: List[str]): + self.config = config + self.status_codes = status_codes + + +class TemporaryError(Exception): + response: httpx.Response + + def __init__(self, response: httpx.Response): + self.response = response + + +class PermanentError(Exception): + inner: Exception + + def __init__(self, inner: Exception): + self.inner = inner + + +def retry(func, retries: Retries): + if retries.config.strategy == "backoff": + + def do_request() -> httpx.Response: + res: httpx.Response + try: + res = func() + + for code in retries.status_codes: + if "X" in code.upper(): + code_range = int(code[0]) + + status_major = res.status_code / 100 + + if code_range <= status_major < code_range + 1: + raise TemporaryError(res) + else: + parsed_code = int(code) + + if res.status_code == parsed_code: + raise TemporaryError(res) + except httpx.ConnectError as exception: + if retries.config.retry_connection_errors: + raise + + raise PermanentError(exception) from exception + except httpx.TimeoutException as exception: + if retries.config.retry_connection_errors: + raise + + raise PermanentError(exception) from exception + except TemporaryError: + raise + except Exception as exception: + raise PermanentError(exception) from exception + + return res + + return retry_with_backoff( + do_request, + retries.config.backoff.initial_interval, + retries.config.backoff.max_interval, + retries.config.backoff.exponent, + retries.config.backoff.max_elapsed_time, + ) + + return func() + + +async def retry_async(func, retries: Retries): + if retries.config.strategy == "backoff": + + async def do_request() -> httpx.Response: + res: httpx.Response + try: + res = await func() + + for code in retries.status_codes: + if "X" in code.upper(): + code_range = int(code[0]) + + status_major = res.status_code / 100 + + if code_range <= status_major < code_range + 1: + raise TemporaryError(res) + else: + parsed_code = int(code) + + if res.status_code == parsed_code: + raise TemporaryError(res) + except httpx.ConnectError as exception: + if retries.config.retry_connection_errors: + raise + + raise PermanentError(exception) from exception + except httpx.TimeoutException as exception: + if retries.config.retry_connection_errors: + raise + + raise PermanentError(exception) from exception + except TemporaryError: + raise + except Exception as exception: + raise PermanentError(exception) from exception + + return res + + return await retry_with_backoff_async( + do_request, + retries.config.backoff.initial_interval, + retries.config.backoff.max_interval, + retries.config.backoff.exponent, + retries.config.backoff.max_elapsed_time, + ) + + return await func() + + +def retry_with_backoff( + func, + initial_interval=500, + max_interval=60000, + exponent=1.5, + max_elapsed_time=3600000, +): + start = round(time.time() * 1000) + retries = 0 + + while True: + try: + return func() + except PermanentError as exception: + raise exception.inner + except Exception as exception: # pylint: disable=broad-exception-caught + now = round(time.time() * 1000) + if now - start > max_elapsed_time: + if isinstance(exception, TemporaryError): + return exception.response + + raise + sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1) + sleep = min(sleep, max_interval / 1000) + time.sleep(sleep) + retries += 1 + + +async def retry_with_backoff_async( + func, + initial_interval=500, + max_interval=60000, + exponent=1.5, + max_elapsed_time=3600000, +): + start = round(time.time() * 1000) + retries = 0 + + while True: + try: + return await func() + except PermanentError as exception: + raise exception.inner + except Exception as exception: # pylint: disable=broad-exception-caught + now = round(time.time() * 1000) + if now - start > max_elapsed_time: + if isinstance(exception, TemporaryError): + return exception.response + + raise + sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1) + sleep = min(sleep, max_interval / 1000) + await asyncio.sleep(sleep) + retries += 1 diff --git a/src/openrouter/utils/security.py b/src/openrouter/utils/security.py new file mode 100644 index 0000000..8db6ee7 --- /dev/null +++ b/src/openrouter/utils/security.py @@ -0,0 +1,192 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import base64 + +from typing import ( + Any, + Dict, + List, + Optional, + Tuple, +) +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from .metadata import ( + SecurityMetadata, + find_field_metadata, +) +import os + + +def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]: + headers: Dict[str, str] = {} + query_params: Dict[str, List[str]] = {} + + if security is None: + return headers, query_params + + if not isinstance(security, BaseModel): + raise TypeError("security must be a pydantic model") + + sec_fields: Dict[str, FieldInfo] = security.__class__.model_fields + for name in sec_fields: + sec_field = sec_fields[name] + + value = getattr(security, name) + if value is None: + continue + + metadata = find_field_metadata(sec_field, SecurityMetadata) + if metadata is None: + continue + if metadata.option: + _parse_security_option(headers, query_params, value) + return headers, query_params + if metadata.scheme: + # Special case for basic auth or custom auth which could be a flattened model + if metadata.sub_type in ["basic", "custom"] and not isinstance( + value, BaseModel + ): + _parse_security_scheme(headers, query_params, metadata, name, security) + else: + _parse_security_scheme(headers, query_params, metadata, name, value) + + return headers, query_params + + +def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseModel]: + if security is not None: + return security + + if not issubclass(security_class, BaseModel): + raise TypeError("security_class must be a pydantic model class") + + security_dict: Any = {} + + if os.getenv("OPENROUTER_BEARER_AUTH"): + security_dict["bearer_auth"] = os.getenv("OPENROUTER_BEARER_AUTH") + + return security_class(**security_dict) if security_dict else None + + +def _parse_security_option( + headers: Dict[str, str], query_params: Dict[str, List[str]], option: Any +): + if not isinstance(option, BaseModel): + raise TypeError("security option must be a pydantic model") + + opt_fields: Dict[str, FieldInfo] = option.__class__.model_fields + for name in opt_fields: + opt_field = opt_fields[name] + + metadata = find_field_metadata(opt_field, SecurityMetadata) + if metadata is None or not metadata.scheme: + continue + _parse_security_scheme( + headers, query_params, metadata, name, getattr(option, name) + ) + + +def _parse_security_scheme( + headers: Dict[str, str], + query_params: Dict[str, List[str]], + scheme_metadata: SecurityMetadata, + field_name: str, + scheme: Any, +): + scheme_type = scheme_metadata.scheme_type + sub_type = scheme_metadata.sub_type + + if isinstance(scheme, BaseModel): + if scheme_type == "http": + if sub_type == "basic": + _parse_basic_auth_scheme(headers, scheme) + return + if sub_type == "custom": + return + + scheme_fields: Dict[str, FieldInfo] = scheme.__class__.model_fields + for name in scheme_fields: + scheme_field = scheme_fields[name] + + metadata = find_field_metadata(scheme_field, SecurityMetadata) + if metadata is None or metadata.field_name is None: + continue + + value = getattr(scheme, name) + + _parse_security_scheme_value( + headers, query_params, scheme_metadata, metadata, name, value + ) + else: + _parse_security_scheme_value( + headers, query_params, scheme_metadata, scheme_metadata, field_name, scheme + ) + + +def _parse_security_scheme_value( + headers: Dict[str, str], + query_params: Dict[str, List[str]], + scheme_metadata: SecurityMetadata, + security_metadata: SecurityMetadata, + field_name: str, + value: Any, +): + scheme_type = scheme_metadata.scheme_type + sub_type = scheme_metadata.sub_type + + header_name = security_metadata.get_field_name(field_name) + + if scheme_type == "apiKey": + if sub_type == "header": + headers[header_name] = value + elif sub_type == "query": + query_params[header_name] = [value] + else: + raise ValueError("sub type {sub_type} not supported") + elif scheme_type == "openIdConnect": + headers[header_name] = _apply_bearer(value) + elif scheme_type == "oauth2": + if sub_type != "client_credentials": + headers[header_name] = _apply_bearer(value) + elif scheme_type == "http": + if sub_type == "bearer": + headers[header_name] = _apply_bearer(value) + elif sub_type == "custom": + return + else: + raise ValueError("sub type {sub_type} not supported") + else: + raise ValueError("scheme type {scheme_type} not supported") + + +def _apply_bearer(token: str) -> str: + return token.lower().startswith("bearer ") and token or f"Bearer {token}" + + +def _parse_basic_auth_scheme(headers: Dict[str, str], scheme: Any): + username = "" + password = "" + + if not isinstance(scheme, BaseModel): + raise TypeError("basic auth scheme must be a pydantic model") + + scheme_fields: Dict[str, FieldInfo] = scheme.__class__.model_fields + for name in scheme_fields: + scheme_field = scheme_fields[name] + + metadata = find_field_metadata(scheme_field, SecurityMetadata) + if metadata is None or metadata.field_name is None: + continue + + field_name = metadata.field_name + value = getattr(scheme, name) + + if field_name == "username": + username = value + if field_name == "password": + password = value + + data = f"{username}:{password}".encode() + headers["Authorization"] = f"Basic {base64.b64encode(data).decode()}" diff --git a/src/openrouter/utils/serializers.py b/src/openrouter/utils/serializers.py new file mode 100644 index 0000000..378a14c --- /dev/null +++ b/src/openrouter/utils/serializers.py @@ -0,0 +1,249 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from decimal import Decimal +import functools +import json +import typing +from typing import Any, Dict, List, Tuple, Union, get_args +import typing_extensions +from typing_extensions import get_origin + +import httpx +from pydantic import ConfigDict, create_model +from pydantic_core import from_json + +from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset + + +def serialize_decimal(as_str: bool): + def serialize(d): + # Optional[T] is a Union[T, None] + if is_union(type(d)) and type(None) in get_args(type(d)) and d is None: + return None + if isinstance(d, Unset): + return d + + if not isinstance(d, Decimal): + raise ValueError("Expected Decimal object") + + return str(d) if as_str else float(d) + + return serialize + + +def validate_decimal(d): + if d is None: + return None + + if isinstance(d, (Decimal, Unset)): + return d + + if not isinstance(d, (str, int, float)): + raise ValueError("Expected string, int or float") + + return Decimal(str(d)) + + +def serialize_float(as_str: bool): + def serialize(f): + # Optional[T] is a Union[T, None] + if is_union(type(f)) and type(None) in get_args(type(f)) and f is None: + return None + if isinstance(f, Unset): + return f + + if not isinstance(f, float): + raise ValueError("Expected float") + + return str(f) if as_str else f + + return serialize + + +def validate_float(f): + if f is None: + return None + + if isinstance(f, (float, Unset)): + return f + + if not isinstance(f, str): + raise ValueError("Expected string") + + return float(f) + + +def serialize_int(as_str: bool): + def serialize(i): + # Optional[T] is a Union[T, None] + if is_union(type(i)) and type(None) in get_args(type(i)) and i is None: + return None + if isinstance(i, Unset): + return i + + if not isinstance(i, int): + raise ValueError("Expected int") + + return str(i) if as_str else i + + return serialize + + +def validate_int(b): + if b is None: + return None + + if isinstance(b, (int, Unset)): + return b + + if not isinstance(b, str): + raise ValueError("Expected string") + + return int(b) + + +def validate_open_enum(is_int: bool): + def validate(e): + if e is None: + return None + + if isinstance(e, Unset): + return e + + if is_int: + if not isinstance(e, int): + raise ValueError("Expected int") + else: + if not isinstance(e, str): + raise ValueError("Expected string") + + return e + + return validate + + +def validate_const(v): + def validate(c): + # Optional[T] is a Union[T, None] + if is_union(type(c)) and type(None) in get_args(type(c)) and c is None: + return None + + if v != c: + raise ValueError(f"Expected {v}") + + return c + + return validate + + +def unmarshal_json(raw, typ: Any) -> Any: + return unmarshal(from_json(raw), typ) + + +def unmarshal(val, typ: Any) -> Any: + unmarshaller = create_model( + "Unmarshaller", + body=(typ, ...), + __config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True), + ) + + m = unmarshaller(body=val) + + # pyright: ignore[reportAttributeAccessIssue] + return m.body # type: ignore + + +def marshal_json(val, typ): + if is_nullable(typ) and val is None: + return "null" + + marshaller = create_model( + "Marshaller", + body=(typ, ...), + __config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True), + ) + + m = marshaller(body=val) + + d = m.model_dump(by_alias=True, mode="json", exclude_none=True) + + if len(d) == 0: + return "" + + return json.dumps(d[next(iter(d))], separators=(",", ":")) + + +def is_nullable(field): + origin = get_origin(field) + if origin is Nullable or origin is OptionalNullable: + return True + + if not origin is Union or type(None) not in get_args(field): + return False + + for arg in get_args(field): + if get_origin(arg) is Nullable or get_origin(arg) is OptionalNullable: + return True + + return False + + +def is_union(obj: object) -> bool: + """ + Returns True if the given object is a typing.Union or typing_extensions.Union. + """ + return any( + obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union") + ) + + +def stream_to_text(stream: httpx.Response) -> str: + return "".join(stream.iter_text()) + + +async def stream_to_text_async(stream: httpx.Response) -> str: + return "".join([chunk async for chunk in stream.aiter_text()]) + + +def stream_to_bytes(stream: httpx.Response) -> bytes: + return stream.content + + +async def stream_to_bytes_async(stream: httpx.Response) -> bytes: + return await stream.aread() + + +def get_pydantic_model(data: Any, typ: Any) -> Any: + if not _contains_pydantic_model(data): + return unmarshal(data, typ) + + return data + + +def _contains_pydantic_model(data: Any) -> bool: + if isinstance(data, BaseModel): + return True + if isinstance(data, List): + return any(_contains_pydantic_model(item) for item in data) + if isinstance(data, Dict): + return any(_contains_pydantic_model(value) for value in data.values()) + + return False + + +@functools.cache +def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]: + """ + Get typing objects by name from typing and typing_extensions. + Reference: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types + """ + result = tuple( + getattr(module, name) + for module in (typing, typing_extensions) + if hasattr(module, name) + ) + if not result: + raise ValueError( + f"Neither typing nor typing_extensions has an object called {name!r}" + ) + return result diff --git a/src/openrouter/utils/unmarshal_json_response.py b/src/openrouter/utils/unmarshal_json_response.py new file mode 100644 index 0000000..079836c --- /dev/null +++ b/src/openrouter/utils/unmarshal_json_response.py @@ -0,0 +1,24 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from typing import Any, Optional + +import httpx + +from .serializers import unmarshal_json +from openrouter import errors + + +def unmarshal_json_response( + typ: Any, http_res: httpx.Response, body: Optional[str] = None +) -> Any: + if body is None: + body = http_res.text + try: + return unmarshal_json(body, typ) + except Exception as e: + raise errors.ResponseValidationError( + "Response validation failed", + http_res, + e, + body, + ) from e diff --git a/src/openrouter/utils/url.py b/src/openrouter/utils/url.py new file mode 100644 index 0000000..c78ccba --- /dev/null +++ b/src/openrouter/utils/url.py @@ -0,0 +1,155 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from decimal import Decimal +from typing import ( + Any, + Dict, + get_type_hints, + List, + Optional, + Union, + get_args, + get_origin, +) +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from .metadata import ( + PathParamMetadata, + find_field_metadata, +) +from .values import ( + _get_serialized_params, + _is_set, + _populate_from_globals, + _val_to_string, +) + + +def generate_url( + server_url: str, + path: str, + path_params: Any, + gbls: Optional[Any] = None, +) -> str: + path_param_values: Dict[str, str] = {} + + globals_already_populated = _populate_path_params( + path_params, gbls, path_param_values, [] + ) + if _is_set(gbls): + _populate_path_params(gbls, None, path_param_values, globals_already_populated) + + for key, value in path_param_values.items(): + path = path.replace("{" + key + "}", value, 1) + + return remove_suffix(server_url, "/") + path + + +def _populate_path_params( + path_params: Any, + gbls: Any, + path_param_values: Dict[str, str], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] + + if not isinstance(path_params, BaseModel): + return globals_already_populated + + path_param_fields: Dict[str, FieldInfo] = path_params.__class__.model_fields + path_param_field_types = get_type_hints(path_params.__class__) + for name in path_param_fields: + if name in skip_fields: + continue + + field = path_param_fields[name] + + param_metadata = find_field_metadata(field, PathParamMetadata) + if param_metadata is None: + continue + + param = getattr(path_params, name) if _is_set(path_params) else None + param, global_found = _populate_from_globals( + name, param, PathParamMetadata, gbls + ) + if global_found: + globals_already_populated.append(name) + + if not _is_set(param): + continue + + f_name = field.alias if field.alias is not None else name + serialization = param_metadata.serialization + if serialization is not None: + serialized_params = _get_serialized_params( + param_metadata, f_name, param, path_param_field_types[name] + ) + for key, value in serialized_params.items(): + path_param_values[key] = value + else: + pp_vals: List[str] = [] + if param_metadata.style == "simple": + if isinstance(param, List): + for pp_val in param: + if not _is_set(pp_val): + continue + pp_vals.append(_val_to_string(pp_val)) + path_param_values[f_name] = ",".join(pp_vals) + elif isinstance(param, Dict): + for pp_key in param: + if not _is_set(param[pp_key]): + continue + if param_metadata.explode: + pp_vals.append(f"{pp_key}={_val_to_string(param[pp_key])}") + else: + pp_vals.append(f"{pp_key},{_val_to_string(param[pp_key])}") + path_param_values[f_name] = ",".join(pp_vals) + elif not isinstance(param, (str, int, float, complex, bool, Decimal)): + param_fields: Dict[str, FieldInfo] = param.__class__.model_fields + for name in param_fields: + param_field = param_fields[name] + + param_value_metadata = find_field_metadata( + param_field, PathParamMetadata + ) + if param_value_metadata is None: + continue + + param_name = ( + param_field.alias if param_field.alias is not None else name + ) + + param_field_val = getattr(param, name) + if not _is_set(param_field_val): + continue + if param_metadata.explode: + pp_vals.append( + f"{param_name}={_val_to_string(param_field_val)}" + ) + else: + pp_vals.append( + f"{param_name},{_val_to_string(param_field_val)}" + ) + path_param_values[f_name] = ",".join(pp_vals) + elif _is_set(param): + path_param_values[f_name] = _val_to_string(param) + + return globals_already_populated + + +def is_optional(field): + return get_origin(field) is Union and type(None) in get_args(field) + + +def template_url(url_with_params: str, params: Dict[str, str]) -> str: + for key, value in params.items(): + url_with_params = url_with_params.replace("{" + key + "}", value) + + return url_with_params + + +def remove_suffix(input_string, suffix): + if suffix and input_string.endswith(suffix): + return input_string[: -len(suffix)] + return input_string diff --git a/src/openrouter/utils/values.py b/src/openrouter/utils/values.py new file mode 100644 index 0000000..dae01a4 --- /dev/null +++ b/src/openrouter/utils/values.py @@ -0,0 +1,137 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from datetime import datetime +from enum import Enum +from email.message import Message +from functools import partial +import os +from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast + +from httpx import Response +from pydantic import BaseModel +from pydantic.fields import FieldInfo + +from ..types.basemodel import Unset + +from .serializers import marshal_json + +from .metadata import ParamMetadata, find_field_metadata + + +def match_content_type(content_type: str, pattern: str) -> bool: + if pattern in (content_type, "*", "*/*"): + return True + + msg = Message() + msg["content-type"] = content_type + media_type = msg.get_content_type() + + if media_type == pattern: + return True + + parts = media_type.split("/") + if len(parts) == 2: + if pattern in (f"{parts[0]}/*", f"*/{parts[1]}"): + return True + + return False + + +def match_status_codes(status_codes: List[str], status_code: int) -> bool: + if "default" in status_codes: + return True + + for code in status_codes: + if code == str(status_code): + return True + + if code.endswith("XX") and code.startswith(str(status_code)[:1]): + return True + return False + + +T = TypeVar("T") + +def cast_partial(typ): + return partial(cast, typ) + +def get_global_from_env( + value: Optional[T], env_key: str, type_cast: Callable[[str], T] +) -> Optional[T]: + if value is not None: + return value + env_value = os.getenv(env_key) + if env_value is not None: + try: + return type_cast(env_value) + except ValueError: + pass + return None + + +def match_response( + response: Response, code: Union[str, List[str]], content_type: str +) -> bool: + codes = code if isinstance(code, list) else [code] + return match_status_codes(codes, response.status_code) and match_content_type( + response.headers.get("content-type", "application/octet-stream"), content_type + ) + + +def _populate_from_globals( + param_name: str, value: Any, param_metadata_type: type, gbls: Any +) -> Tuple[Any, bool]: + if gbls is None: + return value, False + + if not isinstance(gbls, BaseModel): + raise TypeError("globals must be a pydantic model") + + global_fields: Dict[str, FieldInfo] = gbls.__class__.model_fields + found = False + for name in global_fields: + field = global_fields[name] + if name is not param_name: + continue + + found = True + + if value is not None: + return value, True + + global_value = getattr(gbls, name) + + param_metadata = find_field_metadata(field, param_metadata_type) + if param_metadata is None: + return value, True + + return global_value, True + + return value, found + + +def _val_to_string(val) -> str: + if isinstance(val, bool): + return str(val).lower() + if isinstance(val, datetime): + return str(val.isoformat().replace("+00:00", "Z")) + if isinstance(val, Enum): + return str(val.value) + + return str(val) + + +def _get_serialized_params( + metadata: ParamMetadata, field_name: str, obj: Any, typ: type +) -> Dict[str, str]: + params: Dict[str, str] = {} + + serialization = metadata.serialization + if serialization == "json": + params[field_name] = marshal_json(obj, typ) + + return params + + +def _is_set(value: Any) -> bool: + return value is not None and not isinstance(value, Unset) diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..bd1a55b --- /dev/null +++ b/uv.lock @@ -0,0 +1,460 @@ +version = 1 +revision = 1 +requires-python = ">=3.9.2" +resolution-markers = [ + "python_full_version >= '3.12'", + "python_full_version == '3.11.*'", + "python_full_version < '3.11'", +] + +[[package]] +name = "annotated-types" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643 }, +] + +[[package]] +name = "anyio" +version = "4.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, + { name = "idna" }, + { name = "sniffio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f1/b4/636b3b65173d3ce9a38ef5f0522789614e590dab6a8d505340a4efe4c567/anyio-4.10.0.tar.gz", hash = "sha256:3f3fae35c96039744587aa5b8371e7e8e603c0702999535961dd336026973ba6", size = 213252 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6f/12/e5e0282d673bb9746bacfb6e2dba8719989d3660cdb2ea79aee9a9651afb/anyio-4.10.0-py3-none-any.whl", hash = "sha256:60e474ac86736bbfd6f210f7a61218939c318f43f9972497381f1c5e930ed3d1", size = 107213 }, +] + +[[package]] +name = "astroid" +version = "3.2.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/53/1067e1113ecaf58312357f2cd93063674924119d80d173adc3f6f2387aa2/astroid-3.2.4.tar.gz", hash = "sha256:0e14202810b30da1b735827f78f5157be2bbd4a7a59b7707ca0bfc2fb4c0063a", size = 397576 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/80/96/b32bbbb46170a1c8b8b1f28c794202e25cfe743565e9d3469b8eb1e0cc05/astroid-3.2.4-py3-none-any.whl", hash = "sha256:413658a61eeca6202a59231abb473f932038fbcbf1666587f66d482083413a25", size = 276348 }, +] + +[[package]] +name = "certifi" +version = "2025.8.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/dc/67/960ebe6bf230a96cda2e0abcf73af550ec4f090005363542f0765df162e0/certifi-2025.8.3.tar.gz", hash = "sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407", size = 162386 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/48/1549795ba7742c948d2ad169c1c8cdbae65bc450d6cd753d124b17c8cd32/certifi-2025.8.3-py3-none-any.whl", hash = "sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5", size = 161216 }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 }, +] + +[[package]] +name = "dill" +version = "0.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/12/80/630b4b88364e9a8c8c5797f4602d0f76ef820909ee32f0bacb9f90654042/dill-0.4.0.tar.gz", hash = "sha256:0633f1d2df477324f53a895b02c901fb961bdbf65a17122586ea7019292cbcf0", size = 186976 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/3d/9373ad9c56321fdab5b41197068e1d8c25883b3fea29dd361f9b55116869/dill-0.4.0-py3-none-any.whl", hash = "sha256:44f54bf6412c2c8464c14e8243eb163690a9800dbe2c367330883b19c7561049", size = 119668 }, +] + +[[package]] +name = "exceptiongroup" +version = "1.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0b/9f/a65090624ecf468cdca03533906e7c69ed7588582240cfe7cc9e770b50eb/exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88", size = 29749 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/36/f4/c6e662dade71f56cd2f3735141b265c3c79293c109549c1e6933b0651ffc/exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10", size = 16674 }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515 }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784 }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517 }, +] + +[[package]] +name = "idna" +version = "3.10" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f1/70/7703c29685631f5a7590aa73f1f1d3fa9a380e654b86af429e0934a32f7d/idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9", size = 190490 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 }, +] + +[[package]] +name = "isort" +version = "5.13.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/87/f9/c1eb8635a24e87ade2efce21e3ce8cd6b8630bb685ddc9cdaca1349b2eb5/isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109", size = 175303 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/b3/8def84f539e7d2289a02f0524b944b15d7c75dab7628bedf1c4f0992029c/isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6", size = 92310 }, +] + +[[package]] +name = "mccabe" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/ff/0ffefdcac38932a54d2b5eed4e0ba8a408f215002cd178ad1df0f2806ff8/mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", size = 9658 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/27/1a/1f68f9ba0c207934b35b86a8ca3aad8395a3d6dd7921c0686e23853ff5a9/mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e", size = 7350 }, +] + +[[package]] +name = "mypy" +version = "1.15.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mypy-extensions" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ce/43/d5e49a86afa64bd3839ea0d5b9c7103487007d728e1293f52525d6d5486a/mypy-1.15.0.tar.gz", hash = "sha256:404534629d51d3efea5c800ee7c42b72a6554d6c400e6a79eafe15d11341fd43", size = 3239717 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/68/f8/65a7ce8d0e09b6329ad0c8d40330d100ea343bd4dd04c4f8ae26462d0a17/mypy-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:979e4e1a006511dacf628e36fadfecbcc0160a8af6ca7dad2f5025529e082c13", size = 10738433 }, + { url = "https://files.pythonhosted.org/packages/b4/95/9c0ecb8eacfe048583706249439ff52105b3f552ea9c4024166c03224270/mypy-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c4bb0e1bd29f7d34efcccd71cf733580191e9a264a2202b0239da95984c5b559", size = 9861472 }, + { url = "https://files.pythonhosted.org/packages/84/09/9ec95e982e282e20c0d5407bc65031dfd0f0f8ecc66b69538296e06fcbee/mypy-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be68172e9fd9ad8fb876c6389f16d1c1b5f100ffa779f77b1fb2176fcc9ab95b", size = 11611424 }, + { url = "https://files.pythonhosted.org/packages/78/13/f7d14e55865036a1e6a0a69580c240f43bc1f37407fe9235c0d4ef25ffb0/mypy-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c7be1e46525adfa0d97681432ee9fcd61a3964c2446795714699a998d193f1a3", size = 12365450 }, + { url = "https://files.pythonhosted.org/packages/48/e1/301a73852d40c241e915ac6d7bcd7fedd47d519246db2d7b86b9d7e7a0cb/mypy-1.15.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2e2c2e6d3593f6451b18588848e66260ff62ccca522dd231cd4dd59b0160668b", size = 12551765 }, + { url = "https://files.pythonhosted.org/packages/77/ba/c37bc323ae5fe7f3f15a28e06ab012cd0b7552886118943e90b15af31195/mypy-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:6983aae8b2f653e098edb77f893f7b6aca69f6cffb19b2cc7443f23cce5f4828", size = 9274701 }, + { url = "https://files.pythonhosted.org/packages/03/bc/f6339726c627bd7ca1ce0fa56c9ae2d0144604a319e0e339bdadafbbb599/mypy-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2922d42e16d6de288022e5ca321cd0618b238cfc5570e0263e5ba0a77dbef56f", size = 10662338 }, + { url = "https://files.pythonhosted.org/packages/e2/90/8dcf506ca1a09b0d17555cc00cd69aee402c203911410136cd716559efe7/mypy-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2ee2d57e01a7c35de00f4634ba1bbf015185b219e4dc5909e281016df43f5ee5", size = 9787540 }, + { url = "https://files.pythonhosted.org/packages/05/05/a10f9479681e5da09ef2f9426f650d7b550d4bafbef683b69aad1ba87457/mypy-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:973500e0774b85d9689715feeffcc980193086551110fd678ebe1f4342fb7c5e", size = 11538051 }, + { url = "https://files.pythonhosted.org/packages/e9/9a/1f7d18b30edd57441a6411fcbc0c6869448d1a4bacbaee60656ac0fc29c8/mypy-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a95fb17c13e29d2d5195869262f8125dfdb5c134dc8d9a9d0aecf7525b10c2c", size = 12286751 }, + { url = "https://files.pythonhosted.org/packages/72/af/19ff499b6f1dafcaf56f9881f7a965ac2f474f69f6f618b5175b044299f5/mypy-1.15.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:1905f494bfd7d85a23a88c5d97840888a7bd516545fc5aaedff0267e0bb54e2f", size = 12421783 }, + { url = "https://files.pythonhosted.org/packages/96/39/11b57431a1f686c1aed54bf794870efe0f6aeca11aca281a0bd87a5ad42c/mypy-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:c9817fa23833ff189db061e6d2eff49b2f3b6ed9856b4a0a73046e41932d744f", size = 9265618 }, + { url = "https://files.pythonhosted.org/packages/98/3a/03c74331c5eb8bd025734e04c9840532226775c47a2c39b56a0c8d4f128d/mypy-1.15.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:aea39e0583d05124836ea645f412e88a5c7d0fd77a6d694b60d9b6b2d9f184fd", size = 10793981 }, + { url = "https://files.pythonhosted.org/packages/f0/1a/41759b18f2cfd568848a37c89030aeb03534411eef981df621d8fad08a1d/mypy-1.15.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2f2147ab812b75e5b5499b01ade1f4a81489a147c01585cda36019102538615f", size = 9749175 }, + { url = "https://files.pythonhosted.org/packages/12/7e/873481abf1ef112c582db832740f4c11b2bfa510e829d6da29b0ab8c3f9c/mypy-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ce436f4c6d218a070048ed6a44c0bbb10cd2cc5e272b29e7845f6a2f57ee4464", size = 11455675 }, + { url = "https://files.pythonhosted.org/packages/b3/d0/92ae4cde706923a2d3f2d6c39629134063ff64b9dedca9c1388363da072d/mypy-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8023ff13985661b50a5928fc7a5ca15f3d1affb41e5f0a9952cb68ef090b31ee", size = 12410020 }, + { url = "https://files.pythonhosted.org/packages/46/8b/df49974b337cce35f828ba6fda228152d6db45fed4c86ba56ffe442434fd/mypy-1.15.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:1124a18bc11a6a62887e3e137f37f53fbae476dc36c185d549d4f837a2a6a14e", size = 12498582 }, + { url = "https://files.pythonhosted.org/packages/13/50/da5203fcf6c53044a0b699939f31075c45ae8a4cadf538a9069b165c1050/mypy-1.15.0-cp312-cp312-win_amd64.whl", hash = "sha256:171a9ca9a40cd1843abeca0e405bc1940cd9b305eaeea2dda769ba096932bb22", size = 9366614 }, + { url = "https://files.pythonhosted.org/packages/6a/9b/fd2e05d6ffff24d912f150b87db9e364fa8282045c875654ce7e32fffa66/mypy-1.15.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:93faf3fdb04768d44bf28693293f3904bbb555d076b781ad2530214ee53e3445", size = 10788592 }, + { url = "https://files.pythonhosted.org/packages/74/37/b246d711c28a03ead1fd906bbc7106659aed7c089d55fe40dd58db812628/mypy-1.15.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:811aeccadfb730024c5d3e326b2fbe9249bb7413553f15499a4050f7c30e801d", size = 9753611 }, + { url = "https://files.pythonhosted.org/packages/a6/ac/395808a92e10cfdac8003c3de9a2ab6dc7cde6c0d2a4df3df1b815ffd067/mypy-1.15.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:98b7b9b9aedb65fe628c62a6dc57f6d5088ef2dfca37903a7d9ee374d03acca5", size = 11438443 }, + { url = "https://files.pythonhosted.org/packages/d2/8b/801aa06445d2de3895f59e476f38f3f8d610ef5d6908245f07d002676cbf/mypy-1.15.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43a7682e24b4f576d93072216bf56eeff70d9140241f9edec0c104d0c515036", size = 12402541 }, + { url = "https://files.pythonhosted.org/packages/c7/67/5a4268782eb77344cc613a4cf23540928e41f018a9a1ec4c6882baf20ab8/mypy-1.15.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:baefc32840a9f00babd83251560e0ae1573e2f9d1b067719479bfb0e987c6357", size = 12494348 }, + { url = "https://files.pythonhosted.org/packages/83/3e/57bb447f7bbbfaabf1712d96f9df142624a386d98fb026a761532526057e/mypy-1.15.0-cp313-cp313-win_amd64.whl", hash = "sha256:b9378e2c00146c44793c98b8d5a61039a048e31f429fb0eb546d93f4b000bedf", size = 9373648 }, + { url = "https://files.pythonhosted.org/packages/5a/fa/79cf41a55b682794abe71372151dbbf856e3008f6767057229e6649d294a/mypy-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e601a7fa172c2131bff456bb3ee08a88360760d0d2f8cbd7a75a65497e2df078", size = 10737129 }, + { url = "https://files.pythonhosted.org/packages/d3/33/dd8feb2597d648de29e3da0a8bf4e1afbda472964d2a4a0052203a6f3594/mypy-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:712e962a6357634fef20412699a3655c610110e01cdaa6180acec7fc9f8513ba", size = 9856335 }, + { url = "https://files.pythonhosted.org/packages/e4/b5/74508959c1b06b96674b364ffeb7ae5802646b32929b7701fc6b18447592/mypy-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f95579473af29ab73a10bada2f9722856792a36ec5af5399b653aa28360290a5", size = 11611935 }, + { url = "https://files.pythonhosted.org/packages/6c/53/da61b9d9973efcd6507183fdad96606996191657fe79701b2c818714d573/mypy-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8f8722560a14cde92fdb1e31597760dc35f9f5524cce17836c0d22841830fd5b", size = 12365827 }, + { url = "https://files.pythonhosted.org/packages/c1/72/965bd9ee89540c79a25778cc080c7e6ef40aa1eeac4d52cec7eae6eb5228/mypy-1.15.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:1fbb8da62dc352133d7d7ca90ed2fb0e9d42bb1a32724c287d3c76c58cbaa9c2", size = 12541924 }, + { url = "https://files.pythonhosted.org/packages/46/d0/f41645c2eb263e6c77ada7d76f894c580c9ddb20d77f0c24d34273a4dab2/mypy-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:d10d994b41fb3497719bbf866f227b3489048ea4bbbb5015357db306249f7980", size = 9271176 }, + { url = "https://files.pythonhosted.org/packages/09/4e/a7d65c7322c510de2c409ff3828b03354a7c43f5a8ed458a7a131b41c7b9/mypy-1.15.0-py3-none-any.whl", hash = "sha256:5469affef548bd1895d86d3bf10ce2b44e33d86923c29e4d675b3e323437ea3e", size = 2221777 }, +] + +[[package]] +name = "mypy-extensions" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963 }, +] + +[[package]] +name = "openrouter" +version = "0.1.2" +source = { editable = "." } +dependencies = [ + { name = "httpcore" }, + { name = "httpx" }, + { name = "pydantic" }, +] + +[package.dev-dependencies] +dev = [ + { name = "mypy" }, + { name = "pylint" }, +] + +[package.metadata] +requires-dist = [ + { name = "httpcore", specifier = ">=1.0.9" }, + { name = "httpx", specifier = ">=0.28.1" }, + { name = "pydantic", specifier = ">=2.11.2" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "mypy", specifier = "==1.15.0" }, + { name = "pylint", specifier = "==3.2.3" }, +] + +[[package]] +name = "platformdirs" +version = "4.3.8" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fe/8b/3c73abc9c759ecd3f1f7ceff6685840859e8070c4d947c93fae71f6a0bf2/platformdirs-4.3.8.tar.gz", hash = "sha256:3d512d96e16bcb959a814c9f348431070822a6496326a4be0911c40b5a74c2bc", size = 21362 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fe/39/979e8e21520d4e47a0bbe349e2713c0aac6f3d853d0e5b34d76206c439aa/platformdirs-4.3.8-py3-none-any.whl", hash = "sha256:ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4", size = 18567 }, +] + +[[package]] +name = "pydantic" +version = "2.11.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/00/dd/4325abf92c39ba8623b5af936ddb36ffcfe0beae70405d456ab1fb2f5b8c/pydantic-2.11.7.tar.gz", hash = "sha256:d989c3c6cb79469287b1569f7447a17848c998458d49ebe294e975b9baf0f0db", size = 788350 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6a/c0/ec2b1c8712ca690e5d61979dee872603e92b8a32f94cc1b72d53beab008a/pydantic-2.11.7-py3-none-any.whl", hash = "sha256:dde5df002701f6de26248661f6835bbe296a47bf73990135c7d07ce741b9623b", size = 444782 }, +] + +[[package]] +name = "pydantic-core" +version = "2.33.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ad/88/5f2260bdfae97aabf98f1778d43f69574390ad787afb646292a638c923d4/pydantic_core-2.33.2.tar.gz", hash = "sha256:7cb8bc3605c29176e1b105350d2e6474142d7c1bd1d9327c4a9bdb46bf827acc", size = 435195 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/92/b31726561b5dae176c2d2c2dc43a9c5bfba5d32f96f8b4c0a600dd492447/pydantic_core-2.33.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:2b3d326aaef0c0399d9afffeb6367d5e26ddc24d351dbc9c636840ac355dc5d8", size = 2028817 }, + { url = "https://files.pythonhosted.org/packages/a3/44/3f0b95fafdaca04a483c4e685fe437c6891001bf3ce8b2fded82b9ea3aa1/pydantic_core-2.33.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e5b2671f05ba48b94cb90ce55d8bdcaaedb8ba00cc5359f6810fc918713983d", size = 1861357 }, + { url = "https://files.pythonhosted.org/packages/30/97/e8f13b55766234caae05372826e8e4b3b96e7b248be3157f53237682e43c/pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0069c9acc3f3981b9ff4cdfaf088e98d83440a4c7ea1bc07460af3d4dc22e72d", size = 1898011 }, + { url = "https://files.pythonhosted.org/packages/9b/a3/99c48cf7bafc991cc3ee66fd544c0aae8dc907b752f1dad2d79b1b5a471f/pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d53b22f2032c42eaaf025f7c40c2e3b94568ae077a606f006d206a463bc69572", size = 1982730 }, + { url = "https://files.pythonhosted.org/packages/de/8e/a5b882ec4307010a840fb8b58bd9bf65d1840c92eae7534c7441709bf54b/pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0405262705a123b7ce9f0b92f123334d67b70fd1f20a9372b907ce1080c7ba02", size = 2136178 }, + { url = "https://files.pythonhosted.org/packages/e4/bb/71e35fc3ed05af6834e890edb75968e2802fe98778971ab5cba20a162315/pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4b25d91e288e2c4e0662b8038a28c6a07eaac3e196cfc4ff69de4ea3db992a1b", size = 2736462 }, + { url = "https://files.pythonhosted.org/packages/31/0d/c8f7593e6bc7066289bbc366f2235701dcbebcd1ff0ef8e64f6f239fb47d/pydantic_core-2.33.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bdfe4b3789761f3bcb4b1ddf33355a71079858958e3a552f16d5af19768fef2", size = 2005652 }, + { url = "https://files.pythonhosted.org/packages/d2/7a/996d8bd75f3eda405e3dd219ff5ff0a283cd8e34add39d8ef9157e722867/pydantic_core-2.33.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:efec8db3266b76ef9607c2c4c419bdb06bf335ae433b80816089ea7585816f6a", size = 2113306 }, + { url = "https://files.pythonhosted.org/packages/ff/84/daf2a6fb2db40ffda6578a7e8c5a6e9c8affb251a05c233ae37098118788/pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:031c57d67ca86902726e0fae2214ce6770bbe2f710dc33063187a68744a5ecac", size = 2073720 }, + { url = "https://files.pythonhosted.org/packages/77/fb/2258da019f4825128445ae79456a5499c032b55849dbd5bed78c95ccf163/pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:f8de619080e944347f5f20de29a975c2d815d9ddd8be9b9b7268e2e3ef68605a", size = 2244915 }, + { url = "https://files.pythonhosted.org/packages/d8/7a/925ff73756031289468326e355b6fa8316960d0d65f8b5d6b3a3e7866de7/pydantic_core-2.33.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:73662edf539e72a9440129f231ed3757faab89630d291b784ca99237fb94db2b", size = 2241884 }, + { url = "https://files.pythonhosted.org/packages/0b/b0/249ee6d2646f1cdadcb813805fe76265745c4010cf20a8eba7b0e639d9b2/pydantic_core-2.33.2-cp310-cp310-win32.whl", hash = "sha256:0a39979dcbb70998b0e505fb1556a1d550a0781463ce84ebf915ba293ccb7e22", size = 1910496 }, + { url = "https://files.pythonhosted.org/packages/66/ff/172ba8f12a42d4b552917aa65d1f2328990d3ccfc01d5b7c943ec084299f/pydantic_core-2.33.2-cp310-cp310-win_amd64.whl", hash = "sha256:b0379a2b24882fef529ec3b4987cb5d003b9cda32256024e6fe1586ac45fc640", size = 1955019 }, + { url = "https://files.pythonhosted.org/packages/3f/8d/71db63483d518cbbf290261a1fc2839d17ff89fce7089e08cad07ccfce67/pydantic_core-2.33.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:4c5b0a576fb381edd6d27f0a85915c6daf2f8138dc5c267a57c08a62900758c7", size = 2028584 }, + { url = "https://files.pythonhosted.org/packages/24/2f/3cfa7244ae292dd850989f328722d2aef313f74ffc471184dc509e1e4e5a/pydantic_core-2.33.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e799c050df38a639db758c617ec771fd8fb7a5f8eaaa4b27b101f266b216a246", size = 1855071 }, + { url = "https://files.pythonhosted.org/packages/b3/d3/4ae42d33f5e3f50dd467761304be2fa0a9417fbf09735bc2cce003480f2a/pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dc46a01bf8d62f227d5ecee74178ffc448ff4e5197c756331f71efcc66dc980f", size = 1897823 }, + { url = "https://files.pythonhosted.org/packages/f4/f3/aa5976e8352b7695ff808599794b1fba2a9ae2ee954a3426855935799488/pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a144d4f717285c6d9234a66778059f33a89096dfb9b39117663fd8413d582dcc", size = 1983792 }, + { url = "https://files.pythonhosted.org/packages/d5/7a/cda9b5a23c552037717f2b2a5257e9b2bfe45e687386df9591eff7b46d28/pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:73cf6373c21bc80b2e0dc88444f41ae60b2f070ed02095754eb5a01df12256de", size = 2136338 }, + { url = "https://files.pythonhosted.org/packages/2b/9f/b8f9ec8dd1417eb9da784e91e1667d58a2a4a7b7b34cf4af765ef663a7e5/pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3dc625f4aa79713512d1976fe9f0bc99f706a9dee21dfd1810b4bbbf228d0e8a", size = 2730998 }, + { url = "https://files.pythonhosted.org/packages/47/bc/cd720e078576bdb8255d5032c5d63ee5c0bf4b7173dd955185a1d658c456/pydantic_core-2.33.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:881b21b5549499972441da4758d662aeea93f1923f953e9cbaff14b8b9565aef", size = 2003200 }, + { url = "https://files.pythonhosted.org/packages/ca/22/3602b895ee2cd29d11a2b349372446ae9727c32e78a94b3d588a40fdf187/pydantic_core-2.33.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bdc25f3681f7b78572699569514036afe3c243bc3059d3942624e936ec93450e", size = 2113890 }, + { url = "https://files.pythonhosted.org/packages/ff/e6/e3c5908c03cf00d629eb38393a98fccc38ee0ce8ecce32f69fc7d7b558a7/pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:fe5b32187cbc0c862ee201ad66c30cf218e5ed468ec8dc1cf49dec66e160cc4d", size = 2073359 }, + { url = "https://files.pythonhosted.org/packages/12/e7/6a36a07c59ebefc8777d1ffdaf5ae71b06b21952582e4b07eba88a421c79/pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:bc7aee6f634a6f4a95676fcb5d6559a2c2a390330098dba5e5a5f28a2e4ada30", size = 2245883 }, + { url = "https://files.pythonhosted.org/packages/16/3f/59b3187aaa6cc0c1e6616e8045b284de2b6a87b027cce2ffcea073adf1d2/pydantic_core-2.33.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:235f45e5dbcccf6bd99f9f472858849f73d11120d76ea8707115415f8e5ebebf", size = 2241074 }, + { url = "https://files.pythonhosted.org/packages/e0/ed/55532bb88f674d5d8f67ab121a2a13c385df382de2a1677f30ad385f7438/pydantic_core-2.33.2-cp311-cp311-win32.whl", hash = "sha256:6368900c2d3ef09b69cb0b913f9f8263b03786e5b2a387706c5afb66800efd51", size = 1910538 }, + { url = "https://files.pythonhosted.org/packages/fe/1b/25b7cccd4519c0b23c2dd636ad39d381abf113085ce4f7bec2b0dc755eb1/pydantic_core-2.33.2-cp311-cp311-win_amd64.whl", hash = "sha256:1e063337ef9e9820c77acc768546325ebe04ee38b08703244c1309cccc4f1bab", size = 1952909 }, + { url = "https://files.pythonhosted.org/packages/49/a9/d809358e49126438055884c4366a1f6227f0f84f635a9014e2deb9b9de54/pydantic_core-2.33.2-cp311-cp311-win_arm64.whl", hash = "sha256:6b99022f1d19bc32a4c2a0d544fc9a76e3be90f0b3f4af413f87d38749300e65", size = 1897786 }, + { url = "https://files.pythonhosted.org/packages/18/8a/2b41c97f554ec8c71f2a8a5f85cb56a8b0956addfe8b0efb5b3d77e8bdc3/pydantic_core-2.33.2-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:a7ec89dc587667f22b6a0b6579c249fca9026ce7c333fc142ba42411fa243cdc", size = 2009000 }, + { url = "https://files.pythonhosted.org/packages/a1/02/6224312aacb3c8ecbaa959897af57181fb6cf3a3d7917fd44d0f2917e6f2/pydantic_core-2.33.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3c6db6e52c6d70aa0d00d45cdb9b40f0433b96380071ea80b09277dba021ddf7", size = 1847996 }, + { url = "https://files.pythonhosted.org/packages/d6/46/6dcdf084a523dbe0a0be59d054734b86a981726f221f4562aed313dbcb49/pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e61206137cbc65e6d5256e1166f88331d3b6238e082d9f74613b9b765fb9025", size = 1880957 }, + { url = "https://files.pythonhosted.org/packages/ec/6b/1ec2c03837ac00886ba8160ce041ce4e325b41d06a034adbef11339ae422/pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eb8c529b2819c37140eb51b914153063d27ed88e3bdc31b71198a198e921e011", size = 1964199 }, + { url = "https://files.pythonhosted.org/packages/2d/1d/6bf34d6adb9debd9136bd197ca72642203ce9aaaa85cfcbfcf20f9696e83/pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c52b02ad8b4e2cf14ca7b3d918f3eb0ee91e63b3167c32591e57c4317e134f8f", size = 2120296 }, + { url = "https://files.pythonhosted.org/packages/e0/94/2bd0aaf5a591e974b32a9f7123f16637776c304471a0ab33cf263cf5591a/pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:96081f1605125ba0855dfda83f6f3df5ec90c61195421ba72223de35ccfb2f88", size = 2676109 }, + { url = "https://files.pythonhosted.org/packages/f9/41/4b043778cf9c4285d59742281a769eac371b9e47e35f98ad321349cc5d61/pydantic_core-2.33.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f57a69461af2a5fa6e6bbd7a5f60d3b7e6cebb687f55106933188e79ad155c1", size = 2002028 }, + { url = "https://files.pythonhosted.org/packages/cb/d5/7bb781bf2748ce3d03af04d5c969fa1308880e1dca35a9bd94e1a96a922e/pydantic_core-2.33.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:572c7e6c8bb4774d2ac88929e3d1f12bc45714ae5ee6d9a788a9fb35e60bb04b", size = 2100044 }, + { url = "https://files.pythonhosted.org/packages/fe/36/def5e53e1eb0ad896785702a5bbfd25eed546cdcf4087ad285021a90ed53/pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:db4b41f9bd95fbe5acd76d89920336ba96f03e149097365afe1cb092fceb89a1", size = 2058881 }, + { url = "https://files.pythonhosted.org/packages/01/6c/57f8d70b2ee57fc3dc8b9610315949837fa8c11d86927b9bb044f8705419/pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:fa854f5cf7e33842a892e5c73f45327760bc7bc516339fda888c75ae60edaeb6", size = 2227034 }, + { url = "https://files.pythonhosted.org/packages/27/b9/9c17f0396a82b3d5cbea4c24d742083422639e7bb1d5bf600e12cb176a13/pydantic_core-2.33.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5f483cfb75ff703095c59e365360cb73e00185e01aaea067cd19acffd2ab20ea", size = 2234187 }, + { url = "https://files.pythonhosted.org/packages/b0/6a/adf5734ffd52bf86d865093ad70b2ce543415e0e356f6cacabbc0d9ad910/pydantic_core-2.33.2-cp312-cp312-win32.whl", hash = "sha256:9cb1da0f5a471435a7bc7e439b8a728e8b61e59784b2af70d7c169f8dd8ae290", size = 1892628 }, + { url = "https://files.pythonhosted.org/packages/43/e4/5479fecb3606c1368d496a825d8411e126133c41224c1e7238be58b87d7e/pydantic_core-2.33.2-cp312-cp312-win_amd64.whl", hash = "sha256:f941635f2a3d96b2973e867144fde513665c87f13fe0e193c158ac51bfaaa7b2", size = 1955866 }, + { url = "https://files.pythonhosted.org/packages/0d/24/8b11e8b3e2be9dd82df4b11408a67c61bb4dc4f8e11b5b0fc888b38118b5/pydantic_core-2.33.2-cp312-cp312-win_arm64.whl", hash = "sha256:cca3868ddfaccfbc4bfb1d608e2ccaaebe0ae628e1416aeb9c4d88c001bb45ab", size = 1888894 }, + { url = "https://files.pythonhosted.org/packages/46/8c/99040727b41f56616573a28771b1bfa08a3d3fe74d3d513f01251f79f172/pydantic_core-2.33.2-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:1082dd3e2d7109ad8b7da48e1d4710c8d06c253cbc4a27c1cff4fbcaa97a9e3f", size = 2015688 }, + { url = "https://files.pythonhosted.org/packages/3a/cc/5999d1eb705a6cefc31f0b4a90e9f7fc400539b1a1030529700cc1b51838/pydantic_core-2.33.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f517ca031dfc037a9c07e748cefd8d96235088b83b4f4ba8939105d20fa1dcd6", size = 1844808 }, + { url = "https://files.pythonhosted.org/packages/6f/5e/a0a7b8885c98889a18b6e376f344da1ef323d270b44edf8174d6bce4d622/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a9f2c9dd19656823cb8250b0724ee9c60a82f3cdf68a080979d13092a3b0fef", size = 1885580 }, + { url = "https://files.pythonhosted.org/packages/3b/2a/953581f343c7d11a304581156618c3f592435523dd9d79865903272c256a/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2b0a451c263b01acebe51895bfb0e1cc842a5c666efe06cdf13846c7418caa9a", size = 1973859 }, + { url = "https://files.pythonhosted.org/packages/e6/55/f1a813904771c03a3f97f676c62cca0c0a4138654107c1b61f19c644868b/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ea40a64d23faa25e62a70ad163571c0b342b8bf66d5fa612ac0dec4f069d916", size = 2120810 }, + { url = "https://files.pythonhosted.org/packages/aa/c3/053389835a996e18853ba107a63caae0b9deb4a276c6b472931ea9ae6e48/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fb2d542b4d66f9470e8065c5469ec676978d625a8b7a363f07d9a501a9cb36a", size = 2676498 }, + { url = "https://files.pythonhosted.org/packages/eb/3c/f4abd740877a35abade05e437245b192f9d0ffb48bbbbd708df33d3cda37/pydantic_core-2.33.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fdac5d6ffa1b5a83bca06ffe7583f5576555e6c8b3a91fbd25ea7780f825f7d", size = 2000611 }, + { url = "https://files.pythonhosted.org/packages/59/a7/63ef2fed1837d1121a894d0ce88439fe3e3b3e48c7543b2a4479eb99c2bd/pydantic_core-2.33.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:04a1a413977ab517154eebb2d326da71638271477d6ad87a769102f7c2488c56", size = 2107924 }, + { url = "https://files.pythonhosted.org/packages/04/8f/2551964ef045669801675f1cfc3b0d74147f4901c3ffa42be2ddb1f0efc4/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:c8e7af2f4e0194c22b5b37205bfb293d166a7344a5b0d0eaccebc376546d77d5", size = 2063196 }, + { url = "https://files.pythonhosted.org/packages/26/bd/d9602777e77fc6dbb0c7db9ad356e9a985825547dce5ad1d30ee04903918/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:5c92edd15cd58b3c2d34873597a1e20f13094f59cf88068adb18947df5455b4e", size = 2236389 }, + { url = "https://files.pythonhosted.org/packages/42/db/0e950daa7e2230423ab342ae918a794964b053bec24ba8af013fc7c94846/pydantic_core-2.33.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:65132b7b4a1c0beded5e057324b7e16e10910c106d43675d9bd87d4f38dde162", size = 2239223 }, + { url = "https://files.pythonhosted.org/packages/58/4d/4f937099c545a8a17eb52cb67fe0447fd9a373b348ccfa9a87f141eeb00f/pydantic_core-2.33.2-cp313-cp313-win32.whl", hash = "sha256:52fb90784e0a242bb96ec53f42196a17278855b0f31ac7c3cc6f5c1ec4811849", size = 1900473 }, + { url = "https://files.pythonhosted.org/packages/a0/75/4a0a9bac998d78d889def5e4ef2b065acba8cae8c93696906c3a91f310ca/pydantic_core-2.33.2-cp313-cp313-win_amd64.whl", hash = "sha256:c083a3bdd5a93dfe480f1125926afcdbf2917ae714bdb80b36d34318b2bec5d9", size = 1955269 }, + { url = "https://files.pythonhosted.org/packages/f9/86/1beda0576969592f1497b4ce8e7bc8cbdf614c352426271b1b10d5f0aa64/pydantic_core-2.33.2-cp313-cp313-win_arm64.whl", hash = "sha256:e80b087132752f6b3d714f041ccf74403799d3b23a72722ea2e6ba2e892555b9", size = 1893921 }, + { url = "https://files.pythonhosted.org/packages/a4/7d/e09391c2eebeab681df2b74bfe6c43422fffede8dc74187b2b0bf6fd7571/pydantic_core-2.33.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:61c18fba8e5e9db3ab908620af374db0ac1baa69f0f32df4f61ae23f15e586ac", size = 1806162 }, + { url = "https://files.pythonhosted.org/packages/f1/3d/847b6b1fed9f8ed3bb95a9ad04fbd0b212e832d4f0f50ff4d9ee5a9f15cf/pydantic_core-2.33.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95237e53bb015f67b63c91af7518a62a8660376a6a0db19b89acc77a4d6199f5", size = 1981560 }, + { url = "https://files.pythonhosted.org/packages/6f/9a/e73262f6c6656262b5fdd723ad90f518f579b7bc8622e43a942eec53c938/pydantic_core-2.33.2-cp313-cp313t-win_amd64.whl", hash = "sha256:c2fc0a768ef76c15ab9238afa6da7f69895bb5d1ee83aeea2e3509af4472d0b9", size = 1935777 }, + { url = "https://files.pythonhosted.org/packages/53/ea/bbe9095cdd771987d13c82d104a9c8559ae9aec1e29f139e286fd2e9256e/pydantic_core-2.33.2-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:a2b911a5b90e0374d03813674bf0a5fbbb7741570dcd4b4e85a2e48d17def29d", size = 2028677 }, + { url = "https://files.pythonhosted.org/packages/49/1d/4ac5ed228078737d457a609013e8f7edc64adc37b91d619ea965758369e5/pydantic_core-2.33.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6fa6dfc3e4d1f734a34710f391ae822e0a8eb8559a85c6979e14e65ee6ba2954", size = 1864735 }, + { url = "https://files.pythonhosted.org/packages/23/9a/2e70d6388d7cda488ae38f57bc2f7b03ee442fbcf0d75d848304ac7e405b/pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c54c939ee22dc8e2d545da79fc5381f1c020d6d3141d3bd747eab59164dc89fb", size = 1898467 }, + { url = "https://files.pythonhosted.org/packages/ff/2e/1568934feb43370c1ffb78a77f0baaa5a8b6897513e7a91051af707ffdc4/pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53a57d2ed685940a504248187d5685e49eb5eef0f696853647bf37c418c538f7", size = 1983041 }, + { url = "https://files.pythonhosted.org/packages/01/1a/1a1118f38ab64eac2f6269eb8c120ab915be30e387bb561e3af904b12499/pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:09fb9dd6571aacd023fe6aaca316bd01cf60ab27240d7eb39ebd66a3a15293b4", size = 2136503 }, + { url = "https://files.pythonhosted.org/packages/5c/da/44754d1d7ae0f22d6d3ce6c6b1486fc07ac2c524ed8f6eca636e2e1ee49b/pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0e6116757f7959a712db11f3e9c0a99ade00a5bbedae83cb801985aa154f071b", size = 2736079 }, + { url = "https://files.pythonhosted.org/packages/4d/98/f43cd89172220ec5aa86654967b22d862146bc4d736b1350b4c41e7c9c03/pydantic_core-2.33.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d55ab81c57b8ff8548c3e4947f119551253f4e3787a7bbc0b6b3ca47498a9d3", size = 2006508 }, + { url = "https://files.pythonhosted.org/packages/2b/cc/f77e8e242171d2158309f830f7d5d07e0531b756106f36bc18712dc439df/pydantic_core-2.33.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c20c462aa4434b33a2661701b861604913f912254e441ab8d78d30485736115a", size = 2113693 }, + { url = "https://files.pythonhosted.org/packages/54/7a/7be6a7bd43e0a47c147ba7fbf124fe8aaf1200bc587da925509641113b2d/pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:44857c3227d3fb5e753d5fe4a3420d6376fa594b07b621e220cd93703fe21782", size = 2074224 }, + { url = "https://files.pythonhosted.org/packages/2a/07/31cf8fadffbb03be1cb520850e00a8490c0927ec456e8293cafda0726184/pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_armv7l.whl", hash = "sha256:eb9b459ca4df0e5c87deb59d37377461a538852765293f9e6ee834f0435a93b9", size = 2245403 }, + { url = "https://files.pythonhosted.org/packages/b6/8d/bbaf4c6721b668d44f01861f297eb01c9b35f612f6b8e14173cb204e6240/pydantic_core-2.33.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9fcd347d2cc5c23b06de6d3b7b8275be558a0c90549495c699e379a80bf8379e", size = 2242331 }, + { url = "https://files.pythonhosted.org/packages/bb/93/3cc157026bca8f5006250e74515119fcaa6d6858aceee8f67ab6dc548c16/pydantic_core-2.33.2-cp39-cp39-win32.whl", hash = "sha256:83aa99b1285bc8f038941ddf598501a86f1536789740991d7d8756e34f1e74d9", size = 1910571 }, + { url = "https://files.pythonhosted.org/packages/5b/90/7edc3b2a0d9f0dda8806c04e511a67b0b7a41d2187e2003673a996fb4310/pydantic_core-2.33.2-cp39-cp39-win_amd64.whl", hash = "sha256:f481959862f57f29601ccced557cc2e817bce7533ab8e01a797a48b49c9692b3", size = 1956504 }, + { url = "https://files.pythonhosted.org/packages/30/68/373d55e58b7e83ce371691f6eaa7175e3a24b956c44628eb25d7da007917/pydantic_core-2.33.2-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:5c4aa4e82353f65e548c476b37e64189783aa5384903bfea4f41580f255fddfa", size = 2023982 }, + { url = "https://files.pythonhosted.org/packages/a4/16/145f54ac08c96a63d8ed6442f9dec17b2773d19920b627b18d4f10a061ea/pydantic_core-2.33.2-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d946c8bf0d5c24bf4fe333af284c59a19358aa3ec18cb3dc4370080da1e8ad29", size = 1858412 }, + { url = "https://files.pythonhosted.org/packages/41/b1/c6dc6c3e2de4516c0bb2c46f6a373b91b5660312342a0cf5826e38ad82fa/pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:87b31b6846e361ef83fedb187bb5b4372d0da3f7e28d85415efa92d6125d6e6d", size = 1892749 }, + { url = "https://files.pythonhosted.org/packages/12/73/8cd57e20afba760b21b742106f9dbdfa6697f1570b189c7457a1af4cd8a0/pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa9d91b338f2df0508606f7009fde642391425189bba6d8c653afd80fd6bb64e", size = 2067527 }, + { url = "https://files.pythonhosted.org/packages/e3/d5/0bb5d988cc019b3cba4a78f2d4b3854427fc47ee8ec8e9eaabf787da239c/pydantic_core-2.33.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2058a32994f1fde4ca0480ab9d1e75a0e8c87c22b53a3ae66554f9af78f2fe8c", size = 2108225 }, + { url = "https://files.pythonhosted.org/packages/f1/c5/00c02d1571913d496aabf146106ad8239dc132485ee22efe08085084ff7c/pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:0e03262ab796d986f978f79c943fc5f620381be7287148b8010b4097f79a39ec", size = 2069490 }, + { url = "https://files.pythonhosted.org/packages/22/a8/dccc38768274d3ed3a59b5d06f59ccb845778687652daa71df0cab4040d7/pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:1a8695a8d00c73e50bff9dfda4d540b7dee29ff9b8053e38380426a85ef10052", size = 2237525 }, + { url = "https://files.pythonhosted.org/packages/d4/e7/4f98c0b125dda7cf7ccd14ba936218397b44f50a56dd8c16a3091df116c3/pydantic_core-2.33.2-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:fa754d1850735a0b0e03bcffd9d4b4343eb417e47196e4485d9cca326073a42c", size = 2238446 }, + { url = "https://files.pythonhosted.org/packages/ce/91/2ec36480fdb0b783cd9ef6795753c1dea13882f2e68e73bce76ae8c21e6a/pydantic_core-2.33.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a11c8d26a50bfab49002947d3d237abe4d9e4b5bdc8846a63537b6488e197808", size = 2066678 }, + { url = "https://files.pythonhosted.org/packages/7b/27/d4ae6487d73948d6f20dddcd94be4ea43e74349b56eba82e9bdee2d7494c/pydantic_core-2.33.2-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:dd14041875d09cc0f9308e37a6f8b65f5585cf2598a53aa0123df8b129d481f8", size = 2025200 }, + { url = "https://files.pythonhosted.org/packages/f1/b8/b3cb95375f05d33801024079b9392a5ab45267a63400bf1866e7ce0f0de4/pydantic_core-2.33.2-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:d87c561733f66531dced0da6e864f44ebf89a8fba55f31407b00c2f7f9449593", size = 1859123 }, + { url = "https://files.pythonhosted.org/packages/05/bc/0d0b5adeda59a261cd30a1235a445bf55c7e46ae44aea28f7bd6ed46e091/pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f82865531efd18d6e07a04a17331af02cb7a651583c418df8266f17a63c6612", size = 1892852 }, + { url = "https://files.pythonhosted.org/packages/3e/11/d37bdebbda2e449cb3f519f6ce950927b56d62f0b84fd9cb9e372a26a3d5/pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2bfb5112df54209d820d7bf9317c7a6c9025ea52e49f46b6a2060104bba37de7", size = 2067484 }, + { url = "https://files.pythonhosted.org/packages/8c/55/1f95f0a05ce72ecb02a8a8a1c3be0579bbc29b1d5ab68f1378b7bebc5057/pydantic_core-2.33.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:64632ff9d614e5eecfb495796ad51b0ed98c453e447a76bcbeeb69615079fc7e", size = 2108896 }, + { url = "https://files.pythonhosted.org/packages/53/89/2b2de6c81fa131f423246a9109d7b2a375e83968ad0800d6e57d0574629b/pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:f889f7a40498cc077332c7ab6b4608d296d852182211787d4f3ee377aaae66e8", size = 2069475 }, + { url = "https://files.pythonhosted.org/packages/b8/e9/1f7efbe20d0b2b10f6718944b5d8ece9152390904f29a78e68d4e7961159/pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:de4b83bb311557e439b9e186f733f6c645b9417c84e2eb8203f3f820a4b988bf", size = 2239013 }, + { url = "https://files.pythonhosted.org/packages/3c/b2/5309c905a93811524a49b4e031e9851a6b00ff0fb668794472ea7746b448/pydantic_core-2.33.2-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:82f68293f055f51b51ea42fafc74b6aad03e70e191799430b90c13d643059ebb", size = 2238715 }, + { url = "https://files.pythonhosted.org/packages/32/56/8a7ca5d2cd2cda1d245d34b1c9a942920a718082ae8e54e5f3e5a58b7add/pydantic_core-2.33.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:329467cecfb529c925cf2bbd4d60d2c509bc2fb52a20c1045bf09bb70971a9c1", size = 2066757 }, + { url = "https://files.pythonhosted.org/packages/08/98/dbf3fdfabaf81cda5622154fda78ea9965ac467e3239078e0dcd6df159e7/pydantic_core-2.33.2-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:87acbfcf8e90ca885206e98359d7dca4bcbb35abdc0ff66672a293e1d7a19101", size = 2024034 }, + { url = "https://files.pythonhosted.org/packages/8d/99/7810aa9256e7f2ccd492590f86b79d370df1e9292f1f80b000b6a75bd2fb/pydantic_core-2.33.2-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:7f92c15cd1e97d4b12acd1cc9004fa092578acfa57b67ad5e43a197175d01a64", size = 1858578 }, + { url = "https://files.pythonhosted.org/packages/d8/60/bc06fa9027c7006cc6dd21e48dbf39076dc39d9abbaf718a1604973a9670/pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3f26877a748dc4251cfcfda9dfb5f13fcb034f5308388066bcfe9031b63ae7d", size = 1892858 }, + { url = "https://files.pythonhosted.org/packages/f2/40/9d03997d9518816c68b4dfccb88969756b9146031b61cd37f781c74c9b6a/pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dac89aea9af8cd672fa7b510e7b8c33b0bba9a43186680550ccf23020f32d535", size = 2068498 }, + { url = "https://files.pythonhosted.org/packages/d8/62/d490198d05d2d86672dc269f52579cad7261ced64c2df213d5c16e0aecb1/pydantic_core-2.33.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:970919794d126ba8645f3837ab6046fb4e72bbc057b3709144066204c19a455d", size = 2108428 }, + { url = "https://files.pythonhosted.org/packages/9a/ec/4cd215534fd10b8549015f12ea650a1a973da20ce46430b68fc3185573e8/pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:3eb3fe62804e8f859c49ed20a8451342de53ed764150cb14ca71357c765dc2a6", size = 2069854 }, + { url = "https://files.pythonhosted.org/packages/1a/1a/abbd63d47e1d9b0d632fee6bb15785d0889c8a6e0a6c3b5a8e28ac1ec5d2/pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:3abcd9392a36025e3bd55f9bd38d908bd17962cc49bc6da8e7e96285336e2bca", size = 2237859 }, + { url = "https://files.pythonhosted.org/packages/80/1c/fa883643429908b1c90598fd2642af8839efd1d835b65af1f75fba4d94fe/pydantic_core-2.33.2-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:3a1c81334778f9e3af2f8aeb7a960736e5cab1dfebfb26aabca09afd2906c039", size = 2239059 }, + { url = "https://files.pythonhosted.org/packages/d4/29/3cade8a924a61f60ccfa10842f75eb12787e1440e2b8660ceffeb26685e7/pydantic_core-2.33.2-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2807668ba86cb38c6817ad9bc66215ab8584d1d304030ce4f0887336f28a5e27", size = 2066661 }, +] + +[[package]] +name = "pylint" +version = "3.2.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "astroid" }, + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "dill" }, + { name = "isort" }, + { name = "mccabe" }, + { name = "platformdirs" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, + { name = "tomlkit" }, + { name = "typing-extensions", marker = "python_full_version < '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9a/e9/60280b14cc1012794120345ce378504cf17409e38cd88f455dc24e0ad6b5/pylint-3.2.3.tar.gz", hash = "sha256:02f6c562b215582386068d52a30f520d84fdbcf2a95fc7e855b816060d048b60", size = 1506739 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/d3/d346f779cbc9384d8b805a7557b5f2b8ee9f842bffebec9fc6364d6ae183/pylint-3.2.3-py3-none-any.whl", hash = "sha256:b3d7d2708a3e04b4679e02d99e72329a8b7ee8afb8d04110682278781f889fa8", size = 519244 }, +] + +[[package]] +name = "sniffio" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235 }, +] + +[[package]] +name = "tomli" +version = "2.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/18/87/302344fed471e44a87289cf4967697d07e532f2421fdaf868a303cbae4ff/tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff", size = 17175 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/43/ca/75707e6efa2b37c77dadb324ae7d9571cb424e61ea73fad7c56c2d14527f/tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249", size = 131077 }, + { url = "https://files.pythonhosted.org/packages/c7/16/51ae563a8615d472fdbffc43a3f3d46588c264ac4f024f63f01283becfbb/tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6", size = 123429 }, + { url = "https://files.pythonhosted.org/packages/f1/dd/4f6cd1e7b160041db83c694abc78e100473c15d54620083dbd5aae7b990e/tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a", size = 226067 }, + { url = "https://files.pythonhosted.org/packages/a9/6b/c54ede5dc70d648cc6361eaf429304b02f2871a345bbdd51e993d6cdf550/tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee", size = 236030 }, + { url = "https://files.pythonhosted.org/packages/1f/47/999514fa49cfaf7a92c805a86c3c43f4215621855d151b61c602abb38091/tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e", size = 240898 }, + { url = "https://files.pythonhosted.org/packages/73/41/0a01279a7ae09ee1573b423318e7934674ce06eb33f50936655071d81a24/tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4", size = 229894 }, + { url = "https://files.pythonhosted.org/packages/55/18/5d8bc5b0a0362311ce4d18830a5d28943667599a60d20118074ea1b01bb7/tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106", size = 245319 }, + { url = "https://files.pythonhosted.org/packages/92/a3/7ade0576d17f3cdf5ff44d61390d4b3febb8a9fc2b480c75c47ea048c646/tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8", size = 238273 }, + { url = "https://files.pythonhosted.org/packages/72/6f/fa64ef058ac1446a1e51110c375339b3ec6be245af9d14c87c4a6412dd32/tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff", size = 98310 }, + { url = "https://files.pythonhosted.org/packages/6a/1c/4a2dcde4a51b81be3530565e92eda625d94dafb46dbeb15069df4caffc34/tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b", size = 108309 }, + { url = "https://files.pythonhosted.org/packages/52/e1/f8af4c2fcde17500422858155aeb0d7e93477a0d59a98e56cbfe75070fd0/tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea", size = 132762 }, + { url = "https://files.pythonhosted.org/packages/03/b8/152c68bb84fc00396b83e7bbddd5ec0bd3dd409db4195e2a9b3e398ad2e3/tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8", size = 123453 }, + { url = "https://files.pythonhosted.org/packages/c8/d6/fc9267af9166f79ac528ff7e8c55c8181ded34eb4b0e93daa767b8841573/tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192", size = 233486 }, + { url = "https://files.pythonhosted.org/packages/5c/51/51c3f2884d7bab89af25f678447ea7d297b53b5a3b5730a7cb2ef6069f07/tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222", size = 242349 }, + { url = "https://files.pythonhosted.org/packages/ab/df/bfa89627d13a5cc22402e441e8a931ef2108403db390ff3345c05253935e/tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77", size = 252159 }, + { url = "https://files.pythonhosted.org/packages/9e/6e/fa2b916dced65763a5168c6ccb91066f7639bdc88b48adda990db10c8c0b/tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6", size = 237243 }, + { url = "https://files.pythonhosted.org/packages/b4/04/885d3b1f650e1153cbb93a6a9782c58a972b94ea4483ae4ac5cedd5e4a09/tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd", size = 259645 }, + { url = "https://files.pythonhosted.org/packages/9c/de/6b432d66e986e501586da298e28ebeefd3edc2c780f3ad73d22566034239/tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e", size = 244584 }, + { url = "https://files.pythonhosted.org/packages/1c/9a/47c0449b98e6e7d1be6cbac02f93dd79003234ddc4aaab6ba07a9a7482e2/tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98", size = 98875 }, + { url = "https://files.pythonhosted.org/packages/ef/60/9b9638f081c6f1261e2688bd487625cd1e660d0a85bd469e91d8db969734/tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4", size = 109418 }, + { url = "https://files.pythonhosted.org/packages/04/90/2ee5f2e0362cb8a0b6499dc44f4d7d48f8fff06d28ba46e6f1eaa61a1388/tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7", size = 132708 }, + { url = "https://files.pythonhosted.org/packages/c0/ec/46b4108816de6b385141f082ba99e315501ccd0a2ea23db4a100dd3990ea/tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c", size = 123582 }, + { url = "https://files.pythonhosted.org/packages/a0/bd/b470466d0137b37b68d24556c38a0cc819e8febe392d5b199dcd7f578365/tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13", size = 232543 }, + { url = "https://files.pythonhosted.org/packages/d9/e5/82e80ff3b751373f7cead2815bcbe2d51c895b3c990686741a8e56ec42ab/tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281", size = 241691 }, + { url = "https://files.pythonhosted.org/packages/05/7e/2a110bc2713557d6a1bfb06af23dd01e7dde52b6ee7dadc589868f9abfac/tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272", size = 251170 }, + { url = "https://files.pythonhosted.org/packages/64/7b/22d713946efe00e0adbcdfd6d1aa119ae03fd0b60ebed51ebb3fa9f5a2e5/tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140", size = 236530 }, + { url = "https://files.pythonhosted.org/packages/38/31/3a76f67da4b0cf37b742ca76beaf819dca0ebef26d78fc794a576e08accf/tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2", size = 258666 }, + { url = "https://files.pythonhosted.org/packages/07/10/5af1293da642aded87e8a988753945d0cf7e00a9452d3911dd3bb354c9e2/tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744", size = 243954 }, + { url = "https://files.pythonhosted.org/packages/5b/b9/1ed31d167be802da0fc95020d04cd27b7d7065cc6fbefdd2f9186f60d7bd/tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec", size = 98724 }, + { url = "https://files.pythonhosted.org/packages/c7/32/b0963458706accd9afcfeb867c0f9175a741bf7b19cd424230714d722198/tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69", size = 109383 }, + { url = "https://files.pythonhosted.org/packages/6e/c2/61d3e0f47e2b74ef40a68b9e6ad5984f6241a942f7cd3bbfbdbd03861ea9/tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc", size = 14257 }, +] + +[[package]] +name = "tomlkit" +version = "0.13.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cc/18/0bbf3884e9eaa38819ebe46a7bd25dcd56b67434402b66a58c4b8e552575/tomlkit-0.13.3.tar.gz", hash = "sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1", size = 185207 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/75/8539d011f6be8e29f339c42e633aae3cb73bffa95dd0f9adec09b9c58e85/tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0", size = 38901 }, +] + +[[package]] +name = "typing-extensions" +version = "4.14.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/98/5a/da40306b885cc8c09109dc2e1abd358d5684b1425678151cdaed4731c822/typing_extensions-4.14.1.tar.gz", hash = "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36", size = 107673 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b5/00/d631e67a838026495268c2f6884f3711a15a9a2a96cd244fdaea53b823fb/typing_extensions-4.14.1-py3-none-any.whl", hash = "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76", size = 43906 }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f8/b1/0c11f5058406b3af7609f121aaa6b609744687f1d158b3c3a5bf4cc94238/typing_inspection-0.4.1.tar.gz", hash = "sha256:6ae134cc0203c33377d43188d4064e9b357dba58cff3185f22924610e70a9d28", size = 75726 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/17/69/cd203477f944c353c31bade965f880aa1061fd6bf05ded0726ca845b6ff7/typing_inspection-0.4.1-py3-none-any.whl", hash = "sha256:389055682238f53b04f7badcb49b989835495a96700ced5dab2d8feae4b26f51", size = 14552 }, +]