mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
feat: regenerate SDK with updated OpenAPI spec
Speakeasy regeneration with latest schema changes including type renames and new server tool models.
This commit is contained in:
+2407
-1673
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesannotation import (
|
||||
OpenAIResponsesAnnotation,
|
||||
OpenAIResponsesAnnotationTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
class AnnotationAddedEvent(BaseModel):
|
||||
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: OpenAIResponsesAnnotation
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
ApplyPatchServerToolType = Literal["apply_patch",]
|
||||
|
||||
|
||||
class ApplyPatchServerToolTypedDict(TypedDict):
|
||||
r"""Apply patch tool configuration"""
|
||||
|
||||
type: ApplyPatchServerToolType
|
||||
|
||||
|
||||
class ApplyPatchServerTool(BaseModel):
|
||||
r"""Apply patch tool configuration"""
|
||||
|
||||
type: ApplyPatchServerToolType
|
||||
@@ -5,6 +5,10 @@ from .assistantmessageimages import (
|
||||
AssistantMessageImages,
|
||||
AssistantMessageImagesTypedDict,
|
||||
)
|
||||
from .chatcompletionaudiooutput import (
|
||||
ChatCompletionAudioOutput,
|
||||
ChatCompletionAudioOutputTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitem import (
|
||||
ChatMessageContentItem,
|
||||
ChatMessageContentItemTypedDict,
|
||||
@@ -57,6 +61,8 @@ class AssistantMessageTypedDict(TypedDict):
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
images: NotRequired[List[AssistantMessageImagesTypedDict]]
|
||||
r"""Generated images from image generation models"""
|
||||
audio: NotRequired[ChatCompletionAudioOutputTypedDict]
|
||||
r"""Audio output data or reference"""
|
||||
|
||||
|
||||
class AssistantMessage(BaseModel):
|
||||
@@ -85,6 +91,9 @@ class AssistantMessage(BaseModel):
|
||||
images: Optional[List[AssistantMessageImages]] = None
|
||||
r"""Generated images from image generation models"""
|
||||
|
||||
audio: Optional[ChatCompletionAudioOutput] = None
|
||||
r"""Audio output data or reference"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
@@ -95,6 +104,7 @@ class AssistantMessage(BaseModel):
|
||||
"reasoning",
|
||||
"reasoning_details",
|
||||
"images",
|
||||
"audio",
|
||||
]
|
||||
nullable_fields = ["content", "refusal", "reasoning"]
|
||||
null_default_fields = []
|
||||
|
||||
@@ -0,0 +1,391 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputaudio import InputAudio, InputAudioTypedDict
|
||||
from .inputfile import InputFile, InputFileTypedDict
|
||||
from .inputimage import InputImage, InputImageTypedDict
|
||||
from .inputtext import InputText, InputTextTypedDict
|
||||
from .outputitemimagegenerationcall import (
|
||||
OutputItemImageGenerationCall,
|
||||
OutputItemImageGenerationCallTypedDict,
|
||||
)
|
||||
from .outputmessage import OutputMessage, OutputMessageTypedDict
|
||||
from .toolcallstatusenum import ToolCallStatusEnum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
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[
|
||||
InputTextTypedDict, InputAudioTypedDict, InputImageTypedDict, InputFileTypedDict
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
BaseInputsContent1 = 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")),
|
||||
]
|
||||
|
||||
|
||||
BaseInputsContent2TypedDict = TypeAliasType(
|
||||
"BaseInputsContent2TypedDict", Union[List[BaseInputsContent1TypedDict], str]
|
||||
)
|
||||
|
||||
|
||||
BaseInputsContent2 = TypeAliasType(
|
||||
"BaseInputsContent2", Union[List[BaseInputsContent1], str]
|
||||
)
|
||||
|
||||
|
||||
BaseInputsPhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
BaseInputsPhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
BaseInputsPhaseUnionTypedDict = TypeAliasType(
|
||||
"BaseInputsPhaseUnionTypedDict",
|
||||
Union[BaseInputsPhaseCommentary, BaseInputsPhaseFinalAnswer, Any],
|
||||
)
|
||||
|
||||
|
||||
BaseInputsPhaseUnion = TypeAliasType(
|
||||
"BaseInputsPhaseUnion",
|
||||
Union[BaseInputsPhaseCommentary, BaseInputsPhaseFinalAnswer, Any],
|
||||
)
|
||||
|
||||
|
||||
class BaseInputsMessage1TypedDict(TypedDict):
|
||||
role: BaseInputsRoleUnion1TypedDict
|
||||
content: BaseInputsContent2TypedDict
|
||||
type: NotRequired[BaseInputsTypeMessage1]
|
||||
phase: NotRequired[Nullable[BaseInputsPhaseUnionTypedDict]]
|
||||
|
||||
|
||||
class BaseInputsMessage1(BaseModel):
|
||||
role: BaseInputsRoleUnion1
|
||||
|
||||
content: BaseInputsContent2
|
||||
|
||||
type: Optional[BaseInputsTypeMessage1] = None
|
||||
|
||||
phase: OptionalNullable[BaseInputsPhaseUnion] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["type", "phase"]
|
||||
nullable_fields = ["phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
BaseInputsUnion1TypedDict = TypeAliasType(
|
||||
"BaseInputsUnion1TypedDict",
|
||||
Union[
|
||||
BaseInputsMessage1TypedDict,
|
||||
BaseInputsMessage2TypedDict,
|
||||
OutputItemImageGenerationCallTypedDict,
|
||||
BaseInputsFunctionCallOutputTypedDict,
|
||||
BaseInputsFunctionCallTypedDict,
|
||||
OutputMessageTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
BaseInputsUnion1 = TypeAliasType(
|
||||
"BaseInputsUnion1",
|
||||
Union[
|
||||
BaseInputsMessage1,
|
||||
BaseInputsMessage2,
|
||||
OutputItemImageGenerationCall,
|
||||
BaseInputsFunctionCallOutput,
|
||||
BaseInputsFunctionCall,
|
||||
OutputMessage,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
BaseInputsUnionTypedDict = TypeAliasType(
|
||||
"BaseInputsUnionTypedDict", Union[str, List[BaseInputsUnion1TypedDict], Any]
|
||||
)
|
||||
|
||||
|
||||
BaseInputsUnion = TypeAliasType(
|
||||
"BaseInputsUnion", Union[str, List[BaseInputsUnion1], Any]
|
||||
)
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .reasoningeffortenum import ReasoningEffortEnum
|
||||
from .reasoningsummaryverbosityenum import ReasoningSummaryVerbosityEnum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class BaseReasoningConfigTypedDict(TypedDict):
|
||||
effort: NotRequired[Nullable[ReasoningEffortEnum]]
|
||||
summary: NotRequired[Nullable[ReasoningSummaryVerbosityEnum]]
|
||||
|
||||
|
||||
class BaseReasoningConfig(BaseModel):
|
||||
effort: Annotated[
|
||||
OptionalNullable[ReasoningEffortEnum], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
OptionalNullable[ReasoningSummaryVerbosityEnum],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary"]
|
||||
nullable_fields = ["effort", "summary"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,23 @@
|
||||
"""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 ChatAssistantImagesImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
r"""URL or base64-encoded data of the generated image"""
|
||||
|
||||
|
||||
class ChatAssistantImagesImageURL(BaseModel):
|
||||
url: str
|
||||
r"""URL or base64-encoded data of the generated image"""
|
||||
|
||||
|
||||
class ChatAssistantImagesTypedDict(TypedDict):
|
||||
image_url: ChatAssistantImagesImageURLTypedDict
|
||||
|
||||
|
||||
class ChatAssistantImages(BaseModel):
|
||||
image_url: ChatAssistantImagesImageURL
|
||||
@@ -0,0 +1,125 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatassistantimages import ChatAssistantImages, ChatAssistantImagesTypedDict
|
||||
from .chataudiooutput import ChatAudioOutput, ChatAudioOutputTypedDict
|
||||
from .chatcontentitems import ChatContentItems, ChatContentItemsTypedDict
|
||||
from .chattoolcall import ChatToolCall, ChatToolCallTypedDict
|
||||
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatAssistantMessageRole = Literal["assistant",]
|
||||
|
||||
|
||||
ChatAssistantMessageContentTypedDict = TypeAliasType(
|
||||
"ChatAssistantMessageContentTypedDict",
|
||||
Union[str, List[ChatContentItemsTypedDict], Any],
|
||||
)
|
||||
r"""Assistant message content"""
|
||||
|
||||
|
||||
ChatAssistantMessageContent = TypeAliasType(
|
||||
"ChatAssistantMessageContent", Union[str, List[ChatContentItems], Any]
|
||||
)
|
||||
r"""Assistant message content"""
|
||||
|
||||
|
||||
class ChatAssistantMessageTypedDict(TypedDict):
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
role: ChatAssistantMessageRole
|
||||
content: NotRequired[Nullable[ChatAssistantMessageContentTypedDict]]
|
||||
r"""Assistant message content"""
|
||||
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"""
|
||||
|
||||
|
||||
class ChatAssistantMessage(BaseModel):
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
role: ChatAssistantMessageRole
|
||||
|
||||
content: OptionalNullable[ChatAssistantMessageContent] = UNSET
|
||||
r"""Assistant message content"""
|
||||
|
||||
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"""
|
||||
|
||||
audio: Optional[ChatAudioOutput] = None
|
||||
r"""Audio output data or reference"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"content",
|
||||
"name",
|
||||
"tool_calls",
|
||||
"refusal",
|
||||
"reasoning",
|
||||
"reasoning_details",
|
||||
"images",
|
||||
"audio",
|
||||
]
|
||||
nullable_fields = ["content", "refusal", "reasoning"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,35 @@
|
||||
"""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 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"""
|
||||
transcript: NotRequired[str]
|
||||
r"""Audio transcript"""
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
transcript: Optional[str] = None
|
||||
r"""Audio transcript"""
|
||||
@@ -0,0 +1,72 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatassistantmessage import ChatAssistantMessage, ChatAssistantMessageTypedDict
|
||||
from .chattokenlogprobs import ChatTokenLogprobs, ChatTokenLogprobsTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Any
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatChoiceTypedDict(TypedDict):
|
||||
r"""Chat completion choice"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
message: ChatAssistantMessageTypedDict
|
||||
r"""Assistant message for requests and responses"""
|
||||
logprobs: NotRequired[Nullable[ChatTokenLogprobsTypedDict]]
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
|
||||
class ChatChoice(BaseModel):
|
||||
r"""Chat completion choice"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
|
||||
message: ChatAssistantMessage
|
||||
r"""Assistant message for requests and responses"""
|
||||
|
||||
logprobs: OptionalNullable[ChatTokenLogprobs] = UNSET
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["logprobs"]
|
||||
nullable_fields = ["finish_reason", "logprobs"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatCompletionAudioOutputTypedDict(TypedDict):
|
||||
r"""Audio output data or reference"""
|
||||
|
||||
id: NotRequired[str]
|
||||
r"""Audio output identifier"""
|
||||
expires_at: NotRequired[float]
|
||||
r"""Audio expiration timestamp"""
|
||||
data: NotRequired[str]
|
||||
r"""Base64 encoded audio data"""
|
||||
transcript: NotRequired[str]
|
||||
r"""Audio transcript"""
|
||||
|
||||
|
||||
class ChatCompletionAudioOutput(BaseModel):
|
||||
r"""Audio output data or reference"""
|
||||
|
||||
id: Optional[str] = None
|
||||
r"""Audio output identifier"""
|
||||
|
||||
expires_at: Optional[float] = None
|
||||
r"""Audio expiration timestamp"""
|
||||
|
||||
data: Optional[str] = None
|
||||
r"""Base64 encoded audio data"""
|
||||
|
||||
transcript: Optional[str] = None
|
||||
r"""Audio transcript"""
|
||||
@@ -0,0 +1,40 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
import pydantic
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
ChatContentAudioType = Literal["input_audio",]
|
||||
|
||||
|
||||
class ChatContentAudioInputAudioTypedDict(TypedDict):
|
||||
data: str
|
||||
r"""Base64 encoded audio data"""
|
||||
format_: str
|
||||
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
|
||||
|
||||
|
||||
class ChatContentAudioInputAudio(BaseModel):
|
||||
data: str
|
||||
r"""Base64 encoded audio data"""
|
||||
|
||||
format_: Annotated[str, pydantic.Field(alias="format")]
|
||||
r"""Audio format (e.g., wav, mp3, flac, m4a, ogg, aiff, aac, pcm16, pcm24). Supported formats vary by provider."""
|
||||
|
||||
|
||||
class ChatContentAudioTypedDict(TypedDict):
|
||||
r"""Audio input content part. Supported audio formats vary by provider."""
|
||||
|
||||
type: ChatContentAudioType
|
||||
input_audio: ChatContentAudioInputAudioTypedDict
|
||||
|
||||
|
||||
class ChatContentAudio(BaseModel):
|
||||
r"""Audio input content part. Supported audio formats vary by provider."""
|
||||
|
||||
type: ChatContentAudioType
|
||||
|
||||
input_audio: ChatContentAudioInputAudio
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatContentCacheControlType = Literal["ephemeral",]
|
||||
|
||||
|
||||
ChatContentCacheControlTTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
"1h",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ChatContentCacheControlTypedDict(TypedDict):
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
type: ChatContentCacheControlType
|
||||
ttl: NotRequired[ChatContentCacheControlTTL]
|
||||
|
||||
|
||||
class ChatContentCacheControl(BaseModel):
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
type: ChatContentCacheControlType
|
||||
|
||||
ttl: Annotated[
|
||||
Optional[ChatContentCacheControlTTL], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatContentFileType = Literal["file",]
|
||||
|
||||
|
||||
class FileTypedDict(TypedDict):
|
||||
file_data: NotRequired[str]
|
||||
r"""File content as base64 data URL or URL"""
|
||||
file_id: NotRequired[str]
|
||||
r"""File ID for previously uploaded files"""
|
||||
filename: NotRequired[str]
|
||||
r"""Original filename"""
|
||||
|
||||
|
||||
class File(BaseModel):
|
||||
file_data: Optional[str] = None
|
||||
r"""File content as base64 data URL or URL"""
|
||||
|
||||
file_id: Optional[str] = None
|
||||
r"""File ID for previously uploaded files"""
|
||||
|
||||
filename: Optional[str] = None
|
||||
r"""Original filename"""
|
||||
|
||||
|
||||
class ChatContentFileTypedDict(TypedDict):
|
||||
r"""File content part for document processing"""
|
||||
|
||||
type: ChatContentFileType
|
||||
file: FileTypedDict
|
||||
|
||||
|
||||
class ChatContentFile(BaseModel):
|
||||
r"""File content part for document processing"""
|
||||
|
||||
type: ChatContentFileType
|
||||
|
||||
file: File
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatContentImageType = Literal["image_url",]
|
||||
|
||||
|
||||
ChatContentImageDetail = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"low",
|
||||
"high",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatContentImageImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
r"""URL of the image (data: URLs supported)"""
|
||||
detail: NotRequired[ChatContentImageDetail]
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatContentImageImageURL(BaseModel):
|
||||
url: str
|
||||
r"""URL of the image (data: URLs supported)"""
|
||||
|
||||
detail: Annotated[
|
||||
Optional[ChatContentImageDetail], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Image detail level for vision models"""
|
||||
|
||||
|
||||
class ChatContentImageTypedDict(TypedDict):
|
||||
r"""Image content part for vision models"""
|
||||
|
||||
type: ChatContentImageType
|
||||
image_url: ChatContentImageImageURLTypedDict
|
||||
|
||||
|
||||
class ChatContentImage(BaseModel):
|
||||
r"""Image content part for vision models"""
|
||||
|
||||
type: ChatContentImageType
|
||||
|
||||
image_url: ChatContentImageImageURL
|
||||
@@ -0,0 +1,57 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentaudio import ChatContentAudio, ChatContentAudioTypedDict
|
||||
from .chatcontentfile import ChatContentFile, ChatContentFileTypedDict
|
||||
from .chatcontentimage import ChatContentImage, ChatContentImageTypedDict
|
||||
from .chatcontenttext import ChatContentText, ChatContentTextTypedDict
|
||||
from .chatcontentvideo import ChatContentVideo, ChatContentVideoTypedDict
|
||||
from .legacy_chatcontentvideo import (
|
||||
LegacyChatContentVideo,
|
||||
LegacyChatContentVideoTypedDict,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
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,
|
||||
ChatContentFileTypedDict,
|
||||
ChatContentTextTypedDict,
|
||||
ChatContentItems1TypedDict,
|
||||
],
|
||||
)
|
||||
r"""Content part for chat completion messages"""
|
||||
|
||||
|
||||
ChatContentItems = TypeAliasType(
|
||||
"ChatContentItems",
|
||||
Union[
|
||||
ChatContentImage,
|
||||
ChatContentAudio,
|
||||
ChatContentFile,
|
||||
ChatContentText,
|
||||
ChatContentItems1,
|
||||
],
|
||||
)
|
||||
r"""Content part for chat completion messages"""
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentcachecontrol import (
|
||||
ChatContentCacheControl,
|
||||
ChatContentCacheControlTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatContentTextType = Literal["text",]
|
||||
|
||||
|
||||
class ChatContentTextTypedDict(TypedDict):
|
||||
r"""Text content part"""
|
||||
|
||||
type: ChatContentTextType
|
||||
text: str
|
||||
cache_control: NotRequired[ChatContentCacheControlTypedDict]
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
|
||||
class ChatContentText(BaseModel):
|
||||
r"""Text content part"""
|
||||
|
||||
type: ChatContentTextType
|
||||
|
||||
text: str
|
||||
|
||||
cache_control: Optional[ChatContentCacheControl] = None
|
||||
r"""Cache control for the content part"""
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentvideoinput import ChatContentVideoInput, ChatContentVideoInputTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
ChatContentVideoType = Literal["video_url",]
|
||||
|
||||
|
||||
class ChatContentVideoTypedDict(TypedDict):
|
||||
r"""Video input content part"""
|
||||
|
||||
type: ChatContentVideoType
|
||||
video_url: ChatContentVideoInputTypedDict
|
||||
r"""Video input object"""
|
||||
|
||||
|
||||
class ChatContentVideo(BaseModel):
|
||||
r"""Video input content part"""
|
||||
|
||||
type: ChatContentVideoType
|
||||
|
||||
video_url: ChatContentVideoInput
|
||||
r"""Video input object"""
|
||||
@@ -0,0 +1,19 @@
|
||||
"""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 ChatContentVideoInputTypedDict(TypedDict):
|
||||
r"""Video input object"""
|
||||
|
||||
url: str
|
||||
r"""URL of the video (data: URLs supported)"""
|
||||
|
||||
|
||||
class ChatContentVideoInput(BaseModel):
|
||||
r"""Video input object"""
|
||||
|
||||
url: str
|
||||
r"""URL of the video (data: URLs supported)"""
|
||||
@@ -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 ChatDebugOptionsTypedDict(TypedDict):
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
echo_upstream_body: NotRequired[bool]
|
||||
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
|
||||
|
||||
|
||||
class ChatDebugOptions(BaseModel):
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
echo_upstream_body: Optional[bool] = None
|
||||
r"""If true, includes the transformed upstream request body in a debug chunk at the start of the stream. Only works with streaming mode."""
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontenttext import ChatContentText, ChatContentTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatDeveloperMessageRole = Literal["developer",]
|
||||
|
||||
|
||||
ChatDeveloperMessageContentTypedDict = TypeAliasType(
|
||||
"ChatDeveloperMessageContentTypedDict", Union[str, List[ChatContentTextTypedDict]]
|
||||
)
|
||||
r"""Developer message content"""
|
||||
|
||||
|
||||
ChatDeveloperMessageContent = TypeAliasType(
|
||||
"ChatDeveloperMessageContent", Union[str, List[ChatContentText]]
|
||||
)
|
||||
r"""Developer message content"""
|
||||
|
||||
|
||||
class ChatDeveloperMessageTypedDict(TypedDict):
|
||||
r"""Developer message"""
|
||||
|
||||
role: ChatDeveloperMessageRole
|
||||
content: ChatDeveloperMessageContentTypedDict
|
||||
r"""Developer message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the developer message"""
|
||||
|
||||
|
||||
class ChatDeveloperMessage(BaseModel):
|
||||
r"""Developer message"""
|
||||
|
||||
role: ChatDeveloperMessageRole
|
||||
|
||||
content: ChatDeveloperMessageContent
|
||||
r"""Developer message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the developer message"""
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ChatFinishReasonEnum = Union[
|
||||
Literal[
|
||||
"tool_calls",
|
||||
"stop",
|
||||
"length",
|
||||
"content_filter",
|
||||
"error",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatFormatGrammarConfigType = Literal["grammar",]
|
||||
|
||||
|
||||
class ChatFormatGrammarConfigTypedDict(TypedDict):
|
||||
r"""Custom grammar response format"""
|
||||
|
||||
type: ChatFormatGrammarConfigType
|
||||
grammar: str
|
||||
r"""Custom grammar for text generation"""
|
||||
|
||||
|
||||
class ChatFormatGrammarConfig(BaseModel):
|
||||
r"""Custom grammar response format"""
|
||||
|
||||
type: ChatFormatGrammarConfigType
|
||||
|
||||
grammar: str
|
||||
r"""Custom grammar for text generation"""
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatjsonschemaconfig import ChatJSONSchemaConfig, ChatJSONSchemaConfigTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
|
||||
class ChatFormatJSONSchemaConfig(BaseModel):
|
||||
r"""JSON Schema response format for structured outputs"""
|
||||
|
||||
type: ChatFormatJSONSchemaConfigType
|
||||
|
||||
json_schema: ChatJSONSchemaConfig
|
||||
r"""JSON Schema configuration object"""
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatFormatPythonConfigType = Literal["python",]
|
||||
|
||||
|
||||
class ChatFormatPythonConfigTypedDict(TypedDict):
|
||||
r"""Python code response format"""
|
||||
|
||||
type: ChatFormatPythonConfigType
|
||||
|
||||
|
||||
class ChatFormatPythonConfig(BaseModel):
|
||||
r"""Python code response format"""
|
||||
|
||||
type: ChatFormatPythonConfigType
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatFormatTextConfigType = Literal["text",]
|
||||
|
||||
|
||||
class ChatFormatTextConfigTypedDict(TypedDict):
|
||||
r"""Default text response format"""
|
||||
|
||||
type: ChatFormatTextConfigType
|
||||
|
||||
|
||||
class ChatFormatTextConfig(BaseModel):
|
||||
r"""Default text response format"""
|
||||
|
||||
type: ChatFormatTextConfigType
|
||||
@@ -0,0 +1,134 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentcachecontrol import (
|
||||
ChatContentCacheControl,
|
||||
ChatContentCacheControlTypedDict,
|
||||
)
|
||||
from .chatwebsearchservertool import (
|
||||
ChatWebSearchServerTool,
|
||||
ChatWebSearchServerToolTypedDict,
|
||||
)
|
||||
from .chatwebsearchshorthand import (
|
||||
ChatWebSearchShorthand,
|
||||
ChatWebSearchShorthandTypedDict,
|
||||
)
|
||||
from .datetimeservertool import DatetimeServerTool, DatetimeServerToolTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from typing import Any, Dict, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatFunctionToolType = Literal["function",]
|
||||
|
||||
|
||||
class ChatFunctionToolFunctionFunctionTypedDict(TypedDict):
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
name: str
|
||||
r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
description: NotRequired[str]
|
||||
r"""Function description for the model"""
|
||||
parameters: NotRequired[Dict[str, Nullable[Any]]]
|
||||
r"""Function parameters as JSON Schema object"""
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
|
||||
class ChatFunctionToolFunctionFunction(BaseModel):
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
name: str
|
||||
r"""Function name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
|
||||
description: Optional[str] = None
|
||||
r"""Function description for the model"""
|
||||
|
||||
parameters: Optional[Dict[str, Nullable[Any]]] = None
|
||||
r"""Function parameters as JSON Schema object"""
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["description", "parameters", "strict"]
|
||||
nullable_fields = ["strict"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatFunctionToolFunctionTypedDict(TypedDict):
|
||||
type: ChatFunctionToolType
|
||||
function: ChatFunctionToolFunctionFunctionTypedDict
|
||||
r"""Function definition for tool calling"""
|
||||
cache_control: NotRequired[ChatContentCacheControlTypedDict]
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
|
||||
class ChatFunctionToolFunction(BaseModel):
|
||||
type: ChatFunctionToolType
|
||||
|
||||
function: ChatFunctionToolFunctionFunction
|
||||
r"""Function definition for tool calling"""
|
||||
|
||||
cache_control: Optional[ChatContentCacheControl] = None
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
|
||||
ChatFunctionToolTypedDict = TypeAliasType(
|
||||
"ChatFunctionToolTypedDict",
|
||||
Union[
|
||||
DatetimeServerToolTypedDict,
|
||||
ChatWebSearchServerToolTypedDict,
|
||||
ChatFunctionToolFunctionTypedDict,
|
||||
ChatWebSearchShorthandTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Tool definition for function calling (regular function or OpenRouter built-in server tool)"""
|
||||
|
||||
|
||||
ChatFunctionTool = Annotated[
|
||||
Union[
|
||||
Annotated[ChatFunctionToolFunction, Tag("function")],
|
||||
Annotated[DatetimeServerTool, Tag("openrouter:datetime")],
|
||||
Annotated[ChatWebSearchServerTool, Tag("openrouter:web_search")],
|
||||
Annotated[ChatWebSearchShorthand, Tag("web_search")],
|
||||
Annotated[ChatWebSearchShorthand, Tag("web_search_preview")],
|
||||
Annotated[ChatWebSearchShorthand, Tag("web_search_preview_2025_03_11")],
|
||||
Annotated[ChatWebSearchShorthand, Tag("web_search_2025_08_26")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""Tool definition for function calling (regular function or OpenRouter built-in server tool)"""
|
||||
@@ -87,6 +87,7 @@ ChatGenerationParamsSortEnum = Union[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -96,6 +97,7 @@ ChatGenerationParamsProviderSortConfigEnum = Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
]
|
||||
|
||||
|
||||
@@ -104,6 +106,7 @@ ChatGenerationParamsBy = Union[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -194,6 +197,7 @@ ChatGenerationParamsProviderSort = Union[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -449,6 +453,10 @@ class ChatGenerationParamsPluginWebTypedDict(TypedDict):
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[WebSearchEngine]
|
||||
r"""The search engine to use for web search."""
|
||||
include_domains: NotRequired[List[str]]
|
||||
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
exclude_domains: NotRequired[List[str]]
|
||||
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
|
||||
class ChatGenerationParamsPluginWeb(BaseModel):
|
||||
@@ -466,6 +474,12 @@ class ChatGenerationParamsPluginWeb(BaseModel):
|
||||
] = None
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
include_domains: Optional[List[str]] = None
|
||||
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
exclude_domains: Optional[List[str]] = None
|
||||
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
|
||||
ChatGenerationParamsIDModeration = Literal["moderation",]
|
||||
|
||||
@@ -671,11 +685,41 @@ Modality = Union[
|
||||
Literal[
|
||||
"text",
|
||||
"image",
|
||||
"audio",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
ChatGenerationParamsType = Literal["ephemeral",]
|
||||
|
||||
|
||||
ChatGenerationParamsTTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
"1h",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class CacheControlTypedDict(TypedDict):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: ChatGenerationParamsType
|
||||
ttl: NotRequired[ChatGenerationParamsTTL]
|
||||
|
||||
|
||||
class CacheControl(BaseModel):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: ChatGenerationParamsType
|
||||
|
||||
ttl: Annotated[
|
||||
Optional[ChatGenerationParamsTTL], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
|
||||
class ChatGenerationParamsTypedDict(TypedDict):
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
@@ -706,7 +750,7 @@ class ChatGenerationParamsTypedDict(TypedDict):
|
||||
max_completion_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens in completion"""
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16."""
|
||||
metadata: NotRequired[Dict[str, str]]
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
presence_penalty: NotRequired[Nullable[float]]
|
||||
@@ -737,7 +781,9 @@ class ChatGenerationParamsTypedDict(TypedDict):
|
||||
image_config: NotRequired[Dict[str, ChatGenerationParamsImageConfigTypedDict]]
|
||||
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
|
||||
modalities: NotRequired[List[Modality]]
|
||||
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
|
||||
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
|
||||
cache_control: NotRequired[CacheControlTypedDict]
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
|
||||
class ChatGenerationParams(BaseModel):
|
||||
@@ -783,7 +829,7 @@ class ChatGenerationParams(BaseModel):
|
||||
r"""Maximum tokens in completion"""
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16."""
|
||||
|
||||
metadata: Optional[Dict[str, str]] = None
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
@@ -832,7 +878,10 @@ class ChatGenerationParams(BaseModel):
|
||||
modalities: Optional[
|
||||
List[Annotated[Modality, PlainValidator(validate_open_enum(False))]]
|
||||
] = None
|
||||
r"""Output modalities for the response. Supported values are \"text\" and \"image\"."""
|
||||
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
|
||||
|
||||
cache_control: Optional[CacheControl] = None
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
@@ -866,6 +915,7 @@ class ChatGenerationParams(BaseModel):
|
||||
"debug",
|
||||
"image_config",
|
||||
"modalities",
|
||||
"cache_control",
|
||||
]
|
||||
nullable_fields = [
|
||||
"provider",
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatJSONSchemaConfigTypedDict(TypedDict):
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
name: str
|
||||
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
description: NotRequired[str]
|
||||
r"""Schema description for the model"""
|
||||
schema_: NotRequired[Dict[str, Nullable[Any]]]
|
||||
r"""JSON Schema object"""
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
|
||||
class ChatJSONSchemaConfig(BaseModel):
|
||||
r"""JSON Schema configuration object"""
|
||||
|
||||
name: str
|
||||
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
|
||||
|
||||
description: Optional[str] = None
|
||||
r"""Schema description for the model"""
|
||||
|
||||
schema_: Annotated[
|
||||
Optional[Dict[str, Nullable[Any]]], pydantic.Field(alias="schema")
|
||||
] = None
|
||||
r"""JSON Schema object"""
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
r"""Enable strict schema adherence"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["description", "schema", "strict"]
|
||||
nullable_fields = ["strict"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -5,6 +5,10 @@ from .chatmessagecontentitemaudio import (
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemfile import (
|
||||
ChatMessageContentItemFile,
|
||||
ChatMessageContentItemFileTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemimage import (
|
||||
ChatMessageContentItemImage,
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
@@ -49,6 +53,7 @@ ChatMessageContentItemTypedDict = TypeAliasType(
|
||||
Union[
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
ChatMessageContentItemFileTypedDict,
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
ChatMessageContentItem1TypedDict,
|
||||
],
|
||||
@@ -61,6 +66,7 @@ ChatMessageContentItem = TypeAliasType(
|
||||
Union[
|
||||
ChatMessageContentItemImage,
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemFile,
|
||||
ChatMessageContentItemText,
|
||||
ChatMessageContentItem1,
|
||||
],
|
||||
|
||||
@@ -11,7 +11,7 @@ from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
ChatMessageContentItemCacheControlType = Literal["ephemeral",]
|
||||
|
||||
|
||||
TTL = Union[
|
||||
ChatMessageContentItemCacheControlTTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
"1h",
|
||||
@@ -24,7 +24,7 @@ class ChatMessageContentItemCacheControlTypedDict(TypedDict):
|
||||
r"""Cache control for the content part"""
|
||||
|
||||
type: ChatMessageContentItemCacheControlType
|
||||
ttl: NotRequired[TTL]
|
||||
ttl: NotRequired[ChatMessageContentItemCacheControlTTL]
|
||||
|
||||
|
||||
class ChatMessageContentItemCacheControl(BaseModel):
|
||||
@@ -32,4 +32,7 @@ class ChatMessageContentItemCacheControl(BaseModel):
|
||||
|
||||
type: ChatMessageContentItemCacheControlType
|
||||
|
||||
ttl: Annotated[Optional[TTL], PlainValidator(validate_open_enum(False))] = None
|
||||
ttl: Annotated[
|
||||
Optional[ChatMessageContentItemCacheControlTTL],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemFileType = Literal["file",]
|
||||
|
||||
|
||||
class FileTypedDict(TypedDict):
|
||||
file_data: NotRequired[str]
|
||||
r"""File content as base64 data URL or URL"""
|
||||
file_id: NotRequired[str]
|
||||
r"""File ID for previously uploaded files"""
|
||||
filename: NotRequired[str]
|
||||
r"""Original filename"""
|
||||
|
||||
|
||||
class File(BaseModel):
|
||||
file_data: Optional[str] = None
|
||||
r"""File content as base64 data URL or URL"""
|
||||
|
||||
file_id: Optional[str] = None
|
||||
r"""File ID for previously uploaded files"""
|
||||
|
||||
filename: Optional[str] = None
|
||||
r"""Original filename"""
|
||||
|
||||
|
||||
class ChatMessageContentItemFileTypedDict(TypedDict):
|
||||
r"""File content part for document processing"""
|
||||
|
||||
type: ChatMessageContentItemFileType
|
||||
file: FileTypedDict
|
||||
|
||||
|
||||
class ChatMessageContentItemFile(BaseModel):
|
||||
r"""File content part for document processing"""
|
||||
|
||||
type: ChatMessageContentItemFileType
|
||||
|
||||
file: File
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatassistantmessage import ChatAssistantMessage, ChatAssistantMessageTypedDict
|
||||
from .chatdevelopermessage import ChatDeveloperMessage, ChatDeveloperMessageTypedDict
|
||||
from .chatsystemmessage import ChatSystemMessage, ChatSystemMessageTypedDict
|
||||
from .chattoolmessage import ChatToolMessage, ChatToolMessageTypedDict
|
||||
from .chatusermessage import ChatUserMessage, ChatUserMessageTypedDict
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ChatMessagesTypedDict = TypeAliasType(
|
||||
"ChatMessagesTypedDict",
|
||||
Union[
|
||||
ChatSystemMessageTypedDict,
|
||||
ChatUserMessageTypedDict,
|
||||
ChatDeveloperMessageTypedDict,
|
||||
ChatToolMessageTypedDict,
|
||||
ChatAssistantMessageTypedDict,
|
||||
],
|
||||
)
|
||||
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[ChatToolMessage, Tag("tool")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "role", "role")),
|
||||
]
|
||||
r"""Chat completion message with role-based discrimination"""
|
||||
@@ -5,10 +5,16 @@ from .chatmessagetokenlogprob import (
|
||||
ChatMessageTokenLogprob,
|
||||
ChatMessageTokenLogprobTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import TypedDict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobsTypedDict(TypedDict):
|
||||
@@ -16,7 +22,7 @@ class ChatMessageTokenLogprobsTypedDict(TypedDict):
|
||||
|
||||
content: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
refusal: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
refusal: NotRequired[Nullable[List[ChatMessageTokenLogprobTypedDict]]]
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
|
||||
@@ -26,12 +32,12 @@ class ChatMessageTokenLogprobs(BaseModel):
|
||||
content: Nullable[List[ChatMessageTokenLogprob]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
|
||||
refusal: Nullable[List[ChatMessageTokenLogprob]]
|
||||
refusal: OptionalNullable[List[ChatMessageTokenLogprob]] = UNSET
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
optional_fields = ["refusal"]
|
||||
nullable_fields = ["content", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatNamedToolChoiceType = Literal["function",]
|
||||
|
||||
|
||||
class ChatNamedToolChoiceFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
|
||||
class ChatNamedToolChoiceFunction(BaseModel):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
|
||||
class ChatNamedToolChoiceTypedDict(TypedDict):
|
||||
r"""Named tool choice for specific function"""
|
||||
|
||||
type: ChatNamedToolChoiceType
|
||||
function: ChatNamedToolChoiceFunctionTypedDict
|
||||
|
||||
|
||||
class ChatNamedToolChoice(BaseModel):
|
||||
r"""Named tool choice for specific function"""
|
||||
|
||||
type: ChatNamedToolChoiceType
|
||||
|
||||
function: ChatNamedToolChoiceFunction
|
||||
@@ -0,0 +1,15 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ChatReasoningSummaryVerbosityEnum = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"concise",
|
||||
"detailed",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,996 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatdebugoptions import ChatDebugOptions, ChatDebugOptionsTypedDict
|
||||
from .chatformatgrammarconfig import (
|
||||
ChatFormatGrammarConfig,
|
||||
ChatFormatGrammarConfigTypedDict,
|
||||
)
|
||||
from .chatformatjsonschemaconfig import (
|
||||
ChatFormatJSONSchemaConfig,
|
||||
ChatFormatJSONSchemaConfigTypedDict,
|
||||
)
|
||||
from .chatformatpythonconfig import (
|
||||
ChatFormatPythonConfig,
|
||||
ChatFormatPythonConfigTypedDict,
|
||||
)
|
||||
from .chatformattextconfig import ChatFormatTextConfig, ChatFormatTextConfigTypedDict
|
||||
from .chatfunctiontool import ChatFunctionTool, ChatFunctionToolTypedDict
|
||||
from .chatmessages import ChatMessages, ChatMessagesTypedDict
|
||||
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
|
||||
from .chattoolchoice import ChatToolChoice, ChatToolChoiceTypedDict
|
||||
from .contextcompressionengine import ContextCompressionEngine
|
||||
from .datacollection import DataCollection
|
||||
from .formatjsonobjectconfig import (
|
||||
FormatJSONObjectConfig,
|
||||
FormatJSONObjectConfigTypedDict,
|
||||
)
|
||||
from .pdfparseroptions import PDFParserOptions, PDFParserOptionsTypedDict
|
||||
from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
|
||||
from .preferredminthroughput import (
|
||||
PreferredMinThroughput,
|
||||
PreferredMinThroughputTypedDict,
|
||||
)
|
||||
from .providername import ProviderName
|
||||
from .quantization import Quantization
|
||||
from .websearchengine import WebSearchEngine
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatRequestOrderTypedDict = TypeAliasType(
|
||||
"ChatRequestOrderTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatRequestOrder = TypeAliasType(
|
||||
"ChatRequestOrder",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestOnlyTypedDict = TypeAliasType(
|
||||
"ChatRequestOnlyTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatRequestOnly = TypeAliasType(
|
||||
"ChatRequestOnly",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestIgnoreTypedDict = TypeAliasType(
|
||||
"ChatRequestIgnoreTypedDict", Union[ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
ChatRequestIgnore = TypeAliasType(
|
||||
"ChatRequestIgnore",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestSortEnum = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
ChatRequestProviderSortConfigEnum = Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
]
|
||||
|
||||
|
||||
ChatRequestBy = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
ChatRequestPartition = Union[
|
||||
Literal[
|
||||
"model",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ChatRequestProviderSortConfigTypedDict(TypedDict):
|
||||
by: NotRequired[Nullable[ChatRequestBy]]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
partition: NotRequired[Nullable[ChatRequestPartition]]
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
|
||||
class ChatRequestProviderSortConfig(BaseModel):
|
||||
by: Annotated[
|
||||
OptionalNullable[ChatRequestBy], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
partition: Annotated[
|
||||
OptionalNullable[ChatRequestPartition],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["by", "partition"]
|
||||
nullable_fields = ["by", "partition"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
ChatRequestProviderSortConfigUnionTypedDict = TypeAliasType(
|
||||
"ChatRequestProviderSortConfigUnionTypedDict",
|
||||
Union[ChatRequestProviderSortConfigTypedDict, ChatRequestProviderSortConfigEnum],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestProviderSortConfigUnion = TypeAliasType(
|
||||
"ChatRequestProviderSortConfigUnion",
|
||||
Union[ChatRequestProviderSortConfig, ChatRequestProviderSortConfigEnum],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestProviderSort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
"exacto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The provider sorting strategy (price, throughput, latency)"""
|
||||
|
||||
|
||||
ChatRequestSortUnionTypedDict = TypeAliasType(
|
||||
"ChatRequestSortUnionTypedDict",
|
||||
Union[
|
||||
ChatRequestProviderSort,
|
||||
ChatRequestProviderSortConfigUnionTypedDict,
|
||||
ChatRequestSortEnum,
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
ChatRequestSortUnion = TypeAliasType(
|
||||
"ChatRequestSortUnion",
|
||||
Union[
|
||||
Annotated[ChatRequestProviderSort, PlainValidator(validate_open_enum(False))],
|
||||
ChatRequestProviderSortConfigUnion,
|
||||
Annotated[ChatRequestSortEnum, PlainValidator(validate_open_enum(False))],
|
||||
],
|
||||
)
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
class ChatRequestMaxPriceTypedDict(TypedDict):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: NotRequired[str]
|
||||
r"""Price per million prompt tokens"""
|
||||
completion: NotRequired[str]
|
||||
image: NotRequired[str]
|
||||
audio: NotRequired[str]
|
||||
request: NotRequired[str]
|
||||
|
||||
|
||||
class ChatRequestMaxPrice(BaseModel):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: Optional[str] = None
|
||||
r"""Price per million prompt tokens"""
|
||||
|
||||
completion: Optional[str] = None
|
||||
|
||||
image: Optional[str] = None
|
||||
|
||||
audio: Optional[str] = None
|
||||
|
||||
request: Optional[str] = None
|
||||
|
||||
|
||||
class ChatRequestProviderTypedDict(TypedDict):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
allow_fallbacks: NotRequired[Nullable[bool]]
|
||||
r"""Whether to allow backup providers to serve requests
|
||||
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
||||
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
||||
|
||||
"""
|
||||
require_parameters: NotRequired[Nullable[bool]]
|
||||
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
|
||||
data_collection: NotRequired[Nullable[DataCollection]]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
|
||||
- deny: use only providers which do not collect user data.
|
||||
"""
|
||||
zdr: NotRequired[Nullable[bool]]
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
enforce_distillable_text: NotRequired[Nullable[bool]]
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
order: NotRequired[Nullable[List[ChatRequestOrderTypedDict]]]
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
only: NotRequired[Nullable[List[ChatRequestOnlyTypedDict]]]
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
ignore: NotRequired[Nullable[List[ChatRequestIgnoreTypedDict]]]
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
quantizations: NotRequired[Nullable[List[Quantization]]]
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
sort: NotRequired[Nullable[ChatRequestSortUnionTypedDict]]
|
||||
max_price: NotRequired[ChatRequestMaxPriceTypedDict]
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
|
||||
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
||||
preferred_max_latency: NotRequired[Nullable[PreferredMaxLatencyTypedDict]]
|
||||
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
||||
|
||||
|
||||
class ChatRequestProvider(BaseModel):
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
allow_fallbacks: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to allow backup providers to serve requests
|
||||
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
||||
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
||||
|
||||
"""
|
||||
|
||||
require_parameters: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
|
||||
|
||||
data_collection: Annotated[
|
||||
OptionalNullable[DataCollection], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
|
||||
- deny: use only providers which do not collect user data.
|
||||
"""
|
||||
|
||||
zdr: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
|
||||
enforce_distillable_text: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
|
||||
order: OptionalNullable[List[ChatRequestOrder]] = UNSET
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
|
||||
only: OptionalNullable[List[ChatRequestOnly]] = UNSET
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
|
||||
ignore: OptionalNullable[List[ChatRequestIgnore]] = UNSET
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
|
||||
quantizations: OptionalNullable[
|
||||
List[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: OptionalNullable[ChatRequestSortUnion] = UNSET
|
||||
|
||||
max_price: Optional[ChatRequestMaxPrice] = None
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = UNSET
|
||||
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
||||
|
||||
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
|
||||
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
]
|
||||
nullable_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"preferred_min_throughput",
|
||||
"preferred_max_latency",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
ChatRequestIDContextCompression = Literal["context-compression",]
|
||||
|
||||
|
||||
class ChatRequestPluginContextCompressionTypedDict(TypedDict):
|
||||
id: ChatRequestIDContextCompression
|
||||
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 ChatRequestPluginContextCompression(BaseModel):
|
||||
id: ChatRequestIDContextCompression
|
||||
|
||||
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\"."""
|
||||
|
||||
|
||||
ChatRequestIDResponseHealing = Literal["response-healing",]
|
||||
|
||||
|
||||
class ChatRequestPluginResponseHealingTypedDict(TypedDict):
|
||||
id: ChatRequestIDResponseHealing
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
class ChatRequestPluginResponseHealing(BaseModel):
|
||||
id: ChatRequestIDResponseHealing
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the response-healing plugin for this request. Defaults to true."""
|
||||
|
||||
|
||||
ChatRequestIDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
class ChatRequestPluginFileParserTypedDict(TypedDict):
|
||||
id: ChatRequestIDFileParser
|
||||
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 ChatRequestPluginFileParser(BaseModel):
|
||||
id: ChatRequestIDFileParser
|
||||
|
||||
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."""
|
||||
|
||||
|
||||
ChatRequestIDWeb = Literal["web",]
|
||||
|
||||
|
||||
class ChatRequestPluginWebTypedDict(TypedDict):
|
||||
id: ChatRequestIDWeb
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
max_results: NotRequired[float]
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[WebSearchEngine]
|
||||
r"""The search engine to use for web search."""
|
||||
include_domains: NotRequired[List[str]]
|
||||
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
exclude_domains: NotRequired[List[str]]
|
||||
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
|
||||
class ChatRequestPluginWeb(BaseModel):
|
||||
id: ChatRequestIDWeb
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the web-search plugin for this request. Defaults to true."""
|
||||
|
||||
max_results: Optional[float] = None
|
||||
|
||||
search_prompt: Optional[str] = None
|
||||
|
||||
engine: Annotated[
|
||||
Optional[WebSearchEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""The search engine to use for web search."""
|
||||
|
||||
include_domains: Optional[List[str]] = None
|
||||
r"""A list of domains to restrict web search results to. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
exclude_domains: Optional[List[str]] = None
|
||||
r"""A list of domains to exclude from web search results. Supports wildcards (e.g. \"*.substack.com\") and path filtering (e.g. \"openai.com/blog\")."""
|
||||
|
||||
|
||||
ChatRequestIDModeration = Literal["moderation",]
|
||||
|
||||
|
||||
class ChatRequestPluginModerationTypedDict(TypedDict):
|
||||
id: ChatRequestIDModeration
|
||||
|
||||
|
||||
class ChatRequestPluginModeration(BaseModel):
|
||||
id: ChatRequestIDModeration
|
||||
|
||||
|
||||
ChatRequestIDAutoRouter = Literal["auto-router",]
|
||||
|
||||
|
||||
class ChatRequestPluginAutoRouterTypedDict(TypedDict):
|
||||
id: ChatRequestIDAutoRouter
|
||||
enabled: NotRequired[bool]
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
allowed_models: NotRequired[List[str]]
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
class ChatRequestPluginAutoRouter(BaseModel):
|
||||
id: ChatRequestIDAutoRouter
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||||
|
||||
allowed_models: Optional[List[str]] = None
|
||||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||||
|
||||
|
||||
ChatRequestPluginUnionTypedDict = TypeAliasType(
|
||||
"ChatRequestPluginUnionTypedDict",
|
||||
Union[
|
||||
ChatRequestPluginModerationTypedDict,
|
||||
ChatRequestPluginResponseHealingTypedDict,
|
||||
ChatRequestPluginAutoRouterTypedDict,
|
||||
ChatRequestPluginFileParserTypedDict,
|
||||
ChatRequestPluginContextCompressionTypedDict,
|
||||
ChatRequestPluginWebTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatRequestPluginUnion = Annotated[
|
||||
Union[
|
||||
Annotated[ChatRequestPluginAutoRouter, Tag("auto-router")],
|
||||
Annotated[ChatRequestPluginModeration, Tag("moderation")],
|
||||
Annotated[ChatRequestPluginWeb, Tag("web")],
|
||||
Annotated[ChatRequestPluginFileParser, Tag("file-parser")],
|
||||
Annotated[ChatRequestPluginResponseHealing, Tag("response-healing")],
|
||||
Annotated[ChatRequestPluginContextCompression, Tag("context-compression")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "id", "id")),
|
||||
]
|
||||
|
||||
|
||||
class ChatRequestTraceTypedDict(TypedDict):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
trace_id: NotRequired[str]
|
||||
trace_name: NotRequired[str]
|
||||
span_name: NotRequired[str]
|
||||
generation_name: NotRequired[str]
|
||||
parent_span_id: NotRequired[str]
|
||||
|
||||
|
||||
class ChatRequestTrace(BaseModel):
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
||||
)
|
||||
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
|
||||
|
||||
trace_id: Optional[str] = None
|
||||
|
||||
trace_name: Optional[str] = None
|
||||
|
||||
span_name: Optional[str] = None
|
||||
|
||||
generation_name: Optional[str] = None
|
||||
|
||||
parent_span_id: Optional[str] = None
|
||||
|
||||
@property
|
||||
def additional_properties(self):
|
||||
return self.__pydantic_extra__
|
||||
|
||||
@additional_properties.setter
|
||||
def additional_properties(self, value):
|
||||
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
||||
|
||||
|
||||
Effort = Union[
|
||||
Literal[
|
||||
"xhigh",
|
||||
"high",
|
||||
"medium",
|
||||
"low",
|
||||
"minimal",
|
||||
"none",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
|
||||
|
||||
class ReasoningTypedDict(TypedDict):
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
effort: NotRequired[Nullable[Effort]]
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
summary: NotRequired[Nullable[Any]]
|
||||
|
||||
|
||||
class Reasoning(BaseModel):
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
effort: Annotated[
|
||||
OptionalNullable[Effort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Constrains effort on reasoning for reasoning models"""
|
||||
|
||||
summary: OptionalNullable[Any] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary"]
|
||||
nullable_fields = ["effort", "summary"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
ResponseFormatTypedDict = TypeAliasType(
|
||||
"ResponseFormatTypedDict",
|
||||
Union[
|
||||
ChatFormatTextConfigTypedDict,
|
||||
FormatJSONObjectConfigTypedDict,
|
||||
ChatFormatPythonConfigTypedDict,
|
||||
ChatFormatJSONSchemaConfigTypedDict,
|
||||
ChatFormatGrammarConfigTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Response format configuration"""
|
||||
|
||||
|
||||
ResponseFormat = Annotated[
|
||||
Union[
|
||||
Annotated[ChatFormatTextConfig, Tag("text")],
|
||||
Annotated[FormatJSONObjectConfig, Tag("json_object")],
|
||||
Annotated[ChatFormatJSONSchemaConfig, Tag("json_schema")],
|
||||
Annotated[ChatFormatGrammarConfig, Tag("grammar")],
|
||||
Annotated[ChatFormatPythonConfig, Tag("python")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""Response format configuration"""
|
||||
|
||||
|
||||
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str], Any])
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
|
||||
Stop = TypeAliasType("Stop", Union[str, List[str], Any])
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
|
||||
ChatRequestImageConfigTypedDict = TypeAliasType(
|
||||
"ChatRequestImageConfigTypedDict", Union[str, float, List[Nullable[Any]]]
|
||||
)
|
||||
|
||||
|
||||
ChatRequestImageConfig = TypeAliasType(
|
||||
"ChatRequestImageConfig", Union[str, float, List[Nullable[Any]]]
|
||||
)
|
||||
|
||||
|
||||
Modality = Union[
|
||||
Literal[
|
||||
"text",
|
||||
"image",
|
||||
"audio",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
ChatRequestType = Literal["ephemeral",]
|
||||
|
||||
|
||||
ChatRequestTTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
"1h",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class CacheControlTypedDict(TypedDict):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: ChatRequestType
|
||||
ttl: NotRequired[ChatRequestTTL]
|
||||
|
||||
|
||||
class CacheControl(BaseModel):
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
type: ChatRequestType
|
||||
|
||||
ttl: Annotated[
|
||||
Optional[ChatRequestTTL], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
|
||||
ChatRequestServiceTier = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"default",
|
||||
"flex",
|
||||
"priority",
|
||||
"scale",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The service tier to use for processing this request."""
|
||||
|
||||
|
||||
class ChatRequestTypedDict(TypedDict):
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
messages: List[ChatMessagesTypedDict]
|
||||
r"""List of messages for the conversation"""
|
||||
provider: NotRequired[Nullable[ChatRequestProviderTypedDict]]
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
plugins: NotRequired[List[ChatRequestPluginUnionTypedDict]]
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
user: NotRequired[str]
|
||||
r"""Unique user identifier"""
|
||||
session_id: NotRequired[str]
|
||||
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters."""
|
||||
trace: NotRequired[ChatRequestTraceTypedDict]
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
model: NotRequired[str]
|
||||
r"""Model to use for completion"""
|
||||
models: NotRequired[List[str]]
|
||||
r"""Models to use for completion"""
|
||||
frequency_penalty: NotRequired[Nullable[float]]
|
||||
r"""Frequency penalty (-2.0 to 2.0)"""
|
||||
logit_bias: NotRequired[Nullable[Dict[str, float]]]
|
||||
r"""Token logit bias adjustments"""
|
||||
logprobs: NotRequired[Nullable[bool]]
|
||||
r"""Return log probabilities"""
|
||||
top_logprobs: NotRequired[Nullable[float]]
|
||||
r"""Number of top log probabilities to return (0-20)"""
|
||||
max_completion_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens in completion"""
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16."""
|
||||
metadata: NotRequired[Dict[str, str]]
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
presence_penalty: NotRequired[Nullable[float]]
|
||||
r"""Presence penalty (-2.0 to 2.0)"""
|
||||
reasoning: NotRequired[ReasoningTypedDict]
|
||||
r"""Configuration options for reasoning models"""
|
||||
response_format: NotRequired[ResponseFormatTypedDict]
|
||||
r"""Response format configuration"""
|
||||
seed: NotRequired[Nullable[int]]
|
||||
r"""Random seed for deterministic outputs"""
|
||||
stop: NotRequired[Nullable[StopTypedDict]]
|
||||
r"""Stop sequences (up to 4)"""
|
||||
stream: NotRequired[bool]
|
||||
r"""Enable streaming response"""
|
||||
stream_options: NotRequired[Nullable[ChatStreamOptionsTypedDict]]
|
||||
r"""Streaming configuration options"""
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
r"""Sampling temperature (0-2)"""
|
||||
parallel_tool_calls: NotRequired[Nullable[bool]]
|
||||
tool_choice: NotRequired[ChatToolChoiceTypedDict]
|
||||
r"""Tool choice configuration"""
|
||||
tools: NotRequired[List[ChatFunctionToolTypedDict]]
|
||||
r"""Available tools for function calling"""
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
debug: NotRequired[ChatDebugOptionsTypedDict]
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
image_config: NotRequired[Dict[str, ChatRequestImageConfigTypedDict]]
|
||||
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
|
||||
modalities: NotRequired[List[Modality]]
|
||||
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
|
||||
cache_control: NotRequired[CacheControlTypedDict]
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
service_tier: NotRequired[Nullable[ChatRequestServiceTier]]
|
||||
r"""The service tier to use for processing this request."""
|
||||
|
||||
|
||||
class ChatRequest(BaseModel):
|
||||
r"""Chat completion request parameters"""
|
||||
|
||||
messages: List[ChatMessages]
|
||||
r"""List of messages for the conversation"""
|
||||
|
||||
provider: OptionalNullable[ChatRequestProvider] = UNSET
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
plugins: Optional[List[ChatRequestPluginUnion]] = None
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
user: Optional[str] = None
|
||||
r"""Unique user identifier"""
|
||||
|
||||
session_id: Optional[str] = None
|
||||
r"""A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters."""
|
||||
|
||||
trace: Optional[ChatRequestTrace] = None
|
||||
r"""Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations."""
|
||||
|
||||
model: Optional[str] = None
|
||||
r"""Model to use for completion"""
|
||||
|
||||
models: Optional[List[str]] = None
|
||||
r"""Models to use for completion"""
|
||||
|
||||
frequency_penalty: OptionalNullable[float] = UNSET
|
||||
r"""Frequency penalty (-2.0 to 2.0)"""
|
||||
|
||||
logit_bias: OptionalNullable[Dict[str, float]] = UNSET
|
||||
r"""Token logit bias adjustments"""
|
||||
|
||||
logprobs: OptionalNullable[bool] = UNSET
|
||||
r"""Return log probabilities"""
|
||||
|
||||
top_logprobs: OptionalNullable[float] = UNSET
|
||||
r"""Number of top log probabilities to return (0-20)"""
|
||||
|
||||
max_completion_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Maximum tokens in completion"""
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16."""
|
||||
|
||||
metadata: Optional[Dict[str, str]] = None
|
||||
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
|
||||
|
||||
presence_penalty: OptionalNullable[float] = UNSET
|
||||
r"""Presence penalty (-2.0 to 2.0)"""
|
||||
|
||||
reasoning: Optional[Reasoning] = None
|
||||
r"""Configuration options for reasoning models"""
|
||||
|
||||
response_format: Optional[ResponseFormat] = None
|
||||
r"""Response format configuration"""
|
||||
|
||||
seed: OptionalNullable[int] = UNSET
|
||||
r"""Random seed for deterministic outputs"""
|
||||
|
||||
stop: OptionalNullable[Stop] = UNSET
|
||||
r"""Stop sequences (up to 4)"""
|
||||
|
||||
stream: Optional[bool] = False
|
||||
r"""Enable streaming response"""
|
||||
|
||||
stream_options: OptionalNullable[ChatStreamOptions] = UNSET
|
||||
r"""Streaming configuration options"""
|
||||
|
||||
temperature: OptionalNullable[float] = 1
|
||||
r"""Sampling temperature (0-2)"""
|
||||
|
||||
parallel_tool_calls: OptionalNullable[bool] = UNSET
|
||||
|
||||
tool_choice: Optional[ChatToolChoice] = None
|
||||
r"""Tool choice configuration"""
|
||||
|
||||
tools: Optional[List[ChatFunctionTool]] = None
|
||||
r"""Available tools for function calling"""
|
||||
|
||||
top_p: OptionalNullable[float] = 1
|
||||
r"""Nucleus sampling parameter (0-1)"""
|
||||
|
||||
debug: Optional[ChatDebugOptions] = None
|
||||
r"""Debug options for inspecting request transformations (streaming only)"""
|
||||
|
||||
image_config: Optional[Dict[str, ChatRequestImageConfig]] = None
|
||||
r"""Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details."""
|
||||
|
||||
modalities: Optional[
|
||||
List[Annotated[Modality, PlainValidator(validate_open_enum(False))]]
|
||||
] = None
|
||||
r"""Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\"."""
|
||||
|
||||
cache_control: Optional[CacheControl] = None
|
||||
r"""Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
|
||||
|
||||
service_tier: Annotated[
|
||||
OptionalNullable[ChatRequestServiceTier],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""The service tier to use for processing this request."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"provider",
|
||||
"plugins",
|
||||
"user",
|
||||
"session_id",
|
||||
"trace",
|
||||
"model",
|
||||
"models",
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"top_logprobs",
|
||||
"max_completion_tokens",
|
||||
"max_tokens",
|
||||
"metadata",
|
||||
"presence_penalty",
|
||||
"reasoning",
|
||||
"response_format",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream",
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"parallel_tool_calls",
|
||||
"tool_choice",
|
||||
"tools",
|
||||
"top_p",
|
||||
"debug",
|
||||
"image_config",
|
||||
"modalities",
|
||||
"cache_control",
|
||||
"service_tier",
|
||||
]
|
||||
nullable_fields = [
|
||||
"provider",
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"top_logprobs",
|
||||
"max_completion_tokens",
|
||||
"max_tokens",
|
||||
"presence_penalty",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"parallel_tool_calls",
|
||||
"top_p",
|
||||
"service_tier",
|
||||
]
|
||||
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
|
||||
@@ -6,13 +6,7 @@ from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsageTypedDict,
|
||||
)
|
||||
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
@@ -33,7 +27,7 @@ class ChatResponseTypedDict(TypedDict):
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
object: ChatResponseObject
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
system_fingerprint: Nullable[str]
|
||||
r"""System fingerprint"""
|
||||
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
|
||||
r"""Token usage statistics"""
|
||||
@@ -56,7 +50,7 @@ class ChatResponse(BaseModel):
|
||||
|
||||
object: ChatResponseObject
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
system_fingerprint: Nullable[str]
|
||||
r"""System fingerprint"""
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
@@ -64,7 +58,7 @@ class ChatResponse(BaseModel):
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["system_fingerprint", "usage"]
|
||||
optional_fields = ["usage"]
|
||||
nullable_fields = ["system_fingerprint"]
|
||||
null_default_fields = []
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatchoice import ChatChoice, ChatChoiceTypedDict
|
||||
from .chatusage import ChatUsage, ChatUsageTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
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
|
||||
r"""Unix timestamp of creation"""
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
object: ChatResultObject
|
||||
system_fingerprint: Nullable[str]
|
||||
r"""System fingerprint"""
|
||||
service_tier: NotRequired[Nullable[str]]
|
||||
r"""The service tier used by the upstream provider for this request"""
|
||||
usage: NotRequired[ChatUsageTypedDict]
|
||||
r"""Token usage statistics"""
|
||||
|
||||
|
||||
class ChatResult(BaseModel):
|
||||
r"""Chat completion response"""
|
||||
|
||||
id: str
|
||||
r"""Unique completion identifier"""
|
||||
|
||||
choices: List[ChatChoice]
|
||||
r"""List of completion choices"""
|
||||
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
|
||||
object: ChatResultObject
|
||||
|
||||
system_fingerprint: Nullable[str]
|
||||
r"""System fingerprint"""
|
||||
|
||||
service_tier: OptionalNullable[str] = UNSET
|
||||
r"""The service tier used by the upstream provider for this request"""
|
||||
|
||||
usage: Optional[ChatUsage] = None
|
||||
r"""Token usage statistics"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["service_tier", "usage"]
|
||||
nullable_fields = ["system_fingerprint", "service_tier"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,72 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatstreamdelta import ChatStreamDelta, ChatStreamDeltaTypedDict
|
||||
from .chattokenlogprobs import ChatTokenLogprobs, ChatTokenLogprobsTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Any
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamChoiceTypedDict(TypedDict):
|
||||
r"""Streaming completion choice chunk"""
|
||||
|
||||
delta: ChatStreamDeltaTypedDict
|
||||
r"""Delta changes in streaming response"""
|
||||
finish_reason: Nullable[Any]
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
logprobs: NotRequired[Nullable[ChatTokenLogprobsTypedDict]]
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
|
||||
class ChatStreamChoice(BaseModel):
|
||||
r"""Streaming completion choice chunk"""
|
||||
|
||||
delta: ChatStreamDelta
|
||||
r"""Delta changes in streaming response"""
|
||||
|
||||
finish_reason: Nullable[Any]
|
||||
|
||||
index: float
|
||||
r"""Choice index"""
|
||||
|
||||
logprobs: OptionalNullable[ChatTokenLogprobs] = UNSET
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["logprobs"]
|
||||
nullable_fields = ["finish_reason", "logprobs"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,119 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatstreamchoice import ChatStreamChoice, ChatStreamChoiceTypedDict
|
||||
from .chatusage import ChatUsage, ChatUsageTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatStreamChunkObject = Literal["chat.completion.chunk",]
|
||||
|
||||
|
||||
class ErrorTypedDict(TypedDict):
|
||||
r"""Error information"""
|
||||
|
||||
message: str
|
||||
r"""Error message"""
|
||||
code: float
|
||||
r"""Error code"""
|
||||
|
||||
|
||||
class Error(BaseModel):
|
||||
r"""Error information"""
|
||||
|
||||
message: str
|
||||
r"""Error message"""
|
||||
|
||||
code: float
|
||||
r"""Error code"""
|
||||
|
||||
|
||||
class ChatStreamChunkTypedDict(TypedDict):
|
||||
r"""Streaming chat completion chunk"""
|
||||
|
||||
id: str
|
||||
r"""Unique chunk identifier"""
|
||||
choices: List[ChatStreamChoiceTypedDict]
|
||||
r"""List of streaming chunk choices"""
|
||||
created: float
|
||||
r"""Unix timestamp of creation"""
|
||||
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"""
|
||||
usage: NotRequired[ChatUsageTypedDict]
|
||||
r"""Token usage statistics"""
|
||||
|
||||
|
||||
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
|
||||
r"""Unix timestamp of creation"""
|
||||
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
|
||||
object: ChatStreamChunkObject
|
||||
|
||||
system_fingerprint: Optional[str] = None
|
||||
r"""System fingerprint"""
|
||||
|
||||
service_tier: OptionalNullable[str] = UNSET
|
||||
r"""The service tier used by the upstream provider for this request"""
|
||||
|
||||
error: Optional[Error] = None
|
||||
r"""Error information"""
|
||||
|
||||
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"]
|
||||
nullable_fields = ["service_tier"]
|
||||
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,100 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chataudiooutput import ChatAudioOutput, ChatAudioOutputTypedDict
|
||||
from .chatstreamtoolcall import ChatStreamToolCall, ChatStreamToolCallTypedDict
|
||||
from .reasoningdetailunion import ReasoningDetailUnion, ReasoningDetailUnionTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatStreamDeltaRole = Literal["assistant",]
|
||||
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"""
|
||||
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]
|
||||
|
||||
|
||||
class ChatStreamDelta(BaseModel):
|
||||
r"""Delta changes in streaming response"""
|
||||
|
||||
role: Optional[ChatStreamDeltaRole] = None
|
||||
r"""The role of the message author"""
|
||||
|
||||
content: OptionalNullable[str] = UNSET
|
||||
r"""Message content delta"""
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
r"""Reasoning content delta"""
|
||||
|
||||
refusal: OptionalNullable[str] = UNSET
|
||||
r"""Refusal message delta"""
|
||||
|
||||
tool_calls: Optional[List[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",
|
||||
"content",
|
||||
"reasoning",
|
||||
"refusal",
|
||||
"tool_calls",
|
||||
"reasoning_details",
|
||||
"audio",
|
||||
]
|
||||
nullable_fields = ["content", "reasoning", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -1,6 +1,10 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcompletionaudiooutput import (
|
||||
ChatCompletionAudioOutput,
|
||||
ChatCompletionAudioOutputTypedDict,
|
||||
)
|
||||
from .chatstreamingmessagetoolcall import (
|
||||
ChatStreamingMessageToolCall,
|
||||
ChatStreamingMessageToolCallTypedDict,
|
||||
@@ -37,6 +41,7 @@ class ChatStreamingMessageChunkTypedDict(TypedDict):
|
||||
r"""Tool calls delta"""
|
||||
reasoning_details: NotRequired[List[ReasoningDetailUnionTypedDict]]
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
audio: NotRequired[ChatCompletionAudioOutputTypedDict]
|
||||
|
||||
|
||||
class ChatStreamingMessageChunk(BaseModel):
|
||||
@@ -60,6 +65,8 @@ class ChatStreamingMessageChunk(BaseModel):
|
||||
reasoning_details: Optional[List[ReasoningDetailUnion]] = None
|
||||
r"""Reasoning details for extended thinking models"""
|
||||
|
||||
audio: Optional[ChatCompletionAudioOutput] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
@@ -69,6 +76,7 @@ class ChatStreamingMessageChunk(BaseModel):
|
||||
"refusal",
|
||||
"tool_calls",
|
||||
"reasoning_details",
|
||||
"audio",
|
||||
]
|
||||
nullable_fields = ["content", "reasoning", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
@@ -6,14 +6,7 @@ from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsageTypedDict,
|
||||
)
|
||||
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
@@ -52,7 +45,7 @@ class ChatStreamingResponseChunkTypedDict(TypedDict):
|
||||
model: str
|
||||
r"""Model used for completion"""
|
||||
object: ChatStreamingResponseChunkObject
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
system_fingerprint: NotRequired[str]
|
||||
r"""System fingerprint"""
|
||||
error: NotRequired[ErrorTypedDict]
|
||||
r"""Error information"""
|
||||
@@ -77,7 +70,7 @@ class ChatStreamingResponseChunk(BaseModel):
|
||||
|
||||
object: ChatStreamingResponseChunkObject
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
system_fingerprint: Optional[str] = None
|
||||
r"""System fingerprint"""
|
||||
|
||||
error: Optional[Error] = None
|
||||
@@ -85,33 +78,3 @@ class ChatStreamingResponseChunk(BaseModel):
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
r"""Token usage statistics"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["system_fingerprint", "error", "usage"]
|
||||
nullable_fields = ["system_fingerprint"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
|
||||
class ChatStreamToolCallFunction(BaseModel):
|
||||
r"""Function call details"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Function name"""
|
||||
|
||||
arguments: Optional[str] = None
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatStreamToolCallTypedDict(TypedDict):
|
||||
r"""Tool call delta for streaming responses"""
|
||||
|
||||
index: float
|
||||
r"""Tool call index in the array"""
|
||||
id: NotRequired[str]
|
||||
r"""Tool call identifier"""
|
||||
type: NotRequired[ChatStreamToolCallType]
|
||||
r"""Tool call type"""
|
||||
function: NotRequired[ChatStreamToolCallFunctionTypedDict]
|
||||
r"""Function call details"""
|
||||
|
||||
|
||||
class ChatStreamToolCall(BaseModel):
|
||||
r"""Tool call delta for streaming responses"""
|
||||
|
||||
index: float
|
||||
r"""Tool call index in the array"""
|
||||
|
||||
id: Optional[str] = None
|
||||
r"""Tool call identifier"""
|
||||
|
||||
type: Optional[ChatStreamToolCallType] = None
|
||||
r"""Tool call type"""
|
||||
|
||||
function: Optional[ChatStreamToolCallFunction] = None
|
||||
r"""Function call details"""
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontenttext import ChatContentText, ChatContentTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatSystemMessageRole = Literal["system",]
|
||||
|
||||
|
||||
ChatSystemMessageContentTypedDict = TypeAliasType(
|
||||
"ChatSystemMessageContentTypedDict", Union[str, List[ChatContentTextTypedDict]]
|
||||
)
|
||||
r"""System message content"""
|
||||
|
||||
|
||||
ChatSystemMessageContent = TypeAliasType(
|
||||
"ChatSystemMessageContent", Union[str, List[ChatContentText]]
|
||||
)
|
||||
r"""System message content"""
|
||||
|
||||
|
||||
class ChatSystemMessageTypedDict(TypedDict):
|
||||
r"""System message for setting behavior"""
|
||||
|
||||
role: ChatSystemMessageRole
|
||||
content: ChatSystemMessageContentTypedDict
|
||||
r"""System message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the system message"""
|
||||
|
||||
|
||||
class ChatSystemMessage(BaseModel):
|
||||
r"""System message for setting behavior"""
|
||||
|
||||
role: ChatSystemMessageRole
|
||||
|
||||
content: ChatSystemMessageContent
|
||||
r"""System message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the system message"""
|
||||
@@ -0,0 +1,111 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ChatTokenLogprobTopLogprobTypedDict(TypedDict):
|
||||
token: str
|
||||
logprob: float
|
||||
bytes_: Nullable[List[float]]
|
||||
|
||||
|
||||
class ChatTokenLogprobTopLogprob(BaseModel):
|
||||
token: str
|
||||
|
||||
logprob: float
|
||||
|
||||
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["bytes"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatTokenLogprobTypedDict(TypedDict):
|
||||
r"""Token log probability information"""
|
||||
|
||||
token: str
|
||||
r"""The token"""
|
||||
logprob: float
|
||||
r"""Log probability of the token"""
|
||||
bytes_: Nullable[List[float]]
|
||||
r"""UTF-8 bytes of the token"""
|
||||
top_logprobs: List[ChatTokenLogprobTopLogprobTypedDict]
|
||||
r"""Top alternative tokens with probabilities"""
|
||||
|
||||
|
||||
class ChatTokenLogprob(BaseModel):
|
||||
r"""Token log probability information"""
|
||||
|
||||
token: str
|
||||
r"""The token"""
|
||||
|
||||
logprob: float
|
||||
r"""Log probability of the token"""
|
||||
|
||||
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
|
||||
r"""UTF-8 bytes of the token"""
|
||||
|
||||
top_logprobs: List[ChatTokenLogprobTopLogprob]
|
||||
r"""Top alternative tokens with probabilities"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["bytes"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chattokenlogprob import ChatTokenLogprob, ChatTokenLogprobTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatTokenLogprobsTypedDict(TypedDict):
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
content: Nullable[List[ChatTokenLogprobTypedDict]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
refusal: NotRequired[Nullable[List[ChatTokenLogprobTypedDict]]]
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
|
||||
class ChatTokenLogprobs(BaseModel):
|
||||
r"""Log probabilities for the completion"""
|
||||
|
||||
content: Nullable[List[ChatTokenLogprob]]
|
||||
r"""Log probabilities for content tokens"""
|
||||
|
||||
refusal: OptionalNullable[List[ChatTokenLogprob]] = UNSET
|
||||
r"""Log probabilities for refusal tokens"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["refusal"]
|
||||
nullable_fields = ["content", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,44 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatToolCallType = Literal["function",]
|
||||
|
||||
|
||||
class ChatToolCallFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
arguments: str
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatToolCallFunction(BaseModel):
|
||||
name: str
|
||||
r"""Function name to call"""
|
||||
|
||||
arguments: str
|
||||
r"""Function arguments as JSON string"""
|
||||
|
||||
|
||||
class ChatToolCallTypedDict(TypedDict):
|
||||
r"""Tool call made by the assistant"""
|
||||
|
||||
id: str
|
||||
r"""Tool call identifier"""
|
||||
type: ChatToolCallType
|
||||
function: ChatToolCallFunctionTypedDict
|
||||
|
||||
|
||||
class ChatToolCall(BaseModel):
|
||||
r"""Tool call made by the assistant"""
|
||||
|
||||
id: str
|
||||
r"""Tool call identifier"""
|
||||
|
||||
type: ChatToolCallType
|
||||
|
||||
function: ChatToolCallFunction
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatnamedtoolchoice import ChatNamedToolChoice, ChatNamedToolChoiceTypedDict
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
ChatToolChoiceRequired = Literal["required",]
|
||||
|
||||
|
||||
ChatToolChoiceAuto = Literal["auto",]
|
||||
|
||||
|
||||
ChatToolChoiceNone = Literal["none",]
|
||||
|
||||
|
||||
ChatToolChoiceTypedDict = TypeAliasType(
|
||||
"ChatToolChoiceTypedDict",
|
||||
Union[
|
||||
ChatNamedToolChoiceTypedDict,
|
||||
ChatToolChoiceNone,
|
||||
ChatToolChoiceAuto,
|
||||
ChatToolChoiceRequired,
|
||||
],
|
||||
)
|
||||
r"""Tool choice configuration"""
|
||||
|
||||
|
||||
ChatToolChoice = TypeAliasType(
|
||||
"ChatToolChoice",
|
||||
Union[
|
||||
ChatNamedToolChoice,
|
||||
ChatToolChoiceNone,
|
||||
ChatToolChoiceAuto,
|
||||
ChatToolChoiceRequired,
|
||||
],
|
||||
)
|
||||
r"""Tool choice configuration"""
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentitems import ChatContentItems, ChatContentItemsTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Union
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatToolMessageRole = Literal["tool",]
|
||||
|
||||
|
||||
ChatToolMessageContentTypedDict = TypeAliasType(
|
||||
"ChatToolMessageContentTypedDict", Union[str, List[ChatContentItemsTypedDict]]
|
||||
)
|
||||
r"""Tool response content"""
|
||||
|
||||
|
||||
ChatToolMessageContent = TypeAliasType(
|
||||
"ChatToolMessageContent", Union[str, List[ChatContentItems]]
|
||||
)
|
||||
r"""Tool response content"""
|
||||
|
||||
|
||||
class ChatToolMessageTypedDict(TypedDict):
|
||||
r"""Tool response message"""
|
||||
|
||||
role: ChatToolMessageRole
|
||||
content: ChatToolMessageContentTypedDict
|
||||
r"""Tool response content"""
|
||||
tool_call_id: str
|
||||
r"""ID of the assistant message tool call this message responds to"""
|
||||
|
||||
|
||||
class ChatToolMessage(BaseModel):
|
||||
r"""Tool response message"""
|
||||
|
||||
role: ChatToolMessageRole
|
||||
|
||||
content: ChatToolMessageContent
|
||||
r"""Tool response content"""
|
||||
|
||||
tool_call_id: str
|
||||
r"""ID of the assistant message tool call this message responds to"""
|
||||
@@ -0,0 +1,175 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class CompletionTokensDetailsTypedDict(TypedDict):
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
reasoning_tokens: NotRequired[Nullable[float]]
|
||||
r"""Tokens used for reasoning"""
|
||||
audio_tokens: NotRequired[Nullable[float]]
|
||||
r"""Tokens used for audio output"""
|
||||
accepted_prediction_tokens: NotRequired[Nullable[float]]
|
||||
r"""Accepted prediction tokens"""
|
||||
rejected_prediction_tokens: NotRequired[Nullable[float]]
|
||||
r"""Rejected prediction tokens"""
|
||||
|
||||
|
||||
class CompletionTokensDetails(BaseModel):
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
reasoning_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Tokens used for reasoning"""
|
||||
|
||||
audio_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Tokens used for audio output"""
|
||||
|
||||
accepted_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Accepted prediction tokens"""
|
||||
|
||||
rejected_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
r"""Rejected prediction tokens"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"reasoning_tokens",
|
||||
"audio_tokens",
|
||||
"accepted_prediction_tokens",
|
||||
"rejected_prediction_tokens",
|
||||
]
|
||||
nullable_fields = [
|
||||
"reasoning_tokens",
|
||||
"audio_tokens",
|
||||
"accepted_prediction_tokens",
|
||||
"rejected_prediction_tokens",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class PromptTokensDetailsTypedDict(TypedDict):
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
cached_tokens: NotRequired[float]
|
||||
r"""Cached prompt tokens"""
|
||||
cache_write_tokens: NotRequired[float]
|
||||
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
|
||||
audio_tokens: NotRequired[float]
|
||||
r"""Audio input tokens"""
|
||||
video_tokens: NotRequired[float]
|
||||
r"""Video input tokens"""
|
||||
|
||||
|
||||
class PromptTokensDetails(BaseModel):
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
cached_tokens: Optional[float] = None
|
||||
r"""Cached prompt tokens"""
|
||||
|
||||
cache_write_tokens: Optional[float] = None
|
||||
r"""Tokens written to cache. Only returned for models with explicit caching and cache write pricing."""
|
||||
|
||||
audio_tokens: Optional[float] = None
|
||||
r"""Audio input tokens"""
|
||||
|
||||
video_tokens: Optional[float] = None
|
||||
r"""Video input tokens"""
|
||||
|
||||
|
||||
class ChatUsageTypedDict(TypedDict):
|
||||
r"""Token usage statistics"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Number of tokens in the completion"""
|
||||
prompt_tokens: float
|
||||
r"""Number of tokens in the prompt"""
|
||||
total_tokens: float
|
||||
r"""Total number of tokens"""
|
||||
completion_tokens_details: NotRequired[Nullable[CompletionTokensDetailsTypedDict]]
|
||||
r"""Detailed completion token usage"""
|
||||
prompt_tokens_details: NotRequired[Nullable[PromptTokensDetailsTypedDict]]
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
|
||||
class ChatUsage(BaseModel):
|
||||
r"""Token usage statistics"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Number of tokens in the completion"""
|
||||
|
||||
prompt_tokens: float
|
||||
r"""Number of tokens in the prompt"""
|
||||
|
||||
total_tokens: float
|
||||
r"""Total number of tokens"""
|
||||
|
||||
completion_tokens_details: OptionalNullable[CompletionTokensDetails] = UNSET
|
||||
r"""Detailed completion token usage"""
|
||||
|
||||
prompt_tokens_details: OptionalNullable[PromptTokensDetails] = UNSET
|
||||
r"""Detailed prompt token usage"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["completion_tokens_details", "prompt_tokens_details"]
|
||||
nullable_fields = ["completion_tokens_details", "prompt_tokens_details"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentitems import ChatContentItems, ChatContentItemsTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ChatUserMessageRole = Literal["user",]
|
||||
|
||||
|
||||
ChatUserMessageContentTypedDict = TypeAliasType(
|
||||
"ChatUserMessageContentTypedDict", Union[str, List[ChatContentItemsTypedDict]]
|
||||
)
|
||||
r"""User message content"""
|
||||
|
||||
|
||||
ChatUserMessageContent = TypeAliasType(
|
||||
"ChatUserMessageContent", Union[str, List[ChatContentItems]]
|
||||
)
|
||||
r"""User message content"""
|
||||
|
||||
|
||||
class ChatUserMessageTypedDict(TypedDict):
|
||||
r"""User message"""
|
||||
|
||||
role: ChatUserMessageRole
|
||||
content: ChatUserMessageContentTypedDict
|
||||
r"""User message content"""
|
||||
name: NotRequired[str]
|
||||
r"""Optional name for the user"""
|
||||
|
||||
|
||||
class ChatUserMessage(BaseModel):
|
||||
r"""User message"""
|
||||
|
||||
role: ChatUserMessageRole
|
||||
|
||||
content: ChatUserMessageContent
|
||||
r"""User message content"""
|
||||
|
||||
name: Optional[str] = None
|
||||
r"""Optional name for the user"""
|
||||
@@ -0,0 +1,123 @@
|
||||
"""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
|
||||
@@ -0,0 +1,225 @@
|
||||
"""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
|
||||
|
||||
|
||||
ChatWebSearchShorthandType = Union[
|
||||
Literal[
|
||||
"web_search",
|
||||
"web_search_preview",
|
||||
"web_search_preview_2025_03_11",
|
||||
"web_search_2025_08_26",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
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."""
|
||||
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]
|
||||
|
||||
|
||||
class ChatWebSearchShorthand(BaseModel):
|
||||
r"""Web search tool using OpenAI Responses API syntax. Automatically converted to openrouter:web_search."""
|
||||
|
||||
type: Annotated[
|
||||
ChatWebSearchShorthandType, PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
engine: Annotated[
|
||||
Optional[ChatWebSearchShorthandEngine],
|
||||
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[ChatWebSearchShorthandSearchContextSize],
|
||||
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
|
||||
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
|
||||
@@ -0,0 +1,102 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeCodeInterpreter = Literal["code_interpreter",]
|
||||
|
||||
|
||||
ContainerType = Literal["auto",]
|
||||
|
||||
|
||||
MemoryLimit = Union[
|
||||
Literal[
|
||||
"1g",
|
||||
"4g",
|
||||
"16g",
|
||||
"64g",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ContainerAutoTypedDict(TypedDict):
|
||||
type: ContainerType
|
||||
file_ids: NotRequired[List[str]]
|
||||
memory_limit: NotRequired[Nullable[MemoryLimit]]
|
||||
|
||||
|
||||
class ContainerAuto(BaseModel):
|
||||
type: ContainerType
|
||||
|
||||
file_ids: Optional[List[str]] = None
|
||||
|
||||
memory_limit: Annotated[
|
||||
OptionalNullable[MemoryLimit], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["file_ids", "memory_limit"]
|
||||
nullable_fields = ["memory_limit"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
ContainerTypedDict = TypeAliasType(
|
||||
"ContainerTypedDict", Union[ContainerAutoTypedDict, str]
|
||||
)
|
||||
|
||||
|
||||
Container = TypeAliasType("Container", Union[ContainerAuto, str])
|
||||
|
||||
|
||||
class CodeInterpreterServerToolTypedDict(TypedDict):
|
||||
r"""Code interpreter tool configuration"""
|
||||
|
||||
type: TypeCodeInterpreter
|
||||
container: ContainerTypedDict
|
||||
|
||||
|
||||
class CodeInterpreterServerTool(BaseModel):
|
||||
r"""Code interpreter tool configuration"""
|
||||
|
||||
type: TypeCodeInterpreter
|
||||
|
||||
container: Container
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
CodexLocalShellToolType = Literal["local_shell",]
|
||||
|
||||
|
||||
class CodexLocalShellToolTypedDict(TypedDict):
|
||||
r"""Local shell tool configuration"""
|
||||
|
||||
type: CodexLocalShellToolType
|
||||
|
||||
|
||||
class CodexLocalShellTool(BaseModel):
|
||||
r"""Local shell tool configuration"""
|
||||
|
||||
type: CodexLocalShellToolType
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
CompoundFilterType = Union[
|
||||
Literal[
|
||||
"and",
|
||||
"or",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class CompoundFilterTypedDict(TypedDict):
|
||||
r"""A compound filter that combines multiple comparison or compound filters"""
|
||||
|
||||
type: CompoundFilterType
|
||||
filters: List[Dict[str, Nullable[Any]]]
|
||||
|
||||
|
||||
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]]]
|
||||
@@ -0,0 +1,44 @@
|
||||
"""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
|
||||
|
||||
|
||||
ComputerUseServerToolType = Literal["computer_use_preview",]
|
||||
|
||||
|
||||
Environment = Union[
|
||||
Literal[
|
||||
"windows",
|
||||
"mac",
|
||||
"linux",
|
||||
"ubuntu",
|
||||
"browser",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ComputerUseServerToolTypedDict(TypedDict):
|
||||
r"""Computer use preview tool configuration"""
|
||||
|
||||
type: ComputerUseServerToolType
|
||||
display_height: float
|
||||
display_width: float
|
||||
environment: Environment
|
||||
|
||||
|
||||
class ComputerUseServerTool(BaseModel):
|
||||
r"""Computer use preview tool configuration"""
|
||||
|
||||
type: ComputerUseServerToolType
|
||||
|
||||
display_height: float
|
||||
|
||||
display_width: float
|
||||
|
||||
environment: Annotated[Environment, PlainValidator(validate_open_enum(False))]
|
||||
@@ -0,0 +1,61 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ConflictResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for ConflictResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class ConflictResponseErrorData(BaseModel):
|
||||
r"""Error data for ConflictResponse"""
|
||||
|
||||
code: int
|
||||
|
||||
message: str
|
||||
|
||||
metadata: OptionalNullable[Dict[str, Nullable[Any]]] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["metadata"]
|
||||
nullable_fields = ["metadata"]
|
||||
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,64 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ContentPartAddedEventType = Literal["response.content_part.added",]
|
||||
|
||||
|
||||
ContentPartAddedEventPartTypedDict = TypeAliasType(
|
||||
"ContentPartAddedEventPartTypedDict",
|
||||
Union[
|
||||
ReasoningTextContentTypedDict,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
ResponseOutputTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ContentPartAddedEventPart = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseOutputText, Tag("output_text")],
|
||||
Annotated[ReasoningTextContent, Tag("reasoning_text")],
|
||||
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class ContentPartAddedEventTypedDict(TypedDict):
|
||||
r"""Event emitted when a new content part is added to an output item"""
|
||||
|
||||
type: ContentPartAddedEventType
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
part: ContentPartAddedEventPartTypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class ContentPartAddedEvent(BaseModel):
|
||||
r"""Event emitted when a new content part is added to an output item"""
|
||||
|
||||
type: ContentPartAddedEventType
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
part: ContentPartAddedEventPart
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
ContentPartDoneEventType = Literal["response.content_part.done",]
|
||||
|
||||
|
||||
ContentPartDoneEventPartTypedDict = TypeAliasType(
|
||||
"ContentPartDoneEventPartTypedDict",
|
||||
Union[
|
||||
ReasoningTextContentTypedDict,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
ResponseOutputTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ContentPartDoneEventPart = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseOutputText, Tag("output_text")],
|
||||
Annotated[ReasoningTextContent, Tag("reasoning_text")],
|
||||
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class ContentPartDoneEventTypedDict(TypedDict):
|
||||
r"""Event emitted when a content part is complete"""
|
||||
|
||||
type: ContentPartDoneEventType
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
part: ContentPartDoneEventPartTypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class ContentPartDoneEvent(BaseModel):
|
||||
r"""Event emitted when a content part is complete"""
|
||||
|
||||
type: ContentPartDoneEventType
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
part: ContentPartDoneEventPart
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,8 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Literal
|
||||
|
||||
|
||||
ContextCompressionEngine = Literal["middle-out",]
|
||||
r"""The compression engine to use. Defaults to \"middle-out\"."""
|
||||
@@ -0,0 +1,82 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeCustom = Literal["custom",]
|
||||
|
||||
|
||||
FormatTypeGrammar = Literal["grammar",]
|
||||
|
||||
|
||||
Syntax = Union[
|
||||
Literal[
|
||||
"lark",
|
||||
"regex",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class FormatGrammarTypedDict(TypedDict):
|
||||
type: FormatTypeGrammar
|
||||
definition: str
|
||||
syntax: Syntax
|
||||
|
||||
|
||||
class FormatGrammar(BaseModel):
|
||||
type: FormatTypeGrammar
|
||||
|
||||
definition: str
|
||||
|
||||
syntax: Annotated[Syntax, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
|
||||
FormatTypeText = Literal["text",]
|
||||
|
||||
|
||||
class FormatTextTypedDict(TypedDict):
|
||||
type: FormatTypeText
|
||||
|
||||
|
||||
class FormatText(BaseModel):
|
||||
type: FormatTypeText
|
||||
|
||||
|
||||
FormatTypedDict = TypeAliasType(
|
||||
"FormatTypedDict", Union[FormatTextTypedDict, FormatGrammarTypedDict]
|
||||
)
|
||||
|
||||
|
||||
Format = Annotated[
|
||||
Union[Annotated[FormatText, Tag("text")], Annotated[FormatGrammar, Tag("grammar")]],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class CustomToolTypedDict(TypedDict):
|
||||
r"""Custom tool configuration"""
|
||||
|
||||
type: TypeCustom
|
||||
name: str
|
||||
description: NotRequired[str]
|
||||
format_: NotRequired[FormatTypedDict]
|
||||
|
||||
|
||||
class CustomTool(BaseModel):
|
||||
r"""Custom tool configuration"""
|
||||
|
||||
type: TypeCustom
|
||||
|
||||
name: str
|
||||
|
||||
description: Optional[str] = None
|
||||
|
||||
format_: Annotated[Optional[Format], pydantic.Field(alias="format")] = None
|
||||
@@ -0,0 +1,34 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
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]
|
||||
|
||||
|
||||
class DatetimeServerTool(BaseModel):
|
||||
r"""OpenRouter built-in server tool: returns the current date and time"""
|
||||
|
||||
type: DatetimeServerToolType
|
||||
|
||||
parameters: Optional[DatetimeServerToolParameters] = None
|
||||
@@ -17,7 +17,10 @@ class DefaultParametersTypedDict(TypedDict):
|
||||
|
||||
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]]
|
||||
|
||||
|
||||
class DefaultParameters(BaseModel):
|
||||
@@ -27,12 +30,32 @@ class DefaultParameters(BaseModel):
|
||||
|
||||
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
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["temperature", "top_p", "frequency_penalty"]
|
||||
nullable_fields = ["temperature", "top_p", "frequency_penalty"]
|
||||
optional_fields = [
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"frequency_penalty",
|
||||
"presence_penalty",
|
||||
"repetition_penalty",
|
||||
]
|
||||
nullable_fields = [
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"frequency_penalty",
|
||||
"presence_penalty",
|
||||
"repetition_penalty",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputaudio import InputAudio, InputAudioTypedDict
|
||||
from .inputfile import InputFile, InputFileTypedDict
|
||||
from .inputtext import InputText, InputTextTypedDict
|
||||
from .inputvideo import InputVideo, InputVideoTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
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",
|
||||
"high",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class EasyInputMessageContentInputImageTypedDict(TypedDict):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: EasyInputMessageContentType
|
||||
detail: EasyInputMessageDetail
|
||||
image_url: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class EasyInputMessageContentInputImage(BaseModel):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: EasyInputMessageContentType
|
||||
|
||||
detail: Annotated[EasyInputMessageDetail, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
image_url: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["image_url"]
|
||||
nullable_fields = ["image_url"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
EasyInputMessageContentUnion1TypedDict = TypeAliasType(
|
||||
"EasyInputMessageContentUnion1TypedDict",
|
||||
Union[
|
||||
InputTextTypedDict,
|
||||
InputAudioTypedDict,
|
||||
InputVideoTypedDict,
|
||||
EasyInputMessageContentInputImageTypedDict,
|
||||
InputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
EasyInputMessageContentUnion1 = Annotated[
|
||||
Union[
|
||||
Annotated[InputText, Tag("input_text")],
|
||||
Annotated[EasyInputMessageContentInputImage, Tag("input_image")],
|
||||
Annotated[InputFile, Tag("input_file")],
|
||||
Annotated[InputAudio, Tag("input_audio")],
|
||||
Annotated[InputVideo, Tag("input_video")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
EasyInputMessageContentUnion2TypedDict = TypeAliasType(
|
||||
"EasyInputMessageContentUnion2TypedDict",
|
||||
Union[List[EasyInputMessageContentUnion1TypedDict], str, Any],
|
||||
)
|
||||
|
||||
|
||||
EasyInputMessageContentUnion2 = TypeAliasType(
|
||||
"EasyInputMessageContentUnion2",
|
||||
Union[List[EasyInputMessageContentUnion1], str, Any],
|
||||
)
|
||||
|
||||
|
||||
EasyInputMessagePhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
EasyInputMessagePhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
EasyInputMessagePhaseUnionTypedDict = TypeAliasType(
|
||||
"EasyInputMessagePhaseUnionTypedDict",
|
||||
Union[EasyInputMessagePhaseCommentary, EasyInputMessagePhaseFinalAnswer, Any],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
EasyInputMessagePhaseUnion = TypeAliasType(
|
||||
"EasyInputMessagePhaseUnion",
|
||||
Union[EasyInputMessagePhaseCommentary, EasyInputMessagePhaseFinalAnswer, Any],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class 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."""
|
||||
|
||||
|
||||
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."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["type", "content", "phase"]
|
||||
nullable_fields = ["content", "phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["code", "param"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,148 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .compoundfilter import CompoundFilter, CompoundFilterTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeFileSearch = Literal["file_search",]
|
||||
|
||||
|
||||
FiltersType = Union[
|
||||
Literal[
|
||||
"eq",
|
||||
"ne",
|
||||
"gt",
|
||||
"gte",
|
||||
"lt",
|
||||
"lte",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Value1TypedDict = TypeAliasType("Value1TypedDict", Union[str, float])
|
||||
|
||||
|
||||
Value1 = TypeAliasType("Value1", Union[str, float])
|
||||
|
||||
|
||||
Value2TypedDict = TypeAliasType(
|
||||
"Value2TypedDict", Union[str, float, bool, List[Value1TypedDict]]
|
||||
)
|
||||
|
||||
|
||||
Value2 = TypeAliasType("Value2", Union[str, float, bool, List[Value1]])
|
||||
|
||||
|
||||
class FileSearchServerToolFiltersTypedDict(TypedDict):
|
||||
key: str
|
||||
type: FiltersType
|
||||
value: Value2TypedDict
|
||||
|
||||
|
||||
class FileSearchServerToolFilters(BaseModel):
|
||||
key: str
|
||||
|
||||
type: Annotated[FiltersType, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
value: Value2
|
||||
|
||||
|
||||
FiltersTypedDict = TypeAliasType(
|
||||
"FiltersTypedDict",
|
||||
Union[CompoundFilterTypedDict, FileSearchServerToolFiltersTypedDict, Any],
|
||||
)
|
||||
|
||||
|
||||
Filters = TypeAliasType(
|
||||
"Filters", Union[CompoundFilter, FileSearchServerToolFilters, Any]
|
||||
)
|
||||
|
||||
|
||||
Ranker = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"default-2024-11-15",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class RankingOptionsTypedDict(TypedDict):
|
||||
ranker: NotRequired[Ranker]
|
||||
score_threshold: NotRequired[float]
|
||||
|
||||
|
||||
class RankingOptions(BaseModel):
|
||||
ranker: Annotated[Optional[Ranker], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
|
||||
score_threshold: Optional[float] = None
|
||||
|
||||
|
||||
class FileSearchServerToolTypedDict(TypedDict):
|
||||
r"""File search tool configuration"""
|
||||
|
||||
type: TypeFileSearch
|
||||
vector_store_ids: List[str]
|
||||
filters: NotRequired[Nullable[FiltersTypedDict]]
|
||||
max_num_results: NotRequired[int]
|
||||
ranking_options: NotRequired[RankingOptionsTypedDict]
|
||||
|
||||
|
||||
class FileSearchServerTool(BaseModel):
|
||||
r"""File search tool configuration"""
|
||||
|
||||
type: TypeFileSearch
|
||||
|
||||
vector_store_ids: List[str]
|
||||
|
||||
filters: OptionalNullable[Filters] = UNSET
|
||||
|
||||
max_num_results: Optional[int] = None
|
||||
|
||||
ranking_options: Optional[RankingOptions] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["filters", "max_num_results", "ranking_options"]
|
||||
nullable_fields = ["filters"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
FormatJSONObjectConfigType = Literal["json_object",]
|
||||
|
||||
|
||||
class FormatJSONObjectConfigTypedDict(TypedDict):
|
||||
r"""JSON object response format"""
|
||||
|
||||
type: FormatJSONObjectConfigType
|
||||
|
||||
|
||||
class FormatJSONObjectConfig(BaseModel):
|
||||
r"""JSON object response format"""
|
||||
|
||||
type: FormatJSONObjectConfigType
|
||||
@@ -0,0 +1,71 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
FormatJSONSchemaConfigType = Literal["json_schema",]
|
||||
|
||||
|
||||
class FormatJSONSchemaConfigTypedDict(TypedDict):
|
||||
r"""JSON schema constrained response format"""
|
||||
|
||||
type: FormatJSONSchemaConfigType
|
||||
name: str
|
||||
schema_: Dict[str, Nullable[Any]]
|
||||
description: NotRequired[str]
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class FormatJSONSchemaConfig(BaseModel):
|
||||
r"""JSON schema constrained response format"""
|
||||
|
||||
type: FormatJSONSchemaConfigType
|
||||
|
||||
name: str
|
||||
|
||||
schema_: Annotated[Dict[str, Nullable[Any]], pydantic.Field(alias="schema")]
|
||||
|
||||
description: Optional[str] = None
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["description", "strict"]
|
||||
nullable_fields = ["strict"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .formatjsonobjectconfig import (
|
||||
FormatJSONObjectConfig,
|
||||
FormatJSONObjectConfigTypedDict,
|
||||
)
|
||||
from .formatjsonschemaconfig import (
|
||||
FormatJSONSchemaConfig,
|
||||
FormatJSONSchemaConfigTypedDict,
|
||||
)
|
||||
from .formattextconfig import FormatTextConfig, FormatTextConfigTypedDict
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
FormatsTypedDict = TypeAliasType(
|
||||
"FormatsTypedDict",
|
||||
Union[
|
||||
FormatTextConfigTypedDict,
|
||||
FormatJSONObjectConfigTypedDict,
|
||||
FormatJSONSchemaConfigTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Text response format configuration"""
|
||||
|
||||
|
||||
Formats = Annotated[
|
||||
Union[
|
||||
Annotated[FormatTextConfig, Tag("text")],
|
||||
Annotated[FormatJSONObjectConfig, Tag("json_object")],
|
||||
Annotated[FormatJSONSchemaConfig, Tag("json_schema")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
r"""Text response format configuration"""
|
||||
@@ -0,0 +1,21 @@
|
||||
"""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
|
||||
|
||||
|
||||
FormatTextConfigType = Literal["text",]
|
||||
|
||||
|
||||
class FormatTextConfigTypedDict(TypedDict):
|
||||
r"""Plain text response format"""
|
||||
|
||||
type: FormatTextConfigType
|
||||
|
||||
|
||||
class FormatTextConfig(BaseModel):
|
||||
r"""Plain text response format"""
|
||||
|
||||
type: FormatTextConfigType
|
||||
@@ -0,0 +1,33 @@
|
||||
"""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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
class FunctionCallArgsDeltaEvent(BaseModel):
|
||||
r"""Event emitted when function call arguments are being streamed"""
|
||||
|
||||
type: FunctionCallArgsDeltaEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,36 @@
|
||||
"""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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
class FunctionCallArgsDoneEvent(BaseModel):
|
||||
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
|
||||
@@ -0,0 +1,78 @@
|
||||
"""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 openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
FunctionCallItemType = Literal["function_call",]
|
||||
|
||||
|
||||
class FunctionCallItemTypedDict(TypedDict):
|
||||
r"""A function call initiated by the model"""
|
||||
|
||||
type: FunctionCallItemType
|
||||
call_id: str
|
||||
name: str
|
||||
arguments: str
|
||||
id: str
|
||||
status: NotRequired[Nullable[ToolCallStatusEnum]]
|
||||
|
||||
|
||||
class FunctionCallItem(BaseModel):
|
||||
r"""A function call initiated by the model"""
|
||||
|
||||
type: FunctionCallItemType
|
||||
|
||||
call_id: str
|
||||
|
||||
name: str
|
||||
|
||||
arguments: str
|
||||
|
||||
id: str
|
||||
|
||||
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
|
||||
@@ -0,0 +1,169 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputfile import InputFile, InputFileTypedDict
|
||||
from .inputtext import InputText, InputTextTypedDict
|
||||
from .toolcallstatusenum import ToolCallStatusEnum
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
FunctionCallOutputItemTypeFunctionCallOutput = Literal["function_call_output",]
|
||||
|
||||
|
||||
OutputType = Literal["input_image",]
|
||||
|
||||
|
||||
FunctionCallOutputItemDetail = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"high",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OutputInputImageTypedDict(TypedDict):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: OutputType
|
||||
detail: FunctionCallOutputItemDetail
|
||||
image_url: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class OutputInputImage(BaseModel):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: OutputType
|
||||
|
||||
detail: Annotated[
|
||||
FunctionCallOutputItemDetail, PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
image_url: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["image_url"]
|
||||
nullable_fields = ["image_url"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
FunctionCallOutputItemOutputUnion1TypedDict = TypeAliasType(
|
||||
"FunctionCallOutputItemOutputUnion1TypedDict",
|
||||
Union[InputTextTypedDict, OutputInputImageTypedDict, InputFileTypedDict],
|
||||
)
|
||||
|
||||
|
||||
FunctionCallOutputItemOutputUnion1 = Annotated[
|
||||
Union[
|
||||
Annotated[InputText, Tag("input_text")],
|
||||
Annotated[OutputInputImage, Tag("input_image")],
|
||||
Annotated[InputFile, Tag("input_file")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
FunctionCallOutputItemOutputUnion2TypedDict = TypeAliasType(
|
||||
"FunctionCallOutputItemOutputUnion2TypedDict",
|
||||
Union[str, List[FunctionCallOutputItemOutputUnion1TypedDict]],
|
||||
)
|
||||
|
||||
|
||||
FunctionCallOutputItemOutputUnion2 = TypeAliasType(
|
||||
"FunctionCallOutputItemOutputUnion2",
|
||||
Union[str, List[FunctionCallOutputItemOutputUnion1]],
|
||||
)
|
||||
|
||||
|
||||
class FunctionCallOutputItemTypedDict(TypedDict):
|
||||
r"""The output from a function call execution"""
|
||||
|
||||
type: FunctionCallOutputItemTypeFunctionCallOutput
|
||||
call_id: str
|
||||
output: FunctionCallOutputItemOutputUnion2TypedDict
|
||||
id: NotRequired[Nullable[str]]
|
||||
status: NotRequired[Nullable[ToolCallStatusEnum]]
|
||||
|
||||
|
||||
class FunctionCallOutputItem(BaseModel):
|
||||
r"""The output from a function call execution"""
|
||||
|
||||
type: FunctionCallOutputItemTypeFunctionCallOutput
|
||||
|
||||
call_id: str
|
||||
|
||||
output: FunctionCallOutputItemOutputUnion2
|
||||
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
"""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
|
||||
|
||||
|
||||
ImageGenCallCompletedEventType = Literal["response.image_generation_call.completed",]
|
||||
|
||||
|
||||
class ImageGenCallCompletedEventTypedDict(TypedDict):
|
||||
r"""Image generation call completed"""
|
||||
|
||||
type: ImageGenCallCompletedEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class ImageGenCallCompletedEvent(BaseModel):
|
||||
r"""Image generation call completed"""
|
||||
|
||||
type: ImageGenCallCompletedEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,30 @@
|
||||
"""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
|
||||
|
||||
|
||||
ImageGenCallGeneratingEventType = Literal["response.image_generation_call.generating",]
|
||||
|
||||
|
||||
class ImageGenCallGeneratingEventTypedDict(TypedDict):
|
||||
r"""Image generation call is generating"""
|
||||
|
||||
type: ImageGenCallGeneratingEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class ImageGenCallGeneratingEvent(BaseModel):
|
||||
r"""Image generation call is generating"""
|
||||
|
||||
type: ImageGenCallGeneratingEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,30 @@
|
||||
"""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
|
||||
|
||||
|
||||
ImageGenCallInProgressEventType = Literal["response.image_generation_call.in_progress",]
|
||||
|
||||
|
||||
class ImageGenCallInProgressEventTypedDict(TypedDict):
|
||||
r"""Image generation call in progress"""
|
||||
|
||||
type: ImageGenCallInProgressEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class ImageGenCallInProgressEvent(BaseModel):
|
||||
r"""Image generation call in progress"""
|
||||
|
||||
type: ImageGenCallInProgressEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,38 @@
|
||||
"""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
|
||||
|
||||
|
||||
ImageGenCallPartialImageEventType = Literal[
|
||||
"response.image_generation_call.partial_image",
|
||||
]
|
||||
|
||||
|
||||
class ImageGenCallPartialImageEventTypedDict(TypedDict):
|
||||
r"""Image generation call with partial image"""
|
||||
|
||||
type: ImageGenCallPartialImageEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
partial_image_b64: str
|
||||
partial_image_index: float
|
||||
|
||||
|
||||
class ImageGenCallPartialImageEvent(BaseModel):
|
||||
r"""Image generation call with partial image"""
|
||||
|
||||
type: ImageGenCallPartialImageEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
|
||||
partial_image_b64: str
|
||||
|
||||
partial_image_index: float
|
||||
@@ -0,0 +1,194 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ImageGenerationServerToolType = Literal["image_generation",]
|
||||
|
||||
|
||||
Background = Union[
|
||||
Literal[
|
||||
"transparent",
|
||||
"opaque",
|
||||
"auto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
InputFidelity = Union[
|
||||
Literal[
|
||||
"high",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class InputImageMaskTypedDict(TypedDict):
|
||||
image_url: NotRequired[str]
|
||||
file_id: NotRequired[str]
|
||||
|
||||
|
||||
class InputImageMask(BaseModel):
|
||||
image_url: Optional[str] = None
|
||||
|
||||
file_id: Optional[str] = None
|
||||
|
||||
|
||||
ModelEnum = Union[
|
||||
Literal[
|
||||
"gpt-image-1",
|
||||
"gpt-image-1-mini",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Moderation = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
OutputFormat = Union[
|
||||
Literal[
|
||||
"png",
|
||||
"webp",
|
||||
"jpeg",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Quality = Union[
|
||||
Literal[
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"auto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Size = Union[
|
||||
Literal[
|
||||
"1024x1024",
|
||||
"1024x1536",
|
||||
"1536x1024",
|
||||
"auto",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ImageGenerationServerToolTypedDict(TypedDict):
|
||||
r"""Image generation tool configuration"""
|
||||
|
||||
type: ImageGenerationServerToolType
|
||||
background: NotRequired[Background]
|
||||
input_fidelity: NotRequired[Nullable[InputFidelity]]
|
||||
input_image_mask: NotRequired[InputImageMaskTypedDict]
|
||||
model: NotRequired[ModelEnum]
|
||||
moderation: NotRequired[Moderation]
|
||||
output_compression: NotRequired[float]
|
||||
output_format: NotRequired[OutputFormat]
|
||||
partial_images: NotRequired[float]
|
||||
quality: NotRequired[Quality]
|
||||
size: NotRequired[Size]
|
||||
|
||||
|
||||
class ImageGenerationServerTool(BaseModel):
|
||||
r"""Image generation tool configuration"""
|
||||
|
||||
type: ImageGenerationServerToolType
|
||||
|
||||
background: Annotated[
|
||||
Optional[Background], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
input_fidelity: Annotated[
|
||||
OptionalNullable[InputFidelity], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
input_image_mask: Optional[InputImageMask] = None
|
||||
|
||||
model: Annotated[Optional[ModelEnum], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
|
||||
moderation: Annotated[
|
||||
Optional[Moderation], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
output_compression: Optional[float] = None
|
||||
|
||||
output_format: Annotated[
|
||||
Optional[OutputFormat], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
partial_images: Optional[float] = None
|
||||
|
||||
quality: Annotated[Optional[Quality], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
|
||||
size: Annotated[Optional[Size], PlainValidator(validate_open_enum(False))] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"background",
|
||||
"input_fidelity",
|
||||
"input_image_mask",
|
||||
"model",
|
||||
"moderation",
|
||||
"output_compression",
|
||||
"output_format",
|
||||
"partial_images",
|
||||
"quality",
|
||||
"size",
|
||||
]
|
||||
nullable_fields = ["input_fidelity"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
Reason = Union[
|
||||
Literal[
|
||||
"max_output_tokens",
|
||||
"content_filter",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class IncompleteDetailsTypedDict(TypedDict):
|
||||
reason: NotRequired[Reason]
|
||||
|
||||
|
||||
class IncompleteDetails(BaseModel):
|
||||
reason: Annotated[Optional[Reason], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
InputAudioType = Literal["input_audio",]
|
||||
|
||||
|
||||
InputAudioFormat = Union[
|
||||
Literal[
|
||||
"mp3",
|
||||
"wav",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class InputAudioInputAudioTypedDict(TypedDict):
|
||||
data: str
|
||||
format_: InputAudioFormat
|
||||
|
||||
|
||||
class InputAudioInputAudio(BaseModel):
|
||||
data: str
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[InputAudioFormat, PlainValidator(validate_open_enum(False))],
|
||||
pydantic.Field(alias="format"),
|
||||
]
|
||||
|
||||
|
||||
class InputAudioTypedDict(TypedDict):
|
||||
r"""Audio input content item"""
|
||||
|
||||
type: InputAudioType
|
||||
input_audio: InputAudioInputAudioTypedDict
|
||||
|
||||
|
||||
class InputAudio(BaseModel):
|
||||
r"""Audio input content item"""
|
||||
|
||||
type: InputAudioType
|
||||
|
||||
input_audio: InputAudioInputAudio
|
||||
@@ -0,0 +1,70 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
InputFileType = Literal["input_file",]
|
||||
|
||||
|
||||
class InputFileTypedDict(TypedDict):
|
||||
r"""File input content item"""
|
||||
|
||||
type: InputFileType
|
||||
file_id: NotRequired[Nullable[str]]
|
||||
file_data: NotRequired[str]
|
||||
filename: NotRequired[str]
|
||||
file_url: NotRequired[str]
|
||||
|
||||
|
||||
class InputFile(BaseModel):
|
||||
r"""File input content item"""
|
||||
|
||||
type: InputFileType
|
||||
|
||||
file_id: OptionalNullable[str] = UNSET
|
||||
|
||||
file_data: Optional[str] = None
|
||||
|
||||
filename: Optional[str] = None
|
||||
|
||||
file_url: Optional[str] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["file_id", "file_data", "filename", "file_url"]
|
||||
nullable_fields = ["file_id"]
|
||||
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,77 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
InputImageType = Literal["input_image",]
|
||||
|
||||
|
||||
InputImageDetail = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"high",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class InputImageTypedDict(TypedDict):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: InputImageType
|
||||
detail: InputImageDetail
|
||||
image_url: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class InputImage(BaseModel):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: InputImageType
|
||||
|
||||
detail: Annotated[InputImageDetail, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
image_url: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["image_url"]
|
||||
nullable_fields = ["image_url"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,184 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputaudio import InputAudio, InputAudioTypedDict
|
||||
from .inputfile import InputFile, InputFileTypedDict
|
||||
from .inputtext import InputText, InputTextTypedDict
|
||||
from .inputvideo import InputVideo, InputVideoTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
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",
|
||||
"high",
|
||||
"low",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class InputMessageItemContentInputImageTypedDict(TypedDict):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: InputMessageItemContentType
|
||||
detail: InputMessageItemDetail
|
||||
image_url: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class InputMessageItemContentInputImage(BaseModel):
|
||||
r"""Image input content item"""
|
||||
|
||||
type: InputMessageItemContentType
|
||||
|
||||
detail: Annotated[InputMessageItemDetail, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
image_url: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["image_url"]
|
||||
nullable_fields = ["image_url"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
InputMessageItemContentUnionTypedDict = TypeAliasType(
|
||||
"InputMessageItemContentUnionTypedDict",
|
||||
Union[
|
||||
InputTextTypedDict,
|
||||
InputAudioTypedDict,
|
||||
InputVideoTypedDict,
|
||||
InputMessageItemContentInputImageTypedDict,
|
||||
InputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
InputMessageItemContentUnion = Annotated[
|
||||
Union[
|
||||
Annotated[InputText, Tag("input_text")],
|
||||
Annotated[InputMessageItemContentInputImage, Tag("input_image")],
|
||||
Annotated[InputFile, Tag("input_file")],
|
||||
Annotated[InputAudio, Tag("input_audio")],
|
||||
Annotated[InputVideo, Tag("input_video")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class InputMessageItemTypedDict(TypedDict):
|
||||
role: InputMessageItemRoleUnionTypedDict
|
||||
id: NotRequired[str]
|
||||
type: NotRequired[InputMessageItemTypeMessage]
|
||||
content: NotRequired[Nullable[List[InputMessageItemContentUnionTypedDict]]]
|
||||
|
||||
|
||||
class InputMessageItem(BaseModel):
|
||||
role: InputMessageItemRoleUnion
|
||||
|
||||
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"]
|
||||
nullable_fields = ["content"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,350 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .easyinputmessage import EasyInputMessage, EasyInputMessageTypedDict
|
||||
from .functioncallitem import FunctionCallItem, FunctionCallItemTypedDict
|
||||
from .functioncalloutputitem import (
|
||||
FunctionCallOutputItem,
|
||||
FunctionCallOutputItemTypedDict,
|
||||
)
|
||||
from .inputmessageitem import InputMessageItem, InputMessageItemTypedDict
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .outputdatetimeitem import OutputDatetimeItem, OutputDatetimeItemTypedDict
|
||||
from .outputfilesearchcallitem import (
|
||||
OutputFileSearchCallItem,
|
||||
OutputFileSearchCallItemTypedDict,
|
||||
)
|
||||
from .outputfunctioncallitem import (
|
||||
OutputFunctionCallItem,
|
||||
OutputFunctionCallItemTypedDict,
|
||||
)
|
||||
from .outputimagegenerationcallitem import (
|
||||
OutputImageGenerationCallItem,
|
||||
OutputImageGenerationCallItemTypedDict,
|
||||
)
|
||||
from .outputservertoolitem import OutputServerToolItem, OutputServerToolItemTypedDict
|
||||
from .outputwebsearchcallitem import (
|
||||
OutputWebSearchCallItem,
|
||||
OutputWebSearchCallItemTypedDict,
|
||||
)
|
||||
from .reasoningitem import ReasoningItem, ReasoningItemTypedDict
|
||||
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
InputsTypeReasoning = Literal["reasoning",]
|
||||
|
||||
|
||||
InputsStatusInProgress2 = Literal["in_progress",]
|
||||
|
||||
|
||||
InputsStatusIncomplete2 = Literal["incomplete",]
|
||||
|
||||
|
||||
InputsStatusCompleted2 = Literal["completed",]
|
||||
|
||||
|
||||
InputsStatusUnion2TypedDict = TypeAliasType(
|
||||
"InputsStatusUnion2TypedDict",
|
||||
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
||||
)
|
||||
|
||||
|
||||
InputsStatusUnion2 = TypeAliasType(
|
||||
"InputsStatusUnion2",
|
||||
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
||||
)
|
||||
|
||||
|
||||
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"""
|
||||
|
||||
|
||||
class InputsReasoningTypedDict(TypedDict):
|
||||
r"""An output item containing reasoning"""
|
||||
|
||||
type: InputsTypeReasoning
|
||||
id: str
|
||||
summary: Nullable[List[ReasoningSummaryTextTypedDict]]
|
||||
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
|
||||
encrypted_content: NotRequired[Nullable[str]]
|
||||
status: NotRequired[InputsStatusUnion2TypedDict]
|
||||
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]]
|
||||
|
||||
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))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
r"""The format of the reasoning content"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"content",
|
||||
"encrypted_content",
|
||||
"status",
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
nullable_fields = [
|
||||
"content",
|
||||
"summary",
|
||||
"encrypted_content",
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
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],
|
||||
)
|
||||
|
||||
|
||||
InputsContent1 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseOutputText, Tag("output_text")],
|
||||
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
InputsContent2TypedDict = TypeAliasType(
|
||||
"InputsContent2TypedDict", Union[List[InputsContent1TypedDict], str, Any]
|
||||
)
|
||||
|
||||
|
||||
InputsContent2 = TypeAliasType("InputsContent2", Union[List[InputsContent1], str, Any])
|
||||
|
||||
|
||||
InputsPhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
InputsPhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
InputsPhaseUnionTypedDict = TypeAliasType(
|
||||
"InputsPhaseUnionTypedDict",
|
||||
Union[InputsPhaseCommentary, InputsPhaseFinalAnswer, Any],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
InputsPhaseUnion = TypeAliasType(
|
||||
"InputsPhaseUnion", Union[InputsPhaseCommentary, InputsPhaseFinalAnswer, Any]
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class InputsMessageTypedDict(TypedDict):
|
||||
r"""An output message item"""
|
||||
|
||||
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."""
|
||||
|
||||
|
||||
class InputsMessage(BaseModel):
|
||||
r"""An output message item"""
|
||||
|
||||
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."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["status", "phase"]
|
||||
nullable_fields = ["content", "phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
InputsUnion1TypedDict = TypeAliasType(
|
||||
"InputsUnion1TypedDict",
|
||||
Union[
|
||||
OutputWebSearchCallItemTypedDict,
|
||||
EasyInputMessageTypedDict,
|
||||
InputMessageItemTypedDict,
|
||||
OutputServerToolItemTypedDict,
|
||||
OutputImageGenerationCallItemTypedDict,
|
||||
OutputFileSearchCallItemTypedDict,
|
||||
FunctionCallOutputItemTypedDict,
|
||||
OutputDatetimeItemTypedDict,
|
||||
FunctionCallItemTypedDict,
|
||||
OutputFunctionCallItemTypedDict,
|
||||
InputsMessageTypedDict,
|
||||
InputsReasoningTypedDict,
|
||||
ReasoningItemTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
InputsUnion1 = TypeAliasType(
|
||||
"InputsUnion1",
|
||||
Union[
|
||||
OutputWebSearchCallItem,
|
||||
EasyInputMessage,
|
||||
InputMessageItem,
|
||||
OutputServerToolItem,
|
||||
OutputImageGenerationCallItem,
|
||||
OutputFileSearchCallItem,
|
||||
FunctionCallOutputItem,
|
||||
OutputDatetimeItem,
|
||||
FunctionCallItem,
|
||||
OutputFunctionCallItem,
|
||||
InputsMessage,
|
||||
InputsReasoning,
|
||||
ReasoningItem,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
InputsUnionTypedDict = TypeAliasType(
|
||||
"InputsUnionTypedDict", Union[str, List[InputsUnion1TypedDict]]
|
||||
)
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
|
||||
|
||||
InputsUnion = TypeAliasType("InputsUnion", Union[str, List[InputsUnion1]])
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
@@ -0,0 +1,24 @@
|
||||
"""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
|
||||
|
||||
|
||||
InputTextType = Literal["input_text",]
|
||||
|
||||
|
||||
class InputTextTypedDict(TypedDict):
|
||||
r"""Text input content item"""
|
||||
|
||||
type: InputTextType
|
||||
text: str
|
||||
|
||||
|
||||
class InputText(BaseModel):
|
||||
r"""Text input content item"""
|
||||
|
||||
type: InputTextType
|
||||
|
||||
text: str
|
||||
@@ -0,0 +1,26 @@
|
||||
"""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
|
||||
|
||||
|
||||
InputVideoType = Literal["input_video",]
|
||||
|
||||
|
||||
class InputVideoTypedDict(TypedDict):
|
||||
r"""Video input content item"""
|
||||
|
||||
type: InputVideoType
|
||||
video_url: str
|
||||
r"""A base64 data URL or remote URL that resolves to a video file"""
|
||||
|
||||
|
||||
class InputVideo(BaseModel):
|
||||
r"""Video input content item"""
|
||||
|
||||
type: InputVideoType
|
||||
|
||||
video_url: str
|
||||
r"""A base64 data URL or remote URL that resolves to a video file"""
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcontentvideoinput import ChatContentVideoInput, ChatContentVideoInputTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict, deprecated
|
||||
|
||||
|
||||
LegacyChatContentVideoType = Literal["input_video",]
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class LegacyChatContentVideoTypedDict(TypedDict):
|
||||
r"""Video input content part (legacy format - deprecated)"""
|
||||
|
||||
type: LegacyChatContentVideoType
|
||||
video_url: ChatContentVideoInputTypedDict
|
||||
r"""Video input object"""
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class LegacyChatContentVideo(BaseModel):
|
||||
r"""Video input content part (legacy format - deprecated)"""
|
||||
|
||||
type: LegacyChatContentVideoType
|
||||
|
||||
video_url: ChatContentVideoInput
|
||||
r"""Video input object"""
|
||||
@@ -0,0 +1,151 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .searchcontextsizeenum import SearchContextSizeEnum
|
||||
from .websearchuserlocation import WebSearchUserLocation, WebSearchUserLocationTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, 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]]
|
||||
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):
|
||||
r"""Web search tool configuration"""
|
||||
|
||||
type: LegacyWebSearchServerToolType
|
||||
|
||||
filters: OptionalNullable[LegacyWebSearchServerToolFilters] = UNSET
|
||||
|
||||
search_context_size: Annotated[
|
||||
Optional[SearchContextSizeEnum], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Size of the search context for web search tools"""
|
||||
|
||||
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 = [
|
||||
"filters",
|
||||
"search_context_size",
|
||||
"user_location",
|
||||
"engine",
|
||||
"max_results",
|
||||
]
|
||||
nullable_fields = ["filters", "user_location"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,154 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
McpServerToolType = Literal["mcp",]
|
||||
|
||||
|
||||
class AllowedToolsTypedDict(TypedDict):
|
||||
tool_names: NotRequired[List[str]]
|
||||
read_only: NotRequired[bool]
|
||||
|
||||
|
||||
class AllowedTools(BaseModel):
|
||||
tool_names: Optional[List[str]] = None
|
||||
|
||||
read_only: Optional[bool] = None
|
||||
|
||||
|
||||
ConnectorID = Union[
|
||||
Literal[
|
||||
"connector_dropbox",
|
||||
"connector_gmail",
|
||||
"connector_googlecalendar",
|
||||
"connector_googledrive",
|
||||
"connector_microsoftteams",
|
||||
"connector_outlookcalendar",
|
||||
"connector_outlookemail",
|
||||
"connector_sharepoint",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
RequireApprovalNever = Literal["never",]
|
||||
|
||||
|
||||
RequireApprovalAlways = Literal["always",]
|
||||
|
||||
|
||||
class NeverTypedDict(TypedDict):
|
||||
tool_names: NotRequired[List[str]]
|
||||
|
||||
|
||||
class Never(BaseModel):
|
||||
tool_names: Optional[List[str]] = None
|
||||
|
||||
|
||||
class AlwaysTypedDict(TypedDict):
|
||||
tool_names: NotRequired[List[str]]
|
||||
|
||||
|
||||
class Always(BaseModel):
|
||||
tool_names: Optional[List[str]] = None
|
||||
|
||||
|
||||
class RequireApprovalTypedDict(TypedDict):
|
||||
never: NotRequired[NeverTypedDict]
|
||||
always: NotRequired[AlwaysTypedDict]
|
||||
|
||||
|
||||
class RequireApproval(BaseModel):
|
||||
never: Optional[Never] = None
|
||||
|
||||
always: Optional[Always] = None
|
||||
|
||||
|
||||
class McpServerToolTypedDict(TypedDict):
|
||||
r"""MCP (Model Context Protocol) tool configuration"""
|
||||
|
||||
type: McpServerToolType
|
||||
server_label: str
|
||||
allowed_tools: NotRequired[Nullable[Any]]
|
||||
authorization: NotRequired[str]
|
||||
connector_id: NotRequired[ConnectorID]
|
||||
headers: NotRequired[Nullable[Dict[str, str]]]
|
||||
require_approval: NotRequired[Nullable[Any]]
|
||||
server_description: NotRequired[str]
|
||||
server_url: NotRequired[str]
|
||||
|
||||
|
||||
class McpServerTool(BaseModel):
|
||||
r"""MCP (Model Context Protocol) tool configuration"""
|
||||
|
||||
type: McpServerToolType
|
||||
|
||||
server_label: str
|
||||
|
||||
allowed_tools: OptionalNullable[Any] = UNSET
|
||||
|
||||
authorization: Optional[str] = None
|
||||
|
||||
connector_id: Annotated[
|
||||
Optional[ConnectorID], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
headers: OptionalNullable[Dict[str, str]] = UNSET
|
||||
|
||||
require_approval: OptionalNullable[Any] = UNSET
|
||||
|
||||
server_description: Optional[str] = None
|
||||
|
||||
server_url: Optional[str] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"allowed_tools",
|
||||
"authorization",
|
||||
"connector_id",
|
||||
"headers",
|
||||
"require_approval",
|
||||
"server_description",
|
||||
"server_url",
|
||||
]
|
||||
nullable_fields = ["allowed_tools", "headers", "require_approval"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -50,6 +50,8 @@ class ModelTypedDict(TypedDict):
|
||||
r"""Hugging Face model identifier, if applicable"""
|
||||
description: NotRequired[str]
|
||||
r"""Description of the model"""
|
||||
knowledge_cutoff: NotRequired[Nullable[str]]
|
||||
r"""The date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown."""
|
||||
expiration_date: NotRequired[Nullable[str]]
|
||||
r"""The date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration."""
|
||||
|
||||
@@ -98,17 +100,26 @@ class Model(BaseModel):
|
||||
description: Optional[str] = None
|
||||
r"""Description of the model"""
|
||||
|
||||
knowledge_cutoff: OptionalNullable[str] = UNSET
|
||||
r"""The date up to which the model was trained on data. ISO 8601 date string (YYYY-MM-DD) or null if unknown."""
|
||||
|
||||
expiration_date: OptionalNullable[str] = UNSET
|
||||
r"""The date after which the model may be removed. ISO 8601 date string (YYYY-MM-DD) or null if no expiration."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["hugging_face_id", "description", "expiration_date"]
|
||||
optional_fields = [
|
||||
"hugging_face_id",
|
||||
"description",
|
||||
"knowledge_cutoff",
|
||||
"expiration_date",
|
||||
]
|
||||
nullable_fields = [
|
||||
"hugging_face_id",
|
||||
"context_length",
|
||||
"per_request_limits",
|
||||
"default_parameters",
|
||||
"knowledge_cutoff",
|
||||
"expiration_date",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
@@ -86,10 +86,41 @@ class OpenAIResponsesInputFunctionCall(BaseModel):
|
||||
OpenAIResponsesInputTypeFunctionCallOutput = Literal["function_call_output",]
|
||||
|
||||
|
||||
OpenAIResponsesInputOutput1TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputOutput1TypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputOutput1 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseInputText, Tag("input_text")],
|
||||
Annotated[ResponseInputImage, Tag("input_image")],
|
||||
Annotated[ResponseInputFile, Tag("input_file")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
OpenAIResponsesInputOutput2TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputOutput2TypedDict",
|
||||
Union[str, List[OpenAIResponsesInputOutput1TypedDict]],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputOutput2 = TypeAliasType(
|
||||
"OpenAIResponsesInputOutput2", Union[str, List[OpenAIResponsesInputOutput1]]
|
||||
)
|
||||
|
||||
|
||||
class OpenAIResponsesInputFunctionCallOutputTypedDict(TypedDict):
|
||||
type: OpenAIResponsesInputTypeFunctionCallOutput
|
||||
call_id: str
|
||||
output: str
|
||||
output: OpenAIResponsesInputOutput2TypedDict
|
||||
id: NotRequired[Nullable[str]]
|
||||
status: NotRequired[Nullable[ToolCallStatus]]
|
||||
|
||||
@@ -99,7 +130,7 @@ class OpenAIResponsesInputFunctionCallOutput(BaseModel):
|
||||
|
||||
call_id: str
|
||||
|
||||
output: str
|
||||
output: OpenAIResponsesInputOutput2
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
@@ -279,10 +310,33 @@ OpenAIResponsesInputContent2 = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputPhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
OpenAIResponsesInputPhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
OpenAIResponsesInputPhaseUnionTypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputPhaseUnionTypedDict",
|
||||
Union[
|
||||
OpenAIResponsesInputPhaseCommentary, OpenAIResponsesInputPhaseFinalAnswer, Any
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputPhaseUnion = TypeAliasType(
|
||||
"OpenAIResponsesInputPhaseUnion",
|
||||
Union[
|
||||
OpenAIResponsesInputPhaseCommentary, OpenAIResponsesInputPhaseFinalAnswer, Any
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage1TypedDict(TypedDict):
|
||||
role: OpenAIResponsesInputRoleUnion1TypedDict
|
||||
content: OpenAIResponsesInputContent2TypedDict
|
||||
type: NotRequired[OpenAIResponsesInputTypeMessage1]
|
||||
phase: NotRequired[Nullable[OpenAIResponsesInputPhaseUnionTypedDict]]
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage1(BaseModel):
|
||||
@@ -292,6 +346,38 @@ class OpenAIResponsesInputMessage1(BaseModel):
|
||||
|
||||
type: Optional[OpenAIResponsesInputTypeMessage1] = None
|
||||
|
||||
phase: OptionalNullable[OpenAIResponsesInputPhaseUnion] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["type", "phase"]
|
||||
nullable_fields = ["phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
OpenAIResponsesInputUnion1TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputUnion1TypedDict",
|
||||
@@ -300,8 +386,8 @@ OpenAIResponsesInputUnion1TypedDict = TypeAliasType(
|
||||
OpenAIResponsesInputMessage2TypedDict,
|
||||
OutputItemImageGenerationCallTypedDict,
|
||||
OpenAIResponsesInputFunctionCallOutputTypedDict,
|
||||
OutputMessageTypedDict,
|
||||
OpenAIResponsesInputFunctionCallTypedDict,
|
||||
OutputMessageTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
@@ -313,8 +399,8 @@ OpenAIResponsesInputUnion1 = TypeAliasType(
|
||||
OpenAIResponsesInputMessage2,
|
||||
OutputItemImageGenerationCall,
|
||||
OpenAIResponsesInputFunctionCallOutput,
|
||||
OutputMessage,
|
||||
OpenAIResponsesInputFunctionCall,
|
||||
OutputMessage,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenResponsesApplyPatchToolType = Literal["apply_patch",]
|
||||
|
||||
|
||||
class OpenResponsesApplyPatchToolTypedDict(TypedDict):
|
||||
r"""Apply patch tool configuration"""
|
||||
|
||||
type: OpenResponsesApplyPatchToolType
|
||||
|
||||
|
||||
class OpenResponsesApplyPatchTool(BaseModel):
|
||||
r"""Apply patch tool configuration"""
|
||||
|
||||
type: OpenResponsesApplyPatchToolType
|
||||
@@ -0,0 +1,102 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeCodeInterpreter = Literal["code_interpreter",]
|
||||
|
||||
|
||||
ContainerType = Literal["auto",]
|
||||
|
||||
|
||||
MemoryLimit = Union[
|
||||
Literal[
|
||||
"1g",
|
||||
"4g",
|
||||
"16g",
|
||||
"64g",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ContainerAutoTypedDict(TypedDict):
|
||||
type: ContainerType
|
||||
file_ids: NotRequired[List[str]]
|
||||
memory_limit: NotRequired[Nullable[MemoryLimit]]
|
||||
|
||||
|
||||
class ContainerAuto(BaseModel):
|
||||
type: ContainerType
|
||||
|
||||
file_ids: Optional[List[str]] = None
|
||||
|
||||
memory_limit: Annotated[
|
||||
OptionalNullable[MemoryLimit], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["file_ids", "memory_limit"]
|
||||
nullable_fields = ["memory_limit"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
ContainerTypedDict = TypeAliasType(
|
||||
"ContainerTypedDict", Union[ContainerAutoTypedDict, str]
|
||||
)
|
||||
|
||||
|
||||
Container = TypeAliasType("Container", Union[ContainerAuto, str])
|
||||
|
||||
|
||||
class OpenResponsesCodeInterpreterToolTypedDict(TypedDict):
|
||||
r"""Code interpreter tool configuration"""
|
||||
|
||||
type: TypeCodeInterpreter
|
||||
container: ContainerTypedDict
|
||||
|
||||
|
||||
class OpenResponsesCodeInterpreterTool(BaseModel):
|
||||
r"""Code interpreter tool configuration"""
|
||||
|
||||
type: TypeCodeInterpreter
|
||||
|
||||
container: Container
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
OpenResponsesComputerToolType = Literal["computer_use_preview",]
|
||||
|
||||
|
||||
Environment = Union[
|
||||
Literal[
|
||||
"windows",
|
||||
"mac",
|
||||
"linux",
|
||||
"ubuntu",
|
||||
"browser",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesComputerToolTypedDict(TypedDict):
|
||||
r"""Computer use preview tool configuration"""
|
||||
|
||||
type: OpenResponsesComputerToolType
|
||||
display_height: float
|
||||
display_width: float
|
||||
environment: Environment
|
||||
|
||||
|
||||
class OpenResponsesComputerTool(BaseModel):
|
||||
r"""Computer use preview tool configuration"""
|
||||
|
||||
type: OpenResponsesComputerToolType
|
||||
|
||||
display_height: float
|
||||
|
||||
display_width: float
|
||||
|
||||
environment: Annotated[Environment, PlainValidator(validate_open_enum(False))]
|
||||
@@ -0,0 +1,82 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeCustom = Literal["custom",]
|
||||
|
||||
|
||||
FormatTypeGrammar = Literal["grammar",]
|
||||
|
||||
|
||||
Syntax = Union[
|
||||
Literal[
|
||||
"lark",
|
||||
"regex",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class FormatGrammarTypedDict(TypedDict):
|
||||
type: FormatTypeGrammar
|
||||
definition: str
|
||||
syntax: Syntax
|
||||
|
||||
|
||||
class FormatGrammar(BaseModel):
|
||||
type: FormatTypeGrammar
|
||||
|
||||
definition: str
|
||||
|
||||
syntax: Annotated[Syntax, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
|
||||
FormatTypeText = Literal["text",]
|
||||
|
||||
|
||||
class FormatTextTypedDict(TypedDict):
|
||||
type: FormatTypeText
|
||||
|
||||
|
||||
class FormatText(BaseModel):
|
||||
type: FormatTypeText
|
||||
|
||||
|
||||
FormatTypedDict = TypeAliasType(
|
||||
"FormatTypedDict", Union[FormatTextTypedDict, FormatGrammarTypedDict]
|
||||
)
|
||||
|
||||
|
||||
Format = Annotated[
|
||||
Union[Annotated[FormatText, Tag("text")], Annotated[FormatGrammar, Tag("grammar")]],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesCustomToolTypedDict(TypedDict):
|
||||
r"""Custom tool configuration"""
|
||||
|
||||
type: TypeCustom
|
||||
name: str
|
||||
description: NotRequired[str]
|
||||
format_: NotRequired[FormatTypedDict]
|
||||
|
||||
|
||||
class OpenResponsesCustomTool(BaseModel):
|
||||
r"""Custom tool configuration"""
|
||||
|
||||
type: TypeCustom
|
||||
|
||||
name: str
|
||||
|
||||
description: Optional[str] = None
|
||||
|
||||
format_: Annotated[Optional[Format], pydantic.Field(alias="format")] = None
|
||||
@@ -16,7 +16,7 @@ from openrouter.types import (
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
@@ -146,25 +146,88 @@ OpenResponsesEasyInputMessageContentUnion1 = Annotated[
|
||||
|
||||
OpenResponsesEasyInputMessageContentUnion2TypedDict = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageContentUnion2TypedDict",
|
||||
Union[List[OpenResponsesEasyInputMessageContentUnion1TypedDict], str],
|
||||
Union[List[OpenResponsesEasyInputMessageContentUnion1TypedDict], str, Any],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageContentUnion2 = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageContentUnion2",
|
||||
Union[List[OpenResponsesEasyInputMessageContentUnion1], str],
|
||||
Union[List[OpenResponsesEasyInputMessageContentUnion1], str, Any],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessagePhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessagePhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessagePhaseUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessagePhaseUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessagePhaseCommentary,
|
||||
OpenResponsesEasyInputMessagePhaseFinalAnswer,
|
||||
Any,
|
||||
],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessagePhaseUnion = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessagePhaseUnion",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessagePhaseCommentary,
|
||||
OpenResponsesEasyInputMessagePhaseFinalAnswer,
|
||||
Any,
|
||||
],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class OpenResponsesEasyInputMessageTypedDict(TypedDict):
|
||||
role: OpenResponsesEasyInputMessageRoleUnionTypedDict
|
||||
content: OpenResponsesEasyInputMessageContentUnion2TypedDict
|
||||
type: NotRequired[OpenResponsesEasyInputMessageTypeMessage]
|
||||
content: NotRequired[Nullable[OpenResponsesEasyInputMessageContentUnion2TypedDict]]
|
||||
phase: NotRequired[Nullable[OpenResponsesEasyInputMessagePhaseUnionTypedDict]]
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class OpenResponsesEasyInputMessage(BaseModel):
|
||||
role: OpenResponsesEasyInputMessageRoleUnion
|
||||
|
||||
content: OpenResponsesEasyInputMessageContentUnion2
|
||||
|
||||
type: Optional[OpenResponsesEasyInputMessageTypeMessage] = None
|
||||
|
||||
content: OptionalNullable[OpenResponsesEasyInputMessageContentUnion2] = UNSET
|
||||
|
||||
phase: OptionalNullable[OpenResponsesEasyInputMessagePhaseUnion] = UNSET
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["type", "content", "phase"]
|
||||
nullable_fields = ["content", "phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user