chore: clean up removed docs and update generated SDK files

Remove obsolete component documentation and update speakeasy-generated
files to match the latest OpenAPI spec regeneration.
This commit is contained in:
Matt Apperson
2026-04-02 10:21:41 -04:00
parent 5ab44f08f0
commit e6b0242969
478 changed files with 326 additions and 17219 deletions
+8 -11
View File
@@ -392,11 +392,6 @@ if TYPE_CHECKING:
ContentPartDoneEventTypedDict,
)
from .contextcompressionengine import ContextCompressionEngine
from .createchargerequest import (
ChainID,
CreateChargeRequest,
CreateChargeRequestTypedDict,
)
from .customtool import (
CustomTool,
CustomToolTypedDict,
@@ -516,6 +511,10 @@ if TYPE_CHECKING:
OutputInputImageTypedDict,
OutputType,
)
from .goneresponseerrordata import (
GoneResponseErrorData,
GoneResponseErrorDataTypedDict,
)
from .imagegencallcompletedevent import (
ImageGenCallCompletedEvent,
ImageGenCallCompletedEventType,
@@ -1268,7 +1267,6 @@ __all__ = [
"By",
"CacheControl",
"CacheControlTypedDict",
"ChainID",
"ChatAssistantImages",
"ChatAssistantImagesImageURL",
"ChatAssistantImagesImageURLTypedDict",
@@ -1510,8 +1508,6 @@ __all__ = [
"ContextCompressionEngine",
"CostDetails",
"CostDetailsTypedDict",
"CreateChargeRequest",
"CreateChargeRequestTypedDict",
"CustomTool",
"CustomToolTypedDict",
"Data",
@@ -1608,6 +1604,8 @@ __all__ = [
"FunctionCallOutputItemOutputUnion2TypedDict",
"FunctionCallOutputItemTypeFunctionCallOutput",
"FunctionCallOutputItemTypedDict",
"GoneResponseErrorData",
"GoneResponseErrorDataTypedDict",
"ImageGenCallCompletedEvent",
"ImageGenCallCompletedEventType",
"ImageGenCallCompletedEventTypedDict",
@@ -2464,9 +2462,6 @@ _dynamic_imports: dict[str, str] = {
"ContentPartDoneEventType": ".contentpartdoneevent",
"ContentPartDoneEventTypedDict": ".contentpartdoneevent",
"ContextCompressionEngine": ".contextcompressionengine",
"ChainID": ".createchargerequest",
"CreateChargeRequest": ".createchargerequest",
"CreateChargeRequestTypedDict": ".createchargerequest",
"CustomTool": ".customtool",
"CustomToolTypedDict": ".customtool",
"Format": ".customtool",
@@ -2568,6 +2563,8 @@ _dynamic_imports: dict[str, str] = {
"OutputInputImage": ".functioncalloutputitem",
"OutputInputImageTypedDict": ".functioncalloutputitem",
"OutputType": ".functioncalloutputitem",
"GoneResponseErrorData": ".goneresponseerrordata",
"GoneResponseErrorDataTypedDict": ".goneresponseerrordata",
"ImageGenCallCompletedEvent": ".imagegencallcompletedevent",
"ImageGenCallCompletedEventType": ".imagegencallcompletedevent",
"ImageGenCallCompletedEventTypedDict": ".imagegencallcompletedevent",
@@ -1,134 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .assistantmessageimages import (
AssistantMessageImages,
AssistantMessageImagesTypedDict,
)
from .chatcompletionaudiooutput import (
ChatCompletionAudioOutput,
ChatCompletionAudioOutputTypedDict,
)
from .chatmessagecontentitem import (
ChatMessageContentItem,
ChatMessageContentItemTypedDict,
)
from .chatmessagetoolcall import ChatMessageToolCall, ChatMessageToolCallTypedDict
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Any, List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
AssistantMessageRole = Literal["assistant",]
AssistantMessageContentTypedDict = TypeAliasType(
"AssistantMessageContentTypedDict",
Union[str, List[ChatMessageContentItemTypedDict], Any],
)
r"""Assistant message content"""
AssistantMessageContent = TypeAliasType(
"AssistantMessageContent", Union[str, List[ChatMessageContentItem], Any]
)
r"""Assistant message content"""
class AssistantMessageTypedDict(TypedDict):
r"""Assistant message for requests and responses"""
role: AssistantMessageRole
content: NotRequired[Nullable[AssistantMessageContentTypedDict]]
r"""Assistant message content"""
name: NotRequired[str]
r"""Optional name for the assistant"""
tool_calls: NotRequired[List[ChatMessageToolCallTypedDict]]
r"""Tool calls made by the assistant"""
refusal: NotRequired[Nullable[str]]
r"""Refusal message if content was refused"""
reasoning: NotRequired[Nullable[str]]
r"""Reasoning output"""
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
r"""Reasoning details for extended thinking models"""
images: NotRequired[List[AssistantMessageImagesTypedDict]]
r"""Generated images from image generation models"""
audio: NotRequired[ChatCompletionAudioOutputTypedDict]
r"""Audio output data or reference"""
class AssistantMessage(BaseModel):
r"""Assistant message for requests and responses"""
role: AssistantMessageRole
content: OptionalNullable[AssistantMessageContent] = UNSET
r"""Assistant message content"""
name: Optional[str] = None
r"""Optional name for the assistant"""
tool_calls: Optional[List[ChatMessageToolCall]] = None
r"""Tool calls made by the assistant"""
refusal: OptionalNullable[str] = UNSET
r"""Refusal message if content was refused"""
reasoning: OptionalNullable[str] = UNSET
r"""Reasoning output"""
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
r"""Reasoning details for extended thinking models"""
images: Optional[List[AssistantMessageImages]] = None
r"""Generated images from image generation models"""
audio: Optional[ChatCompletionAudioOutput] = None
r"""Audio output data or reference"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"content",
"name",
"tool_calls",
"refusal",
"reasoning",
"reasoning_details",
"images",
"audio",
]
nullable_fields = ["content", "refusal", "reasoning"]
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
@@ -1,23 +0,0 @@
"""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 AssistantMessageImagesImageURLTypedDict(TypedDict):
url: str
r"""URL or base64-encoded data of the generated image"""
class AssistantMessageImagesImageURL(BaseModel):
url: str
r"""URL or base64-encoded data of the generated image"""
class AssistantMessageImagesTypedDict(TypedDict):
image_url: AssistantMessageImagesImageURLTypedDict
class AssistantMessageImages(BaseModel):
image_url: AssistantMessageImagesImageURL
@@ -1,35 +0,0 @@
"""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 ChatCompletionAudioOutputTypedDict(TypedDict):
r"""Audio output data or reference"""
id: NotRequired[str]
r"""Audio output identifier"""
expires_at: NotRequired[float]
r"""Audio expiration timestamp"""
data: NotRequired[str]
r"""Base64 encoded audio data"""
transcript: NotRequired[str]
r"""Audio transcript"""
class ChatCompletionAudioOutput(BaseModel):
r"""Audio output data or reference"""
id: Optional[str] = None
r"""Audio output identifier"""
expires_at: Optional[float] = None
r"""Audio expiration timestamp"""
data: Optional[str] = None
r"""Base64 encoded audio data"""
transcript: Optional[str] = None
r"""Audio transcript"""
@@ -1,17 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ChatCompletionFinishReason = Union[
Literal[
"tool_calls",
"stop",
"length",
"content_filter",
"error",
],
UnrecognizedStr,
]
@@ -1,960 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
from .datacollection import DataCollection
from .debugoptions import DebugOptions, DebugOptionsTypedDict
from .message import Message, MessageTypedDict
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
from .preferredminthroughput import (
PreferredMinThroughput,
PreferredMinThroughputTypedDict,
)
from .providername import ProviderName
from .quantization import Quantization
from .responseformatjsonobject import (
ResponseFormatJSONObject,
ResponseFormatJSONObjectTypedDict,
)
from .responseformatjsonschema import (
ResponseFormatJSONSchema,
ResponseFormatJSONSchemaTypedDict,
)
from .responseformattext import ResponseFormatText, ResponseFormatTextTypedDict
from .responseformattextgrammar import (
ResponseFormatTextGrammar,
ResponseFormatTextGrammarTypedDict,
)
from .responseformattextpython import (
ResponseFormatTextPython,
ResponseFormatTextPythonTypedDict,
)
from .toolchoiceoption import ToolChoiceOption, ToolChoiceOptionTypedDict
from .tooldefinitionjson import ToolDefinitionJSON, ToolDefinitionJSONTypedDict
from .websearchengine import WebSearchEngine
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
import pydantic
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ChatGenerationParamsOrderTypedDict = TypeAliasType(
"ChatGenerationParamsOrderTypedDict", Union[ProviderName, str]
)
ChatGenerationParamsOrder = TypeAliasType(
"ChatGenerationParamsOrder",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ChatGenerationParamsOnlyTypedDict = TypeAliasType(
"ChatGenerationParamsOnlyTypedDict", Union[ProviderName, str]
)
ChatGenerationParamsOnly = TypeAliasType(
"ChatGenerationParamsOnly",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ChatGenerationParamsIgnoreTypedDict = TypeAliasType(
"ChatGenerationParamsIgnoreTypedDict", Union[ProviderName, str]
)
ChatGenerationParamsIgnore = TypeAliasType(
"ChatGenerationParamsIgnore",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ChatGenerationParamsSortEnum = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
ChatGenerationParamsProviderSortConfigEnum = Literal[
"price",
"throughput",
"latency",
"exacto",
]
ChatGenerationParamsBy = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
r"""The provider sorting strategy (price, throughput, latency)"""
ChatGenerationParamsPartition = Union[
Literal[
"model",
"none",
],
UnrecognizedStr,
]
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
class ChatGenerationParamsProviderSortConfigTypedDict(TypedDict):
by: NotRequired[Nullable[ChatGenerationParamsBy]]
r"""The provider sorting strategy (price, throughput, latency)"""
partition: NotRequired[Nullable[ChatGenerationParamsPartition]]
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
class ChatGenerationParamsProviderSortConfig(BaseModel):
by: Annotated[
OptionalNullable[ChatGenerationParamsBy],
PlainValidator(validate_open_enum(False)),
] = UNSET
r"""The provider sorting strategy (price, throughput, latency)"""
partition: Annotated[
OptionalNullable[ChatGenerationParamsPartition],
PlainValidator(validate_open_enum(False)),
] = UNSET
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["by", "partition"]
nullable_fields = ["by", "partition"]
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
ChatGenerationParamsProviderSortConfigUnionTypedDict = TypeAliasType(
"ChatGenerationParamsProviderSortConfigUnionTypedDict",
Union[
ChatGenerationParamsProviderSortConfigTypedDict,
ChatGenerationParamsProviderSortConfigEnum,
],
)
ChatGenerationParamsProviderSortConfigUnion = TypeAliasType(
"ChatGenerationParamsProviderSortConfigUnion",
Union[
ChatGenerationParamsProviderSortConfig,
ChatGenerationParamsProviderSortConfigEnum,
],
)
ChatGenerationParamsProviderSort = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
r"""The provider sorting strategy (price, throughput, latency)"""
ChatGenerationParamsSortUnionTypedDict = TypeAliasType(
"ChatGenerationParamsSortUnionTypedDict",
Union[
ChatGenerationParamsProviderSort,
ChatGenerationParamsProviderSortConfigUnionTypedDict,
ChatGenerationParamsSortEnum,
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
ChatGenerationParamsSortUnion = TypeAliasType(
"ChatGenerationParamsSortUnion",
Union[
Annotated[
ChatGenerationParamsProviderSort, PlainValidator(validate_open_enum(False))
],
ChatGenerationParamsProviderSortConfigUnion,
Annotated[
ChatGenerationParamsSortEnum, PlainValidator(validate_open_enum(False))
],
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
class ChatGenerationParamsMaxPriceTypedDict(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[str]
r"""Price per million prompt tokens"""
completion: NotRequired[str]
image: NotRequired[str]
audio: NotRequired[str]
request: NotRequired[str]
class ChatGenerationParamsMaxPrice(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[str] = None
r"""Price per million prompt tokens"""
completion: Optional[str] = None
image: Optional[str] = None
audio: Optional[str] = None
request: Optional[str] = None
class ChatGenerationParamsProviderTypedDict(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[DataCollection]]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
zdr: NotRequired[Nullable[bool]]
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
enforce_distillable_text: NotRequired[Nullable[bool]]
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
order: NotRequired[Nullable[List[ChatGenerationParamsOrderTypedDict]]]
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[ChatGenerationParamsOnlyTypedDict]]]
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[ChatGenerationParamsIgnoreTypedDict]]]
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: NotRequired[Nullable[List[Quantization]]]
r"""A list of quantization levels to filter the provider by."""
sort: NotRequired[Nullable[ChatGenerationParamsSortUnionTypedDict]]
max_price: NotRequired[ChatGenerationParamsMaxPriceTypedDict]
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: NotRequired[Nullable[PreferredMaxLatencyTypedDict]]
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
class ChatGenerationParamsProvider(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: Annotated[
OptionalNullable[DataCollection], PlainValidator(validate_open_enum(False))
] = 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.
"""
zdr: OptionalNullable[bool] = UNSET
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
enforce_distillable_text: OptionalNullable[bool] = UNSET
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
order: OptionalNullable[List[ChatGenerationParamsOrder]] = 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[ChatGenerationParamsOnly]] = 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[ChatGenerationParamsIgnore]] = 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[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
] = UNSET
r"""A list of quantization levels to filter the provider by."""
sort: OptionalNullable[ChatGenerationParamsSortUnion] = UNSET
max_price: Optional[ChatGenerationParamsMaxPrice] = None
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = UNSET
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"max_price",
"preferred_min_throughput",
"preferred_max_latency",
]
nullable_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"preferred_min_throughput",
"preferred_max_latency",
]
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
ChatGenerationParamsIDResponseHealing = Literal["response-healing",]
class ChatGenerationParamsPluginResponseHealingTypedDict(TypedDict):
id: ChatGenerationParamsIDResponseHealing
enabled: NotRequired[bool]
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
class ChatGenerationParamsPluginResponseHealing(BaseModel):
id: ChatGenerationParamsIDResponseHealing
enabled: Optional[bool] = None
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
ChatGenerationParamsIDFileParser = Literal["file-parser",]
class ChatGenerationParamsPluginFileParserTypedDict(TypedDict):
id: ChatGenerationParamsIDFileParser
enabled: NotRequired[bool]
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
pdf: NotRequired[PDFParserOptionsTypedDict]
r"""Options for PDF parsing."""
class ChatGenerationParamsPluginFileParser(BaseModel):
id: ChatGenerationParamsIDFileParser
enabled: Optional[bool] = None
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
pdf: Optional[PDFParserOptions] = None
r"""Options for PDF parsing."""
ChatGenerationParamsIDWeb = Literal["web",]
class ChatGenerationParamsPluginWebTypedDict(TypedDict):
id: ChatGenerationParamsIDWeb
enabled: NotRequired[bool]
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
max_results: NotRequired[float]
search_prompt: NotRequired[str]
engine: NotRequired[WebSearchEngine]
r"""The search engine to use for web search."""
include_domains: NotRequired[List[str]]
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
exclude_domains: NotRequired[List[str]]
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
class ChatGenerationParamsPluginWeb(BaseModel):
id: ChatGenerationParamsIDWeb
enabled: Optional[bool] = None
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
max_results: Optional[float] = None
search_prompt: Optional[str] = None
engine: Annotated[
Optional[WebSearchEngine], PlainValidator(validate_open_enum(False))
] = None
r"""The search engine to use for web search."""
include_domains: Optional[List[str]] = None
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
exclude_domains: Optional[List[str]] = None
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
ChatGenerationParamsIDModeration = Literal["moderation",]
class ChatGenerationParamsPluginModerationTypedDict(TypedDict):
id: ChatGenerationParamsIDModeration
class ChatGenerationParamsPluginModeration(BaseModel):
id: ChatGenerationParamsIDModeration
ChatGenerationParamsIDAutoRouter = Literal["auto-router",]
class ChatGenerationParamsPluginAutoRouterTypedDict(TypedDict):
id: ChatGenerationParamsIDAutoRouter
enabled: NotRequired[bool]
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
allowed_models: NotRequired[List[str]]
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
class ChatGenerationParamsPluginAutoRouter(BaseModel):
id: ChatGenerationParamsIDAutoRouter
enabled: Optional[bool] = None
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
allowed_models: Optional[List[str]] = None
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
ChatGenerationParamsPluginUnionTypedDict = TypeAliasType(
"ChatGenerationParamsPluginUnionTypedDict",
Union[
ChatGenerationParamsPluginModerationTypedDict,
ChatGenerationParamsPluginResponseHealingTypedDict,
ChatGenerationParamsPluginAutoRouterTypedDict,
ChatGenerationParamsPluginFileParserTypedDict,
ChatGenerationParamsPluginWebTypedDict,
],
)
ChatGenerationParamsPluginUnion = Annotated[
Union[
Annotated[ChatGenerationParamsPluginAutoRouter, Tag("auto-router")],
Annotated[ChatGenerationParamsPluginModeration, Tag("moderation")],
Annotated[ChatGenerationParamsPluginWeb, Tag("web")],
Annotated[ChatGenerationParamsPluginFileParser, Tag("file-parser")],
Annotated[ChatGenerationParamsPluginResponseHealing, Tag("response-healing")],
],
Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
class ChatGenerationParamsTraceTypedDict(TypedDict):
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
trace_id: NotRequired[str]
trace_name: NotRequired[str]
span_name: NotRequired[str]
generation_name: NotRequired[str]
parent_span_id: NotRequired[str]
class ChatGenerationParamsTrace(BaseModel):
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
trace_id: Optional[str] = None
trace_name: Optional[str] = None
span_name: Optional[str] = None
generation_name: Optional[str] = None
parent_span_id: Optional[str] = None
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
Effort = Union[
Literal[
"xhigh",
"high",
"medium",
"low",
"minimal",
"none",
],
UnrecognizedStr,
]
r"""Constrains effort on reasoning for reasoning models"""
class ReasoningTypedDict(TypedDict):
r"""Configuration options for reasoning models"""
effort: NotRequired[Nullable[Effort]]
r"""Constrains effort on reasoning for reasoning models"""
summary: NotRequired[Nullable[Any]]
class Reasoning(BaseModel):
r"""Configuration options for reasoning models"""
effort: Annotated[
OptionalNullable[Effort], PlainValidator(validate_open_enum(False))
] = UNSET
r"""Constrains effort on reasoning for reasoning models"""
summary: OptionalNullable[Any] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["effort", "summary"]
nullable_fields = ["effort", "summary"]
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
ResponseFormatTypedDict = TypeAliasType(
"ResponseFormatTypedDict",
Union[
ResponseFormatTextTypedDict,
ResponseFormatJSONObjectTypedDict,
ResponseFormatTextPythonTypedDict,
ResponseFormatJSONSchemaTypedDict,
ResponseFormatTextGrammarTypedDict,
],
)
r"""Response format configuration"""
ResponseFormat = Annotated[
Union[
Annotated[ResponseFormatText, Tag("text")],
Annotated[ResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponseFormatJSONSchema, Tag("json_schema")],
Annotated[ResponseFormatTextGrammar, Tag("grammar")],
Annotated[ResponseFormatTextPython, Tag("python")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Response format configuration"""
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str], Any])
r"""Stop sequences (up to 4)"""
Stop = TypeAliasType("Stop", Union[str, List[str], Any])
r"""Stop sequences (up to 4)"""
ChatGenerationParamsImageConfigTypedDict = TypeAliasType(
"ChatGenerationParamsImageConfigTypedDict", Union[str, float, List[Nullable[Any]]]
)
ChatGenerationParamsImageConfig = TypeAliasType(
"ChatGenerationParamsImageConfig", Union[str, float, List[Nullable[Any]]]
)
Modality = Union[
Literal[
"text",
"image",
"audio",
],
UnrecognizedStr,
]
ChatGenerationParamsType = Literal["ephemeral",]
ChatGenerationParamsTTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
class CacheControlTypedDict(TypedDict):
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
type: ChatGenerationParamsType
ttl: NotRequired[ChatGenerationParamsTTL]
class CacheControl(BaseModel):
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
type: ChatGenerationParamsType
ttl: Annotated[
Optional[ChatGenerationParamsTTL], PlainValidator(validate_open_enum(False))
] = None
class ChatGenerationParamsTypedDict(TypedDict):
r"""Chat completion request parameters"""
messages: List[MessageTypedDict]
r"""List of messages for the conversation"""
provider: NotRequired[Nullable[ChatGenerationParamsProviderTypedDict]]
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: NotRequired[List[ChatGenerationParamsPluginUnionTypedDict]]
r"""Plugins you want to enable for this request, including their settings."""
user: NotRequired[str]
r"""Unique user identifier"""
session_id: NotRequired[str]
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
trace: NotRequired[ChatGenerationParamsTraceTypedDict]
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
model: NotRequired[str]
r"""Model to use for completion"""
models: NotRequired[List[str]]
r"""Models 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). Note: some providers enforce a minimum of 16."""
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[ReasoningTypedDict]
r"""Configuration options for reasoning models"""
response_format: NotRequired[ResponseFormatTypedDict]
r"""Response format configuration"""
seed: NotRequired[Nullable[int]]
r"""Random seed for deterministic outputs"""
stop: NotRequired[Nullable[StopTypedDict]]
r"""Stop sequences (up to 4)"""
stream: NotRequired[bool]
r"""Enable streaming response"""
stream_options: NotRequired[Nullable[ChatStreamOptionsTypedDict]]
r"""Streaming configuration options"""
temperature: NotRequired[Nullable[float]]
r"""Sampling temperature (0-2)"""
parallel_tool_calls: NotRequired[Nullable[bool]]
tool_choice: NotRequired[ToolChoiceOptionTypedDict]
r"""Tool choice configuration"""
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
r"""Available tools for function calling"""
top_p: NotRequired[Nullable[float]]
r"""Nucleus sampling parameter (0-1)"""
debug: NotRequired[DebugOptionsTypedDict]
r"""Debug options for inspecting request transformations (streaming only)"""
image_config: NotRequired[Dict[str, ChatGenerationParamsImageConfigTypedDict]]
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
modalities: NotRequired[List[Modality]]
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
cache_control: NotRequired[CacheControlTypedDict]
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
class ChatGenerationParams(BaseModel):
r"""Chat completion request parameters"""
messages: List[Message]
r"""List of messages for the conversation"""
provider: OptionalNullable[ChatGenerationParamsProvider] = UNSET
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: Optional[List[ChatGenerationParamsPluginUnion]] = None
r"""Plugins you want to enable for this request, including their settings."""
user: Optional[str] = None
r"""Unique user identifier"""
session_id: Optional[str] = None
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
trace: Optional[ChatGenerationParamsTrace] = None
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
model: Optional[str] = None
r"""Model to use for completion"""
models: Optional[List[str]] = None
r"""Models 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). Note: some providers enforce a minimum of 16."""
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: Optional[Reasoning] = None
r"""Configuration options for reasoning models"""
response_format: Optional[ResponseFormat] = None
r"""Response format configuration"""
seed: OptionalNullable[int] = UNSET
r"""Random seed for deterministic outputs"""
stop: OptionalNullable[Stop] = UNSET
r"""Stop sequences (up to 4)"""
stream: Optional[bool] = False
r"""Enable streaming response"""
stream_options: OptionalNullable[ChatStreamOptions] = UNSET
r"""Streaming configuration options"""
temperature: OptionalNullable[float] = 1
r"""Sampling temperature (0-2)"""
parallel_tool_calls: OptionalNullable[bool] = UNSET
tool_choice: Optional[ToolChoiceOption] = None
r"""Tool choice configuration"""
tools: Optional[List[ToolDefinitionJSON]] = None
r"""Available tools for function calling"""
top_p: OptionalNullable[float] = 1
r"""Nucleus sampling parameter (0-1)"""
debug: Optional[DebugOptions] = None
r"""Debug options for inspecting request transformations (streaming only)"""
image_config: Optional[Dict[str, ChatGenerationParamsImageConfig]] = None
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
modalities: Optional[
List[Annotated[Modality, PlainValidator(validate_open_enum(False))]]
] = None
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
cache_control: Optional[CacheControl] = None
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"provider",
"plugins",
"user",
"session_id",
"trace",
"model",
"models",
"frequency_penalty",
"logit_bias",
"logprobs",
"top_logprobs",
"max_completion_tokens",
"max_tokens",
"metadata",
"presence_penalty",
"reasoning",
"response_format",
"seed",
"stop",
"stream",
"stream_options",
"temperature",
"parallel_tool_calls",
"tool_choice",
"tools",
"top_p",
"debug",
"image_config",
"modalities",
"cache_control",
]
nullable_fields = [
"provider",
"frequency_penalty",
"logit_bias",
"logprobs",
"top_logprobs",
"max_completion_tokens",
"max_tokens",
"presence_penalty",
"seed",
"stop",
"stream_options",
"temperature",
"parallel_tool_calls",
"top_p",
]
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
@@ -1,175 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
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 CompletionTokensDetailsTypedDict(TypedDict):
r"""Detailed completion token usage"""
reasoning_tokens: NotRequired[Nullable[float]]
r"""Tokens used for reasoning"""
audio_tokens: NotRequired[Nullable[float]]
r"""Tokens used for audio output"""
accepted_prediction_tokens: NotRequired[Nullable[float]]
r"""Accepted prediction tokens"""
rejected_prediction_tokens: NotRequired[Nullable[float]]
r"""Rejected prediction tokens"""
class CompletionTokensDetails(BaseModel):
r"""Detailed completion token usage"""
reasoning_tokens: OptionalNullable[float] = UNSET
r"""Tokens used for reasoning"""
audio_tokens: OptionalNullable[float] = UNSET
r"""Tokens used for audio output"""
accepted_prediction_tokens: OptionalNullable[float] = UNSET
r"""Accepted prediction tokens"""
rejected_prediction_tokens: OptionalNullable[float] = UNSET
r"""Rejected prediction tokens"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"reasoning_tokens",
"audio_tokens",
"accepted_prediction_tokens",
"rejected_prediction_tokens",
]
nullable_fields = [
"reasoning_tokens",
"audio_tokens",
"accepted_prediction_tokens",
"rejected_prediction_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 PromptTokensDetailsTypedDict(TypedDict):
r"""Detailed prompt token usage"""
cached_tokens: NotRequired[float]
r"""Cached prompt tokens"""
cache_write_tokens: NotRequired[float]
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
audio_tokens: NotRequired[float]
r"""Audio input tokens"""
video_tokens: NotRequired[float]
r"""Video input tokens"""
class PromptTokensDetails(BaseModel):
r"""Detailed prompt token usage"""
cached_tokens: Optional[float] = None
r"""Cached prompt tokens"""
cache_write_tokens: Optional[float] = None
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
audio_tokens: Optional[float] = None
r"""Audio input tokens"""
video_tokens: Optional[float] = None
r"""Video input tokens"""
class ChatGenerationTokenUsageTypedDict(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[Nullable[CompletionTokensDetailsTypedDict]]
r"""Detailed completion token usage"""
prompt_tokens_details: NotRequired[Nullable[PromptTokensDetailsTypedDict]]
r"""Detailed prompt token usage"""
class ChatGenerationTokenUsage(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: OptionalNullable[CompletionTokensDetails] = UNSET
r"""Detailed completion token usage"""
prompt_tokens_details: OptionalNullable[PromptTokensDetails] = UNSET
r"""Detailed prompt token usage"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["completion_tokens_details", "prompt_tokens_details"]
nullable_fields = ["completion_tokens_details", "prompt_tokens_details"]
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
@@ -1,74 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagecontentitemaudio import (
ChatMessageContentItemAudio,
ChatMessageContentItemAudioTypedDict,
)
from .chatmessagecontentitemfile import (
ChatMessageContentItemFile,
ChatMessageContentItemFileTypedDict,
)
from .chatmessagecontentitemimage import (
ChatMessageContentItemImage,
ChatMessageContentItemImageTypedDict,
)
from .chatmessagecontentitemtext import (
ChatMessageContentItemText,
ChatMessageContentItemTextTypedDict,
)
from .chatmessagecontentitemvideo import (
ChatMessageContentItemVideo,
ChatMessageContentItemVideoTypedDict,
)
from .chatmessagecontentitemvideolegacy import (
ChatMessageContentItemVideoLegacy,
ChatMessageContentItemVideoLegacyTypedDict,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypeAliasType
ChatMessageContentItem1TypedDict = TypeAliasType(
"ChatMessageContentItem1TypedDict",
Union[
ChatMessageContentItemVideoLegacyTypedDict, ChatMessageContentItemVideoTypedDict
],
)
ChatMessageContentItem1 = Annotated[
Union[
Annotated[ChatMessageContentItemVideoLegacy, Tag("input_video")],
Annotated[ChatMessageContentItemVideo, Tag("video_url")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ChatMessageContentItemTypedDict = TypeAliasType(
"ChatMessageContentItemTypedDict",
Union[
ChatMessageContentItemImageTypedDict,
ChatMessageContentItemAudioTypedDict,
ChatMessageContentItemFileTypedDict,
ChatMessageContentItemTextTypedDict,
ChatMessageContentItem1TypedDict,
],
)
r"""Content part for chat completion messages"""
ChatMessageContentItem = TypeAliasType(
"ChatMessageContentItem",
Union[
ChatMessageContentItemImage,
ChatMessageContentItemAudio,
ChatMessageContentItemFile,
ChatMessageContentItemText,
ChatMessageContentItem1,
],
)
r"""Content part for chat completion messages"""
@@ -1,40 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
import pydantic
from typing import Literal
from typing_extensions import Annotated, TypedDict
ChatMessageContentItemAudioType = Literal["input_audio",]
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
data: str
r"""Base64 encoded audio data"""
format_: str
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
class ChatMessageContentItemAudioInputAudio(BaseModel):
data: str
r"""Base64 encoded audio data"""
format_: Annotated[str, pydantic.Field(alias="format")]
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
class ChatMessageContentItemAudioTypedDict(TypedDict):
r"""Audio input content part. Supported audio formats vary by provider."""
type: ChatMessageContentItemAudioType
input_audio: ChatMessageContentItemAudioInputAudioTypedDict
class ChatMessageContentItemAudio(BaseModel):
r"""Audio input content part. Supported audio formats vary by provider."""
type: ChatMessageContentItemAudioType
input_audio: ChatMessageContentItemAudioInputAudio
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatMessageContentItemCacheControlType = Literal["ephemeral",]
ChatMessageContentItemCacheControlTTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
class ChatMessageContentItemCacheControlTypedDict(TypedDict):
r"""Cache control for the content part"""
type: ChatMessageContentItemCacheControlType
ttl: NotRequired[ChatMessageContentItemCacheControlTTL]
class ChatMessageContentItemCacheControl(BaseModel):
r"""Cache control for the content part"""
type: ChatMessageContentItemCacheControlType
ttl: Annotated[
Optional[ChatMessageContentItemCacheControlTTL],
PlainValidator(validate_open_enum(False)),
] = None
@@ -1,44 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatMessageContentItemFileType = Literal["file",]
class FileTypedDict(TypedDict):
file_data: NotRequired[str]
r"""File content as base64 data URL or URL"""
file_id: NotRequired[str]
r"""File ID for previously uploaded files"""
filename: NotRequired[str]
r"""Original filename"""
class File(BaseModel):
file_data: Optional[str] = None
r"""File content as base64 data URL or URL"""
file_id: Optional[str] = None
r"""File ID for previously uploaded files"""
filename: Optional[str] = None
r"""Original filename"""
class ChatMessageContentItemFileTypedDict(TypedDict):
r"""File content part for document processing"""
type: ChatMessageContentItemFileType
file: FileTypedDict
class ChatMessageContentItemFile(BaseModel):
r"""File content part for document processing"""
type: ChatMessageContentItemFileType
file: File
@@ -1,55 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatMessageContentItemImageType = Literal["image_url",]
ChatMessageContentItemImageDetail = Union[
Literal[
"auto",
"low",
"high",
],
UnrecognizedStr,
]
r"""Image detail level for vision models"""
class ChatMessageContentItemImageImageURLTypedDict(TypedDict):
url: str
r"""URL of the image (data: URLs supported)"""
detail: NotRequired[ChatMessageContentItemImageDetail]
r"""Image detail level for vision models"""
class ChatMessageContentItemImageImageURL(BaseModel):
url: str
r"""URL of the image (data: URLs supported)"""
detail: Annotated[
Optional[ChatMessageContentItemImageDetail],
PlainValidator(validate_open_enum(False)),
] = None
r"""Image detail level for vision models"""
class ChatMessageContentItemImageTypedDict(TypedDict):
r"""Image content part for vision models"""
type: ChatMessageContentItemImageType
image_url: ChatMessageContentItemImageImageURLTypedDict
class ChatMessageContentItemImage(BaseModel):
r"""Image content part for vision models"""
type: ChatMessageContentItemImageType
image_url: ChatMessageContentItemImageImageURL
@@ -1,33 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagecontentitemcachecontrol import (
ChatMessageContentItemCacheControl,
ChatMessageContentItemCacheControlTypedDict,
)
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatMessageContentItemTextType = Literal["text",]
class ChatMessageContentItemTextTypedDict(TypedDict):
r"""Text content part"""
type: ChatMessageContentItemTextType
text: str
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
r"""Cache control for the content part"""
class ChatMessageContentItemText(BaseModel):
r"""Text content part"""
type: ChatMessageContentItemTextType
text: str
cache_control: Optional[ChatMessageContentItemCacheControl] = None
r"""Cache control for the content part"""
@@ -1,27 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .videoinput import VideoInput, VideoInputTypedDict
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ChatMessageContentItemVideoType = Literal["video_url",]
class ChatMessageContentItemVideoTypedDict(TypedDict):
r"""Video input content part"""
type: ChatMessageContentItemVideoType
video_url: VideoInputTypedDict
r"""Video input object"""
class ChatMessageContentItemVideo(BaseModel):
r"""Video input content part"""
type: ChatMessageContentItemVideoType
video_url: VideoInput
r"""Video input object"""
@@ -1,33 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .videoinput import VideoInput, VideoInputTypedDict
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict, deprecated
ChatMessageContentItemVideoLegacyType = Literal["input_video",]
@deprecated(
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
)
class ChatMessageContentItemVideoLegacyTypedDict(TypedDict):
r"""Video input content part (legacy format - deprecated)"""
type: ChatMessageContentItemVideoLegacyType
video_url: VideoInputTypedDict
r"""Video input object"""
@deprecated(
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
)
class ChatMessageContentItemVideoLegacy(BaseModel):
r"""Video input content part (legacy format - deprecated)"""
type: ChatMessageContentItemVideoLegacyType
video_url: VideoInput
r"""Video input object"""
@@ -1,111 +0,0 @@
"""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 ChatMessageTokenLogprobTopLogprobTypedDict(TypedDict):
token: str
logprob: float
bytes_: Nullable[List[float]]
class ChatMessageTokenLogprobTopLogprob(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 ChatMessageTokenLogprobTypedDict(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[ChatMessageTokenLogprobTopLogprobTypedDict]
r"""Top alternative tokens with probabilities"""
class ChatMessageTokenLogprob(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[ChatMessageTokenLogprobTopLogprob]
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
@@ -1,66 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagetokenlogprob import (
ChatMessageTokenLogprob,
ChatMessageTokenLogprobTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import List
from typing_extensions import NotRequired, TypedDict
class ChatMessageTokenLogprobsTypedDict(TypedDict):
r"""Log probabilities for the completion"""
content: Nullable[List[ChatMessageTokenLogprobTypedDict]]
r"""Log probabilities for content tokens"""
refusal: NotRequired[Nullable[List[ChatMessageTokenLogprobTypedDict]]]
r"""Log probabilities for refusal tokens"""
class ChatMessageTokenLogprobs(BaseModel):
r"""Log probabilities for the completion"""
content: Nullable[List[ChatMessageTokenLogprob]]
r"""Log probabilities for content tokens"""
refusal: OptionalNullable[List[ChatMessageTokenLogprob]] = UNSET
r"""Log probabilities for refusal tokens"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["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
@@ -1,44 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ChatMessageToolCallType = Literal["function",]
class ChatMessageToolCallFunctionTypedDict(TypedDict):
name: str
r"""Function name to call"""
arguments: str
r"""Function arguments as JSON string"""
class ChatMessageToolCallFunction(BaseModel):
name: str
r"""Function name to call"""
arguments: str
r"""Function arguments as JSON string"""
class ChatMessageToolCallTypedDict(TypedDict):
r"""Tool call made by the assistant"""
id: str
r"""Tool call identifier"""
type: ChatMessageToolCallType
function: ChatMessageToolCallFunctionTypedDict
class ChatMessageToolCall(BaseModel):
r"""Tool call made by the assistant"""
id: str
r"""Tool call identifier"""
type: ChatMessageToolCallType
function: ChatMessageToolCallFunction
-87
View File
@@ -1,87 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatgenerationtokenusage import (
ChatGenerationTokenUsage,
ChatGenerationTokenUsageTypedDict,
)
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatResponseObject = Literal["chat.completion",]
class ChatResponseTypedDict(TypedDict):
r"""Chat completion response"""
id: str
r"""Unique completion identifier"""
choices: List[ChatResponseChoiceTypedDict]
r"""List of completion choices"""
created: float
r"""Unix timestamp of creation"""
model: str
r"""Model used for completion"""
object: ChatResponseObject
system_fingerprint: Nullable[str]
r"""System fingerprint"""
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
r"""Token usage statistics"""
class ChatResponse(BaseModel):
r"""Chat completion response"""
id: str
r"""Unique completion identifier"""
choices: List[ChatResponseChoice]
r"""List of completion choices"""
created: float
r"""Unix timestamp of creation"""
model: str
r"""Model used for completion"""
object: ChatResponseObject
system_fingerprint: Nullable[str]
r"""System fingerprint"""
usage: Optional[ChatGenerationTokenUsage] = None
r"""Token usage statistics"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["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
@@ -1,75 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
from .chatmessagetokenlogprobs import (
ChatMessageTokenLogprobs,
ChatMessageTokenLogprobsTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Any
from typing_extensions import NotRequired, TypedDict
class ChatResponseChoiceTypedDict(TypedDict):
r"""Chat completion choice"""
finish_reason: Nullable[Any]
index: float
r"""Choice index"""
message: AssistantMessageTypedDict
r"""Assistant message for requests and responses"""
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
r"""Log probabilities for the completion"""
class ChatResponseChoice(BaseModel):
r"""Chat completion choice"""
finish_reason: Nullable[Any]
index: float
r"""Choice index"""
message: AssistantMessage
r"""Assistant message for requests and responses"""
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = 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
@@ -1,78 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagetokenlogprobs import (
ChatMessageTokenLogprobs,
ChatMessageTokenLogprobsTypedDict,
)
from .chatstreamingmessagechunk import (
ChatStreamingMessageChunk,
ChatStreamingMessageChunkTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Any
from typing_extensions import NotRequired, TypedDict
class ChatStreamingChoiceTypedDict(TypedDict):
r"""Streaming completion choice chunk"""
delta: ChatStreamingMessageChunkTypedDict
r"""Delta changes in streaming response"""
finish_reason: Nullable[Any]
index: float
r"""Choice index"""
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
r"""Log probabilities for the completion"""
class ChatStreamingChoice(BaseModel):
r"""Streaming completion choice chunk"""
delta: ChatStreamingMessageChunk
r"""Delta changes in streaming response"""
finish_reason: Nullable[Any]
index: float
r"""Choice index"""
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = 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
@@ -1,106 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatcompletionaudiooutput import (
ChatCompletionAudioOutput,
ChatCompletionAudioOutputTypedDict,
)
from .chatstreamingmessagetoolcall import (
ChatStreamingMessageToolCall,
ChatStreamingMessageToolCallTypedDict,
)
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatStreamingMessageChunkRole = Literal["assistant",]
r"""The role of the message author"""
class ChatStreamingMessageChunkTypedDict(TypedDict):
r"""Delta changes in streaming response"""
role: NotRequired[ChatStreamingMessageChunkRole]
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[ChatStreamingMessageToolCallTypedDict]]
r"""Tool calls delta"""
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
r"""Reasoning details for extended thinking models"""
audio: NotRequired[ChatCompletionAudioOutputTypedDict]
class ChatStreamingMessageChunk(BaseModel):
r"""Delta changes in streaming response"""
role: Optional[ChatStreamingMessageChunkRole] = 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[ChatStreamingMessageToolCall]] = None
r"""Tool calls delta"""
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
r"""Reasoning details for extended thinking models"""
audio: Optional[ChatCompletionAudioOutput] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"role",
"content",
"reasoning",
"refusal",
"tool_calls",
"reasoning_details",
"audio",
]
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
@@ -1,58 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatStreamingMessageToolCallType = Literal["function",]
r"""Tool call type"""
class ChatStreamingMessageToolCallFunctionTypedDict(TypedDict):
r"""Function call details"""
name: NotRequired[str]
r"""Function name"""
arguments: NotRequired[str]
r"""Function arguments as JSON string"""
class ChatStreamingMessageToolCallFunction(BaseModel):
r"""Function call details"""
name: Optional[str] = None
r"""Function name"""
arguments: Optional[str] = None
r"""Function arguments as JSON string"""
class ChatStreamingMessageToolCallTypedDict(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[ChatStreamingMessageToolCallType]
r"""Tool call type"""
function: NotRequired[ChatStreamingMessageToolCallFunctionTypedDict]
r"""Function call details"""
class ChatStreamingMessageToolCall(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[ChatStreamingMessageToolCallType] = None
r"""Tool call type"""
function: Optional[ChatStreamingMessageToolCallFunction] = None
r"""Function call details"""
@@ -1,80 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatgenerationtokenusage import (
ChatGenerationTokenUsage,
ChatGenerationTokenUsageTypedDict,
)
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
from openrouter.types import BaseModel
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatStreamingResponseChunkObject = Literal["chat.completion.chunk",]
class ErrorTypedDict(TypedDict):
r"""Error information"""
message: str
r"""Error message"""
code: float
r"""Error code"""
class Error(BaseModel):
r"""Error information"""
message: str
r"""Error message"""
code: float
r"""Error code"""
class ChatStreamingResponseChunkTypedDict(TypedDict):
r"""Streaming chat completion chunk"""
id: str
r"""Unique chunk identifier"""
choices: List[ChatStreamingChoiceTypedDict]
r"""List of streaming chunk choices"""
created: float
r"""Unix timestamp of creation"""
model: str
r"""Model used for completion"""
object: ChatStreamingResponseChunkObject
system_fingerprint: NotRequired[str]
r"""System fingerprint"""
error: NotRequired[ErrorTypedDict]
r"""Error information"""
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
r"""Token usage statistics"""
class ChatStreamingResponseChunk(BaseModel):
r"""Streaming chat completion chunk"""
id: str
r"""Unique chunk identifier"""
choices: List[ChatStreamingChoice]
r"""List of streaming chunk choices"""
created: float
r"""Unix timestamp of creation"""
model: str
r"""Model used for completion"""
object: ChatStreamingResponseChunkObject
system_fingerprint: Optional[str] = None
r"""System fingerprint"""
error: Optional[Error] = None
r"""Error information"""
usage: Optional[ChatGenerationTokenUsage] = None
r"""Token usage statistics"""
@@ -1,36 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedInt
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
ChainID = Union[
Literal[
1,
137,
8453,
],
UnrecognizedInt,
]
class CreateChargeRequestTypedDict(TypedDict):
r"""Create a Coinbase charge for crypto payment"""
amount: float
sender: str
chain_id: ChainID
class CreateChargeRequest(BaseModel):
r"""Create a Coinbase charge for crypto payment"""
amount: float
sender: str
chain_id: Annotated[ChainID, PlainValidator(validate_open_enum(True))]
-20
View File
@@ -1,20 +0,0 @@
"""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 DebugOptionsTypedDict(TypedDict):
r"""Debug options for inspecting request transformations (streaming only)"""
echo_upstream_body: NotRequired[bool]
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
class DebugOptions(BaseModel):
r"""Debug options for inspecting request transformations (streaming only)"""
echo_upstream_body: Optional[bool] = None
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
@@ -1,48 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatmessagecontentitemtext import (
ChatMessageContentItemText,
ChatMessageContentItemTextTypedDict,
)
from openrouter.types import BaseModel
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
DeveloperMessageRole = Literal["developer",]
DeveloperMessageContentTypedDict = TypeAliasType(
"DeveloperMessageContentTypedDict",
Union[str, List[ChatMessageContentItemTextTypedDict]],
)
r"""Developer message content"""
DeveloperMessageContent = TypeAliasType(
"DeveloperMessageContent", Union[str, List[ChatMessageContentItemText]]
)
r"""Developer message content"""
class DeveloperMessageTypedDict(TypedDict):
r"""Developer message"""
role: DeveloperMessageRole
content: DeveloperMessageContentTypedDict
r"""Developer message content"""
name: NotRequired[str]
r"""Optional name for the developer message"""
class DeveloperMessage(BaseModel):
r"""Developer message"""
role: DeveloperMessageRole
content: DeveloperMessageContent
r"""Developer message content"""
name: Optional[str] = None
r"""Optional name for the developer message"""
@@ -9,40 +9,31 @@ from openrouter.types import (
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Literal, Optional
from typing import Any, Dict
from typing_extensions import NotRequired, TypedDict
ResponseInputFileType = Literal["input_file",]
class GoneResponseErrorDataTypedDict(TypedDict):
r"""Error data for GoneResponse"""
code: int
message: str
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
class ResponseInputFileTypedDict(TypedDict):
r"""File input content item"""
class GoneResponseErrorData(BaseModel):
r"""Error data for GoneResponse"""
type: ResponseInputFileType
file_id: NotRequired[Nullable[str]]
file_data: NotRequired[str]
filename: NotRequired[str]
file_url: NotRequired[str]
code: int
message: str
class ResponseInputFile(BaseModel):
r"""File input content item"""
type: ResponseInputFileType
file_id: OptionalNullable[str] = UNSET
file_data: Optional[str] = None
filename: Optional[str] = None
file_url: Optional[str] = None
metadata: OptionalNullable[Dict[str, Nullable[Any]]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["file_id", "file_data", "filename", "file_url"]
nullable_fields = ["file_id"]
optional_fields = ["metadata"]
nullable_fields = ["metadata"]
null_default_fields = []
serialized = handler(self)
@@ -1,75 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
class JSONSchemaConfigTypedDict(TypedDict):
r"""JSON Schema configuration object"""
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[Dict[str, Nullable[Any]]]
r"""JSON Schema object"""
strict: NotRequired[Nullable[bool]]
r"""Enable strict schema adherence"""
class JSONSchemaConfig(BaseModel):
r"""JSON Schema configuration object"""
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[Dict[str, Nullable[Any]]], pydantic.Field(alias="schema")
] = None
r"""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
-38
View File
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
from .developermessage import DeveloperMessage, DeveloperMessageTypedDict
from .systemmessage import SystemMessage, SystemMessageTypedDict
from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict
from .usermessage import UserMessage, UserMessageTypedDict
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypeAliasType
MessageTypedDict = TypeAliasType(
"MessageTypedDict",
Union[
SystemMessageTypedDict,
UserMessageTypedDict,
DeveloperMessageTypedDict,
ToolResponseMessageTypedDict,
AssistantMessageTypedDict,
],
)
r"""Chat completion message with role-based discrimination"""
Message = Annotated[
Union[
Annotated[SystemMessage, Tag("system")],
Annotated[UserMessage, Tag("user")],
Annotated[DeveloperMessage, Tag("developer")],
Annotated[AssistantMessage, Tag("assistant")],
Annotated[ToolResponseMessage, Tag("tool")],
],
Discriminator(lambda m: get_discriminator(m, "role", "role")),
]
r"""Chat completion message with role-based discrimination"""
@@ -1,34 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
NamedToolChoiceType = Literal["function",]
class NamedToolChoiceFunctionTypedDict(TypedDict):
name: str
r"""Function name to call"""
class NamedToolChoiceFunction(BaseModel):
name: str
r"""Function name to call"""
class NamedToolChoiceTypedDict(TypedDict):
r"""Named tool choice for specific function"""
type: NamedToolChoiceType
function: NamedToolChoiceFunctionTypedDict
class NamedToolChoice(BaseModel):
r"""Named tool choice for specific function"""
type: NamedToolChoiceType
function: NamedToolChoiceFunction
@@ -1,17 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
OpenAIResponsesIncludable = Union[
Literal[
"file_search_call.results",
"message.input_image.image_url",
"computer_call_output.output.image_url",
"reasoning.encrypted_content",
"code_interpreter_call.outputs",
],
UnrecognizedStr,
]
@@ -1,27 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
Reason = Union[
Literal[
"max_output_tokens",
"content_filter",
],
UnrecognizedStr,
]
class OpenAIResponsesIncompleteDetailsTypedDict(TypedDict):
reason: NotRequired[Reason]
class OpenAIResponsesIncompleteDetails(BaseModel):
reason: Annotated[Optional[Reason], PlainValidator(validate_open_enum(False))] = (
None
)
@@ -1,416 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .outputitemimagegenerationcall import (
OutputItemImageGenerationCall,
OutputItemImageGenerationCallTypedDict,
)
from .outputmessage import OutputMessage, OutputMessageTypedDict
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
from .toolcallstatus import ToolCallStatus
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenAIResponsesInputTypeFunctionCall = Literal["function_call",]
class OpenAIResponsesInputFunctionCallTypedDict(TypedDict):
type: OpenAIResponsesInputTypeFunctionCall
call_id: str
name: str
arguments: str
id: NotRequired[str]
status: NotRequired[Nullable[ToolCallStatus]]
class OpenAIResponsesInputFunctionCall(BaseModel):
type: OpenAIResponsesInputTypeFunctionCall
call_id: str
name: str
arguments: str
id: Optional[str] = None
status: Annotated[
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["id", "status"]
nullable_fields = ["status"]
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
OpenAIResponsesInputTypeFunctionCallOutput = Literal["function_call_output",]
OpenAIResponsesInputOutput1TypedDict = TypeAliasType(
"OpenAIResponsesInputOutput1TypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenAIResponsesInputOutput1 = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[ResponseInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenAIResponsesInputOutput2TypedDict = TypeAliasType(
"OpenAIResponsesInputOutput2TypedDict",
Union[str, List[OpenAIResponsesInputOutput1TypedDict]],
)
OpenAIResponsesInputOutput2 = TypeAliasType(
"OpenAIResponsesInputOutput2", Union[str, List[OpenAIResponsesInputOutput1]]
)
class OpenAIResponsesInputFunctionCallOutputTypedDict(TypedDict):
type: OpenAIResponsesInputTypeFunctionCallOutput
call_id: str
output: OpenAIResponsesInputOutput2TypedDict
id: NotRequired[Nullable[str]]
status: NotRequired[Nullable[ToolCallStatus]]
class OpenAIResponsesInputFunctionCallOutput(BaseModel):
type: OpenAIResponsesInputTypeFunctionCallOutput
call_id: str
output: OpenAIResponsesInputOutput2
id: OptionalNullable[str] = UNSET
status: Annotated[
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["id", "status"]
nullable_fields = ["id", "status"]
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
OpenAIResponsesInputTypeMessage2 = Literal["message",]
OpenAIResponsesInputRoleDeveloper2 = Literal["developer",]
OpenAIResponsesInputRoleSystem2 = Literal["system",]
OpenAIResponsesInputRoleUser2 = Literal["user",]
OpenAIResponsesInputRoleUnion2TypedDict = TypeAliasType(
"OpenAIResponsesInputRoleUnion2TypedDict",
Union[
OpenAIResponsesInputRoleUser2,
OpenAIResponsesInputRoleSystem2,
OpenAIResponsesInputRoleDeveloper2,
],
)
OpenAIResponsesInputRoleUnion2 = TypeAliasType(
"OpenAIResponsesInputRoleUnion2",
Union[
OpenAIResponsesInputRoleUser2,
OpenAIResponsesInputRoleSystem2,
OpenAIResponsesInputRoleDeveloper2,
],
)
OpenAIResponsesInputContent3TypedDict = TypeAliasType(
"OpenAIResponsesInputContent3TypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputAudioTypedDict,
ResponseInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenAIResponsesInputContent3 = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[ResponseInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
Annotated[ResponseInputAudio, Tag("input_audio")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenAIResponsesInputMessage2TypedDict(TypedDict):
id: str
role: OpenAIResponsesInputRoleUnion2TypedDict
content: List[OpenAIResponsesInputContent3TypedDict]
type: NotRequired[OpenAIResponsesInputTypeMessage2]
class OpenAIResponsesInputMessage2(BaseModel):
id: str
role: OpenAIResponsesInputRoleUnion2
content: List[OpenAIResponsesInputContent3]
type: Optional[OpenAIResponsesInputTypeMessage2] = None
OpenAIResponsesInputTypeMessage1 = Literal["message",]
OpenAIResponsesInputRoleDeveloper1 = Literal["developer",]
OpenAIResponsesInputRoleAssistant = Literal["assistant",]
OpenAIResponsesInputRoleSystem1 = Literal["system",]
OpenAIResponsesInputRoleUser1 = Literal["user",]
OpenAIResponsesInputRoleUnion1TypedDict = TypeAliasType(
"OpenAIResponsesInputRoleUnion1TypedDict",
Union[
OpenAIResponsesInputRoleUser1,
OpenAIResponsesInputRoleSystem1,
OpenAIResponsesInputRoleAssistant,
OpenAIResponsesInputRoleDeveloper1,
],
)
OpenAIResponsesInputRoleUnion1 = TypeAliasType(
"OpenAIResponsesInputRoleUnion1",
Union[
OpenAIResponsesInputRoleUser1,
OpenAIResponsesInputRoleSystem1,
OpenAIResponsesInputRoleAssistant,
OpenAIResponsesInputRoleDeveloper1,
],
)
OpenAIResponsesInputContent1TypedDict = TypeAliasType(
"OpenAIResponsesInputContent1TypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputAudioTypedDict,
ResponseInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenAIResponsesInputContent1 = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[ResponseInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
Annotated[ResponseInputAudio, Tag("input_audio")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenAIResponsesInputContent2TypedDict = TypeAliasType(
"OpenAIResponsesInputContent2TypedDict",
Union[List[OpenAIResponsesInputContent1TypedDict], str],
)
OpenAIResponsesInputContent2 = TypeAliasType(
"OpenAIResponsesInputContent2", Union[List[OpenAIResponsesInputContent1], str]
)
OpenAIResponsesInputPhaseFinalAnswer = Literal["final_answer",]
OpenAIResponsesInputPhaseCommentary = Literal["commentary",]
OpenAIResponsesInputPhaseUnionTypedDict = TypeAliasType(
"OpenAIResponsesInputPhaseUnionTypedDict",
Union[
OpenAIResponsesInputPhaseCommentary, OpenAIResponsesInputPhaseFinalAnswer, Any
],
)
OpenAIResponsesInputPhaseUnion = TypeAliasType(
"OpenAIResponsesInputPhaseUnion",
Union[
OpenAIResponsesInputPhaseCommentary, OpenAIResponsesInputPhaseFinalAnswer, Any
],
)
class OpenAIResponsesInputMessage1TypedDict(TypedDict):
role: OpenAIResponsesInputRoleUnion1TypedDict
content: OpenAIResponsesInputContent2TypedDict
type: NotRequired[OpenAIResponsesInputTypeMessage1]
phase: NotRequired[Nullable[OpenAIResponsesInputPhaseUnionTypedDict]]
class OpenAIResponsesInputMessage1(BaseModel):
role: OpenAIResponsesInputRoleUnion1
content: OpenAIResponsesInputContent2
type: Optional[OpenAIResponsesInputTypeMessage1] = None
phase: OptionalNullable[OpenAIResponsesInputPhaseUnion] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["type", "phase"]
nullable_fields = ["phase"]
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
OpenAIResponsesInputUnion1TypedDict = TypeAliasType(
"OpenAIResponsesInputUnion1TypedDict",
Union[
OpenAIResponsesInputMessage1TypedDict,
OpenAIResponsesInputMessage2TypedDict,
OutputItemImageGenerationCallTypedDict,
OpenAIResponsesInputFunctionCallOutputTypedDict,
OpenAIResponsesInputFunctionCallTypedDict,
OutputMessageTypedDict,
],
)
OpenAIResponsesInputUnion1 = TypeAliasType(
"OpenAIResponsesInputUnion1",
Union[
OpenAIResponsesInputMessage1,
OpenAIResponsesInputMessage2,
OutputItemImageGenerationCall,
OpenAIResponsesInputFunctionCallOutput,
OpenAIResponsesInputFunctionCall,
OutputMessage,
],
)
OpenAIResponsesInputUnionTypedDict = TypeAliasType(
"OpenAIResponsesInputUnionTypedDict",
Union[str, List[OpenAIResponsesInputUnion1TypedDict], Any],
)
OpenAIResponsesInputUnion = TypeAliasType(
"OpenAIResponsesInputUnion", Union[str, List[OpenAIResponsesInputUnion1], Any]
)
@@ -1,73 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Dict, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
VariablesTypedDict = TypeAliasType(
"VariablesTypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputImageTypedDict,
ResponseInputFileTypedDict,
str,
],
)
Variables = TypeAliasType(
"Variables", Union[ResponseInputText, ResponseInputImage, ResponseInputFile, str]
)
class OpenAIResponsesPromptTypedDict(TypedDict):
id: str
variables: NotRequired[Nullable[Dict[str, VariablesTypedDict]]]
class OpenAIResponsesPrompt(BaseModel):
id: str
variables: OptionalNullable[Dict[str, Variables]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["variables"]
nullable_fields = ["variables"]
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
@@ -1,63 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesreasoningeffort import OpenAIResponsesReasoningEffort
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing_extensions import Annotated, NotRequired, TypedDict
class OpenAIResponsesReasoningConfigTypedDict(TypedDict):
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
class OpenAIResponsesReasoningConfig(BaseModel):
effort: Annotated[
OptionalNullable[OpenAIResponsesReasoningEffort],
PlainValidator(validate_open_enum(False)),
] = UNSET
summary: Annotated[
OptionalNullable[ReasoningSummaryVerbosity],
PlainValidator(validate_open_enum(False)),
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["effort", "summary"]
nullable_fields = ["effort", "summary"]
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
@@ -1,18 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
OpenAIResponsesReasoningEffort = Union[
Literal[
"xhigh",
"high",
"medium",
"low",
"minimal",
"none",
],
UnrecognizedStr,
]
@@ -1,17 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
OpenAIResponsesServiceTier = Union[
Literal[
"auto",
"default",
"flex",
"priority",
"scale",
],
UnrecognizedStr,
]
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesApplyPatchToolType = Literal["apply_patch",]
class OpenResponsesApplyPatchToolTypedDict(TypedDict):
r"""Apply patch tool configuration"""
type: OpenResponsesApplyPatchToolType
class OpenResponsesApplyPatchTool(BaseModel):
r"""Apply patch tool configuration"""
type: OpenResponsesApplyPatchToolType
@@ -1,102 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeCodeInterpreter = Literal["code_interpreter",]
ContainerType = Literal["auto",]
MemoryLimit = Union[
Literal[
"1g",
"4g",
"16g",
"64g",
],
UnrecognizedStr,
]
class ContainerAutoTypedDict(TypedDict):
type: ContainerType
file_ids: NotRequired[List[str]]
memory_limit: NotRequired[Nullable[MemoryLimit]]
class ContainerAuto(BaseModel):
type: ContainerType
file_ids: Optional[List[str]] = None
memory_limit: Annotated[
OptionalNullable[MemoryLimit], PlainValidator(validate_open_enum(False))
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["file_ids", "memory_limit"]
nullable_fields = ["memory_limit"]
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
ContainerTypedDict = TypeAliasType(
"ContainerTypedDict", Union[ContainerAutoTypedDict, str]
)
Container = TypeAliasType("Container", Union[ContainerAuto, str])
class OpenResponsesCodeInterpreterToolTypedDict(TypedDict):
r"""Code interpreter tool configuration"""
type: TypeCodeInterpreter
container: ContainerTypedDict
class OpenResponsesCodeInterpreterTool(BaseModel):
r"""Code interpreter tool configuration"""
type: TypeCodeInterpreter
container: Container
@@ -1,44 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
OpenResponsesComputerToolType = Literal["computer_use_preview",]
Environment = Union[
Literal[
"windows",
"mac",
"linux",
"ubuntu",
"browser",
],
UnrecognizedStr,
]
class OpenResponsesComputerToolTypedDict(TypedDict):
r"""Computer use preview tool configuration"""
type: OpenResponsesComputerToolType
display_height: float
display_width: float
environment: Environment
class OpenResponsesComputerTool(BaseModel):
r"""Computer use preview tool configuration"""
type: OpenResponsesComputerToolType
display_height: float
display_width: float
environment: Annotated[Environment, PlainValidator(validate_open_enum(False))]
@@ -1,82 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import get_discriminator, validate_open_enum
import pydantic
from pydantic import Discriminator, Tag
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeCustom = Literal["custom",]
FormatTypeGrammar = Literal["grammar",]
Syntax = Union[
Literal[
"lark",
"regex",
],
UnrecognizedStr,
]
class FormatGrammarTypedDict(TypedDict):
type: FormatTypeGrammar
definition: str
syntax: Syntax
class FormatGrammar(BaseModel):
type: FormatTypeGrammar
definition: str
syntax: Annotated[Syntax, PlainValidator(validate_open_enum(False))]
FormatTypeText = Literal["text",]
class FormatTextTypedDict(TypedDict):
type: FormatTypeText
class FormatText(BaseModel):
type: FormatTypeText
FormatTypedDict = TypeAliasType(
"FormatTypedDict", Union[FormatTextTypedDict, FormatGrammarTypedDict]
)
Format = Annotated[
Union[Annotated[FormatText, Tag("text")], Annotated[FormatGrammar, Tag("grammar")]],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesCustomToolTypedDict(TypedDict):
r"""Custom tool configuration"""
type: TypeCustom
name: str
description: NotRequired[str]
format_: NotRequired[FormatTypedDict]
class OpenResponsesCustomTool(BaseModel):
r"""Custom tool configuration"""
type: TypeCustom
name: str
description: Optional[str] = None
format_: Annotated[Optional[Format], pydantic.Field(alias="format")] = None
@@ -1,233 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
from .responseinputvideo import ResponseInputVideo, ResponseInputVideoTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesEasyInputMessageTypeMessage = Literal["message",]
OpenResponsesEasyInputMessageRoleDeveloper = Literal["developer",]
OpenResponsesEasyInputMessageRoleAssistant = Literal["assistant",]
OpenResponsesEasyInputMessageRoleSystem = Literal["system",]
OpenResponsesEasyInputMessageRoleUser = Literal["user",]
OpenResponsesEasyInputMessageRoleUnionTypedDict = TypeAliasType(
"OpenResponsesEasyInputMessageRoleUnionTypedDict",
Union[
OpenResponsesEasyInputMessageRoleUser,
OpenResponsesEasyInputMessageRoleSystem,
OpenResponsesEasyInputMessageRoleAssistant,
OpenResponsesEasyInputMessageRoleDeveloper,
],
)
OpenResponsesEasyInputMessageRoleUnion = TypeAliasType(
"OpenResponsesEasyInputMessageRoleUnion",
Union[
OpenResponsesEasyInputMessageRoleUser,
OpenResponsesEasyInputMessageRoleSystem,
OpenResponsesEasyInputMessageRoleAssistant,
OpenResponsesEasyInputMessageRoleDeveloper,
],
)
OpenResponsesEasyInputMessageContentType = Literal["input_image",]
OpenResponsesEasyInputMessageDetail = Union[
Literal[
"auto",
"high",
"low",
],
UnrecognizedStr,
]
class OpenResponsesEasyInputMessageContentInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: OpenResponsesEasyInputMessageContentType
detail: OpenResponsesEasyInputMessageDetail
image_url: NotRequired[Nullable[str]]
class OpenResponsesEasyInputMessageContentInputImage(BaseModel):
r"""Image input content item"""
type: OpenResponsesEasyInputMessageContentType
detail: Annotated[
OpenResponsesEasyInputMessageDetail, PlainValidator(validate_open_enum(False))
]
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["image_url"]
nullable_fields = ["image_url"]
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
OpenResponsesEasyInputMessageContentUnion1TypedDict = TypeAliasType(
"OpenResponsesEasyInputMessageContentUnion1TypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputAudioTypedDict,
ResponseInputVideoTypedDict,
OpenResponsesEasyInputMessageContentInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenResponsesEasyInputMessageContentUnion1 = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[OpenResponsesEasyInputMessageContentInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
Annotated[ResponseInputAudio, Tag("input_audio")],
Annotated[ResponseInputVideo, Tag("input_video")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenResponsesEasyInputMessageContentUnion2TypedDict = TypeAliasType(
"OpenResponsesEasyInputMessageContentUnion2TypedDict",
Union[List[OpenResponsesEasyInputMessageContentUnion1TypedDict], str, Any],
)
OpenResponsesEasyInputMessageContentUnion2 = TypeAliasType(
"OpenResponsesEasyInputMessageContentUnion2",
Union[List[OpenResponsesEasyInputMessageContentUnion1], str, Any],
)
OpenResponsesEasyInputMessagePhaseFinalAnswer = Literal["final_answer",]
OpenResponsesEasyInputMessagePhaseCommentary = Literal["commentary",]
OpenResponsesEasyInputMessagePhaseUnionTypedDict = TypeAliasType(
"OpenResponsesEasyInputMessagePhaseUnionTypedDict",
Union[
OpenResponsesEasyInputMessagePhaseCommentary,
OpenResponsesEasyInputMessagePhaseFinalAnswer,
Any,
],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
OpenResponsesEasyInputMessagePhaseUnion = TypeAliasType(
"OpenResponsesEasyInputMessagePhaseUnion",
Union[
OpenResponsesEasyInputMessagePhaseCommentary,
OpenResponsesEasyInputMessagePhaseFinalAnswer,
Any,
],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class OpenResponsesEasyInputMessageTypedDict(TypedDict):
role: OpenResponsesEasyInputMessageRoleUnionTypedDict
type: NotRequired[OpenResponsesEasyInputMessageTypeMessage]
content: NotRequired[Nullable[OpenResponsesEasyInputMessageContentUnion2TypedDict]]
phase: NotRequired[Nullable[OpenResponsesEasyInputMessagePhaseUnionTypedDict]]
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class OpenResponsesEasyInputMessage(BaseModel):
role: OpenResponsesEasyInputMessageRoleUnion
type: Optional[OpenResponsesEasyInputMessageTypeMessage] = None
content: OptionalNullable[OpenResponsesEasyInputMessageContentUnion2] = UNSET
phase: OptionalNullable[OpenResponsesEasyInputMessagePhaseUnion] = UNSET
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["type", "content", "phase"]
nullable_fields = ["content", "phase"]
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
@@ -1,64 +0,0 @@
"""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 import Literal
from typing_extensions import TypedDict
OpenResponsesErrorEventType = Literal["error",]
class OpenResponsesErrorEventTypedDict(TypedDict):
r"""Event emitted when an error occurs during streaming"""
type: OpenResponsesErrorEventType
code: Nullable[str]
message: str
param: Nullable[str]
sequence_number: float
class OpenResponsesErrorEvent(BaseModel):
r"""Event emitted when an error occurs during streaming"""
type: OpenResponsesErrorEventType
code: Nullable[str]
message: str
param: Nullable[str]
sequence_number: float
@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
@@ -1,148 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .compoundfilter import CompoundFilter, CompoundFilterTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeFileSearch = Literal["file_search",]
FiltersType = Union[
Literal[
"eq",
"ne",
"gt",
"gte",
"lt",
"lte",
],
UnrecognizedStr,
]
Value1TypedDict = TypeAliasType("Value1TypedDict", Union[str, float])
Value1 = TypeAliasType("Value1", Union[str, float])
Value2TypedDict = TypeAliasType(
"Value2TypedDict", Union[str, float, bool, List[Value1TypedDict]]
)
Value2 = TypeAliasType("Value2", Union[str, float, bool, List[Value1]])
class OpenResponsesFileSearchToolFiltersTypedDict(TypedDict):
key: str
type: FiltersType
value: Value2TypedDict
class OpenResponsesFileSearchToolFilters(BaseModel):
key: str
type: Annotated[FiltersType, PlainValidator(validate_open_enum(False))]
value: Value2
FiltersTypedDict = TypeAliasType(
"FiltersTypedDict",
Union[CompoundFilterTypedDict, OpenResponsesFileSearchToolFiltersTypedDict, Any],
)
Filters = TypeAliasType(
"Filters", Union[CompoundFilter, OpenResponsesFileSearchToolFilters, Any]
)
Ranker = Union[
Literal[
"auto",
"default-2024-11-15",
],
UnrecognizedStr,
]
class RankingOptionsTypedDict(TypedDict):
ranker: NotRequired[Ranker]
score_threshold: NotRequired[float]
class RankingOptions(BaseModel):
ranker: Annotated[Optional[Ranker], PlainValidator(validate_open_enum(False))] = (
None
)
score_threshold: Optional[float] = None
class OpenResponsesFileSearchToolTypedDict(TypedDict):
r"""File search tool configuration"""
type: TypeFileSearch
vector_store_ids: List[str]
filters: NotRequired[Nullable[FiltersTypedDict]]
max_num_results: NotRequired[int]
ranking_options: NotRequired[RankingOptionsTypedDict]
class OpenResponsesFileSearchTool(BaseModel):
r"""File search tool configuration"""
type: TypeFileSearch
vector_store_ids: List[str]
filters: OptionalNullable[Filters] = UNSET
max_num_results: Optional[int] = None
ranking_options: Optional[RankingOptions] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["filters", "max_num_results", "ranking_options"]
nullable_fields = ["filters"]
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
@@ -1,173 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
from .toolcallstatus import ToolCallStatus
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesFunctionCallOutputTypeFunctionCallOutput = Literal["function_call_output",]
OutputType = Literal["input_image",]
OpenResponsesFunctionCallOutputDetail = Union[
Literal[
"auto",
"high",
"low",
],
UnrecognizedStr,
]
class OutputInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: OutputType
detail: OpenResponsesFunctionCallOutputDetail
image_url: NotRequired[Nullable[str]]
class OutputInputImage(BaseModel):
r"""Image input content item"""
type: OutputType
detail: Annotated[
OpenResponsesFunctionCallOutputDetail, PlainValidator(validate_open_enum(False))
]
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["image_url"]
nullable_fields = ["image_url"]
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
OpenResponsesFunctionCallOutputOutputUnion1TypedDict = TypeAliasType(
"OpenResponsesFunctionCallOutputOutputUnion1TypedDict",
Union[
ResponseInputTextTypedDict,
OutputInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenResponsesFunctionCallOutputOutputUnion1 = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[OutputInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenResponsesFunctionCallOutputOutputUnion2TypedDict = TypeAliasType(
"OpenResponsesFunctionCallOutputOutputUnion2TypedDict",
Union[str, List[OpenResponsesFunctionCallOutputOutputUnion1TypedDict]],
)
OpenResponsesFunctionCallOutputOutputUnion2 = TypeAliasType(
"OpenResponsesFunctionCallOutputOutputUnion2",
Union[str, List[OpenResponsesFunctionCallOutputOutputUnion1]],
)
class OpenResponsesFunctionCallOutputTypedDict(TypedDict):
r"""The output from a function call execution"""
type: OpenResponsesFunctionCallOutputTypeFunctionCallOutput
call_id: str
output: OpenResponsesFunctionCallOutputOutputUnion2TypedDict
id: NotRequired[Nullable[str]]
status: NotRequired[Nullable[ToolCallStatus]]
class OpenResponsesFunctionCallOutput(BaseModel):
r"""The output from a function call execution"""
type: OpenResponsesFunctionCallOutputTypeFunctionCallOutput
call_id: str
output: OpenResponsesFunctionCallOutputOutputUnion2
id: OptionalNullable[str] = UNSET
status: Annotated[
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["id", "status"]
nullable_fields = ["id", "status"]
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
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesFunctionShellToolType = Literal["shell",]
class OpenResponsesFunctionShellToolTypedDict(TypedDict):
r"""Shell tool configuration"""
type: OpenResponsesFunctionShellToolType
class OpenResponsesFunctionShellTool(BaseModel):
r"""Shell tool configuration"""
type: OpenResponsesFunctionShellToolType
@@ -1,78 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .toolcallstatus import ToolCallStatus
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesFunctionToolCallType = Literal["function_call",]
class OpenResponsesFunctionToolCallTypedDict(TypedDict):
r"""A function call initiated by the model"""
type: OpenResponsesFunctionToolCallType
call_id: str
name: str
arguments: str
id: str
status: NotRequired[Nullable[ToolCallStatus]]
class OpenResponsesFunctionToolCall(BaseModel):
r"""A function call initiated by the model"""
type: OpenResponsesFunctionToolCallType
call_id: str
name: str
arguments: str
id: str
status: Annotated[
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["status"]
nullable_fields = ["status"]
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
@@ -1,32 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesImageGenCallCompletedType = Literal[
"response.image_generation_call.completed",
]
class OpenResponsesImageGenCallCompletedTypedDict(TypedDict):
r"""Image generation call completed"""
type: OpenResponsesImageGenCallCompletedType
item_id: str
output_index: float
sequence_number: float
class OpenResponsesImageGenCallCompleted(BaseModel):
r"""Image generation call completed"""
type: OpenResponsesImageGenCallCompletedType
item_id: str
output_index: float
sequence_number: float
@@ -1,32 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesImageGenCallGeneratingType = Literal[
"response.image_generation_call.generating",
]
class OpenResponsesImageGenCallGeneratingTypedDict(TypedDict):
r"""Image generation call is generating"""
type: OpenResponsesImageGenCallGeneratingType
item_id: str
output_index: float
sequence_number: float
class OpenResponsesImageGenCallGenerating(BaseModel):
r"""Image generation call is generating"""
type: OpenResponsesImageGenCallGeneratingType
item_id: str
output_index: float
sequence_number: float
@@ -1,32 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesImageGenCallInProgressType = Literal[
"response.image_generation_call.in_progress",
]
class OpenResponsesImageGenCallInProgressTypedDict(TypedDict):
r"""Image generation call in progress"""
type: OpenResponsesImageGenCallInProgressType
item_id: str
output_index: float
sequence_number: float
class OpenResponsesImageGenCallInProgress(BaseModel):
r"""Image generation call in progress"""
type: OpenResponsesImageGenCallInProgressType
item_id: str
output_index: float
sequence_number: float
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesImageGenCallPartialImageType = Literal[
"response.image_generation_call.partial_image",
]
class OpenResponsesImageGenCallPartialImageTypedDict(TypedDict):
r"""Image generation call with partial image"""
type: OpenResponsesImageGenCallPartialImageType
item_id: str
output_index: float
sequence_number: float
partial_image_b64: str
partial_image_index: float
class OpenResponsesImageGenCallPartialImage(BaseModel):
r"""Image generation call with partial image"""
type: OpenResponsesImageGenCallPartialImageType
item_id: str
output_index: float
sequence_number: float
partial_image_b64: str
partial_image_index: float
@@ -1,194 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesImageGenerationToolType = Literal["image_generation",]
Background = Union[
Literal[
"transparent",
"opaque",
"auto",
],
UnrecognizedStr,
]
InputFidelity = Union[
Literal[
"high",
"low",
],
UnrecognizedStr,
]
class InputImageMaskTypedDict(TypedDict):
image_url: NotRequired[str]
file_id: NotRequired[str]
class InputImageMask(BaseModel):
image_url: Optional[str] = None
file_id: Optional[str] = None
ModelEnum = Union[
Literal[
"gpt-image-1",
"gpt-image-1-mini",
],
UnrecognizedStr,
]
Moderation = Union[
Literal[
"auto",
"low",
],
UnrecognizedStr,
]
OutputFormat = Union[
Literal[
"png",
"webp",
"jpeg",
],
UnrecognizedStr,
]
Quality = Union[
Literal[
"low",
"medium",
"high",
"auto",
],
UnrecognizedStr,
]
Size = Union[
Literal[
"1024x1024",
"1024x1536",
"1536x1024",
"auto",
],
UnrecognizedStr,
]
class OpenResponsesImageGenerationToolTypedDict(TypedDict):
r"""Image generation tool configuration"""
type: OpenResponsesImageGenerationToolType
background: NotRequired[Background]
input_fidelity: NotRequired[Nullable[InputFidelity]]
input_image_mask: NotRequired[InputImageMaskTypedDict]
model: NotRequired[ModelEnum]
moderation: NotRequired[Moderation]
output_compression: NotRequired[float]
output_format: NotRequired[OutputFormat]
partial_images: NotRequired[float]
quality: NotRequired[Quality]
size: NotRequired[Size]
class OpenResponsesImageGenerationTool(BaseModel):
r"""Image generation tool configuration"""
type: OpenResponsesImageGenerationToolType
background: Annotated[
Optional[Background], PlainValidator(validate_open_enum(False))
] = None
input_fidelity: Annotated[
OptionalNullable[InputFidelity], PlainValidator(validate_open_enum(False))
] = UNSET
input_image_mask: Optional[InputImageMask] = None
model: Annotated[Optional[ModelEnum], PlainValidator(validate_open_enum(False))] = (
None
)
moderation: Annotated[
Optional[Moderation], PlainValidator(validate_open_enum(False))
] = None
output_compression: Optional[float] = None
output_format: Annotated[
Optional[OutputFormat], PlainValidator(validate_open_enum(False))
] = None
partial_images: Optional[float] = None
quality: Annotated[Optional[Quality], PlainValidator(validate_open_enum(False))] = (
None
)
size: Annotated[Optional[Size], PlainValidator(validate_open_enum(False))] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"background",
"input_fidelity",
"input_image_mask",
"model",
"moderation",
"output_compression",
"output_format",
"partial_images",
"quality",
"size",
]
nullable_fields = ["input_fidelity"]
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
@@ -1,97 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openresponseseasyinputmessage import (
OpenResponsesEasyInputMessage,
OpenResponsesEasyInputMessageTypedDict,
)
from .openresponsesfunctioncalloutput import (
OpenResponsesFunctionCallOutput,
OpenResponsesFunctionCallOutputTypedDict,
)
from .openresponsesfunctiontoolcall import (
OpenResponsesFunctionToolCall,
OpenResponsesFunctionToolCallTypedDict,
)
from .openresponsesinputmessageitem import (
OpenResponsesInputMessageItem,
OpenResponsesInputMessageItemTypedDict,
)
from .openresponsesreasoning import (
OpenResponsesReasoning,
OpenResponsesReasoningTypedDict,
)
from .responsesimagegenerationcall import (
ResponsesImageGenerationCall,
ResponsesImageGenerationCallTypedDict,
)
from .responsesoutputitemfilesearchcall import (
ResponsesOutputItemFileSearchCall,
ResponsesOutputItemFileSearchCallTypedDict,
)
from .responsesoutputitemfunctioncall import (
ResponsesOutputItemFunctionCall,
ResponsesOutputItemFunctionCallTypedDict,
)
from .responsesoutputitemreasoning import (
ResponsesOutputItemReasoning,
ResponsesOutputItemReasoningTypedDict,
)
from .responsesoutputmessage import (
ResponsesOutputMessage,
ResponsesOutputMessageTypedDict,
)
from .responseswebsearchcalloutput import (
ResponsesWebSearchCallOutput,
ResponsesWebSearchCallOutputTypedDict,
)
from typing import List, Union
from typing_extensions import TypeAliasType
OpenResponsesInput1TypedDict = TypeAliasType(
"OpenResponsesInput1TypedDict",
Union[
OpenResponsesEasyInputMessageTypedDict,
ResponsesWebSearchCallOutputTypedDict,
OpenResponsesInputMessageItemTypedDict,
ResponsesOutputItemFileSearchCallTypedDict,
ResponsesImageGenerationCallTypedDict,
OpenResponsesFunctionCallOutputTypedDict,
ResponsesOutputMessageTypedDict,
OpenResponsesFunctionToolCallTypedDict,
ResponsesOutputItemFunctionCallTypedDict,
OpenResponsesReasoningTypedDict,
ResponsesOutputItemReasoningTypedDict,
],
)
OpenResponsesInput1 = TypeAliasType(
"OpenResponsesInput1",
Union[
OpenResponsesEasyInputMessage,
ResponsesWebSearchCallOutput,
OpenResponsesInputMessageItem,
ResponsesOutputItemFileSearchCall,
ResponsesImageGenerationCall,
OpenResponsesFunctionCallOutput,
ResponsesOutputMessage,
OpenResponsesFunctionToolCall,
ResponsesOutputItemFunctionCall,
OpenResponsesReasoning,
ResponsesOutputItemReasoning,
],
)
OpenResponsesInputTypedDict = TypeAliasType(
"OpenResponsesInputTypedDict", Union[str, List[OpenResponsesInput1TypedDict]]
)
r"""Input for a response request - can be a string or array of items"""
OpenResponsesInput = TypeAliasType(
"OpenResponsesInput", Union[str, List[OpenResponsesInput1]]
)
r"""Input for a response request - can be a string or array of items"""
@@ -1,380 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesrefusalcontent import (
OpenAIResponsesRefusalContent,
OpenAIResponsesRefusalContentTypedDict,
)
from .openresponseseasyinputmessage import (
OpenResponsesEasyInputMessage,
OpenResponsesEasyInputMessageTypedDict,
)
from .openresponsesfunctioncalloutput import (
OpenResponsesFunctionCallOutput,
OpenResponsesFunctionCallOutputTypedDict,
)
from .openresponsesfunctiontoolcall import (
OpenResponsesFunctionToolCall,
OpenResponsesFunctionToolCallTypedDict,
)
from .openresponsesinputmessageitem import (
OpenResponsesInputMessageItem,
OpenResponsesInputMessageItemTypedDict,
)
from .openresponsesreasoning import (
OpenResponsesReasoning,
OpenResponsesReasoningTypedDict,
)
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from .responsesimagegenerationcall import (
ResponsesImageGenerationCall,
ResponsesImageGenerationCallTypedDict,
)
from .responsesoutputitemfilesearchcall import (
ResponsesOutputItemFileSearchCall,
ResponsesOutputItemFileSearchCallTypedDict,
)
from .responsesoutputitemfunctioncall import (
ResponsesOutputItemFunctionCall,
ResponsesOutputItemFunctionCallTypedDict,
)
from .responseswebsearchcalloutput import (
ResponsesWebSearchCallOutput,
ResponsesWebSearchCallOutputTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
import pydantic
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesInputTypeReasoning = Literal["reasoning",]
OpenResponsesInputStatusInProgress2 = Literal["in_progress",]
OpenResponsesInputStatusIncomplete2 = Literal["incomplete",]
OpenResponsesInputStatusCompleted2 = Literal["completed",]
OpenResponsesInputStatusUnion2TypedDict = TypeAliasType(
"OpenResponsesInputStatusUnion2TypedDict",
Union[
OpenResponsesInputStatusCompleted2,
OpenResponsesInputStatusIncomplete2,
OpenResponsesInputStatusInProgress2,
],
)
OpenResponsesInputStatusUnion2 = TypeAliasType(
"OpenResponsesInputStatusUnion2",
Union[
OpenResponsesInputStatusCompleted2,
OpenResponsesInputStatusIncomplete2,
OpenResponsesInputStatusInProgress2,
],
)
OpenResponsesInputFormat = Union[
Literal[
"unknown",
"openai-responses-v1",
"azure-openai-responses-v1",
"xai-responses-v1",
"anthropic-claude-v1",
"google-gemini-v1",
],
UnrecognizedStr,
]
r"""The format of the reasoning content"""
class OpenResponsesInputReasoningTypedDict(TypedDict):
r"""An output item containing reasoning"""
type: OpenResponsesInputTypeReasoning
id: str
summary: Nullable[List[ReasoningSummaryTextTypedDict]]
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
encrypted_content: NotRequired[Nullable[str]]
status: NotRequired[OpenResponsesInputStatusUnion2TypedDict]
signature: NotRequired[Nullable[str]]
r"""A signature for the reasoning content, used for verification"""
format_: NotRequired[Nullable[OpenResponsesInputFormat]]
r"""The format of the reasoning content"""
class OpenResponsesInputReasoning(BaseModel):
r"""An output item containing reasoning"""
type: OpenResponsesInputTypeReasoning
id: str
summary: Nullable[List[ReasoningSummaryText]]
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
encrypted_content: OptionalNullable[str] = UNSET
status: Optional[OpenResponsesInputStatusUnion2] = None
signature: OptionalNullable[str] = UNSET
r"""A signature for the reasoning content, used for verification"""
format_: Annotated[
Annotated[
OptionalNullable[OpenResponsesInputFormat],
PlainValidator(validate_open_enum(False)),
],
pydantic.Field(alias="format"),
] = UNSET
r"""The format of the reasoning content"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"content",
"encrypted_content",
"status",
"signature",
"format",
]
nullable_fields = [
"content",
"summary",
"encrypted_content",
"signature",
"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
OpenResponsesInputRole = Literal["assistant",]
OpenResponsesInputTypeMessage = Literal["message",]
OpenResponsesInputStatusInProgress1 = Literal["in_progress",]
OpenResponsesInputStatusIncomplete1 = Literal["incomplete",]
OpenResponsesInputStatusCompleted1 = Literal["completed",]
OpenResponsesInputStatusUnion1TypedDict = TypeAliasType(
"OpenResponsesInputStatusUnion1TypedDict",
Union[
OpenResponsesInputStatusCompleted1,
OpenResponsesInputStatusIncomplete1,
OpenResponsesInputStatusInProgress1,
],
)
OpenResponsesInputStatusUnion1 = TypeAliasType(
"OpenResponsesInputStatusUnion1",
Union[
OpenResponsesInputStatusCompleted1,
OpenResponsesInputStatusIncomplete1,
OpenResponsesInputStatusInProgress1,
],
)
OpenResponsesInputContent1TypedDict = TypeAliasType(
"OpenResponsesInputContent1TypedDict",
Union[OpenAIResponsesRefusalContentTypedDict, ResponseOutputTextTypedDict],
)
OpenResponsesInputContent1 = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenResponsesInputContent2TypedDict = TypeAliasType(
"OpenResponsesInputContent2TypedDict",
Union[List[OpenResponsesInputContent1TypedDict], str, Any],
)
OpenResponsesInputContent2 = TypeAliasType(
"OpenResponsesInputContent2", Union[List[OpenResponsesInputContent1], str, Any]
)
OpenResponsesInputPhaseFinalAnswer = Literal["final_answer",]
OpenResponsesInputPhaseCommentary = Literal["commentary",]
OpenResponsesInputPhaseUnionTypedDict = TypeAliasType(
"OpenResponsesInputPhaseUnionTypedDict",
Union[OpenResponsesInputPhaseCommentary, OpenResponsesInputPhaseFinalAnswer, Any],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
OpenResponsesInputPhaseUnion = TypeAliasType(
"OpenResponsesInputPhaseUnion",
Union[OpenResponsesInputPhaseCommentary, OpenResponsesInputPhaseFinalAnswer, Any],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class OpenResponsesInputMessageTypedDict(TypedDict):
r"""An output message item"""
id: str
role: OpenResponsesInputRole
type: OpenResponsesInputTypeMessage
content: Nullable[OpenResponsesInputContent2TypedDict]
status: NotRequired[OpenResponsesInputStatusUnion1TypedDict]
phase: NotRequired[Nullable[OpenResponsesInputPhaseUnionTypedDict]]
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class OpenResponsesInputMessage(BaseModel):
r"""An output message item"""
id: str
role: OpenResponsesInputRole
type: OpenResponsesInputTypeMessage
content: Nullable[OpenResponsesInputContent2]
status: Optional[OpenResponsesInputStatusUnion1] = None
phase: OptionalNullable[OpenResponsesInputPhaseUnion] = UNSET
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["status", "phase"]
nullable_fields = ["content", "phase"]
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
OpenResponsesInputUnion1TypedDict = TypeAliasType(
"OpenResponsesInputUnion1TypedDict",
Union[
OpenResponsesEasyInputMessageTypedDict,
OpenResponsesInputMessageItemTypedDict,
ResponsesWebSearchCallOutputTypedDict,
ResponsesOutputItemFileSearchCallTypedDict,
ResponsesImageGenerationCallTypedDict,
OpenResponsesFunctionCallOutputTypedDict,
OpenResponsesFunctionToolCallTypedDict,
OpenResponsesInputMessageTypedDict,
ResponsesOutputItemFunctionCallTypedDict,
OpenResponsesReasoningTypedDict,
OpenResponsesInputReasoningTypedDict,
],
)
OpenResponsesInputUnion1 = TypeAliasType(
"OpenResponsesInputUnion1",
Union[
OpenResponsesEasyInputMessage,
OpenResponsesInputMessageItem,
ResponsesWebSearchCallOutput,
ResponsesOutputItemFileSearchCall,
ResponsesImageGenerationCall,
OpenResponsesFunctionCallOutput,
OpenResponsesFunctionToolCall,
OpenResponsesInputMessage,
ResponsesOutputItemFunctionCall,
OpenResponsesReasoning,
OpenResponsesInputReasoning,
],
)
OpenResponsesInputUnionTypedDict = TypeAliasType(
"OpenResponsesInputUnionTypedDict",
Union[str, List[OpenResponsesInputUnion1TypedDict]],
)
r"""Input for a response request - can be a string or array of items"""
OpenResponsesInputUnion = TypeAliasType(
"OpenResponsesInputUnion", Union[str, List[OpenResponsesInputUnion1]]
)
r"""Input for a response request - can be a string or array of items"""
@@ -1,188 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
from .responseinputvideo import ResponseInputVideo, ResponseInputVideoTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesInputMessageItemTypeMessage = Literal["message",]
OpenResponsesInputMessageItemRoleDeveloper = Literal["developer",]
OpenResponsesInputMessageItemRoleSystem = Literal["system",]
OpenResponsesInputMessageItemRoleUser = Literal["user",]
OpenResponsesInputMessageItemRoleUnionTypedDict = TypeAliasType(
"OpenResponsesInputMessageItemRoleUnionTypedDict",
Union[
OpenResponsesInputMessageItemRoleUser,
OpenResponsesInputMessageItemRoleSystem,
OpenResponsesInputMessageItemRoleDeveloper,
],
)
OpenResponsesInputMessageItemRoleUnion = TypeAliasType(
"OpenResponsesInputMessageItemRoleUnion",
Union[
OpenResponsesInputMessageItemRoleUser,
OpenResponsesInputMessageItemRoleSystem,
OpenResponsesInputMessageItemRoleDeveloper,
],
)
OpenResponsesInputMessageItemContentType = Literal["input_image",]
OpenResponsesInputMessageItemDetail = Union[
Literal[
"auto",
"high",
"low",
],
UnrecognizedStr,
]
class OpenResponsesInputMessageItemContentInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: OpenResponsesInputMessageItemContentType
detail: OpenResponsesInputMessageItemDetail
image_url: NotRequired[Nullable[str]]
class OpenResponsesInputMessageItemContentInputImage(BaseModel):
r"""Image input content item"""
type: OpenResponsesInputMessageItemContentType
detail: Annotated[
OpenResponsesInputMessageItemDetail, PlainValidator(validate_open_enum(False))
]
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["image_url"]
nullable_fields = ["image_url"]
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
OpenResponsesInputMessageItemContentUnionTypedDict = TypeAliasType(
"OpenResponsesInputMessageItemContentUnionTypedDict",
Union[
ResponseInputTextTypedDict,
ResponseInputAudioTypedDict,
ResponseInputVideoTypedDict,
OpenResponsesInputMessageItemContentInputImageTypedDict,
ResponseInputFileTypedDict,
],
)
OpenResponsesInputMessageItemContentUnion = Annotated[
Union[
Annotated[ResponseInputText, Tag("input_text")],
Annotated[OpenResponsesInputMessageItemContentInputImage, Tag("input_image")],
Annotated[ResponseInputFile, Tag("input_file")],
Annotated[ResponseInputAudio, Tag("input_audio")],
Annotated[ResponseInputVideo, Tag("input_video")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesInputMessageItemTypedDict(TypedDict):
role: OpenResponsesInputMessageItemRoleUnionTypedDict
id: NotRequired[str]
type: NotRequired[OpenResponsesInputMessageItemTypeMessage]
content: NotRequired[
Nullable[List[OpenResponsesInputMessageItemContentUnionTypedDict]]
]
class OpenResponsesInputMessageItem(BaseModel):
role: OpenResponsesInputMessageItemRoleUnion
id: Optional[str] = None
type: Optional[OpenResponsesInputMessageItemTypeMessage] = None
content: OptionalNullable[List[OpenResponsesInputMessageItemContentUnion]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["id", "type", "content"]
nullable_fields = ["content"]
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
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesLocalShellToolType = Literal["local_shell",]
class OpenResponsesLocalShellToolTypedDict(TypedDict):
r"""Local shell tool configuration"""
type: OpenResponsesLocalShellToolType
class OpenResponsesLocalShellTool(BaseModel):
r"""Local shell tool configuration"""
type: OpenResponsesLocalShellToolType
@@ -1,28 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openresponsestoplogprobs import (
OpenResponsesTopLogprobs,
OpenResponsesTopLogprobsTypedDict,
)
from openrouter.types import BaseModel
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
class OpenResponsesLogProbsTypedDict(TypedDict):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: NotRequired[List[OpenResponsesTopLogprobsTypedDict]]
class OpenResponsesLogProbs(BaseModel):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: Optional[List[OpenResponsesTopLogprobs]] = None
@@ -1,154 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesMcpToolType = Literal["mcp",]
class AllowedToolsTypedDict(TypedDict):
tool_names: NotRequired[List[str]]
read_only: NotRequired[bool]
class AllowedTools(BaseModel):
tool_names: Optional[List[str]] = None
read_only: Optional[bool] = None
ConnectorID = Union[
Literal[
"connector_dropbox",
"connector_gmail",
"connector_googlecalendar",
"connector_googledrive",
"connector_microsoftteams",
"connector_outlookcalendar",
"connector_outlookemail",
"connector_sharepoint",
],
UnrecognizedStr,
]
RequireApprovalNever = Literal["never",]
RequireApprovalAlways = Literal["always",]
class NeverTypedDict(TypedDict):
tool_names: NotRequired[List[str]]
class Never(BaseModel):
tool_names: Optional[List[str]] = None
class AlwaysTypedDict(TypedDict):
tool_names: NotRequired[List[str]]
class Always(BaseModel):
tool_names: Optional[List[str]] = None
class RequireApprovalTypedDict(TypedDict):
never: NotRequired[NeverTypedDict]
always: NotRequired[AlwaysTypedDict]
class RequireApproval(BaseModel):
never: Optional[Never] = None
always: Optional[Always] = None
class OpenResponsesMcpToolTypedDict(TypedDict):
r"""MCP (Model Context Protocol) tool configuration"""
type: OpenResponsesMcpToolType
server_label: str
allowed_tools: NotRequired[Nullable[Any]]
authorization: NotRequired[str]
connector_id: NotRequired[ConnectorID]
headers: NotRequired[Nullable[Dict[str, str]]]
require_approval: NotRequired[Nullable[Any]]
server_description: NotRequired[str]
server_url: NotRequired[str]
class OpenResponsesMcpTool(BaseModel):
r"""MCP (Model Context Protocol) tool configuration"""
type: OpenResponsesMcpToolType
server_label: str
allowed_tools: OptionalNullable[Any] = UNSET
authorization: Optional[str] = None
connector_id: Annotated[
Optional[ConnectorID], PlainValidator(validate_open_enum(False))
] = None
headers: OptionalNullable[Dict[str, str]] = UNSET
require_approval: OptionalNullable[Any] = UNSET
server_description: Optional[str] = None
server_url: Optional[str] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allowed_tools",
"authorization",
"connector_id",
"headers",
"require_approval",
"server_description",
"server_url",
]
nullable_fields = ["allowed_tools", "headers", "require_approval"]
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
@@ -1,389 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesincompletedetails import (
OpenAIResponsesIncompleteDetails,
OpenAIResponsesIncompleteDetailsTypedDict,
)
from .openairesponsesinput_union import (
OpenAIResponsesInputUnion,
OpenAIResponsesInputUnionTypedDict,
)
from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict
from .openairesponsesreasoningconfig import (
OpenAIResponsesReasoningConfig,
OpenAIResponsesReasoningConfigTypedDict,
)
from .openairesponsesresponsestatus import OpenAIResponsesResponseStatus
from .openairesponsesservicetier import OpenAIResponsesServiceTier
from .openairesponsestoolchoice_union import (
OpenAIResponsesToolChoiceUnion,
OpenAIResponsesToolChoiceUnionTypedDict,
)
from .openairesponsestruncation import OpenAIResponsesTruncation
from .openresponsesapplypatchtool import (
OpenResponsesApplyPatchTool,
OpenResponsesApplyPatchToolTypedDict,
)
from .openresponsescodeinterpretertool import (
OpenResponsesCodeInterpreterTool,
OpenResponsesCodeInterpreterToolTypedDict,
)
from .openresponsescomputertool import (
OpenResponsesComputerTool,
OpenResponsesComputerToolTypedDict,
)
from .openresponsescustomtool import (
OpenResponsesCustomTool,
OpenResponsesCustomToolTypedDict,
)
from .openresponsesfilesearchtool import (
OpenResponsesFileSearchTool,
OpenResponsesFileSearchToolTypedDict,
)
from .openresponsesfunctionshelltool import (
OpenResponsesFunctionShellTool,
OpenResponsesFunctionShellToolTypedDict,
)
from .openresponsesimagegenerationtool import (
OpenResponsesImageGenerationTool,
OpenResponsesImageGenerationToolTypedDict,
)
from .openresponseslocalshelltool import (
OpenResponsesLocalShellTool,
OpenResponsesLocalShellToolTypedDict,
)
from .openresponsesmcptool import OpenResponsesMcpTool, OpenResponsesMcpToolTypedDict
from .openresponsesusage import OpenResponsesUsage, OpenResponsesUsageTypedDict
from .openresponseswebsearch20250826tool import (
OpenResponsesWebSearch20250826Tool,
OpenResponsesWebSearch20250826ToolTypedDict,
)
from .openresponseswebsearchpreview20250311tool import (
OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesWebSearchPreview20250311ToolTypedDict,
)
from .openresponseswebsearchpreviewtool import (
OpenResponsesWebSearchPreviewTool,
OpenResponsesWebSearchPreviewToolTypedDict,
)
from .openresponseswebsearchtool import (
OpenResponsesWebSearchTool,
OpenResponsesWebSearchToolTypedDict,
)
from .responseserrorfield import ResponsesErrorField, ResponsesErrorFieldTypedDict
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
from .responsetextconfig import ResponseTextConfig, ResponseTextConfigTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesNonStreamingResponseObject = Literal["response",]
OpenResponsesNonStreamingResponseType = Literal["function",]
class OpenResponsesNonStreamingResponseToolFunctionTypedDict(TypedDict):
r"""Function tool definition"""
type: OpenResponsesNonStreamingResponseType
name: str
parameters: Nullable[Dict[str, Nullable[Any]]]
description: NotRequired[Nullable[str]]
strict: NotRequired[Nullable[bool]]
class OpenResponsesNonStreamingResponseToolFunction(BaseModel):
r"""Function tool definition"""
type: OpenResponsesNonStreamingResponseType
name: str
parameters: Nullable[Dict[str, Nullable[Any]]]
description: OptionalNullable[str] = UNSET
strict: OptionalNullable[bool] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["description", "strict"]
nullable_fields = ["description", "strict", "parameters"]
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
OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
"OpenResponsesNonStreamingResponseToolUnionTypedDict",
Union[
OpenResponsesApplyPatchToolTypedDict,
OpenResponsesFunctionShellToolTypedDict,
OpenResponsesLocalShellToolTypedDict,
OpenResponsesCodeInterpreterToolTypedDict,
OpenResponsesWebSearchPreviewToolTypedDict,
OpenResponsesWebSearchPreview20250311ToolTypedDict,
OpenResponsesComputerToolTypedDict,
OpenResponsesWebSearch20250826ToolTypedDict,
OpenResponsesWebSearchToolTypedDict,
OpenResponsesCustomToolTypedDict,
OpenResponsesNonStreamingResponseToolFunctionTypedDict,
OpenResponsesFileSearchToolTypedDict,
OpenResponsesMcpToolTypedDict,
OpenResponsesImageGenerationToolTypedDict,
],
)
OpenResponsesNonStreamingResponseToolUnion = Annotated[
Union[
Annotated[OpenResponsesNonStreamingResponseToolFunction, Tag("function")],
Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
Annotated[
OpenResponsesWebSearchPreview20250311Tool,
Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
Annotated[OpenResponsesFileSearchTool, Tag("file_search")],
Annotated[OpenResponsesComputerTool, Tag("computer_use_preview")],
Annotated[OpenResponsesCodeInterpreterTool, Tag("code_interpreter")],
Annotated[OpenResponsesMcpTool, Tag("mcp")],
Annotated[OpenResponsesImageGenerationTool, Tag("image_generation")],
Annotated[OpenResponsesLocalShellTool, Tag("local_shell")],
Annotated[OpenResponsesFunctionShellTool, Tag("shell")],
Annotated[OpenResponsesApplyPatchTool, Tag("apply_patch")],
Annotated[OpenResponsesCustomTool, Tag("custom")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
r"""Complete non-streaming response from the Responses API"""
id: str
object: OpenResponsesNonStreamingResponseObject
created_at: float
model: str
status: OpenAIResponsesResponseStatus
completed_at: Nullable[float]
output: List[ResponsesOutputItemTypedDict]
error: Nullable[ResponsesErrorFieldTypedDict]
r"""Error information returned from the API"""
incomplete_details: Nullable[OpenAIResponsesIncompleteDetailsTypedDict]
temperature: Nullable[float]
top_p: Nullable[float]
presence_penalty: Nullable[float]
frequency_penalty: Nullable[float]
instructions: Nullable[OpenAIResponsesInputUnionTypedDict]
metadata: Nullable[Dict[str, str]]
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
tools: List[OpenResponsesNonStreamingResponseToolUnionTypedDict]
tool_choice: OpenAIResponsesToolChoiceUnionTypedDict
parallel_tool_calls: bool
user: NotRequired[Nullable[str]]
output_text: NotRequired[str]
prompt_cache_key: NotRequired[Nullable[str]]
safety_identifier: NotRequired[Nullable[str]]
usage: NotRequired[Nullable[OpenResponsesUsageTypedDict]]
r"""Token usage information for the response"""
max_tool_calls: NotRequired[Nullable[float]]
top_logprobs: NotRequired[float]
max_output_tokens: NotRequired[Nullable[float]]
prompt: NotRequired[Nullable[OpenAIResponsesPromptTypedDict]]
background: NotRequired[Nullable[bool]]
previous_response_id: NotRequired[Nullable[str]]
reasoning: NotRequired[Nullable[OpenAIResponsesReasoningConfigTypedDict]]
service_tier: NotRequired[Nullable[OpenAIResponsesServiceTier]]
store: NotRequired[bool]
truncation: NotRequired[Nullable[OpenAIResponsesTruncation]]
text: NotRequired[ResponseTextConfigTypedDict]
r"""Text output configuration including format and verbosity"""
class OpenResponsesNonStreamingResponse(BaseModel):
r"""Complete non-streaming response from the Responses API"""
id: str
object: OpenResponsesNonStreamingResponseObject
created_at: float
model: str
status: Annotated[
OpenAIResponsesResponseStatus, PlainValidator(validate_open_enum(False))
]
completed_at: Nullable[float]
output: List[ResponsesOutputItem]
error: Nullable[ResponsesErrorField]
r"""Error information returned from the API"""
incomplete_details: Nullable[OpenAIResponsesIncompleteDetails]
temperature: Nullable[float]
top_p: Nullable[float]
presence_penalty: Nullable[float]
frequency_penalty: Nullable[float]
instructions: Nullable[OpenAIResponsesInputUnion]
metadata: Nullable[Dict[str, str]]
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
tools: List[OpenResponsesNonStreamingResponseToolUnion]
tool_choice: OpenAIResponsesToolChoiceUnion
parallel_tool_calls: bool
user: OptionalNullable[str] = UNSET
output_text: Optional[str] = None
prompt_cache_key: OptionalNullable[str] = UNSET
safety_identifier: OptionalNullable[str] = UNSET
usage: OptionalNullable[OpenResponsesUsage] = UNSET
r"""Token usage information for the response"""
max_tool_calls: OptionalNullable[float] = UNSET
top_logprobs: Optional[float] = None
max_output_tokens: OptionalNullable[float] = UNSET
prompt: OptionalNullable[OpenAIResponsesPrompt] = UNSET
background: OptionalNullable[bool] = UNSET
previous_response_id: OptionalNullable[str] = UNSET
reasoning: OptionalNullable[OpenAIResponsesReasoningConfig] = UNSET
service_tier: Annotated[
OptionalNullable[OpenAIResponsesServiceTier],
PlainValidator(validate_open_enum(False)),
] = UNSET
store: Optional[bool] = None
truncation: Annotated[
OptionalNullable[OpenAIResponsesTruncation],
PlainValidator(validate_open_enum(False)),
] = UNSET
text: Optional[ResponseTextConfig] = None
r"""Text output configuration including format and verbosity"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"user",
"output_text",
"prompt_cache_key",
"safety_identifier",
"usage",
"max_tool_calls",
"top_logprobs",
"max_output_tokens",
"prompt",
"background",
"previous_response_id",
"reasoning",
"service_tier",
"store",
"truncation",
"text",
]
nullable_fields = [
"completed_at",
"user",
"prompt_cache_key",
"safety_identifier",
"error",
"incomplete_details",
"usage",
"max_tool_calls",
"max_output_tokens",
"temperature",
"top_p",
"presence_penalty",
"frequency_penalty",
"instructions",
"metadata",
"prompt",
"background",
"previous_response_id",
"reasoning",
"service_tier",
"truncation",
]
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
@@ -1,139 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesReasoningType = Literal["reasoning",]
OpenResponsesReasoningStatusInProgress = Literal["in_progress",]
OpenResponsesReasoningStatusIncomplete = Literal["incomplete",]
OpenResponsesReasoningStatusCompleted = Literal["completed",]
OpenResponsesReasoningStatusUnionTypedDict = TypeAliasType(
"OpenResponsesReasoningStatusUnionTypedDict",
Union[
OpenResponsesReasoningStatusCompleted,
OpenResponsesReasoningStatusIncomplete,
OpenResponsesReasoningStatusInProgress,
],
)
OpenResponsesReasoningStatusUnion = TypeAliasType(
"OpenResponsesReasoningStatusUnion",
Union[
OpenResponsesReasoningStatusCompleted,
OpenResponsesReasoningStatusIncomplete,
OpenResponsesReasoningStatusInProgress,
],
)
OpenResponsesReasoningFormat = Union[
Literal[
"unknown",
"openai-responses-v1",
"azure-openai-responses-v1",
"xai-responses-v1",
"anthropic-claude-v1",
"google-gemini-v1",
],
UnrecognizedStr,
]
class OpenResponsesReasoningTypedDict(TypedDict):
r"""Reasoning output item with signature and format extensions"""
type: OpenResponsesReasoningType
id: str
summary: List[ReasoningSummaryTextTypedDict]
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
encrypted_content: NotRequired[Nullable[str]]
status: NotRequired[OpenResponsesReasoningStatusUnionTypedDict]
signature: NotRequired[Nullable[str]]
format_: NotRequired[Nullable[OpenResponsesReasoningFormat]]
class OpenResponsesReasoning(BaseModel):
r"""Reasoning output item with signature and format extensions"""
type: OpenResponsesReasoningType
id: str
summary: List[ReasoningSummaryText]
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
encrypted_content: OptionalNullable[str] = UNSET
status: Optional[OpenResponsesReasoningStatusUnion] = None
signature: OptionalNullable[str] = UNSET
format_: Annotated[
Annotated[
OptionalNullable[OpenResponsesReasoningFormat],
PlainValidator(validate_open_enum(False)),
],
pydantic.Field(alias="format"),
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"content",
"encrypted_content",
"status",
"signature",
"format",
]
nullable_fields = ["content", "encrypted_content", "signature", "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
@@ -1,73 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesreasoningeffort import OpenAIResponsesReasoningEffort
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing_extensions import Annotated, NotRequired, TypedDict
class OpenResponsesReasoningConfigTypedDict(TypedDict):
r"""Configuration for reasoning mode in the response"""
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
max_tokens: NotRequired[Nullable[float]]
enabled: NotRequired[Nullable[bool]]
class OpenResponsesReasoningConfig(BaseModel):
r"""Configuration for reasoning mode in the response"""
effort: Annotated[
OptionalNullable[OpenAIResponsesReasoningEffort],
PlainValidator(validate_open_enum(False)),
] = UNSET
summary: Annotated[
OptionalNullable[ReasoningSummaryVerbosity],
PlainValidator(validate_open_enum(False)),
] = UNSET
max_tokens: OptionalNullable[float] = UNSET
enabled: OptionalNullable[bool] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["effort", "summary", "max_tokens", "enabled"]
nullable_fields = ["effort", "summary", "max_tokens", "enabled"]
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
@@ -1,36 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesReasoningDeltaEventType = Literal["response.reasoning_text.delta",]
class OpenResponsesReasoningDeltaEventTypedDict(TypedDict):
r"""Event emitted when reasoning text delta is streamed"""
type: OpenResponsesReasoningDeltaEventType
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
class OpenResponsesReasoningDeltaEvent(BaseModel):
r"""Event emitted when reasoning text delta is streamed"""
type: OpenResponsesReasoningDeltaEventType
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
@@ -1,36 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesReasoningDoneEventType = Literal["response.reasoning_text.done",]
class OpenResponsesReasoningDoneEventTypedDict(TypedDict):
r"""Event emitted when reasoning text streaming is complete"""
type: OpenResponsesReasoningDoneEventType
output_index: float
item_id: str
content_index: float
text: str
sequence_number: float
class OpenResponsesReasoningDoneEvent(BaseModel):
r"""Event emitted when reasoning text streaming is complete"""
type: OpenResponsesReasoningDoneEventType
output_index: float
item_id: str
content_index: float
text: str
sequence_number: float
@@ -1,39 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesReasoningSummaryPartAddedEventType = Literal[
"response.reasoning_summary_part.added",
]
class OpenResponsesReasoningSummaryPartAddedEventTypedDict(TypedDict):
r"""Event emitted when a reasoning summary part is added"""
type: OpenResponsesReasoningSummaryPartAddedEventType
output_index: float
item_id: str
summary_index: float
part: ReasoningSummaryTextTypedDict
sequence_number: float
class OpenResponsesReasoningSummaryPartAddedEvent(BaseModel):
r"""Event emitted when a reasoning summary part is added"""
type: OpenResponsesReasoningSummaryPartAddedEventType
output_index: float
item_id: str
summary_index: float
part: ReasoningSummaryText
sequence_number: float
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesReasoningSummaryTextDeltaEventType = Literal[
"response.reasoning_summary_text.delta",
]
class OpenResponsesReasoningSummaryTextDeltaEventTypedDict(TypedDict):
r"""Event emitted when reasoning summary text delta is streamed"""
type: OpenResponsesReasoningSummaryTextDeltaEventType
item_id: str
output_index: float
summary_index: float
delta: str
sequence_number: float
class OpenResponsesReasoningSummaryTextDeltaEvent(BaseModel):
r"""Event emitted when reasoning summary text delta is streamed"""
type: OpenResponsesReasoningSummaryTextDeltaEventType
item_id: str
output_index: float
summary_index: float
delta: str
sequence_number: float
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
OpenResponsesReasoningSummaryTextDoneEventType = Literal[
"response.reasoning_summary_text.done",
]
class OpenResponsesReasoningSummaryTextDoneEventTypedDict(TypedDict):
r"""Event emitted when reasoning summary text streaming is complete"""
type: OpenResponsesReasoningSummaryTextDoneEventType
item_id: str
output_index: float
summary_index: float
text: str
sequence_number: float
class OpenResponsesReasoningSummaryTextDoneEvent(BaseModel):
r"""Event emitted when reasoning summary text streaming is complete"""
type: OpenResponsesReasoningSummaryTextDoneEventType
item_id: str
output_index: float
summary_index: float
text: str
sequence_number: float
@@ -1,857 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .datacollection import DataCollection
from .openairesponsesincludable import OpenAIResponsesIncludable
from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict
from .openairesponsestoolchoice_union import (
OpenAIResponsesToolChoiceUnion,
OpenAIResponsesToolChoiceUnionTypedDict,
)
from .openresponsesapplypatchtool import (
OpenResponsesApplyPatchTool,
OpenResponsesApplyPatchToolTypedDict,
)
from .openresponsescodeinterpretertool import (
OpenResponsesCodeInterpreterTool,
OpenResponsesCodeInterpreterToolTypedDict,
)
from .openresponsescomputertool import (
OpenResponsesComputerTool,
OpenResponsesComputerToolTypedDict,
)
from .openresponsescustomtool import (
OpenResponsesCustomTool,
OpenResponsesCustomToolTypedDict,
)
from .openresponsesfilesearchtool import (
OpenResponsesFileSearchTool,
OpenResponsesFileSearchToolTypedDict,
)
from .openresponsesfunctionshelltool import (
OpenResponsesFunctionShellTool,
OpenResponsesFunctionShellToolTypedDict,
)
from .openresponsesimagegenerationtool import (
OpenResponsesImageGenerationTool,
OpenResponsesImageGenerationToolTypedDict,
)
from .openresponsesinput_union import (
OpenResponsesInputUnion,
OpenResponsesInputUnionTypedDict,
)
from .openresponseslocalshelltool import (
OpenResponsesLocalShellTool,
OpenResponsesLocalShellToolTypedDict,
)
from .openresponsesmcptool import OpenResponsesMcpTool, OpenResponsesMcpToolTypedDict
from .openresponsesreasoningconfig import (
OpenResponsesReasoningConfig,
OpenResponsesReasoningConfigTypedDict,
)
from .openresponsesresponsetext import (
OpenResponsesResponseText,
OpenResponsesResponseTextTypedDict,
)
from .openresponseswebsearch20250826tool import (
OpenResponsesWebSearch20250826Tool,
OpenResponsesWebSearch20250826ToolTypedDict,
)
from .openresponseswebsearchpreview20250311tool import (
OpenResponsesWebSearchPreview20250311Tool,
OpenResponsesWebSearchPreview20250311ToolTypedDict,
)
from .openresponseswebsearchpreviewtool import (
OpenResponsesWebSearchPreviewTool,
OpenResponsesWebSearchPreviewToolTypedDict,
)
from .openresponseswebsearchtool import (
OpenResponsesWebSearchTool,
OpenResponsesWebSearchToolTypedDict,
)
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
from .preferredminthroughput import (
PreferredMinThroughput,
PreferredMinThroughputTypedDict,
)
from .providername import ProviderName
from .providersort import ProviderSort
from .providersortconfig import ProviderSortConfig, ProviderSortConfigTypedDict
from .quantization import Quantization
from .responsesoutputmodality import ResponsesOutputModality
from .websearchengine import WebSearchEngine
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
import pydantic
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
from pydantic.functional_validators import AfterValidator, PlainValidator
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
OpenResponsesRequestType = Literal["function",]
class OpenResponsesRequestToolFunctionTypedDict(TypedDict):
r"""Function tool definition"""
type: OpenResponsesRequestType
name: str
parameters: Nullable[Dict[str, Nullable[Any]]]
description: NotRequired[Nullable[str]]
strict: NotRequired[Nullable[bool]]
class OpenResponsesRequestToolFunction(BaseModel):
r"""Function tool definition"""
type: OpenResponsesRequestType
name: str
parameters: Nullable[Dict[str, Nullable[Any]]]
description: OptionalNullable[str] = UNSET
strict: OptionalNullable[bool] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["description", "strict"]
nullable_fields = ["description", "strict", "parameters"]
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
OpenResponsesRequestToolUnionTypedDict = TypeAliasType(
"OpenResponsesRequestToolUnionTypedDict",
Union[
OpenResponsesApplyPatchToolTypedDict,
OpenResponsesFunctionShellToolTypedDict,
OpenResponsesLocalShellToolTypedDict,
OpenResponsesCodeInterpreterToolTypedDict,
OpenResponsesWebSearchPreviewToolTypedDict,
OpenResponsesWebSearchPreview20250311ToolTypedDict,
OpenResponsesComputerToolTypedDict,
OpenResponsesWebSearch20250826ToolTypedDict,
OpenResponsesWebSearchToolTypedDict,
OpenResponsesCustomToolTypedDict,
OpenResponsesRequestToolFunctionTypedDict,
OpenResponsesFileSearchToolTypedDict,
OpenResponsesMcpToolTypedDict,
OpenResponsesImageGenerationToolTypedDict,
],
)
OpenResponsesRequestToolUnion = Annotated[
Union[
Annotated[OpenResponsesRequestToolFunction, Tag("function")],
Annotated[OpenResponsesWebSearchPreviewTool, Tag("web_search_preview")],
Annotated[
OpenResponsesWebSearchPreview20250311Tool,
Tag("web_search_preview_2025_03_11"),
],
Annotated[OpenResponsesWebSearchTool, Tag("web_search")],
Annotated[OpenResponsesWebSearch20250826Tool, Tag("web_search_2025_08_26")],
Annotated[OpenResponsesFileSearchTool, Tag("file_search")],
Annotated[OpenResponsesComputerTool, Tag("computer_use_preview")],
Annotated[OpenResponsesCodeInterpreterTool, Tag("code_interpreter")],
Annotated[OpenResponsesMcpTool, Tag("mcp")],
Annotated[OpenResponsesImageGenerationTool, Tag("image_generation")],
Annotated[OpenResponsesLocalShellTool, Tag("local_shell")],
Annotated[OpenResponsesFunctionShellTool, Tag("shell")],
Annotated[OpenResponsesApplyPatchTool, Tag("apply_patch")],
Annotated[OpenResponsesCustomTool, Tag("custom")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
OpenResponsesRequestImageConfigTypedDict = TypeAliasType(
"OpenResponsesRequestImageConfigTypedDict", Union[str, float]
)
OpenResponsesRequestImageConfig = TypeAliasType(
"OpenResponsesRequestImageConfig", Union[str, float]
)
ServiceTier = Literal["auto",]
Truncation = Union[
Literal[
"auto",
"disabled",
],
UnrecognizedStr,
]
OpenResponsesRequestOrderTypedDict = TypeAliasType(
"OpenResponsesRequestOrderTypedDict", Union[ProviderName, str]
)
OpenResponsesRequestOrder = TypeAliasType(
"OpenResponsesRequestOrder",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
OpenResponsesRequestOnlyTypedDict = TypeAliasType(
"OpenResponsesRequestOnlyTypedDict", Union[ProviderName, str]
)
OpenResponsesRequestOnly = TypeAliasType(
"OpenResponsesRequestOnly",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
OpenResponsesRequestIgnoreTypedDict = TypeAliasType(
"OpenResponsesRequestIgnoreTypedDict", Union[ProviderName, str]
)
OpenResponsesRequestIgnore = TypeAliasType(
"OpenResponsesRequestIgnore",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
OpenResponsesRequestSortTypedDict = TypeAliasType(
"OpenResponsesRequestSortTypedDict",
Union[ProviderSortConfigTypedDict, ProviderSort, Any],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
OpenResponsesRequestSort = TypeAliasType(
"OpenResponsesRequestSort",
Union[
ProviderSortConfig,
Annotated[ProviderSort, PlainValidator(validate_open_enum(False))],
Any,
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
class OpenResponsesRequestMaxPriceTypedDict(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[str]
r"""Price per million prompt tokens"""
completion: NotRequired[str]
image: NotRequired[str]
audio: NotRequired[str]
request: NotRequired[str]
class OpenResponsesRequestMaxPrice(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[str] = None
r"""Price per million prompt tokens"""
completion: Optional[str] = None
image: Optional[str] = None
audio: Optional[str] = None
request: Optional[str] = None
class OpenResponsesRequestProviderTypedDict(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[DataCollection]]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
zdr: NotRequired[Nullable[bool]]
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
enforce_distillable_text: NotRequired[Nullable[bool]]
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
order: NotRequired[Nullable[List[OpenResponsesRequestOrderTypedDict]]]
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[OpenResponsesRequestOnlyTypedDict]]]
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[OpenResponsesRequestIgnoreTypedDict]]]
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: NotRequired[Nullable[List[Quantization]]]
r"""A list of quantization levels to filter the provider by."""
sort: NotRequired[Nullable[OpenResponsesRequestSortTypedDict]]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: NotRequired[OpenResponsesRequestMaxPriceTypedDict]
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: NotRequired[Nullable[PreferredMaxLatencyTypedDict]]
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
class OpenResponsesRequestProvider(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: Annotated[
OptionalNullable[DataCollection], PlainValidator(validate_open_enum(False))
] = 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.
"""
zdr: OptionalNullable[bool] = UNSET
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
enforce_distillable_text: OptionalNullable[bool] = UNSET
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
order: OptionalNullable[List[OpenResponsesRequestOrder]] = 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[OpenResponsesRequestOnly]] = 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[OpenResponsesRequestIgnore]] = 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[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
] = UNSET
r"""A list of quantization levels to filter the provider by."""
sort: OptionalNullable[OpenResponsesRequestSort] = 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[OpenResponsesRequestMaxPrice] = None
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = UNSET
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"max_price",
"preferred_min_throughput",
"preferred_max_latency",
]
nullable_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"preferred_min_throughput",
"preferred_max_latency",
]
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
OpenResponsesRequestIDResponseHealing = Literal["response-healing",]
class OpenResponsesRequestPluginResponseHealingTypedDict(TypedDict):
id: OpenResponsesRequestIDResponseHealing
enabled: NotRequired[bool]
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
class OpenResponsesRequestPluginResponseHealing(BaseModel):
id: OpenResponsesRequestIDResponseHealing
enabled: Optional[bool] = None
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
OpenResponsesRequestIDFileParser = Literal["file-parser",]
class OpenResponsesRequestPluginFileParserTypedDict(TypedDict):
id: OpenResponsesRequestIDFileParser
enabled: NotRequired[bool]
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
pdf: NotRequired[PDFParserOptionsTypedDict]
r"""Options for PDF parsing."""
class OpenResponsesRequestPluginFileParser(BaseModel):
id: OpenResponsesRequestIDFileParser
enabled: Optional[bool] = None
r"""Set to false to disable the file-parser plugin for this request. Defaults to true."""
pdf: Optional[PDFParserOptions] = None
r"""Options for PDF parsing."""
OpenResponsesRequestIDWeb = Literal["web",]
class OpenResponsesRequestPluginWebTypedDict(TypedDict):
id: OpenResponsesRequestIDWeb
enabled: NotRequired[bool]
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
max_results: NotRequired[float]
search_prompt: NotRequired[str]
engine: NotRequired[WebSearchEngine]
r"""The search engine to use for web search."""
include_domains: NotRequired[List[str]]
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
exclude_domains: NotRequired[List[str]]
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
class OpenResponsesRequestPluginWeb(BaseModel):
id: OpenResponsesRequestIDWeb
enabled: Optional[bool] = None
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
max_results: Optional[float] = None
search_prompt: Optional[str] = None
engine: Annotated[
Optional[WebSearchEngine], PlainValidator(validate_open_enum(False))
] = None
r"""The search engine to use for web search."""
include_domains: Optional[List[str]] = None
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
exclude_domains: Optional[List[str]] = None
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
OpenResponsesRequestIDModeration = Literal["moderation",]
class OpenResponsesRequestPluginModerationTypedDict(TypedDict):
id: OpenResponsesRequestIDModeration
class OpenResponsesRequestPluginModeration(BaseModel):
id: OpenResponsesRequestIDModeration
OpenResponsesRequestIDAutoRouter = Literal["auto-router",]
class OpenResponsesRequestPluginAutoRouterTypedDict(TypedDict):
id: OpenResponsesRequestIDAutoRouter
enabled: NotRequired[bool]
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
allowed_models: NotRequired[List[str]]
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
class OpenResponsesRequestPluginAutoRouter(BaseModel):
id: OpenResponsesRequestIDAutoRouter
enabled: Optional[bool] = None
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
allowed_models: Optional[List[str]] = None
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
OpenResponsesRequestPluginUnionTypedDict = TypeAliasType(
"OpenResponsesRequestPluginUnionTypedDict",
Union[
OpenResponsesRequestPluginModerationTypedDict,
OpenResponsesRequestPluginResponseHealingTypedDict,
OpenResponsesRequestPluginAutoRouterTypedDict,
OpenResponsesRequestPluginFileParserTypedDict,
OpenResponsesRequestPluginWebTypedDict,
],
)
OpenResponsesRequestPluginUnion = Annotated[
Union[
Annotated[OpenResponsesRequestPluginAutoRouter, Tag("auto-router")],
Annotated[OpenResponsesRequestPluginModeration, Tag("moderation")],
Annotated[OpenResponsesRequestPluginWeb, Tag("web")],
Annotated[OpenResponsesRequestPluginFileParser, Tag("file-parser")],
Annotated[OpenResponsesRequestPluginResponseHealing, Tag("response-healing")],
],
Discriminator(lambda m: get_discriminator(m, "id", "id")),
]
class OpenResponsesRequestTraceTypedDict(TypedDict):
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
trace_id: NotRequired[str]
trace_name: NotRequired[str]
span_name: NotRequired[str]
generation_name: NotRequired[str]
parent_span_id: NotRequired[str]
class OpenResponsesRequestTrace(BaseModel):
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
trace_id: Optional[str] = None
trace_name: Optional[str] = None
span_name: Optional[str] = None
generation_name: Optional[str] = None
parent_span_id: Optional[str] = None
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
class OpenResponsesRequestTypedDict(TypedDict):
r"""Request schema for Responses endpoint"""
input: NotRequired[OpenResponsesInputUnionTypedDict]
r"""Input for a response request - can be a string or array of items"""
instructions: NotRequired[Nullable[str]]
metadata: NotRequired[Nullable[Dict[str, str]]]
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
tools: NotRequired[List[OpenResponsesRequestToolUnionTypedDict]]
tool_choice: NotRequired[OpenAIResponsesToolChoiceUnionTypedDict]
parallel_tool_calls: NotRequired[Nullable[bool]]
model: NotRequired[str]
models: NotRequired[List[str]]
text: NotRequired[OpenResponsesResponseTextTypedDict]
r"""Text output configuration including format and verbosity"""
reasoning: NotRequired[Nullable[OpenResponsesReasoningConfigTypedDict]]
r"""Configuration for reasoning mode in the response"""
max_output_tokens: NotRequired[Nullable[float]]
temperature: NotRequired[Nullable[float]]
top_p: NotRequired[Nullable[float]]
top_logprobs: NotRequired[Nullable[int]]
max_tool_calls: NotRequired[Nullable[int]]
presence_penalty: NotRequired[Nullable[float]]
frequency_penalty: NotRequired[Nullable[float]]
top_k: NotRequired[float]
image_config: NotRequired[Dict[str, OpenResponsesRequestImageConfigTypedDict]]
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/features/multimodal/image-generation for more details."""
modalities: NotRequired[List[ResponsesOutputModality]]
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
prompt_cache_key: NotRequired[Nullable[str]]
previous_response_id: NotRequired[Nullable[str]]
prompt: NotRequired[Nullable[OpenAIResponsesPromptTypedDict]]
include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]]
background: NotRequired[Nullable[bool]]
safety_identifier: NotRequired[Nullable[str]]
store: Literal[False]
service_tier: NotRequired[ServiceTier]
truncation: NotRequired[Nullable[Truncation]]
stream: NotRequired[bool]
provider: NotRequired[Nullable[OpenResponsesRequestProviderTypedDict]]
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: NotRequired[List[OpenResponsesRequestPluginUnionTypedDict]]
r"""Plugins you want to enable for this request, including their settings."""
user: NotRequired[str]
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
session_id: NotRequired[str]
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
trace: NotRequired[OpenResponsesRequestTraceTypedDict]
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
class OpenResponsesRequest(BaseModel):
r"""Request schema for Responses endpoint"""
input: Optional[OpenResponsesInputUnion] = None
r"""Input for a response request - can be a string or array of items"""
instructions: OptionalNullable[str] = UNSET
metadata: OptionalNullable[Dict[str, str]] = UNSET
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
tools: Optional[List[OpenResponsesRequestToolUnion]] = None
tool_choice: Optional[OpenAIResponsesToolChoiceUnion] = None
parallel_tool_calls: OptionalNullable[bool] = UNSET
model: Optional[str] = None
models: Optional[List[str]] = None
text: Optional[OpenResponsesResponseText] = None
r"""Text output configuration including format and verbosity"""
reasoning: OptionalNullable[OpenResponsesReasoningConfig] = UNSET
r"""Configuration for reasoning mode in the response"""
max_output_tokens: OptionalNullable[float] = UNSET
temperature: OptionalNullable[float] = UNSET
top_p: OptionalNullable[float] = UNSET
top_logprobs: OptionalNullable[int] = UNSET
max_tool_calls: OptionalNullable[int] = UNSET
presence_penalty: OptionalNullable[float] = UNSET
frequency_penalty: OptionalNullable[float] = UNSET
top_k: Optional[float] = None
image_config: Optional[Dict[str, OpenResponsesRequestImageConfig]] = None
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/features/multimodal/image-generation for more details."""
modalities: Optional[
List[
Annotated[
ResponsesOutputModality, PlainValidator(validate_open_enum(False))
]
]
] = None
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
prompt_cache_key: OptionalNullable[str] = UNSET
previous_response_id: OptionalNullable[str] = UNSET
prompt: OptionalNullable[OpenAIResponsesPrompt] = UNSET
include: OptionalNullable[
List[
Annotated[
OpenAIResponsesIncludable, PlainValidator(validate_open_enum(False))
]
]
] = UNSET
background: OptionalNullable[bool] = UNSET
safety_identifier: OptionalNullable[str] = UNSET
STORE: Annotated[
Annotated[Optional[Literal[False]], AfterValidator(validate_const(False))],
pydantic.Field(alias="store"),
] = False
service_tier: Optional[ServiceTier] = "auto"
truncation: Annotated[
OptionalNullable[Truncation], PlainValidator(validate_open_enum(False))
] = UNSET
stream: Optional[bool] = False
provider: OptionalNullable[OpenResponsesRequestProvider] = UNSET
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: Optional[List[OpenResponsesRequestPluginUnion]] = None
r"""Plugins you want to enable for this request, including their settings."""
user: Optional[str] = None
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
session_id: Optional[str] = None
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters."""
trace: Optional[OpenResponsesRequestTrace] = None
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"input",
"instructions",
"metadata",
"tools",
"tool_choice",
"parallel_tool_calls",
"model",
"models",
"text",
"reasoning",
"max_output_tokens",
"temperature",
"top_p",
"top_logprobs",
"max_tool_calls",
"presence_penalty",
"frequency_penalty",
"top_k",
"image_config",
"modalities",
"prompt_cache_key",
"previous_response_id",
"prompt",
"include",
"background",
"safety_identifier",
"store",
"service_tier",
"truncation",
"stream",
"provider",
"plugins",
"user",
"session_id",
"trace",
]
nullable_fields = [
"instructions",
"metadata",
"parallel_tool_calls",
"reasoning",
"max_output_tokens",
"temperature",
"top_p",
"top_logprobs",
"max_tool_calls",
"presence_penalty",
"frequency_penalty",
"prompt_cache_key",
"previous_response_id",
"prompt",
"include",
"background",
"safety_identifier",
"truncation",
"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
@@ -1,83 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseformattextconfig import (
ResponseFormatTextConfig,
ResponseFormatTextConfigTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesResponseTextVerbosity = Union[
Literal[
"high",
"low",
"medium",
],
UnrecognizedStr,
]
class OpenResponsesResponseTextTypedDict(TypedDict):
r"""Text output configuration including format and verbosity"""
format_: NotRequired[ResponseFormatTextConfigTypedDict]
r"""Text response format configuration"""
verbosity: NotRequired[Nullable[OpenResponsesResponseTextVerbosity]]
class OpenResponsesResponseText(BaseModel):
r"""Text output configuration including format and verbosity"""
format_: Annotated[
Optional[ResponseFormatTextConfig], pydantic.Field(alias="format")
] = None
r"""Text response format configuration"""
verbosity: Annotated[
OptionalNullable[OpenResponsesResponseTextVerbosity],
PlainValidator(validate_open_enum(False)),
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["format", "verbosity"]
nullable_fields = ["verbosity"]
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
@@ -1,793 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesannotation import (
OpenAIResponsesAnnotation,
OpenAIResponsesAnnotationTypedDict,
)
from .openairesponsesrefusalcontent import (
OpenAIResponsesRefusalContent,
OpenAIResponsesRefusalContentTypedDict,
)
from .openresponseserrorevent import (
OpenResponsesErrorEvent,
OpenResponsesErrorEventTypedDict,
)
from .openresponsesimagegencallcompleted import (
OpenResponsesImageGenCallCompleted,
OpenResponsesImageGenCallCompletedTypedDict,
)
from .openresponsesimagegencallgenerating import (
OpenResponsesImageGenCallGenerating,
OpenResponsesImageGenCallGeneratingTypedDict,
)
from .openresponsesimagegencallinprogress import (
OpenResponsesImageGenCallInProgress,
OpenResponsesImageGenCallInProgressTypedDict,
)
from .openresponsesimagegencallpartialimage import (
OpenResponsesImageGenCallPartialImage,
OpenResponsesImageGenCallPartialImageTypedDict,
)
from .openresponsesnonstreamingresponse import (
OpenResponsesNonStreamingResponse,
OpenResponsesNonStreamingResponseTypedDict,
)
from .openresponsesreasoningdeltaevent import (
OpenResponsesReasoningDeltaEvent,
OpenResponsesReasoningDeltaEventTypedDict,
)
from .openresponsesreasoningdoneevent import (
OpenResponsesReasoningDoneEvent,
OpenResponsesReasoningDoneEventTypedDict,
)
from .openresponsesreasoningsummarypartaddedevent import (
OpenResponsesReasoningSummaryPartAddedEvent,
OpenResponsesReasoningSummaryPartAddedEventTypedDict,
)
from .openresponsesreasoningsummarytextdeltaevent import (
OpenResponsesReasoningSummaryTextDeltaEvent,
OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
)
from .openresponsesreasoningsummarytextdoneevent import (
OpenResponsesReasoningSummaryTextDoneEvent,
OpenResponsesReasoningSummaryTextDoneEventTypedDict,
)
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
from openrouter.types import BaseModel
from openrouter.utils import get_discriminator
import pydantic
from pydantic import Discriminator, Tag
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",]
class OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict(TypedDict):
r"""Event emitted when a reasoning summary part is complete"""
type: TypeResponseReasoningSummaryPartDone
output_index: float
item_id: str
summary_index: float
part: ReasoningSummaryTextTypedDict
sequence_number: float
class OpenResponsesStreamEventResponseReasoningSummaryPartDone(BaseModel):
r"""Event emitted when a reasoning summary part is complete"""
type: TypeResponseReasoningSummaryPartDone
output_index: float
item_id: str
summary_index: float
part: ReasoningSummaryText
sequence_number: float
TypeResponseFunctionCallArgumentsDone = Literal[
"response.function_call_arguments.done",
]
class OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict(TypedDict):
r"""Event emitted when function call arguments streaming is complete"""
type: TypeResponseFunctionCallArgumentsDone
item_id: str
output_index: float
name: str
arguments: str
sequence_number: float
class OpenResponsesStreamEventResponseFunctionCallArgumentsDone(BaseModel):
r"""Event emitted when function call arguments streaming is complete"""
type: TypeResponseFunctionCallArgumentsDone
item_id: str
output_index: float
name: str
arguments: str
sequence_number: float
TypeResponseFunctionCallArgumentsDelta = Literal[
"response.function_call_arguments.delta",
]
class OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict(TypedDict):
r"""Event emitted when function call arguments are being streamed"""
type: TypeResponseFunctionCallArgumentsDelta
item_id: str
output_index: float
delta: str
sequence_number: float
class OpenResponsesStreamEventResponseFunctionCallArgumentsDelta(BaseModel):
r"""Event emitted when function call arguments are being streamed"""
type: TypeResponseFunctionCallArgumentsDelta
item_id: str
output_index: float
delta: str
sequence_number: float
TypeResponseOutputTextAnnotationAdded = Literal[
"response.output_text.annotation.added",
]
class OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict(TypedDict):
r"""Event emitted when a text annotation is added to output"""
type: TypeResponseOutputTextAnnotationAdded
output_index: float
item_id: str
content_index: float
sequence_number: float
annotation_index: float
annotation: OpenAIResponsesAnnotationTypedDict
class OpenResponsesStreamEventResponseOutputTextAnnotationAdded(BaseModel):
r"""Event emitted when a text annotation is added to output"""
type: TypeResponseOutputTextAnnotationAdded
output_index: float
item_id: str
content_index: float
sequence_number: float
annotation_index: float
annotation: OpenAIResponsesAnnotation
TypeResponseRefusalDone = Literal["response.refusal.done",]
class OpenResponsesStreamEventResponseRefusalDoneTypedDict(TypedDict):
r"""Event emitted when refusal streaming is complete"""
type: TypeResponseRefusalDone
output_index: float
item_id: str
content_index: float
refusal: str
sequence_number: float
class OpenResponsesStreamEventResponseRefusalDone(BaseModel):
r"""Event emitted when refusal streaming is complete"""
type: TypeResponseRefusalDone
output_index: float
item_id: str
content_index: float
refusal: str
sequence_number: float
TypeResponseRefusalDelta = Literal["response.refusal.delta",]
class OpenResponsesStreamEventResponseRefusalDeltaTypedDict(TypedDict):
r"""Event emitted when a refusal delta is streamed"""
type: TypeResponseRefusalDelta
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
class OpenResponsesStreamEventResponseRefusalDelta(BaseModel):
r"""Event emitted when a refusal delta is streamed"""
type: TypeResponseRefusalDelta
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
TypeResponseOutputTextDone = Literal["response.output_text.done",]
class OpenResponsesStreamEventTopLogprob2TypedDict(TypedDict):
r"""Alternative token with its log probability"""
token: NotRequired[str]
logprob: NotRequired[float]
bytes_: NotRequired[List[float]]
class OpenResponsesStreamEventTopLogprob2(BaseModel):
r"""Alternative token with its log probability"""
token: Optional[str] = None
logprob: Optional[float] = None
bytes_: Annotated[Optional[List[float]], pydantic.Field(alias="bytes")] = None
class OpenResponsesStreamEventLogprob2TypedDict(TypedDict):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: NotRequired[List[OpenResponsesStreamEventTopLogprob2TypedDict]]
bytes_: NotRequired[List[float]]
class OpenResponsesStreamEventLogprob2(BaseModel):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: Optional[List[OpenResponsesStreamEventTopLogprob2]] = None
bytes_: Annotated[Optional[List[float]], pydantic.Field(alias="bytes")] = None
class OpenResponsesStreamEventResponseOutputTextDoneTypedDict(TypedDict):
r"""Event emitted when text streaming is complete"""
type: TypeResponseOutputTextDone
output_index: float
item_id: str
content_index: float
text: str
sequence_number: float
logprobs: List[OpenResponsesStreamEventLogprob2TypedDict]
class OpenResponsesStreamEventResponseOutputTextDone(BaseModel):
r"""Event emitted when text streaming is complete"""
type: TypeResponseOutputTextDone
output_index: float
item_id: str
content_index: float
text: str
sequence_number: float
logprobs: List[OpenResponsesStreamEventLogprob2]
TypeResponseOutputTextDelta = Literal["response.output_text.delta",]
class OpenResponsesStreamEventTopLogprob1TypedDict(TypedDict):
r"""Alternative token with its log probability"""
token: NotRequired[str]
logprob: NotRequired[float]
bytes_: NotRequired[List[float]]
class OpenResponsesStreamEventTopLogprob1(BaseModel):
r"""Alternative token with its log probability"""
token: Optional[str] = None
logprob: Optional[float] = None
bytes_: Annotated[Optional[List[float]], pydantic.Field(alias="bytes")] = None
class OpenResponsesStreamEventLogprob1TypedDict(TypedDict):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: NotRequired[List[OpenResponsesStreamEventTopLogprob1TypedDict]]
bytes_: NotRequired[List[float]]
class OpenResponsesStreamEventLogprob1(BaseModel):
r"""Log probability information for a token"""
logprob: float
token: str
top_logprobs: Optional[List[OpenResponsesStreamEventTopLogprob1]] = None
bytes_: Annotated[Optional[List[float]], pydantic.Field(alias="bytes")] = None
class OpenResponsesStreamEventResponseOutputTextDeltaTypedDict(TypedDict):
r"""Event emitted when a text delta is streamed"""
type: TypeResponseOutputTextDelta
logprobs: List[OpenResponsesStreamEventLogprob1TypedDict]
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
class OpenResponsesStreamEventResponseOutputTextDelta(BaseModel):
r"""Event emitted when a text delta is streamed"""
type: TypeResponseOutputTextDelta
logprobs: List[OpenResponsesStreamEventLogprob1]
output_index: float
item_id: str
content_index: float
delta: str
sequence_number: float
TypeResponseContentPartDone = Literal["response.content_part.done",]
Part2TypedDict = TypeAliasType(
"Part2TypedDict",
Union[
ReasoningTextContentTypedDict,
OpenAIResponsesRefusalContentTypedDict,
ResponseOutputTextTypedDict,
],
)
Part2 = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict):
r"""Event emitted when a content part is complete"""
type: TypeResponseContentPartDone
output_index: float
item_id: str
content_index: float
part: Part2TypedDict
sequence_number: float
class OpenResponsesStreamEventResponseContentPartDone(BaseModel):
r"""Event emitted when a content part is complete"""
type: TypeResponseContentPartDone
output_index: float
item_id: str
content_index: float
part: Part2
sequence_number: float
TypeResponseContentPartAdded = Literal["response.content_part.added",]
Part1TypedDict = TypeAliasType(
"Part1TypedDict",
Union[
ReasoningTextContentTypedDict,
OpenAIResponsesRefusalContentTypedDict,
ResponseOutputTextTypedDict,
],
)
Part1 = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[ReasoningTextContent, Tag("reasoning_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict):
r"""Event emitted when a new content part is added to an output item"""
type: TypeResponseContentPartAdded
output_index: float
item_id: str
content_index: float
part: Part1TypedDict
sequence_number: float
class OpenResponsesStreamEventResponseContentPartAdded(BaseModel):
r"""Event emitted when a new content part is added to an output item"""
type: TypeResponseContentPartAdded
output_index: float
item_id: str
content_index: float
part: Part1
sequence_number: float
TypeResponseOutputItemDone = Literal["response.output_item.done",]
class OpenResponsesStreamEventResponseOutputItemDoneTypedDict(TypedDict):
r"""Event emitted when an output item is complete"""
type: TypeResponseOutputItemDone
output_index: float
item: ResponsesOutputItemTypedDict
r"""An output item from the response"""
sequence_number: float
class OpenResponsesStreamEventResponseOutputItemDone(BaseModel):
r"""Event emitted when an output item is complete"""
type: TypeResponseOutputItemDone
output_index: float
item: ResponsesOutputItem
r"""An output item from the response"""
sequence_number: float
TypeResponseOutputItemAdded = Literal["response.output_item.added",]
class OpenResponsesStreamEventResponseOutputItemAddedTypedDict(TypedDict):
r"""Event emitted when a new output item is added to the response"""
type: TypeResponseOutputItemAdded
output_index: float
item: ResponsesOutputItemTypedDict
r"""An output item from the response"""
sequence_number: float
class OpenResponsesStreamEventResponseOutputItemAdded(BaseModel):
r"""Event emitted when a new output item is added to the response"""
type: TypeResponseOutputItemAdded
output_index: float
item: ResponsesOutputItem
r"""An output item from the response"""
sequence_number: float
TypeResponseFailed = Literal["response.failed",]
class OpenResponsesStreamEventResponseFailedTypedDict(TypedDict):
r"""Event emitted when a response has failed"""
type: TypeResponseFailed
response: OpenResponsesNonStreamingResponseTypedDict
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
class OpenResponsesStreamEventResponseFailed(BaseModel):
r"""Event emitted when a response has failed"""
type: TypeResponseFailed
response: OpenResponsesNonStreamingResponse
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
TypeResponseIncomplete = Literal["response.incomplete",]
class OpenResponsesStreamEventResponseIncompleteTypedDict(TypedDict):
r"""Event emitted when a response is incomplete"""
type: TypeResponseIncomplete
response: OpenResponsesNonStreamingResponseTypedDict
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
class OpenResponsesStreamEventResponseIncomplete(BaseModel):
r"""Event emitted when a response is incomplete"""
type: TypeResponseIncomplete
response: OpenResponsesNonStreamingResponse
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
TypeResponseCompleted = Literal["response.completed",]
class OpenResponsesStreamEventResponseCompletedTypedDict(TypedDict):
r"""Event emitted when a response has completed successfully"""
type: TypeResponseCompleted
response: OpenResponsesNonStreamingResponseTypedDict
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
class OpenResponsesStreamEventResponseCompleted(BaseModel):
r"""Event emitted when a response has completed successfully"""
type: TypeResponseCompleted
response: OpenResponsesNonStreamingResponse
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
TypeResponseInProgress = Literal["response.in_progress",]
class OpenResponsesStreamEventResponseInProgressTypedDict(TypedDict):
r"""Event emitted when a response is in progress"""
type: TypeResponseInProgress
response: OpenResponsesNonStreamingResponseTypedDict
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
class OpenResponsesStreamEventResponseInProgress(BaseModel):
r"""Event emitted when a response is in progress"""
type: TypeResponseInProgress
response: OpenResponsesNonStreamingResponse
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
TypeResponseCreated = Literal["response.created",]
class OpenResponsesStreamEventResponseCreatedTypedDict(TypedDict):
r"""Event emitted when a response is created"""
type: TypeResponseCreated
response: OpenResponsesNonStreamingResponseTypedDict
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
class OpenResponsesStreamEventResponseCreated(BaseModel):
r"""Event emitted when a response is created"""
type: TypeResponseCreated
response: OpenResponsesNonStreamingResponse
r"""Complete non-streaming response from the Responses API"""
sequence_number: float
OpenResponsesStreamEventTypedDict = TypeAliasType(
"OpenResponsesStreamEventTypedDict",
Union[
OpenResponsesStreamEventResponseCreatedTypedDict,
OpenResponsesStreamEventResponseInProgressTypedDict,
OpenResponsesStreamEventResponseCompletedTypedDict,
OpenResponsesStreamEventResponseIncompleteTypedDict,
OpenResponsesStreamEventResponseFailedTypedDict,
OpenResponsesStreamEventResponseOutputItemAddedTypedDict,
OpenResponsesStreamEventResponseOutputItemDoneTypedDict,
OpenResponsesImageGenCallCompletedTypedDict,
OpenResponsesImageGenCallGeneratingTypedDict,
OpenResponsesImageGenCallInProgressTypedDict,
OpenResponsesErrorEventTypedDict,
OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict,
OpenResponsesStreamEventResponseRefusalDeltaTypedDict,
OpenResponsesReasoningSummaryPartAddedEventTypedDict,
OpenResponsesStreamEventResponseContentPartAddedTypedDict,
OpenResponsesImageGenCallPartialImageTypedDict,
OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict,
OpenResponsesReasoningDeltaEventTypedDict,
OpenResponsesReasoningDoneEventTypedDict,
OpenResponsesStreamEventResponseRefusalDoneTypedDict,
OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict,
OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
OpenResponsesReasoningSummaryTextDoneEventTypedDict,
OpenResponsesStreamEventResponseContentPartDoneTypedDict,
OpenResponsesStreamEventResponseOutputTextDeltaTypedDict,
OpenResponsesStreamEventResponseOutputTextDoneTypedDict,
OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict,
],
)
r"""Union of all possible event types emitted during response streaming"""
OpenResponsesStreamEvent = Annotated[
Union[
Annotated[OpenResponsesStreamEventResponseCreated, Tag("response.created")],
Annotated[
OpenResponsesStreamEventResponseInProgress, Tag("response.in_progress")
],
Annotated[OpenResponsesStreamEventResponseCompleted, Tag("response.completed")],
Annotated[
OpenResponsesStreamEventResponseIncomplete, Tag("response.incomplete")
],
Annotated[OpenResponsesStreamEventResponseFailed, Tag("response.failed")],
Annotated[OpenResponsesErrorEvent, Tag("error")],
Annotated[
OpenResponsesStreamEventResponseOutputItemAdded,
Tag("response.output_item.added"),
],
Annotated[
OpenResponsesStreamEventResponseOutputItemDone,
Tag("response.output_item.done"),
],
Annotated[
OpenResponsesStreamEventResponseContentPartAdded,
Tag("response.content_part.added"),
],
Annotated[
OpenResponsesStreamEventResponseContentPartDone,
Tag("response.content_part.done"),
],
Annotated[
OpenResponsesStreamEventResponseOutputTextDelta,
Tag("response.output_text.delta"),
],
Annotated[
OpenResponsesStreamEventResponseOutputTextDone,
Tag("response.output_text.done"),
],
Annotated[
OpenResponsesStreamEventResponseRefusalDelta, Tag("response.refusal.delta")
],
Annotated[
OpenResponsesStreamEventResponseRefusalDone, Tag("response.refusal.done")
],
Annotated[
OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
Tag("response.output_text.annotation.added"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
Tag("response.function_call_arguments.delta"),
],
Annotated[
OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
Tag("response.function_call_arguments.done"),
],
Annotated[
OpenResponsesReasoningDeltaEvent, Tag("response.reasoning_text.delta")
],
Annotated[OpenResponsesReasoningDoneEvent, Tag("response.reasoning_text.done")],
Annotated[
OpenResponsesReasoningSummaryPartAddedEvent,
Tag("response.reasoning_summary_part.added"),
],
Annotated[
OpenResponsesStreamEventResponseReasoningSummaryPartDone,
Tag("response.reasoning_summary_part.done"),
],
Annotated[
OpenResponsesReasoningSummaryTextDeltaEvent,
Tag("response.reasoning_summary_text.delta"),
],
Annotated[
OpenResponsesReasoningSummaryTextDoneEvent,
Tag("response.reasoning_summary_text.done"),
],
Annotated[
OpenResponsesImageGenCallInProgress,
Tag("response.image_generation_call.in_progress"),
],
Annotated[
OpenResponsesImageGenCallGenerating,
Tag("response.image_generation_call.generating"),
],
Annotated[
OpenResponsesImageGenCallPartialImage,
Tag("response.image_generation_call.partial_image"),
],
Annotated[
OpenResponsesImageGenCallCompleted,
Tag("response.image_generation_call.completed"),
],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Union of all possible event types emitted during response streaming"""
@@ -1,21 +0,0 @@
"""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 OpenResponsesTopLogprobsTypedDict(TypedDict):
r"""Alternative token with its log probability"""
token: NotRequired[str]
logprob: NotRequired[float]
class OpenResponsesTopLogprobs(BaseModel):
r"""Alternative token with its log probability"""
token: Optional[str] = None
logprob: Optional[float] = None
@@ -1,140 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
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 InputTokensDetailsTypedDict(TypedDict):
cached_tokens: float
class InputTokensDetails(BaseModel):
cached_tokens: float
class OutputTokensDetailsTypedDict(TypedDict):
reasoning_tokens: float
class OutputTokensDetails(BaseModel):
reasoning_tokens: float
class CostDetailsTypedDict(TypedDict):
upstream_inference_input_cost: float
upstream_inference_output_cost: float
upstream_inference_cost: NotRequired[Nullable[float]]
class CostDetails(BaseModel):
upstream_inference_input_cost: float
upstream_inference_output_cost: float
upstream_inference_cost: OptionalNullable[float] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["upstream_inference_cost"]
nullable_fields = ["upstream_inference_cost"]
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 OpenResponsesUsageTypedDict(TypedDict):
r"""Token usage information for the response"""
input_tokens: float
input_tokens_details: InputTokensDetailsTypedDict
output_tokens: float
output_tokens_details: OutputTokensDetailsTypedDict
total_tokens: float
cost: NotRequired[Nullable[float]]
r"""Cost of the completion"""
is_byok: NotRequired[bool]
r"""Whether a request was made using a Bring Your Own Key configuration"""
cost_details: NotRequired[CostDetailsTypedDict]
class OpenResponsesUsage(BaseModel):
r"""Token usage information for the response"""
input_tokens: float
input_tokens_details: InputTokensDetails
output_tokens: float
output_tokens_details: OutputTokensDetails
total_tokens: float
cost: OptionalNullable[float] = UNSET
r"""Cost of the completion"""
is_byok: Optional[bool] = None
r"""Whether a request was made using a Bring Your Own Key configuration"""
cost_details: Optional[CostDetails] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["cost", "is_byok", "cost_details"]
nullable_fields = ["cost"]
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
@@ -1,118 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responsessearchcontextsize import ResponsesSearchContextSize
from .responseswebsearchuserlocation import (
ResponsesWebSearchUserLocation,
ResponsesWebSearchUserLocationTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesWebSearch20250826ToolType = Literal["web_search_2025_08_26",]
class OpenResponsesWebSearch20250826ToolFiltersTypedDict(TypedDict):
allowed_domains: NotRequired[Nullable[List[str]]]
class OpenResponsesWebSearch20250826ToolFilters(BaseModel):
allowed_domains: OptionalNullable[List[str]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["allowed_domains"]
nullable_fields = ["allowed_domains"]
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 OpenResponsesWebSearch20250826ToolTypedDict(TypedDict):
r"""Web search tool configuration (2025-08-26 version)"""
type: OpenResponsesWebSearch20250826ToolType
filters: NotRequired[Nullable[OpenResponsesWebSearch20250826ToolFiltersTypedDict]]
search_context_size: NotRequired[ResponsesSearchContextSize]
r"""Size of the search context for web search tools"""
user_location: NotRequired[Nullable[ResponsesWebSearchUserLocationTypedDict]]
r"""User location information for web search"""
class OpenResponsesWebSearch20250826Tool(BaseModel):
r"""Web search tool configuration (2025-08-26 version)"""
type: OpenResponsesWebSearch20250826ToolType
filters: OptionalNullable[OpenResponsesWebSearch20250826ToolFilters] = UNSET
search_context_size: Annotated[
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
] = None
r"""Size of the search context for web search tools"""
user_location: OptionalNullable[ResponsesWebSearchUserLocation] = UNSET
r"""User location information for web search"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["filters", "search_context_size", "user_location"]
nullable_fields = ["filters", "user_location"]
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
@@ -1,77 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responsessearchcontextsize import ResponsesSearchContextSize
from .websearchpreviewtooluserlocation import (
WebSearchPreviewToolUserLocation,
WebSearchPreviewToolUserLocationTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesWebSearchPreview20250311ToolType = Literal[
"web_search_preview_2025_03_11",
]
class OpenResponsesWebSearchPreview20250311ToolTypedDict(TypedDict):
r"""Web search preview tool configuration (2025-03-11 version)"""
type: OpenResponsesWebSearchPreview20250311ToolType
search_context_size: NotRequired[ResponsesSearchContextSize]
r"""Size of the search context for web search tools"""
user_location: NotRequired[Nullable[WebSearchPreviewToolUserLocationTypedDict]]
class OpenResponsesWebSearchPreview20250311Tool(BaseModel):
r"""Web search preview tool configuration (2025-03-11 version)"""
type: OpenResponsesWebSearchPreview20250311ToolType
search_context_size: Annotated[
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
] = None
r"""Size of the search context for web search tools"""
user_location: OptionalNullable[WebSearchPreviewToolUserLocation] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["search_context_size", "user_location"]
nullable_fields = ["user_location"]
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
@@ -1,75 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responsessearchcontextsize import ResponsesSearchContextSize
from .websearchpreviewtooluserlocation import (
WebSearchPreviewToolUserLocation,
WebSearchPreviewToolUserLocationTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesWebSearchPreviewToolType = Literal["web_search_preview",]
class OpenResponsesWebSearchPreviewToolTypedDict(TypedDict):
r"""Web search preview tool configuration"""
type: OpenResponsesWebSearchPreviewToolType
search_context_size: NotRequired[ResponsesSearchContextSize]
r"""Size of the search context for web search tools"""
user_location: NotRequired[Nullable[WebSearchPreviewToolUserLocationTypedDict]]
class OpenResponsesWebSearchPreviewTool(BaseModel):
r"""Web search preview tool configuration"""
type: OpenResponsesWebSearchPreviewToolType
search_context_size: Annotated[
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
] = None
r"""Size of the search context for web search tools"""
user_location: OptionalNullable[WebSearchPreviewToolUserLocation] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["search_context_size", "user_location"]
nullable_fields = ["user_location"]
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
@@ -1,118 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responsessearchcontextsize import ResponsesSearchContextSize
from .responseswebsearchuserlocation import (
ResponsesWebSearchUserLocation,
ResponsesWebSearchUserLocationTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
OpenResponsesWebSearchToolType = Literal["web_search",]
class OpenResponsesWebSearchToolFiltersTypedDict(TypedDict):
allowed_domains: NotRequired[Nullable[List[str]]]
class OpenResponsesWebSearchToolFilters(BaseModel):
allowed_domains: OptionalNullable[List[str]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["allowed_domains"]
nullable_fields = ["allowed_domains"]
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 OpenResponsesWebSearchToolTypedDict(TypedDict):
r"""Web search tool configuration"""
type: OpenResponsesWebSearchToolType
filters: NotRequired[Nullable[OpenResponsesWebSearchToolFiltersTypedDict]]
search_context_size: NotRequired[ResponsesSearchContextSize]
r"""Size of the search context for web search tools"""
user_location: NotRequired[Nullable[ResponsesWebSearchUserLocationTypedDict]]
r"""User location information for web search"""
class OpenResponsesWebSearchTool(BaseModel):
r"""Web search tool configuration"""
type: OpenResponsesWebSearchToolType
filters: OptionalNullable[OpenResponsesWebSearchToolFilters] = UNSET
search_context_size: Annotated[
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
] = None
r"""Size of the search context for web search tools"""
user_location: OptionalNullable[ResponsesWebSearchUserLocation] = UNSET
r"""User location information for web search"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["filters", "search_context_size", "user_location"]
nullable_fields = ["filters", "user_location"]
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
@@ -1,15 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ReasoningSummaryVerbosity = Union[
Literal[
"auto",
"concise",
"detailed",
],
UnrecognizedStr,
]
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseFormatJSONObjectType = Literal["json_object",]
class ResponseFormatJSONObjectTypedDict(TypedDict):
r"""JSON object response format"""
type: ResponseFormatJSONObjectType
class ResponseFormatJSONObject(BaseModel):
r"""JSON object response format"""
type: ResponseFormatJSONObjectType
@@ -1,27 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .jsonschemaconfig import JSONSchemaConfig, JSONSchemaConfigTypedDict
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseFormatJSONSchemaType = Literal["json_schema",]
class ResponseFormatJSONSchemaTypedDict(TypedDict):
r"""JSON Schema response format for structured outputs"""
type: ResponseFormatJSONSchemaType
json_schema: JSONSchemaConfigTypedDict
r"""JSON Schema configuration object"""
class ResponseFormatJSONSchema(BaseModel):
r"""JSON Schema response format for structured outputs"""
type: ResponseFormatJSONSchemaType
json_schema: JSONSchemaConfig
r"""JSON Schema configuration object"""
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseFormatTextType = Literal["text",]
class ResponseFormatTextTypedDict(TypedDict):
r"""Default text response format"""
type: ResponseFormatTextType
class ResponseFormatText(BaseModel):
r"""Default text response format"""
type: ResponseFormatTextType
@@ -1,38 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseformatjsonobject import (
ResponseFormatJSONObject,
ResponseFormatJSONObjectTypedDict,
)
from .responsesformattext import ResponsesFormatText, ResponsesFormatTextTypedDict
from .responsesformattextjsonschemaconfig import (
ResponsesFormatTextJSONSchemaConfig,
ResponsesFormatTextJSONSchemaConfigTypedDict,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypeAliasType
ResponseFormatTextConfigTypedDict = TypeAliasType(
"ResponseFormatTextConfigTypedDict",
Union[
ResponsesFormatTextTypedDict,
ResponseFormatJSONObjectTypedDict,
ResponsesFormatTextJSONSchemaConfigTypedDict,
],
)
r"""Text response format configuration"""
ResponseFormatTextConfig = Annotated[
Union[
Annotated[ResponsesFormatText, Tag("text")],
Annotated[ResponseFormatJSONObject, Tag("json_object")],
Annotated[ResponsesFormatTextJSONSchemaConfig, Tag("json_schema")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Text response format configuration"""
@@ -1,26 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseFormatTextGrammarType = Literal["grammar",]
class ResponseFormatTextGrammarTypedDict(TypedDict):
r"""Custom grammar response format"""
type: ResponseFormatTextGrammarType
grammar: str
r"""Custom grammar for text generation"""
class ResponseFormatTextGrammar(BaseModel):
r"""Custom grammar response format"""
type: ResponseFormatTextGrammarType
grammar: str
r"""Custom grammar for text generation"""
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseFormatTextPythonType = Literal["python",]
class ResponseFormatTextPythonTypedDict(TypedDict):
r"""Python code response format"""
type: ResponseFormatTextPythonType
class ResponseFormatTextPython(BaseModel):
r"""Python code response format"""
type: ResponseFormatTextPythonType
@@ -1,50 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
import pydantic
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
ResponseInputAudioType = Literal["input_audio",]
ResponseInputAudioFormat = Union[
Literal[
"mp3",
"wav",
],
UnrecognizedStr,
]
class ResponseInputAudioInputAudioTypedDict(TypedDict):
data: str
format_: ResponseInputAudioFormat
class ResponseInputAudioInputAudio(BaseModel):
data: str
format_: Annotated[
Annotated[ResponseInputAudioFormat, PlainValidator(validate_open_enum(False))],
pydantic.Field(alias="format"),
]
class ResponseInputAudioTypedDict(TypedDict):
r"""Audio input content item"""
type: ResponseInputAudioType
input_audio: ResponseInputAudioInputAudioTypedDict
class ResponseInputAudio(BaseModel):
r"""Audio input content item"""
type: ResponseInputAudioType
input_audio: ResponseInputAudioInputAudio
@@ -1,79 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ResponseInputImageType = Literal["input_image",]
ResponseInputImageDetail = Union[
Literal[
"auto",
"high",
"low",
],
UnrecognizedStr,
]
class ResponseInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: ResponseInputImageType
detail: ResponseInputImageDetail
image_url: NotRequired[Nullable[str]]
class ResponseInputImage(BaseModel):
r"""Image input content item"""
type: ResponseInputImageType
detail: Annotated[
ResponseInputImageDetail, PlainValidator(validate_open_enum(False))
]
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["image_url"]
nullable_fields = ["image_url"]
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
@@ -1,24 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseInputTextType = Literal["input_text",]
class ResponseInputTextTypedDict(TypedDict):
r"""Text input content item"""
type: ResponseInputTextType
text: str
class ResponseInputText(BaseModel):
r"""Text input content item"""
type: ResponseInputTextType
text: str
@@ -1,26 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponseInputVideoType = Literal["input_video",]
class ResponseInputVideoTypedDict(TypedDict):
r"""Video input content item"""
type: ResponseInputVideoType
video_url: str
r"""A base64 data URL or remote URL that resolves to a video file"""
class ResponseInputVideo(BaseModel):
r"""Video input content item"""
type: ResponseInputVideoType
video_url: str
r"""A base64 data URL or remote URL that resolves to a video file"""
@@ -1,21 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal
from typing_extensions import TypedDict
ResponsesFormatTextType = Literal["text",]
class ResponsesFormatTextTypedDict(TypedDict):
r"""Plain text response format"""
type: ResponsesFormatTextType
class ResponsesFormatText(BaseModel):
r"""Plain text response format"""
type: ResponsesFormatTextType
@@ -1,71 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
ResponsesFormatTextJSONSchemaConfigType = Literal["json_schema",]
class ResponsesFormatTextJSONSchemaConfigTypedDict(TypedDict):
r"""JSON schema constrained response format"""
type: ResponsesFormatTextJSONSchemaConfigType
name: str
schema_: Dict[str, Nullable[Any]]
description: NotRequired[str]
strict: NotRequired[Nullable[bool]]
class ResponsesFormatTextJSONSchemaConfig(BaseModel):
r"""JSON schema constrained response format"""
type: ResponsesFormatTextJSONSchemaConfigType
name: str
schema_: Annotated[Dict[str, Nullable[Any]], pydantic.Field(alias="schema")]
description: Optional[str] = None
strict: OptionalNullable[bool] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["description", "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
@@ -1,60 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .imagegenerationstatus import ImageGenerationStatus
from openrouter.types import BaseModel, Nullable, OptionalNullable, UNSET_SENTINEL
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal
from typing_extensions import Annotated, NotRequired, TypedDict
ResponsesImageGenerationCallType = Literal["image_generation_call",]
class ResponsesImageGenerationCallTypedDict(TypedDict):
type: ResponsesImageGenerationCallType
id: str
status: ImageGenerationStatus
result: NotRequired[Nullable[str]]
class ResponsesImageGenerationCall(BaseModel):
type: ResponsesImageGenerationCallType
id: str
status: Annotated[ImageGenerationStatus, PlainValidator(validate_open_enum(False))]
result: OptionalNullable[str] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["result"]
nullable_fields = ["result"]
null_default_fields = ["result"]
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
@@ -1,59 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responsesimagegenerationcall import (
ResponsesImageGenerationCall,
ResponsesImageGenerationCallTypedDict,
)
from .responsesoutputitemfilesearchcall import (
ResponsesOutputItemFileSearchCall,
ResponsesOutputItemFileSearchCallTypedDict,
)
from .responsesoutputitemfunctioncall import (
ResponsesOutputItemFunctionCall,
ResponsesOutputItemFunctionCallTypedDict,
)
from .responsesoutputitemreasoning import (
ResponsesOutputItemReasoning,
ResponsesOutputItemReasoningTypedDict,
)
from .responsesoutputmessage import (
ResponsesOutputMessage,
ResponsesOutputMessageTypedDict,
)
from .responseswebsearchcalloutput import (
ResponsesWebSearchCallOutput,
ResponsesWebSearchCallOutputTypedDict,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated, TypeAliasType
ResponsesOutputItemTypedDict = TypeAliasType(
"ResponsesOutputItemTypedDict",
Union[
ResponsesWebSearchCallOutputTypedDict,
ResponsesOutputItemFileSearchCallTypedDict,
ResponsesImageGenerationCallTypedDict,
ResponsesOutputMessageTypedDict,
ResponsesOutputItemFunctionCallTypedDict,
ResponsesOutputItemReasoningTypedDict,
],
)
r"""An output item from the response"""
ResponsesOutputItem = Annotated[
Union[
Annotated[ResponsesOutputMessage, Tag("message")],
Annotated[ResponsesOutputItemReasoning, Tag("reasoning")],
Annotated[ResponsesOutputItemFunctionCall, Tag("function_call")],
Annotated[ResponsesWebSearchCallOutput, Tag("web_search_call")],
Annotated[ResponsesOutputItemFileSearchCall, Tag("file_search_call")],
Annotated[ResponsesImageGenerationCall, Tag("image_generation_call")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""An output item from the response"""
@@ -1,29 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .websearchstatus import WebSearchStatus
from openrouter.types import BaseModel
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import List, Literal
from typing_extensions import Annotated, TypedDict
ResponsesOutputItemFileSearchCallType = Literal["file_search_call",]
class ResponsesOutputItemFileSearchCallTypedDict(TypedDict):
type: ResponsesOutputItemFileSearchCallType
id: str
queries: List[str]
status: WebSearchStatus
class ResponsesOutputItemFileSearchCall(BaseModel):
type: ResponsesOutputItemFileSearchCallType
id: str
queries: List[str]
status: Annotated[WebSearchStatus, PlainValidator(validate_open_enum(False))]
@@ -1,61 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
ResponsesOutputItemFunctionCallType = Literal["function_call",]
ResponsesOutputItemFunctionCallStatusInProgress = Literal["in_progress",]
ResponsesOutputItemFunctionCallStatusIncomplete = Literal["incomplete",]
ResponsesOutputItemFunctionCallStatusCompleted = Literal["completed",]
ResponsesOutputItemFunctionCallStatusUnionTypedDict = TypeAliasType(
"ResponsesOutputItemFunctionCallStatusUnionTypedDict",
Union[
ResponsesOutputItemFunctionCallStatusCompleted,
ResponsesOutputItemFunctionCallStatusIncomplete,
ResponsesOutputItemFunctionCallStatusInProgress,
],
)
ResponsesOutputItemFunctionCallStatusUnion = TypeAliasType(
"ResponsesOutputItemFunctionCallStatusUnion",
Union[
ResponsesOutputItemFunctionCallStatusCompleted,
ResponsesOutputItemFunctionCallStatusIncomplete,
ResponsesOutputItemFunctionCallStatusInProgress,
],
)
class ResponsesOutputItemFunctionCallTypedDict(TypedDict):
type: ResponsesOutputItemFunctionCallType
name: str
arguments: str
call_id: str
id: NotRequired[str]
status: NotRequired[ResponsesOutputItemFunctionCallStatusUnionTypedDict]
class ResponsesOutputItemFunctionCall(BaseModel):
type: ResponsesOutputItemFunctionCallType
name: str
arguments: str
call_id: str
id: Optional[str] = None
status: Optional[ResponsesOutputItemFunctionCallStatusUnion] = None
@@ -1,144 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ResponsesOutputItemReasoningType = Literal["reasoning",]
ResponsesOutputItemReasoningStatusInProgress = Literal["in_progress",]
ResponsesOutputItemReasoningStatusIncomplete = Literal["incomplete",]
ResponsesOutputItemReasoningStatusCompleted = Literal["completed",]
ResponsesOutputItemReasoningStatusUnionTypedDict = TypeAliasType(
"ResponsesOutputItemReasoningStatusUnionTypedDict",
Union[
ResponsesOutputItemReasoningStatusCompleted,
ResponsesOutputItemReasoningStatusIncomplete,
ResponsesOutputItemReasoningStatusInProgress,
],
)
ResponsesOutputItemReasoningStatusUnion = TypeAliasType(
"ResponsesOutputItemReasoningStatusUnion",
Union[
ResponsesOutputItemReasoningStatusCompleted,
ResponsesOutputItemReasoningStatusIncomplete,
ResponsesOutputItemReasoningStatusInProgress,
],
)
ResponsesOutputItemReasoningFormat = Union[
Literal[
"unknown",
"openai-responses-v1",
"azure-openai-responses-v1",
"xai-responses-v1",
"anthropic-claude-v1",
"google-gemini-v1",
],
UnrecognizedStr,
]
r"""The format of the reasoning content"""
class ResponsesOutputItemReasoningTypedDict(TypedDict):
r"""An output item containing reasoning"""
type: ResponsesOutputItemReasoningType
id: str
summary: List[ReasoningSummaryTextTypedDict]
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
encrypted_content: NotRequired[Nullable[str]]
status: NotRequired[ResponsesOutputItemReasoningStatusUnionTypedDict]
signature: NotRequired[Nullable[str]]
r"""A signature for the reasoning content, used for verification"""
format_: NotRequired[Nullable[ResponsesOutputItemReasoningFormat]]
r"""The format of the reasoning content"""
class ResponsesOutputItemReasoning(BaseModel):
r"""An output item containing reasoning"""
type: ResponsesOutputItemReasoningType
id: str
summary: List[ReasoningSummaryText]
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
encrypted_content: OptionalNullable[str] = UNSET
status: Optional[ResponsesOutputItemReasoningStatusUnion] = None
signature: OptionalNullable[str] = UNSET
r"""A signature for the reasoning content, used for verification"""
format_: Annotated[
Annotated[
OptionalNullable[ResponsesOutputItemReasoningFormat],
PlainValidator(validate_open_enum(False)),
],
pydantic.Field(alias="format"),
] = UNSET
r"""The format of the reasoning content"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"content",
"encrypted_content",
"status",
"signature",
"format",
]
nullable_fields = ["content", "encrypted_content", "signature", "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
@@ -1,156 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .openairesponsesrefusalcontent import (
OpenAIResponsesRefusalContent,
OpenAIResponsesRefusalContentTypedDict,
)
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag, model_serializer
from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ResponsesOutputMessageRole = Literal["assistant",]
ResponsesOutputMessageType = Literal["message",]
ResponsesOutputMessageStatusInProgress = Literal["in_progress",]
ResponsesOutputMessageStatusIncomplete = Literal["incomplete",]
ResponsesOutputMessageStatusCompleted = Literal["completed",]
ResponsesOutputMessageStatusUnionTypedDict = TypeAliasType(
"ResponsesOutputMessageStatusUnionTypedDict",
Union[
ResponsesOutputMessageStatusCompleted,
ResponsesOutputMessageStatusIncomplete,
ResponsesOutputMessageStatusInProgress,
],
)
ResponsesOutputMessageStatusUnion = TypeAliasType(
"ResponsesOutputMessageStatusUnion",
Union[
ResponsesOutputMessageStatusCompleted,
ResponsesOutputMessageStatusIncomplete,
ResponsesOutputMessageStatusInProgress,
],
)
ResponsesOutputMessageContentTypedDict = TypeAliasType(
"ResponsesOutputMessageContentTypedDict",
Union[OpenAIResponsesRefusalContentTypedDict, ResponseOutputTextTypedDict],
)
ResponsesOutputMessageContent = Annotated[
Union[
Annotated[ResponseOutputText, Tag("output_text")],
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ResponsesOutputMessagePhaseFinalAnswer = Literal["final_answer",]
ResponsesOutputMessagePhaseCommentary = Literal["commentary",]
ResponsesOutputMessagePhaseUnionTypedDict = TypeAliasType(
"ResponsesOutputMessagePhaseUnionTypedDict",
Union[
ResponsesOutputMessagePhaseCommentary,
ResponsesOutputMessagePhaseFinalAnswer,
Any,
],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
ResponsesOutputMessagePhaseUnion = TypeAliasType(
"ResponsesOutputMessagePhaseUnion",
Union[
ResponsesOutputMessagePhaseCommentary,
ResponsesOutputMessagePhaseFinalAnswer,
Any,
],
)
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class ResponsesOutputMessageTypedDict(TypedDict):
r"""An output message item"""
id: str
role: ResponsesOutputMessageRole
type: ResponsesOutputMessageType
content: List[ResponsesOutputMessageContentTypedDict]
status: NotRequired[ResponsesOutputMessageStatusUnionTypedDict]
phase: NotRequired[Nullable[ResponsesOutputMessagePhaseUnionTypedDict]]
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
class ResponsesOutputMessage(BaseModel):
r"""An output message item"""
id: str
role: ResponsesOutputMessageRole
type: ResponsesOutputMessageType
content: List[ResponsesOutputMessageContent]
status: Optional[ResponsesOutputMessageStatusUnion] = None
phase: OptionalNullable[ResponsesOutputMessagePhaseUnion] = UNSET
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["status", "phase"]
nullable_fields = ["phase"]
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
@@ -1,14 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ResponsesOutputModality = Union[
Literal[
"text",
"image",
],
UnrecognizedStr,
]
@@ -1,16 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
ResponsesSearchContextSize = Union[
Literal[
"low",
"medium",
"high",
],
UnrecognizedStr,
]
r"""Size of the search context for web search tools"""
@@ -1,147 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .websearchstatus import WebSearchStatus
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator, validate_open_enum
from pydantic import Discriminator, Tag, model_serializer
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeWebSearchCall = Literal["web_search_call",]
TypeFindInPage = Literal["find_in_page",]
class ActionFindInPageTypedDict(TypedDict):
type: TypeFindInPage
pattern: str
url: str
class ActionFindInPage(BaseModel):
type: TypeFindInPage
pattern: str
url: str
TypeOpenPage = Literal["open_page",]
class ActionOpenPageTypedDict(TypedDict):
type: TypeOpenPage
url: NotRequired[Nullable[str]]
class ActionOpenPage(BaseModel):
type: TypeOpenPage
url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["url"]
nullable_fields = ["url"]
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
TypeSearch = Literal["search",]
TypeURL = Literal["url",]
class SourceTypedDict(TypedDict):
type: TypeURL
url: str
class Source(BaseModel):
type: TypeURL
url: str
class ActionSearchTypedDict(TypedDict):
type: TypeSearch
query: str
queries: NotRequired[List[str]]
sources: NotRequired[List[SourceTypedDict]]
class ActionSearch(BaseModel):
type: TypeSearch
query: str
queries: Optional[List[str]] = None
sources: Optional[List[Source]] = None
ActionTypedDict = TypeAliasType(
"ActionTypedDict",
Union[ActionOpenPageTypedDict, ActionFindInPageTypedDict, ActionSearchTypedDict],
)
Action = Annotated[
Union[
Annotated[ActionSearch, Tag("search")],
Annotated[ActionOpenPage, Tag("open_page")],
Annotated[ActionFindInPage, Tag("find_in_page")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class ResponsesWebSearchCallOutputTypedDict(TypedDict):
type: TypeWebSearchCall
id: str
action: ActionTypedDict
status: WebSearchStatus
class ResponsesWebSearchCallOutput(BaseModel):
type: TypeWebSearchCall
id: str
action: Action
status: Annotated[WebSearchStatus, PlainValidator(validate_open_enum(False))]
@@ -1,70 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ResponsesWebSearchUserLocationType = Literal["approximate",]
class ResponsesWebSearchUserLocationTypedDict(TypedDict):
r"""User location information for web search"""
type: NotRequired[ResponsesWebSearchUserLocationType]
city: NotRequired[Nullable[str]]
country: NotRequired[Nullable[str]]
region: NotRequired[Nullable[str]]
timezone: NotRequired[Nullable[str]]
class ResponsesWebSearchUserLocation(BaseModel):
r"""User location information for web search"""
type: Optional[ResponsesWebSearchUserLocationType] = None
city: OptionalNullable[str] = UNSET
country: OptionalNullable[str] = UNSET
region: OptionalNullable[str] = UNSET
timezone: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["type", "city", "country", "region", "timezone"]
nullable_fields = ["city", "country", "region", "timezone"]
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
@@ -1,83 +0,0 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .responseformattextconfig import (
ResponseFormatTextConfig,
ResponseFormatTextConfigTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import validate_open_enum
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ResponseTextConfigVerbosity = Union[
Literal[
"high",
"low",
"medium",
],
UnrecognizedStr,
]
class ResponseTextConfigTypedDict(TypedDict):
r"""Text output configuration including format and verbosity"""
format_: NotRequired[ResponseFormatTextConfigTypedDict]
r"""Text response format configuration"""
verbosity: NotRequired[Nullable[ResponseTextConfigVerbosity]]
class ResponseTextConfig(BaseModel):
r"""Text output configuration including format and verbosity"""
format_: Annotated[
Optional[ResponseFormatTextConfig], pydantic.Field(alias="format")
] = None
r"""Text response format configuration"""
verbosity: Annotated[
OptionalNullable[ResponseTextConfigVerbosity],
PlainValidator(validate_open_enum(False)),
] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["format", "verbosity"]
nullable_fields = ["verbosity"]
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

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