fix: add overlay to remove nullable from pagination offset params (#121)

This commit is contained in:
Matt Apperson
2026-04-14 12:48:15 -04:00
committed by GitHub
parent 2bba049182
commit b2386114cd
440 changed files with 36150 additions and 32168 deletions
File diff suppressed because it is too large Load Diff
+28 -28
View File
@@ -7,60 +7,60 @@ from typing_extensions import Annotated, TypedDict
class ActivityItemTypedDict(TypedDict):
byok_usage_inference: float
r"""BYOK inference cost in USD (external credits spent)"""
completion_tokens: int
r"""Total completion tokens generated"""
date_: str
r"""Date of the activity (YYYY-MM-DD format)"""
endpoint_id: str
r"""Unique identifier for the endpoint"""
model: str
r"""Model slug (e.g., \"openai/gpt-4.1\")"""
model_permaslug: str
r"""Model permaslug (e.g., \"openai/gpt-4.1-2025-04-14\")"""
endpoint_id: str
r"""Unique identifier for the endpoint"""
prompt_tokens: int
r"""Total prompt tokens used"""
provider_name: str
r"""Name of the provider serving this endpoint"""
reasoning_tokens: int
r"""Total reasoning tokens used"""
requests: int
r"""Number of requests made"""
usage: float
r"""Total cost in USD (OpenRouter credits spent)"""
byok_usage_inference: float
r"""BYOK inference cost in USD (external credits spent)"""
requests: float
r"""Number of requests made"""
prompt_tokens: float
r"""Total prompt tokens used"""
completion_tokens: float
r"""Total completion tokens generated"""
reasoning_tokens: float
r"""Total reasoning tokens used"""
class ActivityItem(BaseModel):
byok_usage_inference: float
r"""BYOK inference cost in USD (external credits spent)"""
completion_tokens: int
r"""Total completion tokens generated"""
date_: Annotated[str, pydantic.Field(alias="date")]
r"""Date of the activity (YYYY-MM-DD format)"""
endpoint_id: str
r"""Unique identifier for the endpoint"""
model: str
r"""Model slug (e.g., \"openai/gpt-4.1\")"""
model_permaslug: str
r"""Model permaslug (e.g., \"openai/gpt-4.1-2025-04-14\")"""
endpoint_id: str
r"""Unique identifier for the endpoint"""
prompt_tokens: int
r"""Total prompt tokens used"""
provider_name: str
r"""Name of the provider serving this endpoint"""
usage: float
r"""Total cost in USD (OpenRouter credits spent)"""
reasoning_tokens: int
r"""Total reasoning tokens used"""
byok_usage_inference: float
r"""BYOK inference cost in USD (external credits spent)"""
requests: float
requests: int
r"""Number of requests made"""
prompt_tokens: float
r"""Total prompt tokens used"""
completion_tokens: float
r"""Total completion tokens generated"""
reasoning_tokens: float
r"""Total reasoning tokens used"""
usage: float
r"""Total cost in USD (OpenRouter credits spent)"""
@@ -0,0 +1,17 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .activityitem import ActivityItem, ActivityItemTypedDict
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class ActivityResponseTypedDict(TypedDict):
data: List[ActivityItemTypedDict]
r"""List of activity items"""
class ActivityResponse(BaseModel):
data: List[ActivityItem]
r"""List of activity items"""
@@ -16,28 +16,28 @@ AnnotationAddedEventType = Literal["response.output_text.annotation.added",]
class AnnotationAddedEventTypedDict(TypedDict):
r"""Event emitted when a text annotation is added to output"""
type: AnnotationAddedEventType
output_index: float
item_id: str
content_index: float
sequence_number: float
annotation_index: float
annotation: OpenAIResponsesAnnotationTypedDict
annotation_index: int
content_index: int
item_id: str
output_index: int
sequence_number: int
type: AnnotationAddedEventType
class AnnotationAddedEvent(BaseModel):
r"""Event emitted when a text annotation is added to output"""
type: AnnotationAddedEventType
annotation: OpenAIResponsesAnnotation
output_index: float
annotation_index: int
content_index: int
item_id: str
content_index: float
output_index: int
sequence_number: float
sequence_number: int
annotation_index: float
annotation: OpenAIResponsesAnnotation
type: AnnotationAddedEventType
@@ -0,0 +1,29 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .anthropiccachecontrolttl import AnthropicCacheControlTTL
from openrouter.types import BaseModel
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
AnthropicCacheControlDirectiveType = Literal["ephemeral",]
class AnthropicCacheControlDirectiveTypedDict(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: AnthropicCacheControlDirectiveType
ttl: NotRequired[AnthropicCacheControlTTL]
class AnthropicCacheControlDirective(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: AnthropicCacheControlDirectiveType
ttl: Annotated[
Optional[AnthropicCacheControlTTL], PlainValidator(validate_open_enum(False))
] = None
@@ -0,0 +1,14 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
AnthropicCacheControlTTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
@@ -0,0 +1,27 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict
AutoRouterPluginID = Literal["auto-router",]
class AutoRouterPluginTypedDict(TypedDict):
id: AutoRouterPluginID
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."""
enabled: NotRequired[bool]
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
class AutoRouterPlugin(BaseModel):
id: AutoRouterPluginID
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."""
enabled: Optional[bool] = None
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
+69 -258
View File
@@ -5,12 +5,23 @@ from .inputaudio import InputAudio, InputAudioTypedDict
from .inputfile import InputFile, InputFileTypedDict
from .inputimage import InputImage, InputImageTypedDict
from .inputtext import InputText, InputTextTypedDict
from .openairesponsefunctiontoolcall import (
OpenAIResponseFunctionToolCall,
OpenAIResponseFunctionToolCallTypedDict,
)
from .openairesponsefunctiontoolcalloutput import (
OpenAIResponseFunctionToolCallOutput,
OpenAIResponseFunctionToolCallOutputTypedDict,
)
from .openairesponseinputmessageitem import (
OpenAIResponseInputMessageItem,
OpenAIResponseInputMessageItemTypedDict,
)
from .outputitemimagegenerationcall import (
OutputItemImageGenerationCall,
OutputItemImageGenerationCallTypedDict,
)
from .outputmessage import OutputMessage, OutputMessageTypedDict
from .toolcallstatusenum import ToolCallStatusEnum
from openrouter.types import (
BaseModel,
Nullable,
@@ -18,249 +29,12 @@ from openrouter.types import (
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator, validate_open_enum
from openrouter.utils import get_discriminator
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
BaseInputsTypeFunctionCall = Literal["function_call",]
class BaseInputsFunctionCallTypedDict(TypedDict):
type: BaseInputsTypeFunctionCall
call_id: str
name: str
arguments: str
id: NotRequired[str]
status: NotRequired[Nullable[ToolCallStatusEnum]]
class BaseInputsFunctionCall(BaseModel):
type: BaseInputsTypeFunctionCall
call_id: str
name: str
arguments: str
id: Optional[str] = None
status: Annotated[
OptionalNullable[ToolCallStatusEnum], 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
BaseInputsTypeFunctionCallOutput = Literal["function_call_output",]
BaseInputsOutput1TypedDict = TypeAliasType(
"BaseInputsOutput1TypedDict",
Union[InputTextTypedDict, InputImageTypedDict, InputFileTypedDict],
)
BaseInputsOutput1 = Annotated[
Union[
Annotated[InputText, Tag("input_text")],
Annotated[InputImage, Tag("input_image")],
Annotated[InputFile, Tag("input_file")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
BaseInputsOutput2TypedDict = TypeAliasType(
"BaseInputsOutput2TypedDict", Union[str, List[BaseInputsOutput1TypedDict]]
)
BaseInputsOutput2 = TypeAliasType(
"BaseInputsOutput2", Union[str, List[BaseInputsOutput1]]
)
class BaseInputsFunctionCallOutputTypedDict(TypedDict):
type: BaseInputsTypeFunctionCallOutput
call_id: str
output: BaseInputsOutput2TypedDict
id: NotRequired[Nullable[str]]
status: NotRequired[Nullable[ToolCallStatusEnum]]
class BaseInputsFunctionCallOutput(BaseModel):
type: BaseInputsTypeFunctionCallOutput
call_id: str
output: BaseInputsOutput2
id: OptionalNullable[str] = UNSET
status: Annotated[
OptionalNullable[ToolCallStatusEnum], 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
BaseInputsTypeMessage2 = Literal["message",]
BaseInputsRoleDeveloper2 = Literal["developer",]
BaseInputsRoleSystem2 = Literal["system",]
BaseInputsRoleUser2 = Literal["user",]
BaseInputsRoleUnion2TypedDict = TypeAliasType(
"BaseInputsRoleUnion2TypedDict",
Union[BaseInputsRoleUser2, BaseInputsRoleSystem2, BaseInputsRoleDeveloper2],
)
BaseInputsRoleUnion2 = TypeAliasType(
"BaseInputsRoleUnion2",
Union[BaseInputsRoleUser2, BaseInputsRoleSystem2, BaseInputsRoleDeveloper2],
)
BaseInputsContent3TypedDict = TypeAliasType(
"BaseInputsContent3TypedDict",
Union[
InputTextTypedDict, InputAudioTypedDict, InputImageTypedDict, InputFileTypedDict
],
)
BaseInputsContent3 = Annotated[
Union[
Annotated[InputText, Tag("input_text")],
Annotated[InputImage, Tag("input_image")],
Annotated[InputFile, Tag("input_file")],
Annotated[InputAudio, Tag("input_audio")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
class BaseInputsMessage2TypedDict(TypedDict):
id: str
role: BaseInputsRoleUnion2TypedDict
content: List[BaseInputsContent3TypedDict]
type: NotRequired[BaseInputsTypeMessage2]
class BaseInputsMessage2(BaseModel):
id: str
role: BaseInputsRoleUnion2
content: List[BaseInputsContent3]
type: Optional[BaseInputsTypeMessage2] = None
BaseInputsTypeMessage1 = Literal["message",]
BaseInputsRoleDeveloper1 = Literal["developer",]
BaseInputsRoleAssistant = Literal["assistant",]
BaseInputsRoleSystem1 = Literal["system",]
BaseInputsRoleUser1 = Literal["user",]
BaseInputsRoleUnion1TypedDict = TypeAliasType(
"BaseInputsRoleUnion1TypedDict",
Union[
BaseInputsRoleUser1,
BaseInputsRoleSystem1,
BaseInputsRoleAssistant,
BaseInputsRoleDeveloper1,
],
)
BaseInputsRoleUnion1 = TypeAliasType(
"BaseInputsRoleUnion1",
Union[
BaseInputsRoleUser1,
BaseInputsRoleSystem1,
BaseInputsRoleAssistant,
BaseInputsRoleDeveloper1,
],
)
BaseInputsContent1TypedDict = TypeAliasType(
"BaseInputsContent1TypedDict",
Union[
@@ -271,10 +45,10 @@ BaseInputsContent1TypedDict = TypeAliasType(
BaseInputsContent1 = Annotated[
Union[
Annotated[InputText, Tag("input_text")],
Annotated[InputImage, Tag("input_image")],
Annotated[InputFile, Tag("input_file")],
Annotated[InputAudio, Tag("input_audio")],
Annotated[InputFile, Tag("input_file")],
Annotated[InputImage, Tag("input_image")],
Annotated[InputText, Tag("input_text")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
@@ -308,25 +82,62 @@ BaseInputsPhaseUnion = TypeAliasType(
)
class BaseInputsMessage1TypedDict(TypedDict):
role: BaseInputsRoleUnion1TypedDict
BaseInputsRoleDeveloper = Literal["developer",]
BaseInputsRoleAssistant = Literal["assistant",]
BaseInputsRoleSystem = Literal["system",]
BaseInputsRoleUser = Literal["user",]
BaseInputsRoleUnionTypedDict = TypeAliasType(
"BaseInputsRoleUnionTypedDict",
Union[
BaseInputsRoleUser,
BaseInputsRoleSystem,
BaseInputsRoleAssistant,
BaseInputsRoleDeveloper,
],
)
BaseInputsRoleUnion = TypeAliasType(
"BaseInputsRoleUnion",
Union[
BaseInputsRoleUser,
BaseInputsRoleSystem,
BaseInputsRoleAssistant,
BaseInputsRoleDeveloper,
],
)
BaseInputsType = Literal["message",]
class BaseInputsMessageTypedDict(TypedDict):
content: BaseInputsContent2TypedDict
type: NotRequired[BaseInputsTypeMessage1]
role: BaseInputsRoleUnionTypedDict
phase: NotRequired[Nullable[BaseInputsPhaseUnionTypedDict]]
type: NotRequired[BaseInputsType]
class BaseInputsMessage1(BaseModel):
role: BaseInputsRoleUnion1
class BaseInputsMessage(BaseModel):
content: BaseInputsContent2
type: Optional[BaseInputsTypeMessage1] = None
role: BaseInputsRoleUnion
phase: OptionalNullable[BaseInputsPhaseUnion] = UNSET
type: Optional[BaseInputsType] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["type", "phase"]
optional_fields = ["phase", "type"]
nullable_fields = ["phase"]
null_default_fields = []
@@ -358,11 +169,11 @@ class BaseInputsMessage1(BaseModel):
BaseInputsUnion1TypedDict = TypeAliasType(
"BaseInputsUnion1TypedDict",
Union[
BaseInputsMessage1TypedDict,
BaseInputsMessage2TypedDict,
BaseInputsMessageTypedDict,
OpenAIResponseInputMessageItemTypedDict,
OutputItemImageGenerationCallTypedDict,
BaseInputsFunctionCallOutputTypedDict,
BaseInputsFunctionCallTypedDict,
OpenAIResponseFunctionToolCallOutputTypedDict,
OpenAIResponseFunctionToolCallTypedDict,
OutputMessageTypedDict,
],
)
@@ -371,11 +182,11 @@ BaseInputsUnion1TypedDict = TypeAliasType(
BaseInputsUnion1 = TypeAliasType(
"BaseInputsUnion1",
Union[
BaseInputsMessage1,
BaseInputsMessage2,
BaseInputsMessage,
OpenAIResponseInputMessageItem,
OutputItemImageGenerationCall,
BaseInputsFunctionCallOutput,
BaseInputsFunctionCall,
OpenAIResponseFunctionToolCallOutput,
OpenAIResponseFunctionToolCall,
OutputMessage,
],
)
@@ -1,8 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .reasoningeffortenum import ReasoningEffortEnum
from .reasoningsummaryverbosityenum import ReasoningSummaryVerbosityEnum
from .reasoningeffort import ReasoningEffort
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
from openrouter.types import (
BaseModel,
Nullable,
@@ -17,17 +17,17 @@ from typing_extensions import Annotated, NotRequired, TypedDict
class BaseReasoningConfigTypedDict(TypedDict):
effort: NotRequired[Nullable[ReasoningEffortEnum]]
summary: NotRequired[Nullable[ReasoningSummaryVerbosityEnum]]
effort: NotRequired[Nullable[ReasoningEffort]]
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
class BaseReasoningConfig(BaseModel):
effort: Annotated[
OptionalNullable[ReasoningEffortEnum], PlainValidator(validate_open_enum(False))
OptionalNullable[ReasoningEffort], PlainValidator(validate_open_enum(False))
] = UNSET
summary: Annotated[
OptionalNullable[ReasoningSummaryVerbosityEnum],
OptionalNullable[ReasoningSummaryVerbosity],
PlainValidator(validate_open_enum(False)),
] = UNSET
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class BulkAssignKeysRequestTypedDict(TypedDict):
key_hashes: List[str]
r"""Array of API key hashes to assign to the guardrail"""
class BulkAssignKeysRequest(BaseModel):
key_hashes: List[str]
r"""Array of API key hashes to assign to the guardrail"""
@@ -0,0 +1,15 @@
"""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 BulkAssignKeysResponseTypedDict(TypedDict):
assigned_count: int
r"""Number of keys successfully assigned"""
class BulkAssignKeysResponse(BaseModel):
assigned_count: int
r"""Number of keys successfully assigned"""
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class BulkAssignMembersRequestTypedDict(TypedDict):
member_user_ids: List[str]
r"""Array of member user IDs to assign to the guardrail"""
class BulkAssignMembersRequest(BaseModel):
member_user_ids: List[str]
r"""Array of member user IDs to assign to the guardrail"""
@@ -0,0 +1,15 @@
"""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 BulkAssignMembersResponseTypedDict(TypedDict):
assigned_count: int
r"""Number of members successfully assigned"""
class BulkAssignMembersResponse(BaseModel):
assigned_count: int
r"""Number of members successfully assigned"""
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class BulkUnassignKeysRequestTypedDict(TypedDict):
key_hashes: List[str]
r"""Array of API key hashes to unassign from the guardrail"""
class BulkUnassignKeysRequest(BaseModel):
key_hashes: List[str]
r"""Array of API key hashes to unassign from the guardrail"""
@@ -0,0 +1,15 @@
"""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 BulkUnassignKeysResponseTypedDict(TypedDict):
unassigned_count: int
r"""Number of keys successfully unassigned"""
class BulkUnassignKeysResponse(BaseModel):
unassigned_count: int
r"""Number of keys successfully unassigned"""
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class BulkUnassignMembersRequestTypedDict(TypedDict):
member_user_ids: List[str]
r"""Array of member user IDs to unassign from the guardrail"""
class BulkUnassignMembersRequest(BaseModel):
member_user_ids: List[str]
r"""Array of member user IDs to unassign from the guardrail"""
@@ -0,0 +1,15 @@
"""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 BulkUnassignMembersResponseTypedDict(TypedDict):
unassigned_count: int
r"""Number of members successfully unassigned"""
class BulkUnassignMembersResponse(BaseModel):
unassigned_count: int
r"""Number of members successfully unassigned"""
@@ -18,9 +18,6 @@ from typing import Any, List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
ChatAssistantMessageRole = Literal["assistant",]
ChatAssistantMessageContentTypedDict = TypeAliasType(
"ChatAssistantMessageContentTypedDict",
Union[str, List[ChatContentItemsTypedDict], Any],
@@ -34,26 +31,29 @@ ChatAssistantMessageContent = TypeAliasType(
r"""Assistant message content"""
ChatAssistantMessageRole = Literal["assistant",]
class ChatAssistantMessageTypedDict(TypedDict):
r"""Assistant message for requests and responses"""
role: ChatAssistantMessageRole
audio: NotRequired[ChatAudioOutputTypedDict]
r"""Audio output data or reference"""
content: NotRequired[Nullable[ChatAssistantMessageContentTypedDict]]
r"""Assistant message content"""
images: NotRequired[List[ChatAssistantImagesTypedDict]]
r"""Generated images from image generation models"""
name: NotRequired[str]
r"""Optional name for the assistant"""
tool_calls: NotRequired[List[ChatToolCallTypedDict]]
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[ChatAssistantImagesTypedDict]]
r"""Generated images from image generation models"""
audio: NotRequired[ChatAudioOutputTypedDict]
r"""Audio output data or reference"""
refusal: NotRequired[Nullable[str]]
r"""Refusal message if content was refused"""
tool_calls: NotRequired[List[ChatToolCallTypedDict]]
r"""Tool calls made by the assistant"""
class ChatAssistantMessage(BaseModel):
@@ -61,43 +61,43 @@ class ChatAssistantMessage(BaseModel):
role: ChatAssistantMessageRole
audio: Optional[ChatAudioOutput] = None
r"""Audio output data or reference"""
content: OptionalNullable[ChatAssistantMessageContent] = UNSET
r"""Assistant message content"""
images: Optional[List[ChatAssistantImages]] = None
r"""Generated images from image generation models"""
name: Optional[str] = None
r"""Optional name for the assistant"""
tool_calls: Optional[List[ChatToolCall]] = 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[ChatAssistantImages]] = None
r"""Generated images from image generation models"""
refusal: OptionalNullable[str] = UNSET
r"""Refusal message if content was refused"""
audio: Optional[ChatAudioOutput] = None
r"""Audio output data or reference"""
tool_calls: Optional[List[ChatToolCall]] = None
r"""Tool calls made by the assistant"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"audio",
"content",
"images",
"name",
"tool_calls",
"refusal",
"reasoning",
"reasoning_details",
"images",
"audio",
"refusal",
"tool_calls",
]
nullable_fields = ["content", "refusal", "reasoning"]
nullable_fields = ["content", "reasoning", "refusal"]
null_default_fields = []
serialized = handler(self)
+10 -10
View File
@@ -9,12 +9,12 @@ from typing_extensions import NotRequired, TypedDict
class ChatAudioOutputTypedDict(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"""
expires_at: NotRequired[int]
r"""Audio expiration timestamp"""
id: NotRequired[str]
r"""Audio output identifier"""
transcript: NotRequired[str]
r"""Audio transcript"""
@@ -22,14 +22,14 @@ class ChatAudioOutputTypedDict(TypedDict):
class ChatAudioOutput(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"""
expires_at: Optional[int] = None
r"""Audio expiration timestamp"""
id: Optional[str] = None
r"""Audio output identifier"""
transcript: Optional[str] = None
r"""Audio transcript"""
+10 -6
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
from .chatassistantmessage import ChatAssistantMessage, ChatAssistantMessageTypedDict
from .chatfinishreasonenum import ChatFinishReasonEnum
from .chattokenlogprobs import ChatTokenLogprobs, ChatTokenLogprobsTypedDict
from openrouter.types import (
BaseModel,
@@ -10,16 +11,17 @@ from openrouter.types import (
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from typing import Any
from typing_extensions import NotRequired, TypedDict
from pydantic.functional_validators import PlainValidator
from typing_extensions import Annotated, NotRequired, TypedDict
class ChatChoiceTypedDict(TypedDict):
r"""Chat completion choice"""
finish_reason: Nullable[Any]
index: float
finish_reason: Nullable[ChatFinishReasonEnum]
index: int
r"""Choice index"""
message: ChatAssistantMessageTypedDict
r"""Assistant message for requests and responses"""
@@ -30,9 +32,11 @@ class ChatChoiceTypedDict(TypedDict):
class ChatChoice(BaseModel):
r"""Chat completion choice"""
finish_reason: Nullable[Any]
finish_reason: Annotated[
Nullable[ChatFinishReasonEnum], PlainValidator(validate_open_enum(False))
]
index: float
index: int
r"""Choice index"""
message: ChatAssistantMessage
@@ -7,9 +7,6 @@ from typing import Literal
from typing_extensions import Annotated, TypedDict
ChatContentAudioType = Literal["input_audio",]
class ChatContentAudioInputAudioTypedDict(TypedDict):
data: str
r"""Base64 encoded audio data"""
@@ -25,16 +22,19 @@ class ChatContentAudioInputAudio(BaseModel):
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
ChatContentAudioType = Literal["input_audio",]
class ChatContentAudioTypedDict(TypedDict):
r"""Audio input content part. Supported audio formats vary by provider."""
type: ChatContentAudioType
input_audio: ChatContentAudioInputAudioTypedDict
type: ChatContentAudioType
class ChatContentAudio(BaseModel):
r"""Audio input content part. Supported audio formats vary by provider."""
type: ChatContentAudioType
input_audio: ChatContentAudioInputAudio
type: ChatContentAudioType
@@ -1,30 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, UnrecognizedStr
from .anthropiccachecontrolttl import AnthropicCacheControlTTL
from openrouter.types import BaseModel
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import Literal, Optional, Union
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
ChatContentCacheControlType = Literal["ephemeral",]
ChatContentCacheControlTTL = Union[
Literal[
"5m",
"1h",
],
UnrecognizedStr,
]
class ChatContentCacheControlTypedDict(TypedDict):
r"""Cache control for the content part"""
type: ChatContentCacheControlType
ttl: NotRequired[ChatContentCacheControlTTL]
ttl: NotRequired[AnthropicCacheControlTTL]
class ChatContentCacheControl(BaseModel):
@@ -33,5 +25,5 @@ class ChatContentCacheControl(BaseModel):
type: ChatContentCacheControlType
ttl: Annotated[
Optional[ChatContentCacheControlTTL], PlainValidator(validate_open_enum(False))
Optional[AnthropicCacheControlTTL], PlainValidator(validate_open_enum(False))
] = None
+6 -6
View File
@@ -6,9 +6,6 @@ from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatContentFileType = Literal["file",]
class FileTypedDict(TypedDict):
file_data: NotRequired[str]
r"""File content as base64 data URL or URL"""
@@ -29,16 +26,19 @@ class File(BaseModel):
r"""Original filename"""
ChatContentFileType = Literal["file",]
class ChatContentFileTypedDict(TypedDict):
r"""File content part for document processing"""
type: ChatContentFileType
file: FileTypedDict
type: ChatContentFileType
class ChatContentFile(BaseModel):
r"""File content part for document processing"""
type: ChatContentFileType
file: File
type: ChatContentFileType
@@ -8,9 +8,6 @@ from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatContentImageType = Literal["image_url",]
ChatContentImageDetail = Union[
Literal[
"auto",
@@ -39,16 +36,19 @@ class ChatContentImageImageURL(BaseModel):
r"""Image detail level for vision models"""
ChatContentImageType = Literal["image_url",]
class ChatContentImageTypedDict(TypedDict):
r"""Image content part for vision models"""
type: ChatContentImageType
image_url: ChatContentImageImageURLTypedDict
type: ChatContentImageType
class ChatContentImage(BaseModel):
r"""Image content part for vision models"""
type: ChatContentImageType
image_url: ChatContentImageImageURL
type: ChatContentImageType
+11 -24
View File
@@ -16,42 +16,29 @@ from typing import Union
from typing_extensions import Annotated, TypeAliasType
ChatContentItems1TypedDict = TypeAliasType(
"ChatContentItems1TypedDict",
Union[LegacyChatContentVideoTypedDict, ChatContentVideoTypedDict],
)
ChatContentItems1 = Annotated[
Union[
Annotated[LegacyChatContentVideo, Tag("input_video")],
Annotated[ChatContentVideo, Tag("video_url")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
ChatContentItemsTypedDict = TypeAliasType(
"ChatContentItemsTypedDict",
Union[
ChatContentImageTypedDict,
ChatContentAudioTypedDict,
LegacyChatContentVideoTypedDict,
ChatContentVideoTypedDict,
ChatContentFileTypedDict,
ChatContentTextTypedDict,
ChatContentItems1TypedDict,
],
)
r"""Content part for chat completion messages"""
ChatContentItems = TypeAliasType(
"ChatContentItems",
ChatContentItems = Annotated[
Union[
ChatContentImage,
ChatContentAudio,
ChatContentFile,
ChatContentText,
ChatContentItems1,
Annotated[ChatContentFile, Tag("file")],
Annotated[ChatContentImage, Tag("image_url")],
Annotated[ChatContentAudio, Tag("input_audio")],
Annotated[LegacyChatContentVideo, Tag("input_video")],
Annotated[ChatContentText, Tag("text")],
Annotated[ChatContentVideo, Tag("video_url")],
],
)
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
r"""Content part for chat completion messages"""
+3 -3
View File
@@ -16,8 +16,8 @@ ChatContentTextType = Literal["text",]
class ChatContentTextTypedDict(TypedDict):
r"""Text content part"""
type: ChatContentTextType
text: str
type: ChatContentTextType
cache_control: NotRequired[ChatContentCacheControlTypedDict]
r"""Cache control for the content part"""
@@ -25,9 +25,9 @@ class ChatContentTextTypedDict(TypedDict):
class ChatContentText(BaseModel):
r"""Text content part"""
type: ChatContentTextType
text: str
type: ChatContentTextType
cache_control: Optional[ChatContentCacheControl] = None
r"""Cache control for the content part"""
@@ -7,9 +7,6 @@ from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
ChatDeveloperMessageRole = Literal["developer",]
ChatDeveloperMessageContentTypedDict = TypeAliasType(
"ChatDeveloperMessageContentTypedDict", Union[str, List[ChatContentTextTypedDict]]
)
@@ -22,12 +19,15 @@ ChatDeveloperMessageContent = TypeAliasType(
r"""Developer message content"""
ChatDeveloperMessageRole = Literal["developer",]
class ChatDeveloperMessageTypedDict(TypedDict):
r"""Developer message"""
role: ChatDeveloperMessageRole
content: ChatDeveloperMessageContentTypedDict
r"""Developer message content"""
role: ChatDeveloperMessageRole
name: NotRequired[str]
r"""Optional name for the developer message"""
@@ -35,10 +35,10 @@ class ChatDeveloperMessageTypedDict(TypedDict):
class ChatDeveloperMessage(BaseModel):
r"""Developer message"""
role: ChatDeveloperMessageRole
content: ChatDeveloperMessageContent
r"""Developer message content"""
role: ChatDeveloperMessageRole
name: Optional[str] = None
r"""Optional name for the developer message"""
@@ -12,15 +12,15 @@ ChatFormatGrammarConfigType = Literal["grammar",]
class ChatFormatGrammarConfigTypedDict(TypedDict):
r"""Custom grammar response format"""
type: ChatFormatGrammarConfigType
grammar: str
r"""Custom grammar for text generation"""
type: ChatFormatGrammarConfigType
class ChatFormatGrammarConfig(BaseModel):
r"""Custom grammar response format"""
type: ChatFormatGrammarConfigType
grammar: str
r"""Custom grammar for text generation"""
type: ChatFormatGrammarConfigType
@@ -13,15 +13,15 @@ ChatFormatJSONSchemaConfigType = Literal["json_schema",]
class ChatFormatJSONSchemaConfigTypedDict(TypedDict):
r"""JSON Schema response format for structured outputs"""
type: ChatFormatJSONSchemaConfigType
json_schema: ChatJSONSchemaConfigTypedDict
r"""JSON Schema configuration object"""
type: ChatFormatJSONSchemaConfigType
class ChatFormatJSONSchemaConfig(BaseModel):
r"""JSON Schema response format for structured outputs"""
type: ChatFormatJSONSchemaConfigType
json_schema: ChatJSONSchemaConfig
r"""JSON Schema configuration object"""
type: ChatFormatJSONSchemaConfigType
+27 -11
View File
@@ -5,15 +5,23 @@ from .chatcontentcachecontrol import (
ChatContentCacheControl,
ChatContentCacheControlTypedDict,
)
from .chatwebsearchservertool import (
ChatWebSearchServerTool,
ChatWebSearchServerToolTypedDict,
from .chatsearchmodelsservertool import (
ChatSearchModelsServerTool,
ChatSearchModelsServerToolTypedDict,
)
from .chatwebsearchshorthand import (
ChatWebSearchShorthand,
ChatWebSearchShorthandTypedDict,
)
from .datetimeservertool import DatetimeServerTool, DatetimeServerToolTypedDict
from .imagegenerationservertool_openrouter import (
ImageGenerationServerToolOpenRouter,
ImageGenerationServerToolOpenRouterTypedDict,
)
from .openrouterwebsearchservertool import (
OpenRouterWebSearchServerTool,
OpenRouterWebSearchServerToolTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
@@ -27,9 +35,6 @@ from typing import Any, Dict, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ChatFunctionToolType = Literal["function",]
class ChatFunctionToolFunctionFunctionTypedDict(TypedDict):
r"""Function definition for tool calling"""
@@ -89,20 +94,23 @@ class ChatFunctionToolFunctionFunction(BaseModel):
return m
ChatFunctionToolType = Literal["function",]
class ChatFunctionToolFunctionTypedDict(TypedDict):
type: ChatFunctionToolType
function: ChatFunctionToolFunctionFunctionTypedDict
r"""Function definition for tool calling"""
type: ChatFunctionToolType
cache_control: NotRequired[ChatContentCacheControlTypedDict]
r"""Cache control for the content part"""
class ChatFunctionToolFunction(BaseModel):
type: ChatFunctionToolType
function: ChatFunctionToolFunctionFunction
r"""Function definition for tool calling"""
type: ChatFunctionToolType
cache_control: Optional[ChatContentCacheControl] = None
r"""Cache control for the content part"""
@@ -111,7 +119,9 @@ ChatFunctionToolTypedDict = TypeAliasType(
"ChatFunctionToolTypedDict",
Union[
DatetimeServerToolTypedDict,
ChatWebSearchServerToolTypedDict,
ImageGenerationServerToolOpenRouterTypedDict,
ChatSearchModelsServerToolTypedDict,
OpenRouterWebSearchServerToolTypedDict,
ChatFunctionToolFunctionTypedDict,
ChatWebSearchShorthandTypedDict,
],
@@ -123,7 +133,13 @@ ChatFunctionTool = Annotated[
Union[
Annotated[ChatFunctionToolFunction, Tag("function")],
Annotated[DatetimeServerTool, Tag("openrouter:datetime")],
Annotated[ChatWebSearchServerTool, Tag("openrouter:web_search")],
Annotated[
ImageGenerationServerToolOpenRouter, Tag("openrouter:image_generation")
],
Annotated[
ChatSearchModelsServerTool, Tag("openrouter:experimental__search_models")
],
Annotated[OpenRouterWebSearchServerTool, Tag("openrouter:web_search")],
Annotated[ChatWebSearchShorthand, Tag("web_search")],
Annotated[ChatWebSearchShorthand, Tag("web_search_preview")],
Annotated[ChatWebSearchShorthand, Tag("web_search_preview_2025_03_11")],
+3 -3
View File
@@ -27,11 +27,11 @@ r"""Chat completion message with role-based discrimination"""
ChatMessages = Annotated[
Union[
Annotated[ChatSystemMessage, Tag("system")],
Annotated[ChatUserMessage, Tag("user")],
Annotated[ChatDeveloperMessage, Tag("developer")],
Annotated[ChatAssistantMessage, Tag("assistant")],
Annotated[ChatDeveloperMessage, Tag("developer")],
Annotated[ChatSystemMessage, Tag("system")],
Annotated[ChatToolMessage, Tag("tool")],
Annotated[ChatUserMessage, Tag("user")],
],
Discriminator(lambda m: get_discriminator(m, "role", "role")),
]
@@ -6,9 +6,6 @@ from typing import Literal
from typing_extensions import TypedDict
ChatNamedToolChoiceType = Literal["function",]
class ChatNamedToolChoiceFunctionTypedDict(TypedDict):
name: str
r"""Function name to call"""
@@ -19,16 +16,19 @@ class ChatNamedToolChoiceFunction(BaseModel):
r"""Function name to call"""
ChatNamedToolChoiceType = Literal["function",]
class ChatNamedToolChoiceTypedDict(TypedDict):
r"""Named tool choice for specific function"""
type: ChatNamedToolChoiceType
function: ChatNamedToolChoiceFunctionTypedDict
type: ChatNamedToolChoiceType
class ChatNamedToolChoice(BaseModel):
r"""Named tool choice for specific function"""
type: ChatNamedToolChoiceType
function: ChatNamedToolChoiceFunction
type: ChatNamedToolChoiceType
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -21,12 +21,12 @@ ChatResultObject = Literal["chat.completion",]
class ChatResultTypedDict(TypedDict):
r"""Chat completion response"""
id: str
r"""Unique completion identifier"""
choices: List[ChatChoiceTypedDict]
r"""List of completion choices"""
created: float
created: int
r"""Unix timestamp of creation"""
id: str
r"""Unique completion identifier"""
model: str
r"""Model used for completion"""
object: ChatResultObject
@@ -41,15 +41,15 @@ class ChatResultTypedDict(TypedDict):
class ChatResult(BaseModel):
r"""Chat completion response"""
id: str
r"""Unique completion identifier"""
choices: List[ChatChoice]
r"""List of completion choices"""
created: float
created: int
r"""Unix timestamp of creation"""
id: str
r"""Unique completion identifier"""
model: str
r"""Model used for completion"""
@@ -67,7 +67,7 @@ class ChatResult(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["service_tier", "usage"]
nullable_fields = ["system_fingerprint", "service_tier"]
nullable_fields = ["service_tier", "system_fingerprint"]
null_default_fields = []
serialized = handler(self)
@@ -0,0 +1,30 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .searchmodelsservertoolconfig import (
SearchModelsServerToolConfig,
SearchModelsServerToolConfigTypedDict,
)
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatSearchModelsServerToolType = Literal["openrouter:experimental__search_models",]
class ChatSearchModelsServerToolTypedDict(TypedDict):
r"""OpenRouter built-in server tool: searches and filters AI models available on OpenRouter"""
type: ChatSearchModelsServerToolType
parameters: NotRequired[SearchModelsServerToolConfigTypedDict]
r"""Configuration for the openrouter:experimental__search_models server tool"""
class ChatSearchModelsServerTool(BaseModel):
r"""OpenRouter built-in server tool: searches and filters AI models available on OpenRouter"""
type: ChatSearchModelsServerToolType
parameters: Optional[SearchModelsServerToolConfig] = None
r"""Configuration for the openrouter:experimental__search_models server tool"""
+10 -6
View File
@@ -1,6 +1,7 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatfinishreasonenum import ChatFinishReasonEnum
from .chatstreamdelta import ChatStreamDelta, ChatStreamDeltaTypedDict
from .chattokenlogprobs import ChatTokenLogprobs, ChatTokenLogprobsTypedDict
from openrouter.types import (
@@ -10,9 +11,10 @@ from openrouter.types import (
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from typing import Any
from typing_extensions import NotRequired, TypedDict
from pydantic.functional_validators import PlainValidator
from typing_extensions import Annotated, NotRequired, TypedDict
class ChatStreamChoiceTypedDict(TypedDict):
@@ -20,8 +22,8 @@ class ChatStreamChoiceTypedDict(TypedDict):
delta: ChatStreamDeltaTypedDict
r"""Delta changes in streaming response"""
finish_reason: Nullable[Any]
index: float
finish_reason: Nullable[ChatFinishReasonEnum]
index: int
r"""Choice index"""
logprobs: NotRequired[Nullable[ChatTokenLogprobsTypedDict]]
r"""Log probabilities for the completion"""
@@ -33,9 +35,11 @@ class ChatStreamChoice(BaseModel):
delta: ChatStreamDelta
r"""Delta changes in streaming response"""
finish_reason: Nullable[Any]
finish_reason: Annotated[
Nullable[ChatFinishReasonEnum], PlainValidator(validate_open_enum(False))
]
index: float
index: int
r"""Choice index"""
logprobs: OptionalNullable[ChatTokenLogprobs] = UNSET
+23 -23
View File
@@ -15,46 +15,46 @@ from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatStreamChunkObject = Literal["chat.completion.chunk",]
class ErrorTypedDict(TypedDict):
r"""Error information"""
code: int
r"""Error code"""
message: str
r"""Error message"""
code: float
r"""Error code"""
class Error(BaseModel):
r"""Error information"""
code: int
r"""Error code"""
message: str
r"""Error message"""
code: float
r"""Error code"""
ChatStreamChunkObject = Literal["chat.completion.chunk",]
class ChatStreamChunkTypedDict(TypedDict):
r"""Streaming chat completion chunk"""
id: str
r"""Unique chunk identifier"""
choices: List[ChatStreamChoiceTypedDict]
r"""List of streaming chunk choices"""
created: float
created: int
r"""Unix timestamp of creation"""
id: str
r"""Unique chunk identifier"""
model: str
r"""Model used for completion"""
object: ChatStreamChunkObject
system_fingerprint: NotRequired[str]
r"""System fingerprint"""
service_tier: NotRequired[Nullable[str]]
r"""The service tier used by the upstream provider for this request"""
error: NotRequired[ErrorTypedDict]
r"""Error information"""
service_tier: NotRequired[Nullable[str]]
r"""The service tier used by the upstream provider for this request"""
system_fingerprint: NotRequired[str]
r"""System fingerprint"""
usage: NotRequired[ChatUsageTypedDict]
r"""Token usage statistics"""
@@ -62,35 +62,35 @@ class ChatStreamChunkTypedDict(TypedDict):
class ChatStreamChunk(BaseModel):
r"""Streaming chat completion chunk"""
id: str
r"""Unique chunk identifier"""
choices: List[ChatStreamChoice]
r"""List of streaming chunk choices"""
created: float
created: int
r"""Unix timestamp of creation"""
id: str
r"""Unique chunk identifier"""
model: str
r"""Model used for completion"""
object: ChatStreamChunkObject
system_fingerprint: Optional[str] = None
r"""System fingerprint"""
error: Optional[Error] = None
r"""Error information"""
service_tier: OptionalNullable[str] = UNSET
r"""The service tier used by the upstream provider for this request"""
error: Optional[Error] = None
r"""Error information"""
system_fingerprint: Optional[str] = None
r"""System fingerprint"""
usage: Optional[ChatUsage] = None
r"""Token usage statistics"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["system_fingerprint", "service_tier", "error", "usage"]
optional_fields = ["error", "service_tier", "system_fingerprint", "usage"]
nullable_fields = ["service_tier"]
null_default_fields = []
+18 -18
View File
@@ -23,26 +23,25 @@ r"""The role of the message author"""
class ChatStreamDeltaTypedDict(TypedDict):
r"""Delta changes in streaming response"""
role: NotRequired[ChatStreamDeltaRole]
r"""The role of the message author"""
audio: NotRequired[ChatAudioOutputTypedDict]
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[ChatStreamToolCallTypedDict]]
r"""Tool calls delta"""
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
r"""Reasoning details for extended thinking models"""
audio: NotRequired[ChatAudioOutputTypedDict]
refusal: NotRequired[Nullable[str]]
r"""Refusal message delta"""
role: NotRequired[ChatStreamDeltaRole]
r"""The role of the message author"""
tool_calls: NotRequired[List[ChatStreamToolCallTypedDict]]
r"""Tool calls delta"""
class ChatStreamDelta(BaseModel):
r"""Delta changes in streaming response"""
role: Optional[ChatStreamDeltaRole] = None
r"""The role of the message author"""
audio: Optional[ChatAudioOutput] = None
content: OptionalNullable[str] = UNSET
r"""Message content delta"""
@@ -50,27 +49,28 @@ class ChatStreamDelta(BaseModel):
reasoning: OptionalNullable[str] = UNSET
r"""Reasoning content delta"""
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
r"""Reasoning details for extended thinking models"""
refusal: OptionalNullable[str] = UNSET
r"""Refusal message delta"""
role: Optional[ChatStreamDeltaRole] = None
r"""The role of the message author"""
tool_calls: Optional[List[ChatStreamToolCall]] = None
r"""Tool calls delta"""
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
r"""Reasoning details for extended thinking models"""
audio: Optional[ChatAudioOutput] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"role",
"audio",
"content",
"reasoning",
"refusal",
"tool_calls",
"reasoning_details",
"audio",
"refusal",
"role",
"tool_calls",
]
nullable_fields = ["content", "reasoning", "refusal"]
null_default_fields = []
+15 -15
View File
@@ -6,53 +6,53 @@ from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ChatStreamToolCallType = Literal["function",]
r"""Tool call type"""
class ChatStreamToolCallFunctionTypedDict(TypedDict):
r"""Function call details"""
name: NotRequired[str]
r"""Function name"""
arguments: NotRequired[str]
r"""Function arguments as JSON string"""
name: NotRequired[str]
r"""Function name"""
class ChatStreamToolCallFunction(BaseModel):
r"""Function call details"""
arguments: Optional[str] = None
r"""Function arguments as JSON string"""
name: Optional[str] = None
r"""Function name"""
arguments: Optional[str] = None
r"""Function arguments as JSON string"""
ChatStreamToolCallType = Literal["function",]
r"""Tool call type"""
class ChatStreamToolCallTypedDict(TypedDict):
r"""Tool call delta for streaming responses"""
index: float
index: int
r"""Tool call index in the array"""
function: NotRequired[ChatStreamToolCallFunctionTypedDict]
r"""Function call details"""
id: NotRequired[str]
r"""Tool call identifier"""
type: NotRequired[ChatStreamToolCallType]
r"""Tool call type"""
function: NotRequired[ChatStreamToolCallFunctionTypedDict]
r"""Function call details"""
class ChatStreamToolCall(BaseModel):
r"""Tool call delta for streaming responses"""
index: float
index: int
r"""Tool call index in the array"""
function: Optional[ChatStreamToolCallFunction] = None
r"""Function call details"""
id: Optional[str] = None
r"""Tool call identifier"""
type: Optional[ChatStreamToolCallType] = None
r"""Tool call type"""
function: Optional[ChatStreamToolCallFunction] = None
r"""Function call details"""
@@ -7,9 +7,6 @@ from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
ChatSystemMessageRole = Literal["system",]
ChatSystemMessageContentTypedDict = TypeAliasType(
"ChatSystemMessageContentTypedDict", Union[str, List[ChatContentTextTypedDict]]
)
@@ -22,12 +19,15 @@ ChatSystemMessageContent = TypeAliasType(
r"""System message content"""
ChatSystemMessageRole = Literal["system",]
class ChatSystemMessageTypedDict(TypedDict):
r"""System message for setting behavior"""
role: ChatSystemMessageRole
content: ChatSystemMessageContentTypedDict
r"""System message content"""
role: ChatSystemMessageRole
name: NotRequired[str]
r"""Optional name for the system message"""
@@ -35,10 +35,10 @@ class ChatSystemMessageTypedDict(TypedDict):
class ChatSystemMessage(BaseModel):
r"""System message for setting behavior"""
role: ChatSystemMessageRole
content: ChatSystemMessageContent
r"""System message content"""
role: ChatSystemMessageRole
name: Optional[str] = None
r"""Optional name for the system message"""
+12 -12
View File
@@ -9,17 +9,17 @@ from typing_extensions import Annotated, TypedDict
class ChatTokenLogprobTopLogprobTypedDict(TypedDict):
token: str
bytes_: Nullable[List[int]]
logprob: float
bytes_: Nullable[List[float]]
token: str
class ChatTokenLogprobTopLogprob(BaseModel):
token: str
bytes_: Annotated[Nullable[List[int]], pydantic.Field(alias="bytes")]
logprob: float
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
token: str
@model_serializer(mode="wrap")
def serialize_model(self, handler):
@@ -55,12 +55,12 @@ class ChatTokenLogprobTopLogprob(BaseModel):
class ChatTokenLogprobTypedDict(TypedDict):
r"""Token log probability information"""
token: str
r"""The token"""
bytes_: Nullable[List[int]]
r"""UTF-8 bytes of the token"""
logprob: float
r"""Log probability of the token"""
bytes_: Nullable[List[float]]
r"""UTF-8 bytes of the token"""
token: str
r"""The token"""
top_logprobs: List[ChatTokenLogprobTopLogprobTypedDict]
r"""Top alternative tokens with probabilities"""
@@ -68,14 +68,14 @@ class ChatTokenLogprobTypedDict(TypedDict):
class ChatTokenLogprob(BaseModel):
r"""Token log probability information"""
token: str
r"""The token"""
bytes_: Annotated[Nullable[List[int]], pydantic.Field(alias="bytes")]
r"""UTF-8 bytes of 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"""
token: str
r"""The token"""
top_logprobs: List[ChatTokenLogprobTopLogprob]
r"""Top alternative tokens with probabilities"""
+10 -10
View File
@@ -6,39 +6,39 @@ from typing import Literal
from typing_extensions import TypedDict
ChatToolCallType = Literal["function",]
class ChatToolCallFunctionTypedDict(TypedDict):
name: str
r"""Function name to call"""
arguments: str
r"""Function arguments as JSON string"""
name: str
r"""Function name to call"""
class ChatToolCallFunction(BaseModel):
arguments: str
r"""Function arguments as JSON string"""
name: str
r"""Function name to call"""
arguments: str
r"""Function arguments as JSON string"""
ChatToolCallType = Literal["function",]
class ChatToolCallTypedDict(TypedDict):
r"""Tool call made by the assistant"""
function: ChatToolCallFunctionTypedDict
id: str
r"""Tool call identifier"""
type: ChatToolCallType
function: ChatToolCallFunctionTypedDict
class ChatToolCall(BaseModel):
r"""Tool call made by the assistant"""
function: ChatToolCallFunction
id: str
r"""Tool call identifier"""
type: ChatToolCallType
function: ChatToolCallFunction
+6 -6
View File
@@ -7,9 +7,6 @@ from typing import List, Literal, Union
from typing_extensions import TypeAliasType, TypedDict
ChatToolMessageRole = Literal["tool",]
ChatToolMessageContentTypedDict = TypeAliasType(
"ChatToolMessageContentTypedDict", Union[str, List[ChatContentItemsTypedDict]]
)
@@ -22,12 +19,15 @@ ChatToolMessageContent = TypeAliasType(
r"""Tool response content"""
ChatToolMessageRole = Literal["tool",]
class ChatToolMessageTypedDict(TypedDict):
r"""Tool response message"""
role: ChatToolMessageRole
content: ChatToolMessageContentTypedDict
r"""Tool response content"""
role: ChatToolMessageRole
tool_call_id: str
r"""ID of the assistant message tool call this message responds to"""
@@ -35,10 +35,10 @@ class ChatToolMessageTypedDict(TypedDict):
class ChatToolMessage(BaseModel):
r"""Tool response message"""
role: ChatToolMessageRole
content: ChatToolMessageContent
r"""Tool response content"""
role: ChatToolMessageRole
tool_call_id: str
r"""ID of the assistant message tool call this message responds to"""
+38 -38
View File
@@ -16,43 +16,43 @@ 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]]
accepted_prediction_tokens: NotRequired[Nullable[int]]
r"""Accepted prediction tokens"""
rejected_prediction_tokens: NotRequired[Nullable[float]]
audio_tokens: NotRequired[Nullable[int]]
r"""Tokens used for audio output"""
reasoning_tokens: NotRequired[Nullable[int]]
r"""Tokens used for reasoning"""
rejected_prediction_tokens: NotRequired[Nullable[int]]
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
accepted_prediction_tokens: OptionalNullable[int] = UNSET
r"""Accepted prediction tokens"""
rejected_prediction_tokens: OptionalNullable[float] = UNSET
audio_tokens: OptionalNullable[int] = UNSET
r"""Tokens used for audio output"""
reasoning_tokens: OptionalNullable[int] = UNSET
r"""Tokens used for reasoning"""
rejected_prediction_tokens: OptionalNullable[int] = UNSET
r"""Rejected prediction tokens"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"reasoning_tokens",
"audio_tokens",
"accepted_prediction_tokens",
"audio_tokens",
"reasoning_tokens",
"rejected_prediction_tokens",
]
nullable_fields = [
"reasoning_tokens",
"audio_tokens",
"accepted_prediction_tokens",
"audio_tokens",
"reasoning_tokens",
"rejected_prediction_tokens",
]
null_default_fields = []
@@ -85,40 +85,40 @@ class CompletionTokensDetails(BaseModel):
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]
audio_tokens: NotRequired[int]
r"""Audio input tokens"""
video_tokens: NotRequired[float]
cache_write_tokens: NotRequired[int]
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
cached_tokens: NotRequired[int]
r"""Cached prompt tokens"""
video_tokens: NotRequired[int]
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
audio_tokens: Optional[int] = None
r"""Audio input tokens"""
video_tokens: Optional[float] = None
cache_write_tokens: Optional[int] = None
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
cached_tokens: Optional[int] = None
r"""Cached prompt tokens"""
video_tokens: Optional[int] = None
r"""Video input tokens"""
class ChatUsageTypedDict(TypedDict):
r"""Token usage statistics"""
completion_tokens: float
completion_tokens: int
r"""Number of tokens in the completion"""
prompt_tokens: float
prompt_tokens: int
r"""Number of tokens in the prompt"""
total_tokens: float
total_tokens: int
r"""Total number of tokens"""
completion_tokens_details: NotRequired[Nullable[CompletionTokensDetailsTypedDict]]
r"""Detailed completion token usage"""
@@ -129,13 +129,13 @@ class ChatUsageTypedDict(TypedDict):
class ChatUsage(BaseModel):
r"""Token usage statistics"""
completion_tokens: float
completion_tokens: int
r"""Number of tokens in the completion"""
prompt_tokens: float
prompt_tokens: int
r"""Number of tokens in the prompt"""
total_tokens: float
total_tokens: int
r"""Total number of tokens"""
completion_tokens_details: OptionalNullable[CompletionTokensDetails] = UNSET
+6 -6
View File
@@ -7,9 +7,6 @@ from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
ChatUserMessageRole = Literal["user",]
ChatUserMessageContentTypedDict = TypeAliasType(
"ChatUserMessageContentTypedDict", Union[str, List[ChatContentItemsTypedDict]]
)
@@ -22,12 +19,15 @@ ChatUserMessageContent = TypeAliasType(
r"""User message content"""
ChatUserMessageRole = Literal["user",]
class ChatUserMessageTypedDict(TypedDict):
r"""User message"""
role: ChatUserMessageRole
content: ChatUserMessageContentTypedDict
r"""User message content"""
role: ChatUserMessageRole
name: NotRequired[str]
r"""Optional name for the user"""
@@ -35,10 +35,10 @@ class ChatUserMessageTypedDict(TypedDict):
class ChatUserMessage(BaseModel):
r"""User message"""
role: ChatUserMessageRole
content: ChatUserMessageContent
r"""User message content"""
role: ChatUserMessageRole
name: Optional[str] = None
r"""Optional name for the user"""
@@ -1,123 +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 List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatWebSearchServerToolTypeOpenrouterWebSearch = Literal["openrouter:web_search",]
ChatWebSearchServerToolEngine = Union[
Literal[
"auto",
"native",
"exa",
"firecrawl",
"parallel",
],
UnrecognizedStr,
]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
ChatWebSearchServerToolSearchContextSize = Union[
Literal[
"low",
"medium",
"high",
],
UnrecognizedStr,
]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
ChatWebSearchServerToolParametersType = Literal["approximate",]
class ChatWebSearchServerToolUserLocationTypedDict(TypedDict):
r"""Approximate user location for location-biased results."""
type: NotRequired[ChatWebSearchServerToolParametersType]
city: NotRequired[str]
region: NotRequired[str]
country: NotRequired[str]
timezone: NotRequired[str]
class ChatWebSearchServerToolUserLocation(BaseModel):
r"""Approximate user location for location-biased results."""
type: Optional[ChatWebSearchServerToolParametersType] = None
city: Optional[str] = None
region: Optional[str] = None
country: Optional[str] = None
timezone: Optional[str] = None
class ChatWebSearchServerToolParametersTypedDict(TypedDict):
engine: NotRequired[ChatWebSearchServerToolEngine]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: NotRequired[float]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: NotRequired[float]
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
search_context_size: NotRequired[ChatWebSearchServerToolSearchContextSize]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: NotRequired[ChatWebSearchServerToolUserLocationTypedDict]
r"""Approximate user location for location-biased results."""
allowed_domains: NotRequired[List[str]]
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
excluded_domains: NotRequired[List[str]]
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
class ChatWebSearchServerToolParameters(BaseModel):
engine: Annotated[
Optional[ChatWebSearchServerToolEngine],
PlainValidator(validate_open_enum(False)),
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: Optional[float] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: Optional[float] = None
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
search_context_size: Annotated[
Optional[ChatWebSearchServerToolSearchContextSize],
PlainValidator(validate_open_enum(False)),
] = None
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: Optional[ChatWebSearchServerToolUserLocation] = None
r"""Approximate user location for location-biased results."""
allowed_domains: Optional[List[str]] = None
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
excluded_domains: Optional[List[str]] = None
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
class ChatWebSearchServerToolTypedDict(TypedDict):
r"""OpenRouter built-in server tool: searches the web for current information"""
type: ChatWebSearchServerToolTypeOpenrouterWebSearch
parameters: NotRequired[ChatWebSearchServerToolParametersTypedDict]
class ChatWebSearchServerTool(BaseModel):
r"""OpenRouter built-in server tool: searches the web for current information"""
type: ChatWebSearchServerToolTypeOpenrouterWebSearch
parameters: Optional[ChatWebSearchServerToolParameters] = None
@@ -1,6 +1,13 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .searchqualitylevel import SearchQualityLevel
from .websearchconfig import WebSearchConfig, WebSearchConfigTypedDict
from .websearchengineenum import WebSearchEngineEnum
from .websearchuserlocationservertool import (
WebSearchUserLocationServerTool,
WebSearchUserLocationServerToolTypedDict,
)
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
@@ -19,173 +26,25 @@ ChatWebSearchShorthandType = Union[
]
ChatWebSearchShorthandEngine = Union[
Literal[
"auto",
"native",
"exa",
"firecrawl",
"parallel",
],
UnrecognizedStr,
]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
ChatWebSearchShorthandSearchContextSize = Union[
Literal[
"low",
"medium",
"high",
],
UnrecognizedStr,
]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
ChatWebSearchShorthandTypeApproximate = Literal["approximate",]
class ChatWebSearchShorthandUserLocationTypedDict(TypedDict):
r"""Approximate user location for location-biased results."""
type: NotRequired[ChatWebSearchShorthandTypeApproximate]
city: NotRequired[str]
region: NotRequired[str]
country: NotRequired[str]
timezone: NotRequired[str]
class ChatWebSearchShorthandUserLocation(BaseModel):
r"""Approximate user location for location-biased results."""
type: Optional[ChatWebSearchShorthandTypeApproximate] = None
city: Optional[str] = None
region: Optional[str] = None
country: Optional[str] = None
timezone: Optional[str] = None
ChatWebSearchShorthandParametersEngine = Union[
Literal[
"auto",
"native",
"exa",
"firecrawl",
"parallel",
],
UnrecognizedStr,
]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
ChatWebSearchShorthandParametersSearchContextSize = Union[
Literal[
"low",
"medium",
"high",
],
UnrecognizedStr,
]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
ChatWebSearchShorthandParametersType = Literal["approximate",]
class ChatWebSearchShorthandParametersUserLocationTypedDict(TypedDict):
r"""Approximate user location for location-biased results."""
type: NotRequired[ChatWebSearchShorthandParametersType]
city: NotRequired[str]
region: NotRequired[str]
country: NotRequired[str]
timezone: NotRequired[str]
class ChatWebSearchShorthandParametersUserLocation(BaseModel):
r"""Approximate user location for location-biased results."""
type: Optional[ChatWebSearchShorthandParametersType] = None
city: Optional[str] = None
region: Optional[str] = None
country: Optional[str] = None
timezone: Optional[str] = None
class ChatWebSearchShorthandParametersTypedDict(TypedDict):
engine: NotRequired[ChatWebSearchShorthandParametersEngine]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: NotRequired[float]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: NotRequired[float]
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
search_context_size: NotRequired[ChatWebSearchShorthandParametersSearchContextSize]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: NotRequired[ChatWebSearchShorthandParametersUserLocationTypedDict]
r"""Approximate user location for location-biased results."""
allowed_domains: NotRequired[List[str]]
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
excluded_domains: NotRequired[List[str]]
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
class ChatWebSearchShorthandParameters(BaseModel):
engine: Annotated[
Optional[ChatWebSearchShorthandParametersEngine],
PlainValidator(validate_open_enum(False)),
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: Optional[float] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: Optional[float] = None
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
search_context_size: Annotated[
Optional[ChatWebSearchShorthandParametersSearchContextSize],
PlainValidator(validate_open_enum(False)),
] = None
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: Optional[ChatWebSearchShorthandParametersUserLocation] = None
r"""Approximate user location for location-biased results."""
allowed_domains: Optional[List[str]] = None
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
excluded_domains: Optional[List[str]] = None
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
class ChatWebSearchShorthandTypedDict(TypedDict):
r"""Web search tool using OpenAI Responses API syntax. Automatically converted to openrouter:web_search."""
type: ChatWebSearchShorthandType
engine: NotRequired[ChatWebSearchShorthandEngine]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: NotRequired[float]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: NotRequired[float]
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
search_context_size: NotRequired[ChatWebSearchShorthandSearchContextSize]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: NotRequired[ChatWebSearchShorthandUserLocationTypedDict]
r"""Approximate user location for location-biased results."""
allowed_domains: NotRequired[List[str]]
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
r"""Limit search results to these domains. Supported by Exa, Parallel, and most native providers (Anthropic, OpenAI, xAI). Not supported with Firecrawl or Perplexity."""
engine: NotRequired[WebSearchEngineEnum]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
excluded_domains: NotRequired[List[str]]
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
parameters: NotRequired[ChatWebSearchShorthandParametersTypedDict]
r"""Exclude search results from these domains. Supported by Exa, Parallel, Anthropic, and xAI. Not supported with Firecrawl, OpenAI (silently ignored), or Perplexity."""
max_results: NotRequired[int]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: NotRequired[int]
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
parameters: NotRequired[WebSearchConfigTypedDict]
search_context_size: NotRequired[SearchQualityLevel]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: NotRequired[WebSearchUserLocationServerToolTypedDict]
r"""Approximate user location for location-biased results."""
class ChatWebSearchShorthand(BaseModel):
@@ -195,31 +54,29 @@ class ChatWebSearchShorthand(BaseModel):
ChatWebSearchShorthandType, PlainValidator(validate_open_enum(False))
]
allowed_domains: Optional[List[str]] = None
r"""Limit search results to these domains. Supported by Exa, Parallel, and most native providers (Anthropic, OpenAI, xAI). Not supported with Firecrawl or Perplexity."""
engine: Annotated[
Optional[ChatWebSearchShorthandEngine],
PlainValidator(validate_open_enum(False)),
Optional[WebSearchEngineEnum], PlainValidator(validate_open_enum(False))
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: Optional[float] = None
excluded_domains: Optional[List[str]] = None
r"""Exclude search results from these domains. Supported by Exa, Parallel, Anthropic, and xAI. Not supported with Firecrawl, OpenAI (silently ignored), or Perplexity."""
max_results: Optional[int] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: Optional[float] = None
max_total_results: Optional[int] = None
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
parameters: Optional[WebSearchConfig] = None
search_context_size: Annotated[
Optional[ChatWebSearchShorthandSearchContextSize],
PlainValidator(validate_open_enum(False)),
Optional[SearchQualityLevel], PlainValidator(validate_open_enum(False))
] = None
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: Optional[ChatWebSearchShorthandUserLocation] = None
user_location: Optional[WebSearchUserLocationServerTool] = None
r"""Approximate user location for location-biased results."""
allowed_domains: Optional[List[str]] = None
r"""Limit search results to these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
excluded_domains: Optional[List[str]] = None
r"""Exclude search results from these domains. Applies to Exa and Parallel engines. Not supported with Firecrawl or native provider search."""
parameters: Optional[ChatWebSearchShorthandParameters] = None
@@ -16,12 +16,6 @@ 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",
@@ -33,6 +27,9 @@ MemoryLimit = Union[
]
ContainerType = Literal["auto",]
class ContainerAutoTypedDict(TypedDict):
type: ContainerType
file_ids: NotRequired[List[str]]
@@ -87,16 +84,19 @@ ContainerTypedDict = TypeAliasType(
Container = TypeAliasType("Container", Union[ContainerAuto, str])
TypeCodeInterpreter = Literal["code_interpreter",]
class CodeInterpreterServerToolTypedDict(TypedDict):
r"""Code interpreter tool configuration"""
type: TypeCodeInterpreter
container: ContainerTypedDict
type: TypeCodeInterpreter
class CodeInterpreterServerTool(BaseModel):
r"""Code interpreter tool configuration"""
type: TypeCodeInterpreter
container: Container
type: TypeCodeInterpreter
+3 -3
View File
@@ -20,13 +20,13 @@ CompoundFilterType = Union[
class CompoundFilterTypedDict(TypedDict):
r"""A compound filter that combines multiple comparison or compound filters"""
type: CompoundFilterType
filters: List[Dict[str, Nullable[Any]]]
type: CompoundFilterType
class CompoundFilter(BaseModel):
r"""A compound filter that combines multiple comparison or compound filters"""
type: Annotated[CompoundFilterType, PlainValidator(validate_open_enum(False))]
filters: List[Dict[str, Nullable[Any]]]
type: Annotated[CompoundFilterType, PlainValidator(validate_open_enum(False))]
@@ -8,9 +8,6 @@ from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
ComputerUseServerToolType = Literal["computer_use_preview",]
Environment = Union[
Literal[
"windows",
@@ -23,22 +20,25 @@ Environment = Union[
]
ComputerUseServerToolType = Literal["computer_use_preview",]
class ComputerUseServerToolTypedDict(TypedDict):
r"""Computer use preview tool configuration"""
type: ComputerUseServerToolType
display_height: float
display_width: float
display_height: int
display_width: int
environment: Environment
type: ComputerUseServerToolType
class ComputerUseServerTool(BaseModel):
r"""Computer use preview tool configuration"""
type: ComputerUseServerToolType
display_height: int
display_height: float
display_width: float
display_width: int
environment: Annotated[Environment, PlainValidator(validate_open_enum(False))]
type: ComputerUseServerToolType
@@ -14,9 +14,6 @@ from typing import Literal, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict
ContentPartAddedEventType = Literal["response.content_part.added",]
ContentPartAddedEventPartTypedDict = TypeAliasType(
"ContentPartAddedEventPartTypedDict",
Union[
@@ -37,28 +34,31 @@ ContentPartAddedEventPart = Annotated[
]
ContentPartAddedEventType = Literal["response.content_part.added",]
class ContentPartAddedEventTypedDict(TypedDict):
r"""Event emitted when a new content part is added to an output item"""
type: ContentPartAddedEventType
output_index: float
content_index: int
item_id: str
content_index: float
output_index: int
part: ContentPartAddedEventPartTypedDict
sequence_number: float
sequence_number: int
type: ContentPartAddedEventType
class ContentPartAddedEvent(BaseModel):
r"""Event emitted when a new content part is added to an output item"""
type: ContentPartAddedEventType
output_index: float
content_index: int
item_id: str
content_index: float
output_index: int
part: ContentPartAddedEventPart
sequence_number: float
sequence_number: int
type: ContentPartAddedEventType
@@ -14,9 +14,6 @@ from typing import Literal, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict
ContentPartDoneEventType = Literal["response.content_part.done",]
ContentPartDoneEventPartTypedDict = TypeAliasType(
"ContentPartDoneEventPartTypedDict",
Union[
@@ -37,28 +34,31 @@ ContentPartDoneEventPart = Annotated[
]
ContentPartDoneEventType = Literal["response.content_part.done",]
class ContentPartDoneEventTypedDict(TypedDict):
r"""Event emitted when a content part is complete"""
type: ContentPartDoneEventType
output_index: float
content_index: int
item_id: str
content_index: float
output_index: int
part: ContentPartDoneEventPartTypedDict
sequence_number: float
sequence_number: int
type: ContentPartDoneEventType
class ContentPartDoneEvent(BaseModel):
r"""Event emitted when a content part is complete"""
type: ContentPartDoneEventType
output_index: float
content_index: int
item_id: str
content_index: float
output_index: int
part: ContentPartDoneEventPart
sequence_number: float
sequence_number: int
type: ContentPartDoneEventType
@@ -0,0 +1,28 @@
"""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
class ContentPartImageImageURLTypedDict(TypedDict):
url: str
class ContentPartImageImageURL(BaseModel):
url: str
ContentPartImageType = Literal["image_url",]
class ContentPartImageTypedDict(TypedDict):
image_url: ContentPartImageImageURLTypedDict
type: ContentPartImageType
class ContentPartImage(BaseModel):
image_url: ContentPartImageImageURL
type: ContentPartImageType
@@ -0,0 +1,28 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .contextcompressionengine import ContextCompressionEngine
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ContextCompressionPluginID = Literal["context-compression",]
class ContextCompressionPluginTypedDict(TypedDict):
id: ContextCompressionPluginID
enabled: NotRequired[bool]
r"""Set to false to disable the context-compression plugin for this request. Defaults to true."""
engine: NotRequired[ContextCompressionEngine]
r"""The compression engine to use. Defaults to \"middle-out\"."""
class ContextCompressionPlugin(BaseModel):
id: ContextCompressionPluginID
enabled: Optional[bool] = None
r"""Set to false to disable the context-compression plugin for this request. Defaults to true."""
engine: Optional[ContextCompressionEngine] = None
r"""The compression engine to use. Defaults to \"middle-out\"."""
@@ -0,0 +1,116 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .guardrailinterval import GuardrailInterval
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
from typing_extensions import Annotated, NotRequired, TypedDict
class CreateGuardrailRequestTypedDict(TypedDict):
name: str
r"""Name for the new guardrail"""
allowed_models: NotRequired[Nullable[List[str]]]
r"""Array of model identifiers (slug or canonical_slug accepted)"""
allowed_providers: NotRequired[Nullable[List[str]]]
r"""List of allowed provider IDs"""
description: NotRequired[Nullable[str]]
r"""Description of the guardrail"""
enforce_zdr: NotRequired[Nullable[bool]]
r"""Whether to enforce zero data retention"""
ignored_models: NotRequired[Nullable[List[str]]]
r"""Array of model identifiers to exclude from routing (slug or canonical_slug accepted)"""
ignored_providers: NotRequired[Nullable[List[str]]]
r"""List of provider IDs to exclude from routing"""
limit_usd: NotRequired[Nullable[float]]
r"""Spending limit in USD"""
reset_interval: NotRequired[Nullable[GuardrailInterval]]
r"""Interval at which the limit resets (daily, weekly, monthly)"""
class CreateGuardrailRequest(BaseModel):
name: str
r"""Name for the new guardrail"""
allowed_models: OptionalNullable[List[str]] = UNSET
r"""Array of model identifiers (slug or canonical_slug accepted)"""
allowed_providers: OptionalNullable[List[str]] = UNSET
r"""List of allowed provider IDs"""
description: OptionalNullable[str] = UNSET
r"""Description of the guardrail"""
enforce_zdr: OptionalNullable[bool] = UNSET
r"""Whether to enforce zero data retention"""
ignored_models: OptionalNullable[List[str]] = UNSET
r"""Array of model identifiers to exclude from routing (slug or canonical_slug accepted)"""
ignored_providers: OptionalNullable[List[str]] = UNSET
r"""List of provider IDs to exclude from routing"""
limit_usd: OptionalNullable[float] = UNSET
r"""Spending limit in USD"""
reset_interval: Annotated[
OptionalNullable[GuardrailInterval], PlainValidator(validate_open_enum(False))
] = UNSET
r"""Interval at which the limit resets (daily, weekly, monthly)"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allowed_models",
"allowed_providers",
"description",
"enforce_zdr",
"ignored_models",
"ignored_providers",
"limit_usd",
"reset_interval",
]
nullable_fields = [
"allowed_models",
"allowed_providers",
"description",
"enforce_zdr",
"ignored_models",
"ignored_providers",
"limit_usd",
"reset_interval",
]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
@@ -0,0 +1,14 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .guardrail import Guardrail, GuardrailTypedDict
from openrouter.types import BaseModel
from typing_extensions import TypedDict
class CreateGuardrailResponseTypedDict(TypedDict):
data: GuardrailTypedDict
class CreateGuardrailResponse(BaseModel):
data: Guardrail
+12 -12
View File
@@ -10,12 +10,6 @@ from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeCustom = Literal["custom",]
FormatTypeGrammar = Literal["grammar",]
Syntax = Union[
Literal[
"lark",
@@ -25,19 +19,22 @@ Syntax = Union[
]
FormatTypeGrammar = Literal["grammar",]
class FormatGrammarTypedDict(TypedDict):
type: FormatTypeGrammar
definition: str
syntax: Syntax
type: FormatTypeGrammar
class FormatGrammar(BaseModel):
type: FormatTypeGrammar
definition: str
syntax: Annotated[Syntax, PlainValidator(validate_open_enum(False))]
type: FormatTypeGrammar
FormatTypeText = Literal["text",]
@@ -61,11 +58,14 @@ Format = Annotated[
]
TypeCustom = Literal["custom",]
class CustomToolTypedDict(TypedDict):
r"""Custom tool configuration"""
type: TypeCustom
name: str
type: TypeCustom
description: NotRequired[str]
format_: NotRequired[FormatTypedDict]
@@ -73,10 +73,10 @@ class CustomToolTypedDict(TypedDict):
class CustomTool(BaseModel):
r"""Custom tool configuration"""
type: TypeCustom
name: str
type: TypeCustom
description: Optional[str] = None
format_: Annotated[Optional[Format], pydantic.Field(alias="format")] = None
@@ -1,19 +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
DataCollection = Union[
Literal[
"deny",
"allow",
],
UnrecognizedStr,
]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
@@ -1,6 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .datetimeservertoolconfig import (
DatetimeServerToolConfig,
DatetimeServerToolConfigTypedDict,
)
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
@@ -9,21 +13,12 @@ from typing_extensions import NotRequired, TypedDict
DatetimeServerToolType = Literal["openrouter:datetime",]
class DatetimeServerToolParametersTypedDict(TypedDict):
timezone: NotRequired[str]
r"""IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC."""
class DatetimeServerToolParameters(BaseModel):
timezone: Optional[str] = None
r"""IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC."""
class DatetimeServerToolTypedDict(TypedDict):
r"""OpenRouter built-in server tool: returns the current date and time"""
type: DatetimeServerToolType
parameters: NotRequired[DatetimeServerToolParametersTypedDict]
parameters: NotRequired[DatetimeServerToolConfigTypedDict]
r"""Configuration for the openrouter:datetime server tool"""
class DatetimeServerTool(BaseModel):
@@ -31,4 +26,5 @@ class DatetimeServerTool(BaseModel):
type: DatetimeServerToolType
parameters: Optional[DatetimeServerToolParameters] = None
parameters: Optional[DatetimeServerToolConfig] = None
r"""Configuration for the openrouter:datetime server tool"""
@@ -0,0 +1,20 @@
"""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 DatetimeServerToolConfigTypedDict(TypedDict):
r"""Configuration for the openrouter:datetime server tool"""
timezone: NotRequired[str]
r"""IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC."""
class DatetimeServerToolConfig(BaseModel):
r"""Configuration for the openrouter:datetime server tool"""
timezone: Optional[str] = None
r"""IANA timezone name (e.g. \"America/New_York\"). Defaults to UTC."""
+15 -15
View File
@@ -15,46 +15,46 @@ from typing_extensions import NotRequired, TypedDict
class DefaultParametersTypedDict(TypedDict):
r"""Default parameters for this model"""
temperature: NotRequired[Nullable[float]]
top_p: NotRequired[Nullable[float]]
top_k: NotRequired[Nullable[int]]
frequency_penalty: NotRequired[Nullable[float]]
presence_penalty: NotRequired[Nullable[float]]
repetition_penalty: NotRequired[Nullable[float]]
temperature: NotRequired[Nullable[float]]
top_k: NotRequired[Nullable[int]]
top_p: NotRequired[Nullable[float]]
class DefaultParameters(BaseModel):
r"""Default parameters for this model"""
temperature: OptionalNullable[float] = UNSET
top_p: OptionalNullable[float] = UNSET
top_k: OptionalNullable[int] = UNSET
frequency_penalty: OptionalNullable[float] = UNSET
presence_penalty: OptionalNullable[float] = UNSET
repetition_penalty: OptionalNullable[float] = UNSET
temperature: OptionalNullable[float] = UNSET
top_k: OptionalNullable[int] = UNSET
top_p: OptionalNullable[float] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"temperature",
"top_p",
"top_k",
"frequency_penalty",
"presence_penalty",
"repetition_penalty",
"temperature",
"top_k",
"top_p",
]
nullable_fields = [
"temperature",
"top_p",
"top_k",
"frequency_penalty",
"presence_penalty",
"repetition_penalty",
"temperature",
"top_k",
"top_p",
]
null_default_fields = []
@@ -0,0 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel
from openrouter.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import Literal
from typing_extensions import Annotated, TypedDict
class DeleteGuardrailResponseTypedDict(TypedDict):
deleted: Literal[True]
r"""Confirmation that the guardrail was deleted"""
class DeleteGuardrailResponse(BaseModel):
DELETED: Annotated[
Annotated[Literal[True], AfterValidator(validate_const(True))],
pydantic.Field(alias="deleted"),
] = True
r"""Confirmation that the guardrail was deleted"""
+47 -47
View File
@@ -20,46 +20,6 @@ from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
EasyInputMessageTypeMessage = Literal["message",]
EasyInputMessageRoleDeveloper = Literal["developer",]
EasyInputMessageRoleAssistant = Literal["assistant",]
EasyInputMessageRoleSystem = Literal["system",]
EasyInputMessageRoleUser = Literal["user",]
EasyInputMessageRoleUnionTypedDict = TypeAliasType(
"EasyInputMessageRoleUnionTypedDict",
Union[
EasyInputMessageRoleUser,
EasyInputMessageRoleSystem,
EasyInputMessageRoleAssistant,
EasyInputMessageRoleDeveloper,
],
)
EasyInputMessageRoleUnion = TypeAliasType(
"EasyInputMessageRoleUnion",
Union[
EasyInputMessageRoleUser,
EasyInputMessageRoleSystem,
EasyInputMessageRoleAssistant,
EasyInputMessageRoleDeveloper,
],
)
EasyInputMessageContentType = Literal["input_image",]
EasyInputMessageDetail = Union[
Literal[
"auto",
@@ -70,21 +30,24 @@ EasyInputMessageDetail = Union[
]
EasyInputMessageContentType = Literal["input_image",]
class EasyInputMessageContentInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: EasyInputMessageContentType
detail: EasyInputMessageDetail
type: EasyInputMessageContentType
image_url: NotRequired[Nullable[str]]
class EasyInputMessageContentInputImage(BaseModel):
r"""Image input content item"""
type: EasyInputMessageContentType
detail: Annotated[EasyInputMessageDetail, PlainValidator(validate_open_enum(False))]
type: EasyInputMessageContentType
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
@@ -174,27 +137,64 @@ EasyInputMessagePhaseUnion = TypeAliasType(
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."""
EasyInputMessageRoleDeveloper = Literal["developer",]
EasyInputMessageRoleAssistant = Literal["assistant",]
EasyInputMessageRoleSystem = Literal["system",]
EasyInputMessageRoleUser = Literal["user",]
EasyInputMessageRoleUnionTypedDict = TypeAliasType(
"EasyInputMessageRoleUnionTypedDict",
Union[
EasyInputMessageRoleUser,
EasyInputMessageRoleSystem,
EasyInputMessageRoleAssistant,
EasyInputMessageRoleDeveloper,
],
)
EasyInputMessageRoleUnion = TypeAliasType(
"EasyInputMessageRoleUnion",
Union[
EasyInputMessageRoleUser,
EasyInputMessageRoleSystem,
EasyInputMessageRoleAssistant,
EasyInputMessageRoleDeveloper,
],
)
EasyInputMessageTypeMessage = Literal["message",]
class EasyInputMessageTypedDict(TypedDict):
role: EasyInputMessageRoleUnionTypedDict
type: NotRequired[EasyInputMessageTypeMessage]
content: NotRequired[Nullable[EasyInputMessageContentUnion2TypedDict]]
phase: NotRequired[Nullable[EasyInputMessagePhaseUnionTypedDict]]
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."""
type: NotRequired[EasyInputMessageTypeMessage]
class EasyInputMessage(BaseModel):
role: EasyInputMessageRoleUnion
type: Optional[EasyInputMessageTypeMessage] = None
content: OptionalNullable[EasyInputMessageContentUnion2] = UNSET
phase: OptionalNullable[EasyInputMessagePhaseUnion] = 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."""
type: Optional[EasyInputMessageTypeMessage] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["type", "content", "phase"]
optional_fields = ["content", "phase", "type"]
nullable_fields = ["content", "phase"]
null_default_fields = []
+5 -5
View File
@@ -13,25 +13,25 @@ ErrorEventType = Literal["error",]
class ErrorEventTypedDict(TypedDict):
r"""Event emitted when an error occurs during streaming"""
type: ErrorEventType
code: Nullable[str]
message: str
param: Nullable[str]
sequence_number: float
sequence_number: int
type: ErrorEventType
class ErrorEvent(BaseModel):
r"""Event emitted when an error occurs during streaming"""
type: ErrorEventType
code: Nullable[str]
message: str
param: Nullable[str]
sequence_number: float
sequence_number: int
type: ErrorEventType
@model_serializer(mode="wrap")
def serialize_model(self, handler):
+5 -5
View File
@@ -10,17 +10,17 @@ FileCitationType = Literal["file_citation",]
class FileCitationTypedDict(TypedDict):
type: FileCitationType
file_id: str
filename: str
index: float
index: int
type: FileCitationType
class FileCitation(BaseModel):
type: FileCitationType
file_id: str
filename: str
index: float
index: int
type: FileCitationType
@@ -0,0 +1,28 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
FileParserPluginID = Literal["file-parser",]
class FileParserPluginTypedDict(TypedDict):
id: FileParserPluginID
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 FileParserPlugin(BaseModel):
id: FileParserPluginID
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."""
+5 -5
View File
@@ -10,14 +10,14 @@ FilePathType = Literal["file_path",]
class FilePathTypedDict(TypedDict):
type: FilePathType
file_id: str
index: float
index: int
type: FilePathType
class FilePath(BaseModel):
type: FilePathType
file_id: str
index: float
index: int
type: FilePathType
@@ -17,9 +17,6 @@ from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
TypeFileSearch = Literal["file_search",]
FiltersType = Union[
Literal[
"eq",
@@ -47,13 +44,13 @@ Value2TypedDict = TypeAliasType(
Value2 = TypeAliasType("Value2", Union[str, float, bool, List[Value1]])
class FileSearchServerToolFiltersTypedDict(TypedDict):
class FiltersTypedDict(TypedDict):
key: str
type: FiltersType
value: Value2TypedDict
class FileSearchServerToolFilters(BaseModel):
class Filters(BaseModel):
key: str
type: Annotated[FiltersType, PlainValidator(validate_open_enum(False))]
@@ -61,15 +58,12 @@ class FileSearchServerToolFilters(BaseModel):
value: Value2
FiltersTypedDict = TypeAliasType(
"FiltersTypedDict",
Union[CompoundFilterTypedDict, FileSearchServerToolFiltersTypedDict, Any],
FiltersUnionTypedDict = TypeAliasType(
"FiltersUnionTypedDict", Union[CompoundFilterTypedDict, FiltersTypedDict, Any]
)
Filters = TypeAliasType(
"Filters", Union[CompoundFilter, FileSearchServerToolFilters, Any]
)
FiltersUnion = TypeAliasType("FiltersUnion", Union[CompoundFilter, Filters, Any])
Ranker = Union[
@@ -94,12 +88,15 @@ class RankingOptions(BaseModel):
score_threshold: Optional[float] = None
TypeFileSearch = Literal["file_search",]
class FileSearchServerToolTypedDict(TypedDict):
r"""File search tool configuration"""
type: TypeFileSearch
vector_store_ids: List[str]
filters: NotRequired[Nullable[FiltersTypedDict]]
filters: NotRequired[Nullable[FiltersUnionTypedDict]]
max_num_results: NotRequired[int]
ranking_options: NotRequired[RankingOptionsTypedDict]
@@ -111,7 +108,7 @@ class FileSearchServerTool(BaseModel):
vector_store_ids: List[str]
filters: OptionalNullable[Filters] = UNSET
filters: OptionalNullable[FiltersUnion] = UNSET
max_num_results: Optional[int] = None
@@ -20,9 +20,9 @@ FormatJSONSchemaConfigType = Literal["json_schema",]
class FormatJSONSchemaConfigTypedDict(TypedDict):
r"""JSON schema constrained response format"""
type: FormatJSONSchemaConfigType
name: str
schema_: Dict[str, Nullable[Any]]
type: FormatJSONSchemaConfigType
description: NotRequired[str]
strict: NotRequired[Nullable[bool]]
@@ -30,12 +30,12 @@ class FormatJSONSchemaConfigTypedDict(TypedDict):
class FormatJSONSchemaConfig(BaseModel):
r"""JSON schema constrained response format"""
type: FormatJSONSchemaConfigType
name: str
schema_: Annotated[Dict[str, Nullable[Any]], pydantic.Field(alias="schema")]
type: FormatJSONSchemaConfigType
description: Optional[str] = None
strict: OptionalNullable[bool] = UNSET
+45
View File
@@ -0,0 +1,45 @@
"""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
class FrameImageImageURLTypedDict(TypedDict):
url: str
class FrameImageImageURL(BaseModel):
url: str
FrameImageType = Literal["image_url",]
FrameType = Union[
Literal[
"first_frame",
"last_frame",
],
UnrecognizedStr,
]
r"""Whether this image represents the first or last frame of the video"""
class FrameImageTypedDict(TypedDict):
image_url: FrameImageImageURLTypedDict
type: FrameImageType
frame_type: FrameType
r"""Whether this image represents the first or last frame of the video"""
class FrameImage(BaseModel):
image_url: FrameImageImageURL
type: FrameImageType
frame_type: Annotated[FrameType, PlainValidator(validate_open_enum(False))]
r"""Whether this image represents the first or last frame of the video"""
@@ -12,22 +12,22 @@ FunctionCallArgsDeltaEventType = Literal["response.function_call_arguments.delta
class FunctionCallArgsDeltaEventTypedDict(TypedDict):
r"""Event emitted when function call arguments are being streamed"""
type: FunctionCallArgsDeltaEventType
item_id: str
output_index: float
delta: str
sequence_number: float
item_id: str
output_index: int
sequence_number: int
type: FunctionCallArgsDeltaEventType
class FunctionCallArgsDeltaEvent(BaseModel):
r"""Event emitted when function call arguments are being streamed"""
type: FunctionCallArgsDeltaEventType
delta: str
item_id: str
output_index: float
output_index: int
delta: str
sequence_number: int
sequence_number: float
type: FunctionCallArgsDeltaEventType
@@ -12,25 +12,25 @@ FunctionCallArgsDoneEventType = Literal["response.function_call_arguments.done",
class FunctionCallArgsDoneEventTypedDict(TypedDict):
r"""Event emitted when function call arguments streaming is complete"""
type: FunctionCallArgsDoneEventType
item_id: str
output_index: float
name: str
arguments: str
sequence_number: float
item_id: str
name: str
output_index: int
sequence_number: int
type: FunctionCallArgsDoneEventType
class FunctionCallArgsDoneEvent(BaseModel):
r"""Event emitted when function call arguments streaming is complete"""
type: FunctionCallArgsDoneEventType
arguments: str
item_id: str
output_index: float
name: str
arguments: str
output_index: int
sequence_number: float
sequence_number: int
type: FunctionCallArgsDoneEventType
+14 -51
View File
@@ -1,18 +1,11 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .toolcallstatusenum import ToolCallStatusEnum
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from .toolcallstatus import ToolCallStatus
from openrouter.types import BaseModel
from openrouter.utils import validate_open_enum
from pydantic import model_serializer
from pydantic.functional_validators import PlainValidator
from typing import Literal
from typing import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -22,57 +15,27 @@ FunctionCallItemType = Literal["function_call",]
class FunctionCallItemTypedDict(TypedDict):
r"""A function call initiated by the model"""
type: FunctionCallItemType
call_id: str
name: str
arguments: str
call_id: str
id: str
status: NotRequired[Nullable[ToolCallStatusEnum]]
name: str
type: FunctionCallItemType
status: NotRequired[ToolCallStatus]
class FunctionCallItem(BaseModel):
r"""A function call initiated by the model"""
type: FunctionCallItemType
arguments: str
call_id: str
name: str
arguments: str
id: str
name: str
type: FunctionCallItemType
status: Annotated[
OptionalNullable[ToolCallStatusEnum], 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
Optional[ToolCallStatus], PlainValidator(validate_open_enum(False))
] = None
@@ -3,7 +3,6 @@
from __future__ import annotations
from .inputfile import InputFile, InputFileTypedDict
from .inputtext import InputText, InputTextTypedDict
from .toolcallstatusenum import ToolCallStatusEnum
from openrouter.types import (
BaseModel,
Nullable,
@@ -19,12 +18,6 @@ from typing import List, Literal, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
FunctionCallOutputItemTypeFunctionCallOutput = Literal["function_call_output",]
OutputType = Literal["input_image",]
FunctionCallOutputItemDetail = Union[
Literal[
"auto",
@@ -35,23 +28,26 @@ FunctionCallOutputItemDetail = Union[
]
FunctionCallOutputItemOutputType = Literal["input_image",]
class OutputInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: OutputType
detail: FunctionCallOutputItemDetail
type: FunctionCallOutputItemOutputType
image_url: NotRequired[Nullable[str]]
class OutputInputImage(BaseModel):
r"""Image input content item"""
type: OutputType
detail: Annotated[
FunctionCallOutputItemDetail, PlainValidator(validate_open_enum(False))
]
type: FunctionCallOutputItemOutputType
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
@@ -113,29 +109,43 @@ FunctionCallOutputItemOutputUnion2 = TypeAliasType(
)
FunctionCallOutputItemStatus = Union[
Literal[
"in_progress",
"completed",
"incomplete",
],
UnrecognizedStr,
]
FunctionCallOutputItemTypeFunctionCallOutput = Literal["function_call_output",]
class FunctionCallOutputItemTypedDict(TypedDict):
r"""The output from a function call execution"""
type: FunctionCallOutputItemTypeFunctionCallOutput
call_id: str
output: FunctionCallOutputItemOutputUnion2TypedDict
type: FunctionCallOutputItemTypeFunctionCallOutput
id: NotRequired[Nullable[str]]
status: NotRequired[Nullable[ToolCallStatusEnum]]
status: NotRequired[Nullable[FunctionCallOutputItemStatus]]
class FunctionCallOutputItem(BaseModel):
r"""The output from a function call execution"""
type: FunctionCallOutputItemTypeFunctionCallOutput
call_id: str
output: FunctionCallOutputItemOutputUnion2
type: FunctionCallOutputItemTypeFunctionCallOutput
id: OptionalNullable[str] = UNSET
status: Annotated[
OptionalNullable[ToolCallStatusEnum], PlainValidator(validate_open_enum(False))
OptionalNullable[FunctionCallOutputItemStatus],
PlainValidator(validate_open_enum(False)),
] = UNSET
@model_serializer(mode="wrap")
@@ -0,0 +1,14 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .guardrail import Guardrail, GuardrailTypedDict
from openrouter.types import BaseModel
from typing_extensions import TypedDict
class GetGuardrailResponseTypedDict(TypedDict):
data: GuardrailTypedDict
class GetGuardrailResponse(BaseModel):
data: Guardrail
+133
View File
@@ -0,0 +1,133 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .guardrailinterval import GuardrailInterval
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
from typing_extensions import Annotated, NotRequired, TypedDict
class GuardrailTypedDict(TypedDict):
created_at: str
r"""ISO 8601 timestamp of when the guardrail was created"""
id: str
r"""Unique identifier for the guardrail"""
name: str
r"""Name of the guardrail"""
allowed_models: NotRequired[Nullable[List[str]]]
r"""Array of model canonical_slugs (immutable identifiers)"""
allowed_providers: NotRequired[Nullable[List[str]]]
r"""List of allowed provider IDs"""
description: NotRequired[Nullable[str]]
r"""Description of the guardrail"""
enforce_zdr: NotRequired[Nullable[bool]]
r"""Whether to enforce zero data retention"""
ignored_models: NotRequired[Nullable[List[str]]]
r"""Array of model canonical_slugs to exclude from routing"""
ignored_providers: NotRequired[Nullable[List[str]]]
r"""List of provider IDs to exclude from routing"""
limit_usd: NotRequired[Nullable[float]]
r"""Spending limit in USD"""
reset_interval: NotRequired[Nullable[GuardrailInterval]]
r"""Interval at which the limit resets (daily, weekly, monthly)"""
updated_at: NotRequired[Nullable[str]]
r"""ISO 8601 timestamp of when the guardrail was last updated"""
class Guardrail(BaseModel):
created_at: str
r"""ISO 8601 timestamp of when the guardrail was created"""
id: str
r"""Unique identifier for the guardrail"""
name: str
r"""Name of the guardrail"""
allowed_models: OptionalNullable[List[str]] = UNSET
r"""Array of model canonical_slugs (immutable identifiers)"""
allowed_providers: OptionalNullable[List[str]] = UNSET
r"""List of allowed provider IDs"""
description: OptionalNullable[str] = UNSET
r"""Description of the guardrail"""
enforce_zdr: OptionalNullable[bool] = UNSET
r"""Whether to enforce zero data retention"""
ignored_models: OptionalNullable[List[str]] = UNSET
r"""Array of model canonical_slugs to exclude from routing"""
ignored_providers: OptionalNullable[List[str]] = UNSET
r"""List of provider IDs to exclude from routing"""
limit_usd: OptionalNullable[float] = UNSET
r"""Spending limit in USD"""
reset_interval: Annotated[
OptionalNullable[GuardrailInterval], PlainValidator(validate_open_enum(False))
] = UNSET
r"""Interval at which the limit resets (daily, weekly, monthly)"""
updated_at: OptionalNullable[str] = UNSET
r"""ISO 8601 timestamp of when the guardrail was last updated"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allowed_models",
"allowed_providers",
"description",
"enforce_zdr",
"ignored_models",
"ignored_providers",
"limit_usd",
"reset_interval",
"updated_at",
]
nullable_fields = [
"allowed_models",
"allowed_providers",
"description",
"enforce_zdr",
"ignored_models",
"ignored_providers",
"limit_usd",
"reset_interval",
"updated_at",
]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
@@ -0,0 +1,16 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import UnrecognizedStr
from typing import Literal, Union
GuardrailInterval = Union[
Literal[
"daily",
"weekly",
"monthly",
],
UnrecognizedStr,
]
r"""Interval at which the limit resets (daily, weekly, monthly)"""
+14
View File
@@ -0,0 +1,14 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import Nullable
from typing import Any, List, Union
from typing_extensions import TypeAliasType
ImageConfigTypedDict = TypeAliasType(
"ImageConfigTypedDict", Union[str, float, List[Nullable[Any]]]
)
ImageConfig = TypeAliasType("ImageConfig", Union[str, float, List[Nullable[Any]]])
@@ -12,19 +12,19 @@ ImageGenCallCompletedEventType = Literal["response.image_generation_call.complet
class ImageGenCallCompletedEventTypedDict(TypedDict):
r"""Image generation call completed"""
type: ImageGenCallCompletedEventType
item_id: str
output_index: float
sequence_number: float
output_index: int
sequence_number: int
type: ImageGenCallCompletedEventType
class ImageGenCallCompletedEvent(BaseModel):
r"""Image generation call completed"""
type: ImageGenCallCompletedEventType
item_id: str
output_index: float
output_index: int
sequence_number: float
sequence_number: int
type: ImageGenCallCompletedEventType
@@ -12,19 +12,19 @@ ImageGenCallGeneratingEventType = Literal["response.image_generation_call.genera
class ImageGenCallGeneratingEventTypedDict(TypedDict):
r"""Image generation call is generating"""
type: ImageGenCallGeneratingEventType
item_id: str
output_index: float
sequence_number: float
output_index: int
sequence_number: int
type: ImageGenCallGeneratingEventType
class ImageGenCallGeneratingEvent(BaseModel):
r"""Image generation call is generating"""
type: ImageGenCallGeneratingEventType
item_id: str
output_index: float
output_index: int
sequence_number: float
sequence_number: int
type: ImageGenCallGeneratingEventType
@@ -12,19 +12,19 @@ ImageGenCallInProgressEventType = Literal["response.image_generation_call.in_pro
class ImageGenCallInProgressEventTypedDict(TypedDict):
r"""Image generation call in progress"""
type: ImageGenCallInProgressEventType
item_id: str
output_index: float
sequence_number: float
output_index: int
sequence_number: int
type: ImageGenCallInProgressEventType
class ImageGenCallInProgressEvent(BaseModel):
r"""Image generation call in progress"""
type: ImageGenCallInProgressEventType
item_id: str
output_index: float
output_index: int
sequence_number: float
sequence_number: int
type: ImageGenCallInProgressEventType
@@ -14,25 +14,25 @@ ImageGenCallPartialImageEventType = Literal[
class ImageGenCallPartialImageEventTypedDict(TypedDict):
r"""Image generation call with partial image"""
type: ImageGenCallPartialImageEventType
item_id: str
output_index: float
sequence_number: float
output_index: int
partial_image_b64: str
partial_image_index: float
partial_image_index: int
sequence_number: int
type: ImageGenCallPartialImageEventType
class ImageGenCallPartialImageEvent(BaseModel):
r"""Image generation call with partial image"""
type: ImageGenCallPartialImageEventType
item_id: str
output_index: float
sequence_number: float
output_index: int
partial_image_b64: str
partial_image_index: float
partial_image_index: int
sequence_number: int
type: ImageGenCallPartialImageEventType
@@ -16,9 +16,6 @@ from typing import Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ImageGenerationServerToolType = Literal["image_generation",]
Background = Union[
Literal[
"transparent",
@@ -39,15 +36,15 @@ InputFidelity = Union[
class InputImageMaskTypedDict(TypedDict):
image_url: NotRequired[str]
file_id: NotRequired[str]
image_url: NotRequired[str]
class InputImageMask(BaseModel):
image_url: Optional[str] = None
file_id: Optional[str] = None
image_url: Optional[str] = None
ModelEnum = Union[
Literal[
@@ -99,6 +96,9 @@ Size = Union[
]
ImageGenerationServerToolType = Literal["image_generation",]
class ImageGenerationServerToolTypedDict(TypedDict):
r"""Image generation tool configuration"""
@@ -108,9 +108,9 @@ class ImageGenerationServerToolTypedDict(TypedDict):
input_image_mask: NotRequired[InputImageMaskTypedDict]
model: NotRequired[ModelEnum]
moderation: NotRequired[Moderation]
output_compression: NotRequired[float]
output_compression: NotRequired[int]
output_format: NotRequired[OutputFormat]
partial_images: NotRequired[float]
partial_images: NotRequired[int]
quality: NotRequired[Quality]
size: NotRequired[Size]
@@ -138,13 +138,13 @@ class ImageGenerationServerTool(BaseModel):
Optional[Moderation], PlainValidator(validate_open_enum(False))
] = None
output_compression: Optional[float] = None
output_compression: Optional[int] = None
output_format: Annotated[
Optional[OutputFormat], PlainValidator(validate_open_enum(False))
] = None
partial_images: Optional[float] = None
partial_images: Optional[int] = None
quality: Annotated[Optional[Quality], PlainValidator(validate_open_enum(False))] = (
None
@@ -0,0 +1,30 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .imagegenerationservertoolconfig import (
ImageGenerationServerToolConfig,
ImageGenerationServerToolConfigTypedDict,
)
from openrouter.types import BaseModel
from typing import Literal, Optional
from typing_extensions import NotRequired, TypedDict
ImageGenerationServerToolOpenRouterType = Literal["openrouter:image_generation",]
class ImageGenerationServerToolOpenRouterTypedDict(TypedDict):
r"""OpenRouter built-in server tool: generates images from text prompts using an image generation model"""
type: ImageGenerationServerToolOpenRouterType
parameters: NotRequired[ImageGenerationServerToolConfigTypedDict]
r"""Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field."""
class ImageGenerationServerToolOpenRouter(BaseModel):
r"""OpenRouter built-in server tool: generates images from text prompts using an image generation model"""
type: ImageGenerationServerToolOpenRouterType
parameters: Optional[ImageGenerationServerToolConfig] = None
r"""Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field."""
@@ -0,0 +1,38 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .imagegenerationservertoolconfig_union import ImageGenerationServerToolConfigUnion
from openrouter.types import BaseModel
import pydantic
from pydantic import ConfigDict
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict
class ImageGenerationServerToolConfigTypedDict(TypedDict):
r"""Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field."""
model: NotRequired[str]
r"""Which image generation model to use (e.g. \"openai/gpt-image-1\"). Defaults to \"openai/gpt-image-1\"."""
class ImageGenerationServerToolConfig(BaseModel):
r"""Configuration for the openrouter:image_generation server tool. Accepts all image_config params (aspect_ratio, quality, size, background, output_format, output_compression, moderation, etc.) plus a model field."""
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, ImageGenerationServerToolConfigUnion] = (
pydantic.Field(init=False)
)
model: Optional[str] = None
r"""Which image generation model to use (e.g. \"openai/gpt-image-1\"). Defaults to \"openai/gpt-image-1\"."""
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
@@ -0,0 +1,17 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import Nullable
from typing import Any, List, Union
from typing_extensions import TypeAliasType
ImageGenerationServerToolConfigUnionTypedDict = TypeAliasType(
"ImageGenerationServerToolConfigUnionTypedDict",
Union[str, float, List[Nullable[Any]]],
)
ImageGenerationServerToolConfigUnion = TypeAliasType(
"ImageGenerationServerToolConfigUnion", Union[str, float, List[Nullable[Any]]]
)
+9 -9
View File
@@ -9,10 +9,7 @@ from typing import Literal, Union
from typing_extensions import Annotated, TypedDict
InputAudioType = Literal["input_audio",]
InputAudioFormat = Union[
FormatEnum = Union[
Literal[
"mp3",
"wav",
@@ -23,28 +20,31 @@ InputAudioFormat = Union[
class InputAudioInputAudioTypedDict(TypedDict):
data: str
format_: InputAudioFormat
format_: FormatEnum
class InputAudioInputAudio(BaseModel):
data: str
format_: Annotated[
Annotated[InputAudioFormat, PlainValidator(validate_open_enum(False))],
Annotated[FormatEnum, PlainValidator(validate_open_enum(False))],
pydantic.Field(alias="format"),
]
InputAudioType = Literal["input_audio",]
class InputAudioTypedDict(TypedDict):
r"""Audio input content item"""
type: InputAudioType
input_audio: InputAudioInputAudioTypedDict
type: InputAudioType
class InputAudio(BaseModel):
r"""Audio input content item"""
type: InputAudioType
input_audio: InputAudioInputAudio
type: InputAudioType
+6 -6
View File
@@ -20,10 +20,10 @@ class InputFileTypedDict(TypedDict):
r"""File input content item"""
type: InputFileType
file_id: NotRequired[Nullable[str]]
file_data: NotRequired[str]
filename: NotRequired[str]
file_id: NotRequired[Nullable[str]]
file_url: NotRequired[str]
filename: NotRequired[str]
class InputFile(BaseModel):
@@ -31,17 +31,17 @@ class InputFile(BaseModel):
type: InputFileType
file_id: OptionalNullable[str] = UNSET
file_data: Optional[str] = None
filename: Optional[str] = None
file_id: OptionalNullable[str] = UNSET
file_url: Optional[str] = None
filename: Optional[str] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["file_id", "file_data", "filename", "file_url"]
optional_fields = ["file_data", "file_id", "file_url", "filename"]
nullable_fields = ["file_id"]
null_default_fields = []
+6 -6
View File
@@ -16,9 +16,6 @@ from typing import Literal, Union
from typing_extensions import Annotated, NotRequired, TypedDict
InputImageType = Literal["input_image",]
InputImageDetail = Union[
Literal[
"auto",
@@ -29,21 +26,24 @@ InputImageDetail = Union[
]
InputImageType = Literal["input_image",]
class InputImageTypedDict(TypedDict):
r"""Image input content item"""
type: InputImageType
detail: InputImageDetail
type: InputImageType
image_url: NotRequired[Nullable[str]]
class InputImage(BaseModel):
r"""Image input content item"""
type: InputImageType
detail: Annotated[InputImageDetail, PlainValidator(validate_open_enum(False))]
type: InputImageType
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
+42 -42
View File
@@ -20,41 +20,6 @@ from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
InputMessageItemTypeMessage = Literal["message",]
InputMessageItemRoleDeveloper = Literal["developer",]
InputMessageItemRoleSystem = Literal["system",]
InputMessageItemRoleUser = Literal["user",]
InputMessageItemRoleUnionTypedDict = TypeAliasType(
"InputMessageItemRoleUnionTypedDict",
Union[
InputMessageItemRoleUser,
InputMessageItemRoleSystem,
InputMessageItemRoleDeveloper,
],
)
InputMessageItemRoleUnion = TypeAliasType(
"InputMessageItemRoleUnion",
Union[
InputMessageItemRoleUser,
InputMessageItemRoleSystem,
InputMessageItemRoleDeveloper,
],
)
InputMessageItemContentType = Literal["input_image",]
InputMessageItemDetail = Union[
Literal[
"auto",
@@ -65,21 +30,24 @@ InputMessageItemDetail = Union[
]
InputMessageItemContentType = Literal["input_image",]
class InputMessageItemContentInputImageTypedDict(TypedDict):
r"""Image input content item"""
type: InputMessageItemContentType
detail: InputMessageItemDetail
type: InputMessageItemContentType
image_url: NotRequired[Nullable[str]]
class InputMessageItemContentInputImage(BaseModel):
r"""Image input content item"""
type: InputMessageItemContentType
detail: Annotated[InputMessageItemDetail, PlainValidator(validate_open_enum(False))]
type: InputMessageItemContentType
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
@@ -137,25 +105,57 @@ InputMessageItemContentUnion = Annotated[
]
InputMessageItemRoleDeveloper = Literal["developer",]
InputMessageItemRoleSystem = Literal["system",]
InputMessageItemRoleUser = Literal["user",]
InputMessageItemRoleUnionTypedDict = TypeAliasType(
"InputMessageItemRoleUnionTypedDict",
Union[
InputMessageItemRoleUser,
InputMessageItemRoleSystem,
InputMessageItemRoleDeveloper,
],
)
InputMessageItemRoleUnion = TypeAliasType(
"InputMessageItemRoleUnion",
Union[
InputMessageItemRoleUser,
InputMessageItemRoleSystem,
InputMessageItemRoleDeveloper,
],
)
InputMessageItemTypeMessage = Literal["message",]
class InputMessageItemTypedDict(TypedDict):
role: InputMessageItemRoleUnionTypedDict
content: NotRequired[Nullable[List[InputMessageItemContentUnionTypedDict]]]
id: NotRequired[str]
type: NotRequired[InputMessageItemTypeMessage]
content: NotRequired[Nullable[List[InputMessageItemContentUnionTypedDict]]]
class InputMessageItem(BaseModel):
role: InputMessageItemRoleUnion
content: OptionalNullable[List[InputMessageItemContentUnion]] = UNSET
id: Optional[str] = None
type: Optional[InputMessageItemTypeMessage] = None
content: OptionalNullable[List[InputMessageItemContentUnion]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["id", "type", "content"]
optional_fields = ["content", "id", "type"]
nullable_fields = ["content"]
null_default_fields = []
+53 -66
View File
@@ -25,11 +25,15 @@ from .outputimagegenerationcallitem import (
OutputImageGenerationCallItem,
OutputImageGenerationCallItemTypedDict,
)
from .outputservertoolitem import OutputServerToolItem, OutputServerToolItemTypedDict
from .outputwebsearchcallitem import (
OutputWebSearchCallItem,
OutputWebSearchCallItemTypedDict,
)
from .outputwebsearchservertoolitem import (
OutputWebSearchServerToolItem,
OutputWebSearchServerToolItemTypedDict,
)
from .reasoningformat import ReasoningFormat
from .reasoningitem import ReasoningItem, ReasoningItemTypedDict
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
@@ -40,7 +44,6 @@ from openrouter.types import (
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator, validate_open_enum
import pydantic
@@ -50,9 +53,6 @@ from typing import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
InputsTypeReasoning = Literal["reasoning",]
InputsStatusInProgress2 = Literal["in_progress",]
@@ -74,60 +74,47 @@ InputsStatusUnion2 = TypeAliasType(
)
InputsFormat = 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"""
InputsTypeReasoning = Literal["reasoning",]
class InputsReasoningTypedDict(TypedDict):
r"""An output item containing reasoning"""
type: InputsTypeReasoning
id: str
summary: Nullable[List[ReasoningSummaryTextTypedDict]]
type: InputsTypeReasoning
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
encrypted_content: NotRequired[Nullable[str]]
status: NotRequired[InputsStatusUnion2TypedDict]
format_: NotRequired[Nullable[ReasoningFormat]]
signature: NotRequired[Nullable[str]]
r"""A signature for the reasoning content, used for verification"""
format_: NotRequired[Nullable[InputsFormat]]
r"""The format of the reasoning content"""
class InputsReasoning(BaseModel):
r"""An output item containing reasoning"""
type: InputsTypeReasoning
id: str
summary: Nullable[List[ReasoningSummaryText]]
type: InputsTypeReasoning
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
encrypted_content: OptionalNullable[str] = UNSET
status: Optional[InputsStatusUnion2] = None
signature: OptionalNullable[str] = UNSET
r"""A signature for the reasoning content, used for verification"""
format_: Annotated[
Annotated[
OptionalNullable[InputsFormat], PlainValidator(validate_open_enum(False))
OptionalNullable[ReasoningFormat], PlainValidator(validate_open_enum(False))
],
pydantic.Field(alias="format"),
] = UNSET
r"""The format of the reasoning content"""
signature: OptionalNullable[str] = UNSET
r"""A signature for the reasoning content, used for verification"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
@@ -135,15 +122,15 @@ class InputsReasoning(BaseModel):
"content",
"encrypted_content",
"status",
"signature",
"format",
"signature",
]
nullable_fields = [
"content",
"summary",
"encrypted_content",
"signature",
"summary",
"format",
"signature",
]
null_default_fields = []
@@ -172,33 +159,6 @@ class InputsReasoning(BaseModel):
return m
InputsRole = Literal["assistant",]
InputsTypeMessage = Literal["message",]
InputsStatusInProgress1 = Literal["in_progress",]
InputsStatusIncomplete1 = Literal["incomplete",]
InputsStatusCompleted1 = Literal["completed",]
InputsStatusUnion1TypedDict = TypeAliasType(
"InputsStatusUnion1TypedDict",
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
)
InputsStatusUnion1 = TypeAliasType(
"InputsStatusUnion1",
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
)
InputsContent1TypedDict = TypeAliasType(
"InputsContent1TypedDict",
Union[OpenAIResponsesRefusalContentTypedDict, ResponseOutputTextTypedDict],
@@ -241,37 +201,64 @@ InputsPhaseUnion = TypeAliasType(
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."""
InputsRole = Literal["assistant",]
InputsStatusInProgress1 = Literal["in_progress",]
InputsStatusIncomplete1 = Literal["incomplete",]
InputsStatusCompleted1 = Literal["completed",]
InputsStatusUnion1TypedDict = TypeAliasType(
"InputsStatusUnion1TypedDict",
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
)
InputsStatusUnion1 = TypeAliasType(
"InputsStatusUnion1",
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
)
InputsTypeMessage = Literal["message",]
class InputsMessageTypedDict(TypedDict):
r"""An output message item"""
content: Nullable[InputsContent2TypedDict]
id: str
role: InputsRole
type: InputsTypeMessage
content: Nullable[InputsContent2TypedDict]
status: NotRequired[InputsStatusUnion1TypedDict]
phase: NotRequired[Nullable[InputsPhaseUnionTypedDict]]
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."""
status: NotRequired[InputsStatusUnion1TypedDict]
class InputsMessage(BaseModel):
r"""An output message item"""
content: Nullable[InputsContent2]
id: str
role: InputsRole
type: InputsTypeMessage
content: Nullable[InputsContent2]
status: Optional[InputsStatusUnion1] = None
phase: OptionalNullable[InputsPhaseUnion] = 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."""
status: Optional[InputsStatusUnion1] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["status", "phase"]
optional_fields = ["phase", "status"]
nullable_fields = ["content", "phase"]
null_default_fields = []
@@ -303,10 +290,10 @@ class InputsMessage(BaseModel):
InputsUnion1TypedDict = TypeAliasType(
"InputsUnion1TypedDict",
Union[
OutputWebSearchServerToolItemTypedDict,
OutputWebSearchCallItemTypedDict,
EasyInputMessageTypedDict,
InputMessageItemTypedDict,
OutputServerToolItemTypedDict,
OutputImageGenerationCallItemTypedDict,
OutputFileSearchCallItemTypedDict,
FunctionCallOutputItemTypedDict,
@@ -323,10 +310,10 @@ InputsUnion1TypedDict = TypeAliasType(
InputsUnion1 = TypeAliasType(
"InputsUnion1",
Union[
OutputWebSearchServerToolItem,
OutputWebSearchCallItem,
EasyInputMessage,
InputMessageItem,
OutputServerToolItem,
OutputImageGenerationCallItem,
OutputFileSearchCallItem,
FunctionCallOutputItem,
+3 -3
View File
@@ -12,13 +12,13 @@ InputTextType = Literal["input_text",]
class InputTextTypedDict(TypedDict):
r"""Text input content item"""
type: InputTextType
text: str
type: InputTextType
class InputText(BaseModel):
r"""Text input content item"""
type: InputTextType
text: str
type: InputTextType
@@ -0,0 +1,76 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing_extensions import TypedDict
class KeyAssignmentTypedDict(TypedDict):
assigned_by: Nullable[str]
r"""User ID of who made the assignment"""
created_at: str
r"""ISO 8601 timestamp of when the assignment was created"""
guardrail_id: str
r"""ID of the guardrail"""
id: str
r"""Unique identifier for the assignment"""
key_hash: str
r"""Hash of the assigned API key"""
key_label: str
r"""Label of the API key"""
key_name: str
r"""Name of the API key"""
class KeyAssignment(BaseModel):
assigned_by: Nullable[str]
r"""User ID of who made the assignment"""
created_at: str
r"""ISO 8601 timestamp of when the assignment was created"""
guardrail_id: str
r"""ID of the guardrail"""
id: str
r"""Unique identifier for the assignment"""
key_hash: str
r"""Hash of the assigned API key"""
key_label: str
r"""Label of the API key"""
key_name: str
r"""Name of the API key"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = []
nullable_fields = ["assigned_by"]
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
@@ -2,6 +2,8 @@
from __future__ import annotations
from .searchcontextsizeenum import SearchContextSizeEnum
from .websearchdomainfilter import WebSearchDomainFilter, WebSearchDomainFilterTypedDict
from .websearchengineenum import WebSearchEngineEnum
from .websearchuserlocation import WebSearchUserLocation, WebSearchUserLocationTypedDict
from openrouter.types import (
BaseModel,
@@ -9,85 +11,30 @@ from openrouter.types import (
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 import Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
LegacyWebSearchServerToolType = Literal["web_search",]
class LegacyWebSearchServerToolFiltersTypedDict(TypedDict):
allowed_domains: NotRequired[Nullable[List[str]]]
excluded_domains: NotRequired[Nullable[List[str]]]
class LegacyWebSearchServerToolFilters(BaseModel):
allowed_domains: OptionalNullable[List[str]] = UNSET
excluded_domains: OptionalNullable[List[str]] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["allowed_domains", "excluded_domains"]
nullable_fields = ["allowed_domains", "excluded_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
LegacyWebSearchServerToolEngine = Union[
Literal[
"auto",
"native",
"exa",
"firecrawl",
"parallel",
],
UnrecognizedStr,
]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
class LegacyWebSearchServerToolTypedDict(TypedDict):
r"""Web search tool configuration"""
type: LegacyWebSearchServerToolType
filters: NotRequired[Nullable[LegacyWebSearchServerToolFiltersTypedDict]]
engine: NotRequired[WebSearchEngineEnum]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
filters: NotRequired[Nullable[WebSearchDomainFilterTypedDict]]
max_results: NotRequired[int]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
search_context_size: NotRequired[SearchContextSizeEnum]
r"""Size of the search context for web search tools"""
user_location: NotRequired[Nullable[WebSearchUserLocationTypedDict]]
r"""User location information for web search"""
engine: NotRequired[LegacyWebSearchServerToolEngine]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: NotRequired[float]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
class LegacyWebSearchServerTool(BaseModel):
@@ -95,7 +42,15 @@ class LegacyWebSearchServerTool(BaseModel):
type: LegacyWebSearchServerToolType
filters: OptionalNullable[LegacyWebSearchServerToolFilters] = UNSET
engine: Annotated[
Optional[WebSearchEngineEnum], PlainValidator(validate_open_enum(False))
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
filters: OptionalNullable[WebSearchDomainFilter] = UNSET
max_results: Optional[int] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
search_context_size: Annotated[
Optional[SearchContextSizeEnum], PlainValidator(validate_open_enum(False))
@@ -105,23 +60,14 @@ class LegacyWebSearchServerTool(BaseModel):
user_location: OptionalNullable[WebSearchUserLocation] = UNSET
r"""User location information for web search"""
engine: Annotated[
Optional[LegacyWebSearchServerToolEngine],
PlainValidator(validate_open_enum(False)),
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
max_results: Optional[float] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"engine",
"filters",
"max_results",
"search_context_size",
"user_location",
"engine",
"max_results",
]
nullable_fields = ["filters", "user_location"]
null_default_fields = []
@@ -21,6 +21,7 @@ Tokenizer = Union[
"GPT",
"Claude",
"Gemini",
"Gemma",
"Grok",
"Cohere",
"Nova",
@@ -43,21 +44,24 @@ r"""Tokenizer type used by the model"""
class ArchitectureTypedDict(TypedDict):
r"""Model architecture information"""
tokenizer: Nullable[Tokenizer]
input_modalities: List[InputModality]
r"""Supported input modalities"""
instruct_type: Nullable[InstructType]
r"""Instruction format type"""
modality: Nullable[str]
r"""Primary modality of the model"""
input_modalities: List[InputModality]
r"""Supported input modalities"""
output_modalities: List[OutputModality]
r"""Supported output modalities"""
tokenizer: Nullable[Tokenizer]
class Architecture(BaseModel):
r"""Model architecture information"""
tokenizer: Annotated[Nullable[Tokenizer], PlainValidator(validate_open_enum(False))]
input_modalities: List[
Annotated[InputModality, PlainValidator(validate_open_enum(False))]
]
r"""Supported input modalities"""
instruct_type: Annotated[
Nullable[InstructType], PlainValidator(validate_open_enum(False))
@@ -67,20 +71,17 @@ class Architecture(BaseModel):
modality: Nullable[str]
r"""Primary modality of the model"""
input_modalities: List[
Annotated[InputModality, PlainValidator(validate_open_enum(False))]
]
r"""Supported input modalities"""
output_modalities: List[
Annotated[OutputModality, PlainValidator(validate_open_enum(False))]
]
r"""Supported output modalities"""
tokenizer: Annotated[Nullable[Tokenizer], PlainValidator(validate_open_enum(False))]
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = []
nullable_fields = ["tokenizer", "instruct_type", "modality"]
nullable_fields = ["instruct_type", "modality", "tokenizer"]
null_default_fields = []
serialized = handler(self)
@@ -111,35 +112,35 @@ class Architecture(BaseModel):
class ListEndpointsResponseTypedDict(TypedDict):
r"""List of available endpoints for a model"""
architecture: ArchitectureTypedDict
created: int
r"""Unix timestamp of when the model was created"""
description: str
r"""Description of the model"""
endpoints: List[PublicEndpointTypedDict]
r"""List of available endpoints for this model"""
id: str
r"""Unique identifier for the model"""
name: str
r"""Display name of the model"""
created: float
r"""Unix timestamp of when the model was created"""
description: str
r"""Description of the model"""
architecture: ArchitectureTypedDict
endpoints: List[PublicEndpointTypedDict]
r"""List of available endpoints for this model"""
class ListEndpointsResponse(BaseModel):
r"""List of available endpoints for a model"""
id: str
r"""Unique identifier for the model"""
architecture: Architecture
name: str
r"""Display name of the model"""
created: float
created: int
r"""Unix timestamp of when the model was created"""
description: str
r"""Description of the model"""
architecture: Architecture
endpoints: List[PublicEndpoint]
r"""List of available endpoints for this model"""
id: str
r"""Unique identifier for the model"""
name: str
r"""Display name of the model"""
@@ -0,0 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .guardrail import Guardrail, GuardrailTypedDict
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class ListGuardrailsResponseTypedDict(TypedDict):
data: List[GuardrailTypedDict]
r"""List of guardrails"""
total_count: int
r"""Total number of guardrails"""
class ListGuardrailsResponse(BaseModel):
data: List[Guardrail]
r"""List of guardrails"""
total_count: int
r"""Total number of guardrails"""
@@ -0,0 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .keyassignment import KeyAssignment, KeyAssignmentTypedDict
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class ListKeyAssignmentsResponseTypedDict(TypedDict):
data: List[KeyAssignmentTypedDict]
r"""List of key assignments"""
total_count: int
r"""Total number of key assignments for this guardrail"""
class ListKeyAssignmentsResponse(BaseModel):
data: List[KeyAssignment]
r"""List of key assignments"""
total_count: int
r"""Total number of key assignments for this guardrail"""
@@ -0,0 +1,22 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .memberassignment import MemberAssignment, MemberAssignmentTypedDict
from openrouter.types import BaseModel
from typing import List
from typing_extensions import TypedDict
class ListMemberAssignmentsResponseTypedDict(TypedDict):
data: List[MemberAssignmentTypedDict]
r"""List of member assignments"""
total_count: int
r"""Total number of member assignments"""
class ListMemberAssignmentsResponse(BaseModel):
data: List[MemberAssignment]
r"""List of member assignments"""
total_count: int
r"""Total number of member assignments"""
+45 -23
View File
@@ -13,21 +13,28 @@ 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
McpServerToolType = Literal["mcp",]
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
class AllowedToolsTypedDict(TypedDict):
tool_names: NotRequired[List[str]]
read_only: NotRequired[bool]
tool_names: NotRequired[List[str]]
class AllowedTools(BaseModel):
read_only: Optional[bool] = None
tool_names: Optional[List[str]] = None
read_only: Optional[bool] = None
AllowedToolsUnionTypedDict = TypeAliasType(
"AllowedToolsUnionTypedDict", Union[AllowedToolsTypedDict, List[str], Any]
)
AllowedToolsUnion = TypeAliasType(
"AllowedToolsUnion", Union[AllowedTools, List[str], Any]
)
ConnectorID = Union[
@@ -51,14 +58,6 @@ 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]]
@@ -67,27 +66,50 @@ class Always(BaseModel):
tool_names: Optional[List[str]] = None
class NeverTypedDict(TypedDict):
tool_names: NotRequired[List[str]]
class Never(BaseModel):
tool_names: Optional[List[str]] = None
class RequireApprovalTypedDict(TypedDict):
never: NotRequired[NeverTypedDict]
always: NotRequired[AlwaysTypedDict]
never: NotRequired[NeverTypedDict]
class RequireApproval(BaseModel):
always: Optional[Always] = None
never: Optional[Never] = None
always: Optional[Always] = None
RequireApprovalUnionTypedDict = TypeAliasType(
"RequireApprovalUnionTypedDict",
Union[RequireApprovalTypedDict, RequireApprovalAlways, RequireApprovalNever, Any],
)
RequireApprovalUnion = TypeAliasType(
"RequireApprovalUnion",
Union[RequireApproval, RequireApprovalAlways, RequireApprovalNever, Any],
)
McpServerToolType = Literal["mcp",]
class McpServerToolTypedDict(TypedDict):
r"""MCP (Model Context Protocol) tool configuration"""
type: McpServerToolType
server_label: str
allowed_tools: NotRequired[Nullable[Any]]
type: McpServerToolType
allowed_tools: NotRequired[Nullable[AllowedToolsUnionTypedDict]]
authorization: NotRequired[str]
connector_id: NotRequired[ConnectorID]
headers: NotRequired[Nullable[Dict[str, str]]]
require_approval: NotRequired[Nullable[Any]]
require_approval: NotRequired[Nullable[RequireApprovalUnionTypedDict]]
server_description: NotRequired[str]
server_url: NotRequired[str]
@@ -95,11 +117,11 @@ class McpServerToolTypedDict(TypedDict):
class McpServerTool(BaseModel):
r"""MCP (Model Context Protocol) tool configuration"""
type: McpServerToolType
server_label: str
allowed_tools: OptionalNullable[Any] = UNSET
type: McpServerToolType
allowed_tools: OptionalNullable[AllowedToolsUnion] = UNSET
authorization: Optional[str] = None
@@ -109,7 +131,7 @@ class McpServerTool(BaseModel):
headers: OptionalNullable[Dict[str, str]] = UNSET
require_approval: OptionalNullable[Any] = UNSET
require_approval: OptionalNullable[RequireApprovalUnion] = UNSET
server_description: Optional[str] = None
@@ -0,0 +1,71 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing_extensions import TypedDict
class MemberAssignmentTypedDict(TypedDict):
assigned_by: Nullable[str]
r"""User ID of who made the assignment"""
created_at: str
r"""ISO 8601 timestamp of when the assignment was created"""
guardrail_id: str
r"""ID of the guardrail"""
id: str
r"""Unique identifier for the assignment"""
organization_id: str
r"""Organization ID"""
user_id: str
r"""Clerk user ID of the assigned member"""
class MemberAssignment(BaseModel):
assigned_by: Nullable[str]
r"""User ID of who made the assignment"""
created_at: str
r"""ISO 8601 timestamp of when the assignment was created"""
guardrail_id: str
r"""ID of the guardrail"""
id: str
r"""Unique identifier for the assignment"""
organization_id: str
r"""Organization ID"""
user_id: str
r"""Clerk user ID of the assigned member"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = []
nullable_fields = ["assigned_by"]
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