mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
fixes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
import pydantic
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ActivityItemTypedDict(TypedDict):
|
||||
date_: str
|
||||
r"""Date of the activity (YYYY-MM-DD format)"""
|
||||
model: str
|
||||
r"""Model slug (e.g., \"openai/gpt-4.1\")"""
|
||||
model_permaslug: str
|
||||
r"""Model permaslug (e.g., \"openai/gpt-4.1-2025-04-14\")"""
|
||||
endpoint_id: str
|
||||
r"""Unique identifier for the endpoint"""
|
||||
provider_name: str
|
||||
r"""Name of the provider serving this endpoint"""
|
||||
usage: float
|
||||
r"""Total cost in USD (OpenRouter credits spent)"""
|
||||
byok_usage_inference: float
|
||||
r"""BYOK inference cost in USD (external credits spent)"""
|
||||
requests: float
|
||||
r"""Number of requests made"""
|
||||
prompt_tokens: float
|
||||
r"""Total prompt tokens used"""
|
||||
completion_tokens: float
|
||||
r"""Total completion tokens generated"""
|
||||
reasoning_tokens: float
|
||||
r"""Total reasoning tokens used"""
|
||||
|
||||
|
||||
class ActivityItem(BaseModel):
|
||||
date_: Annotated[str, pydantic.Field(alias="date")]
|
||||
r"""Date of the activity (YYYY-MM-DD format)"""
|
||||
|
||||
model: str
|
||||
r"""Model slug (e.g., \"openai/gpt-4.1\")"""
|
||||
|
||||
model_permaslug: str
|
||||
r"""Model permaslug (e.g., \"openai/gpt-4.1-2025-04-14\")"""
|
||||
|
||||
endpoint_id: str
|
||||
r"""Unique identifier for the endpoint"""
|
||||
|
||||
provider_name: str
|
||||
r"""Name of the provider serving this endpoint"""
|
||||
|
||||
usage: float
|
||||
r"""Total cost in USD (OpenRouter credits spent)"""
|
||||
|
||||
byok_usage_inference: float
|
||||
r"""BYOK inference cost in USD (external credits spent)"""
|
||||
|
||||
requests: float
|
||||
r"""Number of requests made"""
|
||||
|
||||
prompt_tokens: float
|
||||
r"""Total prompt tokens used"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Total completion tokens generated"""
|
||||
|
||||
reasoning_tokens: float
|
||||
r"""Total reasoning tokens used"""
|
||||
@@ -0,0 +1,88 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatmessagecontentitem import (
|
||||
ChatMessageContentItem,
|
||||
ChatMessageContentItemTypedDict,
|
||||
)
|
||||
from .chatmessagetoolcall import ChatMessageToolCall, ChatMessageToolCallTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
AssistantMessageContentTypedDict = TypeAliasType(
|
||||
"AssistantMessageContentTypedDict",
|
||||
Union[str, List[ChatMessageContentItemTypedDict]],
|
||||
)
|
||||
|
||||
|
||||
AssistantMessageContent = TypeAliasType(
|
||||
"AssistantMessageContent", Union[str, List[ChatMessageContentItem]]
|
||||
)
|
||||
|
||||
|
||||
class AssistantMessageTypedDict(TypedDict):
|
||||
role: Literal["assistant"]
|
||||
content: NotRequired[Nullable[AssistantMessageContentTypedDict]]
|
||||
name: NotRequired[str]
|
||||
tool_calls: NotRequired[List[ChatMessageToolCallTypedDict]]
|
||||
refusal: NotRequired[Nullable[str]]
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class AssistantMessage(BaseModel):
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["assistant"], AfterValidator(validate_const("assistant"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "assistant"
|
||||
|
||||
content: OptionalNullable[AssistantMessageContent] = UNSET
|
||||
|
||||
name: Optional[str] = None
|
||||
|
||||
tool_calls: Optional[List[ChatMessageToolCall]] = None
|
||||
|
||||
refusal: OptionalNullable[str] = UNSET
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["content", "name", "tool_calls", "refusal", "reasoning"]
|
||||
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,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 BadGatewayResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for BadGatewayResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class BadGatewayResponseErrorData(BaseModel):
|
||||
r"""Error data for BadGatewayResponse"""
|
||||
|
||||
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,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 BadRequestResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for BadRequestResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class BadRequestResponseErrorData(BaseModel):
|
||||
r"""Error data for BadRequestResponse"""
|
||||
|
||||
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,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
|
||||
|
||||
|
||||
ChatCompletionFinishReason = Union[
|
||||
Literal[
|
||||
"tool_calls",
|
||||
"stop",
|
||||
"length",
|
||||
"content_filter",
|
||||
"error",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,66 @@
|
||||
"""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 Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
CodeTypedDict = TypeAliasType("CodeTypedDict", Union[str, float])
|
||||
|
||||
|
||||
Code = TypeAliasType("Code", Union[str, float])
|
||||
|
||||
|
||||
class ChatErrorErrorTypedDict(TypedDict):
|
||||
code: Nullable[CodeTypedDict]
|
||||
message: str
|
||||
param: NotRequired[Nullable[str]]
|
||||
type: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class ChatErrorError(BaseModel):
|
||||
code: Nullable[Code]
|
||||
|
||||
message: str
|
||||
|
||||
param: OptionalNullable[str] = UNSET
|
||||
|
||||
type: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["param", "type"]
|
||||
nullable_fields = ["code", "param", "type"]
|
||||
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,291 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatstreamoptions import ChatStreamOptions, ChatStreamOptionsTypedDict
|
||||
from .message import Message, MessageTypedDict
|
||||
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
||||
from .responseformatjsonschema import (
|
||||
ResponseFormatJSONSchema,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
)
|
||||
from .responseformattextgrammar import (
|
||||
ResponseFormatTextGrammar,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
)
|
||||
from .tooldefinitionjson import ToolDefinitionJSON, ToolDefinitionJSONTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Effort = Union[
|
||||
Literal[
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ReasoningTypedDict(TypedDict):
|
||||
effort: NotRequired[Nullable[Effort]]
|
||||
summary: NotRequired[Nullable[ReasoningSummaryVerbosity]]
|
||||
|
||||
|
||||
class Reasoning(BaseModel):
|
||||
effort: Annotated[
|
||||
OptionalNullable[Effort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
OptionalNullable[ReasoningSummaryVerbosity],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary"]
|
||||
nullable_fields = ["effort", "summary"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatPythonTypedDict(TypedDict):
|
||||
type: Literal["python"]
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatPython(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["python"], AfterValidator(validate_const("python"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "python"
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
type: Literal["json_object"]
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatJSONObject(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["json_object"], AfterValidator(validate_const("json_object"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "json_object"
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatTextTypedDict(TypedDict):
|
||||
type: Literal["text"]
|
||||
|
||||
|
||||
class ChatGenerationParamsResponseFormatText(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
|
||||
|
||||
ChatGenerationParamsResponseFormatUnionTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsResponseFormatUnionTypedDict",
|
||||
Union[
|
||||
ChatGenerationParamsResponseFormatTextTypedDict,
|
||||
ChatGenerationParamsResponseFormatJSONObjectTypedDict,
|
||||
ChatGenerationParamsResponseFormatPythonTypedDict,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsResponseFormatUnion = TypeAliasType(
|
||||
"ChatGenerationParamsResponseFormatUnion",
|
||||
Union[
|
||||
ChatGenerationParamsResponseFormatText,
|
||||
ChatGenerationParamsResponseFormatJSONObject,
|
||||
ChatGenerationParamsResponseFormatPython,
|
||||
ResponseFormatJSONSchema,
|
||||
ResponseFormatTextGrammar,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsStopTypedDict = TypeAliasType(
|
||||
"ChatGenerationParamsStopTypedDict", Union[str, List[str]]
|
||||
)
|
||||
|
||||
|
||||
ChatGenerationParamsStop = TypeAliasType(
|
||||
"ChatGenerationParamsStop", Union[str, List[str]]
|
||||
)
|
||||
|
||||
|
||||
class ChatGenerationParamsTypedDict(TypedDict):
|
||||
messages: List[MessageTypedDict]
|
||||
model: NotRequired[str]
|
||||
models: NotRequired[List[str]]
|
||||
frequency_penalty: NotRequired[Nullable[float]]
|
||||
logit_bias: NotRequired[Nullable[Dict[str, float]]]
|
||||
logprobs: NotRequired[Nullable[bool]]
|
||||
top_logprobs: NotRequired[Nullable[float]]
|
||||
max_completion_tokens: NotRequired[Nullable[float]]
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
metadata: NotRequired[Dict[str, str]]
|
||||
presence_penalty: NotRequired[Nullable[float]]
|
||||
reasoning: NotRequired[ReasoningTypedDict]
|
||||
response_format: NotRequired[ChatGenerationParamsResponseFormatUnionTypedDict]
|
||||
seed: NotRequired[Nullable[int]]
|
||||
stop: NotRequired[Nullable[ChatGenerationParamsStopTypedDict]]
|
||||
stream: NotRequired[bool]
|
||||
stream_options: NotRequired[Nullable[ChatStreamOptionsTypedDict]]
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
tool_choice: NotRequired[Any]
|
||||
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
user: NotRequired[str]
|
||||
|
||||
|
||||
class ChatGenerationParams(BaseModel):
|
||||
messages: List[Message]
|
||||
|
||||
model: Optional[str] = None
|
||||
|
||||
models: Optional[List[str]] = None
|
||||
|
||||
frequency_penalty: OptionalNullable[float] = UNSET
|
||||
|
||||
logit_bias: OptionalNullable[Dict[str, float]] = UNSET
|
||||
|
||||
logprobs: OptionalNullable[bool] = UNSET
|
||||
|
||||
top_logprobs: OptionalNullable[float] = UNSET
|
||||
|
||||
max_completion_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
metadata: Optional[Dict[str, str]] = None
|
||||
|
||||
presence_penalty: OptionalNullable[float] = UNSET
|
||||
|
||||
reasoning: Optional[Reasoning] = None
|
||||
|
||||
response_format: Optional[ChatGenerationParamsResponseFormatUnion] = None
|
||||
|
||||
seed: OptionalNullable[int] = UNSET
|
||||
|
||||
stop: OptionalNullable[ChatGenerationParamsStop] = UNSET
|
||||
|
||||
stream: Optional[bool] = False
|
||||
|
||||
stream_options: OptionalNullable[ChatStreamOptions] = UNSET
|
||||
|
||||
temperature: OptionalNullable[float] = UNSET
|
||||
|
||||
tool_choice: Optional[Any] = None
|
||||
|
||||
tools: Optional[List[ToolDefinitionJSON]] = None
|
||||
|
||||
top_p: OptionalNullable[float] = UNSET
|
||||
|
||||
user: Optional[str] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"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",
|
||||
"tool_choice",
|
||||
"tools",
|
||||
"top_p",
|
||||
"user",
|
||||
]
|
||||
nullable_fields = [
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"top_logprobs",
|
||||
"max_completion_tokens",
|
||||
"max_tokens",
|
||||
"presence_penalty",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream_options",
|
||||
"temperature",
|
||||
"top_p",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,134 @@
|
||||
"""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):
|
||||
reasoning_tokens: NotRequired[Nullable[float]]
|
||||
audio_tokens: NotRequired[Nullable[float]]
|
||||
accepted_prediction_tokens: NotRequired[Nullable[float]]
|
||||
rejected_prediction_tokens: NotRequired[Nullable[float]]
|
||||
|
||||
|
||||
class CompletionTokensDetails(BaseModel):
|
||||
reasoning_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
audio_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
accepted_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
rejected_prediction_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
@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):
|
||||
cached_tokens: NotRequired[float]
|
||||
audio_tokens: NotRequired[float]
|
||||
video_tokens: NotRequired[float]
|
||||
|
||||
|
||||
class PromptTokensDetails(BaseModel):
|
||||
cached_tokens: Optional[float] = None
|
||||
|
||||
audio_tokens: Optional[float] = None
|
||||
|
||||
video_tokens: Optional[float] = None
|
||||
|
||||
|
||||
class ChatGenerationTokenUsageTypedDict(TypedDict):
|
||||
completion_tokens: float
|
||||
prompt_tokens: float
|
||||
total_tokens: float
|
||||
completion_tokens_details: NotRequired[Nullable[CompletionTokensDetailsTypedDict]]
|
||||
prompt_tokens_details: NotRequired[Nullable[PromptTokensDetailsTypedDict]]
|
||||
|
||||
|
||||
class ChatGenerationTokenUsage(BaseModel):
|
||||
completion_tokens: float
|
||||
|
||||
prompt_tokens: float
|
||||
|
||||
total_tokens: float
|
||||
|
||||
completion_tokens_details: OptionalNullable[CompletionTokensDetails] = UNSET
|
||||
|
||||
prompt_tokens_details: OptionalNullable[PromptTokensDetails] = UNSET
|
||||
|
||||
@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,45 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatmessagecontentitemaudio import (
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemimage import (
|
||||
ChatMessageContentItemImage,
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemtext import (
|
||||
ChatMessageContentItemText,
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemvideo import (
|
||||
ChatMessageContentItemVideo,
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
)
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import Union
|
||||
from typing_extensions import Annotated, TypeAliasType
|
||||
|
||||
|
||||
ChatMessageContentItemTypedDict = TypeAliasType(
|
||||
"ChatMessageContentItemTypedDict",
|
||||
Union[
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ChatMessageContentItem = Annotated[
|
||||
Union[
|
||||
Annotated[ChatMessageContentItemText, Tag("text")],
|
||||
Annotated[ChatMessageContentItemImage, Tag("image_url")],
|
||||
Annotated[ChatMessageContentItemAudio, Tag("input_audio")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("input_video")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
@@ -0,0 +1,55 @@
|
||||
"""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_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemAudioFormat = Union[
|
||||
Literal[
|
||||
"wav",
|
||||
"mp3",
|
||||
"flac",
|
||||
"m4a",
|
||||
"ogg",
|
||||
"pcm16",
|
||||
"pcm24",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
|
||||
data: str
|
||||
format_: ChatMessageContentItemAudioFormat
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudio(BaseModel):
|
||||
data: str
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
ChatMessageContentItemAudioFormat, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioTypedDict(TypedDict):
|
||||
input_audio: ChatMessageContentItemAudioInputAudioTypedDict
|
||||
type: Literal["input_audio"]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudio(BaseModel):
|
||||
input_audio: ChatMessageContentItemAudioInputAudio
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["input_audio"], AfterValidator(validate_const("input_audio"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "input_audio"
|
||||
@@ -0,0 +1,47 @@
|
||||
"""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_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemImageDetail = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"low",
|
||||
"high",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ImageURLTypedDict(TypedDict):
|
||||
url: str
|
||||
detail: NotRequired[ChatMessageContentItemImageDetail]
|
||||
|
||||
|
||||
class ImageURL(BaseModel):
|
||||
url: str
|
||||
|
||||
detail: Annotated[
|
||||
Optional[ChatMessageContentItemImageDetail],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
|
||||
|
||||
class ChatMessageContentItemImageTypedDict(TypedDict):
|
||||
image_url: ImageURLTypedDict
|
||||
type: Literal["image_url"]
|
||||
|
||||
|
||||
class ChatMessageContentItemImage(BaseModel):
|
||||
image_url: ImageURL
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["image_url"], AfterValidator(validate_const("image_url"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "image_url"
|
||||
@@ -0,0 +1,23 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ChatMessageContentItemTextTypedDict(TypedDict):
|
||||
text: str
|
||||
type: Literal["text"]
|
||||
|
||||
|
||||
class ChatMessageContentItemText(BaseModel):
|
||||
text: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class VideoURLTypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class VideoURL(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoTypedDict(TypedDict):
|
||||
video_url: VideoURLTypedDict
|
||||
type: Literal["input_video"]
|
||||
|
||||
|
||||
class ChatMessageContentItemVideo(BaseModel):
|
||||
video_url: VideoURL
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["input_video"], AfterValidator(validate_const("input_video"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "input_video"
|
||||
@@ -0,0 +1,99 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class TopLogprobTypedDict(TypedDict):
|
||||
token: str
|
||||
logprob: float
|
||||
bytes_: Nullable[List[float]]
|
||||
|
||||
|
||||
class TopLogprob(BaseModel):
|
||||
token: str
|
||||
|
||||
logprob: float
|
||||
|
||||
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["bytes"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobTypedDict(TypedDict):
|
||||
token: str
|
||||
logprob: float
|
||||
bytes_: Nullable[List[float]]
|
||||
top_logprobs: List[TopLogprobTypedDict]
|
||||
|
||||
|
||||
class ChatMessageTokenLogprob(BaseModel):
|
||||
token: str
|
||||
|
||||
logprob: float
|
||||
|
||||
bytes_: Annotated[Nullable[List[float]], pydantic.Field(alias="bytes")]
|
||||
|
||||
top_logprobs: List[TopLogprob]
|
||||
|
||||
@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,52 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatmessagetokenlogprob import (
|
||||
ChatMessageTokenLogprob,
|
||||
ChatMessageTokenLogprobTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobsTypedDict(TypedDict):
|
||||
content: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
refusal: Nullable[List[ChatMessageTokenLogprobTypedDict]]
|
||||
|
||||
|
||||
class ChatMessageTokenLogprobs(BaseModel):
|
||||
content: Nullable[List[ChatMessageTokenLogprob]]
|
||||
|
||||
refusal: Nullable[List[ChatMessageTokenLogprob]]
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["content", "refusal"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ChatMessageToolCallFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
arguments: str
|
||||
|
||||
|
||||
class ChatMessageToolCallFunction(BaseModel):
|
||||
name: str
|
||||
|
||||
arguments: str
|
||||
|
||||
|
||||
class ChatMessageToolCallTypedDict(TypedDict):
|
||||
id: str
|
||||
function: ChatMessageToolCallFunctionTypedDict
|
||||
type: Literal["function"]
|
||||
|
||||
|
||||
class ChatMessageToolCall(BaseModel):
|
||||
id: str
|
||||
|
||||
function: ChatMessageToolCallFunction
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
@@ -0,0 +1,83 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsage,
|
||||
ChatGenerationTokenUsageTypedDict,
|
||||
)
|
||||
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatResponseTypedDict(TypedDict):
|
||||
id: str
|
||||
choices: List[ChatResponseChoiceTypedDict]
|
||||
created: float
|
||||
model: str
|
||||
object: Literal["chat.completion"]
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
|
||||
|
||||
|
||||
class ChatResponse(BaseModel):
|
||||
id: str
|
||||
|
||||
choices: List[ChatResponseChoice]
|
||||
|
||||
created: float
|
||||
|
||||
model: str
|
||||
|
||||
OBJECT: Annotated[
|
||||
Annotated[
|
||||
Literal["chat.completion"],
|
||||
AfterValidator(validate_const("chat.completion")),
|
||||
],
|
||||
pydantic.Field(alias="object"),
|
||||
] = "chat.completion"
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["system_fingerprint", "usage"]
|
||||
nullable_fields = ["system_fingerprint"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
)
|
||||
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 ChatResponseChoiceTypedDict(TypedDict):
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
message: AssistantMessageTypedDict
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
|
||||
|
||||
class ChatResponseChoice(BaseModel):
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
index: float
|
||||
|
||||
message: AssistantMessage
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
|
||||
@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,72 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
)
|
||||
from .chatstreamingmessagechunk import (
|
||||
ChatStreamingMessageChunk,
|
||||
ChatStreamingMessageChunkTypedDict,
|
||||
)
|
||||
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 ChatStreamingChoiceTypedDict(TypedDict):
|
||||
delta: ChatStreamingMessageChunkTypedDict
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
|
||||
|
||||
class ChatStreamingChoice(BaseModel):
|
||||
delta: ChatStreamingMessageChunk
|
||||
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
index: float
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
|
||||
@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,70 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatstreamingmessagetoolcall import (
|
||||
ChatStreamingMessageToolCall,
|
||||
ChatStreamingMessageToolCallTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatStreamingMessageChunkRole = Literal["assistant",]
|
||||
|
||||
|
||||
class ChatStreamingMessageChunkTypedDict(TypedDict):
|
||||
role: NotRequired[ChatStreamingMessageChunkRole]
|
||||
content: NotRequired[Nullable[str]]
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
refusal: NotRequired[Nullable[str]]
|
||||
tool_calls: NotRequired[List[ChatStreamingMessageToolCallTypedDict]]
|
||||
|
||||
|
||||
class ChatStreamingMessageChunk(BaseModel):
|
||||
role: Optional[ChatStreamingMessageChunkRole] = None
|
||||
|
||||
content: OptionalNullable[str] = UNSET
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
|
||||
refusal: OptionalNullable[str] = UNSET
|
||||
|
||||
tool_calls: Optional[List[ChatStreamingMessageToolCall]] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["role", "content", "reasoning", "refusal", "tool_calls"]
|
||||
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
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallFunctionTypedDict(TypedDict):
|
||||
name: NotRequired[str]
|
||||
arguments: NotRequired[str]
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallFunction(BaseModel):
|
||||
name: Optional[str] = None
|
||||
|
||||
arguments: Optional[str] = None
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCallTypedDict(TypedDict):
|
||||
index: float
|
||||
id: NotRequired[str]
|
||||
type: Literal["function"]
|
||||
function: NotRequired[ChatStreamingMessageToolCallFunctionTypedDict]
|
||||
|
||||
|
||||
class ChatStreamingMessageToolCall(BaseModel):
|
||||
index: float
|
||||
|
||||
id: Optional[str] = None
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Optional[Literal["function"]], AfterValidator(validate_const("function"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
|
||||
function: Optional[ChatStreamingMessageToolCallFunction] = None
|
||||
@@ -0,0 +1,105 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsage,
|
||||
ChatGenerationTokenUsageTypedDict,
|
||||
)
|
||||
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkErrorTypedDict(TypedDict):
|
||||
message: str
|
||||
code: float
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkError(BaseModel):
|
||||
message: str
|
||||
|
||||
code: float
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkDataTypedDict(TypedDict):
|
||||
id: str
|
||||
choices: List[ChatStreamingChoiceTypedDict]
|
||||
created: float
|
||||
model: str
|
||||
object: Literal["chat.completion.chunk"]
|
||||
system_fingerprint: NotRequired[Nullable[str]]
|
||||
error: NotRequired[ChatStreamingResponseChunkErrorTypedDict]
|
||||
usage: NotRequired[ChatGenerationTokenUsageTypedDict]
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkData(BaseModel):
|
||||
id: str
|
||||
|
||||
choices: List[ChatStreamingChoice]
|
||||
|
||||
created: float
|
||||
|
||||
model: str
|
||||
|
||||
OBJECT: Annotated[
|
||||
Annotated[
|
||||
Literal["chat.completion.chunk"],
|
||||
AfterValidator(validate_const("chat.completion.chunk")),
|
||||
],
|
||||
pydantic.Field(alias="object"),
|
||||
] = "chat.completion.chunk"
|
||||
|
||||
system_fingerprint: OptionalNullable[str] = UNSET
|
||||
|
||||
error: Optional[ChatStreamingResponseChunkError] = None
|
||||
|
||||
usage: Optional[ChatGenerationTokenUsage] = None
|
||||
|
||||
@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
|
||||
|
||||
|
||||
class ChatStreamingResponseChunkTypedDict(TypedDict):
|
||||
data: ChatStreamingResponseChunkDataTypedDict
|
||||
|
||||
|
||||
class ChatStreamingResponseChunk(BaseModel):
|
||||
data: ChatStreamingResponseChunkData
|
||||
@@ -0,0 +1,14 @@
|
||||
"""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 ChatStreamOptionsTypedDict(TypedDict):
|
||||
include_usage: NotRequired[bool]
|
||||
|
||||
|
||||
class ChatStreamOptions(BaseModel):
|
||||
include_usage: Optional[bool] = None
|
||||
@@ -0,0 +1,69 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
|
||||
from openrouter.types import BaseModel, Nullable, 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, TypedDict
|
||||
|
||||
|
||||
CompletionFinishReason = Union[
|
||||
Literal[
|
||||
"stop",
|
||||
"length",
|
||||
"content_filter",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class CompletionChoiceTypedDict(TypedDict):
|
||||
text: str
|
||||
index: float
|
||||
logprobs: Nullable[CompletionLogprobsTypedDict]
|
||||
finish_reason: Nullable[CompletionFinishReason]
|
||||
|
||||
|
||||
class CompletionChoice(BaseModel):
|
||||
text: str
|
||||
|
||||
index: float
|
||||
|
||||
logprobs: Nullable[CompletionLogprobs]
|
||||
|
||||
finish_reason: Annotated[
|
||||
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["logprobs", "finish_reason"]
|
||||
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,277 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responseformatjsonschema import (
|
||||
ResponseFormatJSONSchema,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
)
|
||||
from .responseformattextgrammar import (
|
||||
ResponseFormatTextGrammar,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
PromptTypedDict = TypeAliasType(
|
||||
"PromptTypedDict", Union[str, List[str], List[float], List[List[float]]]
|
||||
)
|
||||
|
||||
|
||||
Prompt = TypeAliasType("Prompt", Union[str, List[str], List[float], List[List[float]]])
|
||||
|
||||
|
||||
CompletionCreateParamsStopTypedDict = TypeAliasType(
|
||||
"CompletionCreateParamsStopTypedDict", Union[str, List[str]]
|
||||
)
|
||||
|
||||
|
||||
CompletionCreateParamsStop = TypeAliasType(
|
||||
"CompletionCreateParamsStop", Union[str, List[str]]
|
||||
)
|
||||
|
||||
|
||||
class StreamOptionsTypedDict(TypedDict):
|
||||
include_usage: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class StreamOptions(BaseModel):
|
||||
include_usage: OptionalNullable[bool] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["include_usage"]
|
||||
nullable_fields = ["include_usage"]
|
||||
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 CompletionCreateParamsResponseFormatPythonTypedDict(TypedDict):
|
||||
type: Literal["python"]
|
||||
|
||||
|
||||
class CompletionCreateParamsResponseFormatPython(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["python"], AfterValidator(validate_const("python"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "python"
|
||||
|
||||
|
||||
class CompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict):
|
||||
type: Literal["json_object"]
|
||||
|
||||
|
||||
class CompletionCreateParamsResponseFormatJSONObject(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["json_object"], AfterValidator(validate_const("json_object"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "json_object"
|
||||
|
||||
|
||||
class CompletionCreateParamsResponseFormatTextTypedDict(TypedDict):
|
||||
type: Literal["text"]
|
||||
|
||||
|
||||
class CompletionCreateParamsResponseFormatText(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
|
||||
|
||||
CompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType(
|
||||
"CompletionCreateParamsResponseFormatUnionTypedDict",
|
||||
Union[
|
||||
CompletionCreateParamsResponseFormatTextTypedDict,
|
||||
CompletionCreateParamsResponseFormatJSONObjectTypedDict,
|
||||
CompletionCreateParamsResponseFormatPythonTypedDict,
|
||||
ResponseFormatJSONSchemaTypedDict,
|
||||
ResponseFormatTextGrammarTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
CompletionCreateParamsResponseFormatUnion = TypeAliasType(
|
||||
"CompletionCreateParamsResponseFormatUnion",
|
||||
Union[
|
||||
CompletionCreateParamsResponseFormatText,
|
||||
CompletionCreateParamsResponseFormatJSONObject,
|
||||
CompletionCreateParamsResponseFormatPython,
|
||||
ResponseFormatJSONSchema,
|
||||
ResponseFormatTextGrammar,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class CompletionCreateParamsTypedDict(TypedDict):
|
||||
prompt: PromptTypedDict
|
||||
model: NotRequired[str]
|
||||
models: NotRequired[List[str]]
|
||||
best_of: NotRequired[Nullable[int]]
|
||||
echo: NotRequired[Nullable[bool]]
|
||||
frequency_penalty: NotRequired[Nullable[float]]
|
||||
logit_bias: NotRequired[Nullable[Dict[str, float]]]
|
||||
logprobs: NotRequired[Nullable[int]]
|
||||
max_tokens: NotRequired[Nullable[int]]
|
||||
n: NotRequired[Nullable[int]]
|
||||
presence_penalty: NotRequired[Nullable[float]]
|
||||
seed: NotRequired[Nullable[int]]
|
||||
stop: NotRequired[Nullable[CompletionCreateParamsStopTypedDict]]
|
||||
stream: NotRequired[bool]
|
||||
stream_options: NotRequired[Nullable[StreamOptionsTypedDict]]
|
||||
suffix: NotRequired[Nullable[str]]
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
user: NotRequired[str]
|
||||
metadata: NotRequired[Nullable[Dict[str, str]]]
|
||||
response_format: NotRequired[
|
||||
Nullable[CompletionCreateParamsResponseFormatUnionTypedDict]
|
||||
]
|
||||
|
||||
|
||||
class CompletionCreateParams(BaseModel):
|
||||
prompt: Prompt
|
||||
|
||||
model: Optional[str] = None
|
||||
|
||||
models: Optional[List[str]] = None
|
||||
|
||||
best_of: OptionalNullable[int] = UNSET
|
||||
|
||||
echo: OptionalNullable[bool] = UNSET
|
||||
|
||||
frequency_penalty: OptionalNullable[float] = UNSET
|
||||
|
||||
logit_bias: OptionalNullable[Dict[str, float]] = UNSET
|
||||
|
||||
logprobs: OptionalNullable[int] = UNSET
|
||||
|
||||
max_tokens: OptionalNullable[int] = UNSET
|
||||
|
||||
n: OptionalNullable[int] = UNSET
|
||||
|
||||
presence_penalty: OptionalNullable[float] = UNSET
|
||||
|
||||
seed: OptionalNullable[int] = UNSET
|
||||
|
||||
stop: OptionalNullable[CompletionCreateParamsStop] = UNSET
|
||||
|
||||
stream: Optional[bool] = False
|
||||
|
||||
stream_options: OptionalNullable[StreamOptions] = UNSET
|
||||
|
||||
suffix: OptionalNullable[str] = UNSET
|
||||
|
||||
temperature: OptionalNullable[float] = UNSET
|
||||
|
||||
top_p: OptionalNullable[float] = UNSET
|
||||
|
||||
user: Optional[str] = None
|
||||
|
||||
metadata: OptionalNullable[Dict[str, str]] = UNSET
|
||||
|
||||
response_format: OptionalNullable[CompletionCreateParamsResponseFormatUnion] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"model",
|
||||
"models",
|
||||
"best_of",
|
||||
"echo",
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"max_tokens",
|
||||
"n",
|
||||
"presence_penalty",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream",
|
||||
"stream_options",
|
||||
"suffix",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"user",
|
||||
"metadata",
|
||||
"response_format",
|
||||
]
|
||||
nullable_fields = [
|
||||
"best_of",
|
||||
"echo",
|
||||
"frequency_penalty",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"max_tokens",
|
||||
"n",
|
||||
"presence_penalty",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream_options",
|
||||
"suffix",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"metadata",
|
||||
"response_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
|
||||
@@ -0,0 +1,54 @@
|
||||
"""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 Dict, List
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class CompletionLogprobsTypedDict(TypedDict):
|
||||
tokens: List[str]
|
||||
token_logprobs: List[float]
|
||||
top_logprobs: Nullable[List[Dict[str, float]]]
|
||||
text_offset: List[float]
|
||||
|
||||
|
||||
class CompletionLogprobs(BaseModel):
|
||||
tokens: List[str]
|
||||
|
||||
token_logprobs: List[float]
|
||||
|
||||
top_logprobs: Nullable[List[Dict[str, float]]]
|
||||
|
||||
text_offset: List[float]
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["top_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,43 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .completionchoice import CompletionChoice, CompletionChoiceTypedDict
|
||||
from .completionusage import CompletionUsage, CompletionUsageTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class CompletionResponseTypedDict(TypedDict):
|
||||
id: str
|
||||
created: float
|
||||
model: str
|
||||
choices: List[CompletionChoiceTypedDict]
|
||||
object: Literal["text_completion"]
|
||||
system_fingerprint: NotRequired[str]
|
||||
usage: NotRequired[CompletionUsageTypedDict]
|
||||
|
||||
|
||||
class CompletionResponse(BaseModel):
|
||||
id: str
|
||||
|
||||
created: float
|
||||
|
||||
model: str
|
||||
|
||||
choices: List[CompletionChoice]
|
||||
|
||||
OBJECT: Annotated[
|
||||
Annotated[
|
||||
Literal["text_completion"],
|
||||
AfterValidator(validate_const("text_completion")),
|
||||
],
|
||||
pydantic.Field(alias="object"),
|
||||
] = "text_completion"
|
||||
|
||||
system_fingerprint: Optional[str] = None
|
||||
|
||||
usage: Optional[CompletionUsage] = None
|
||||
@@ -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 CompletionUsageTypedDict(TypedDict):
|
||||
prompt_tokens: float
|
||||
completion_tokens: float
|
||||
total_tokens: float
|
||||
|
||||
|
||||
class CompletionUsage(BaseModel):
|
||||
prompt_tokens: float
|
||||
|
||||
completion_tokens: float
|
||||
|
||||
total_tokens: float
|
||||
@@ -0,0 +1,36 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedInt
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
ChainID = Union[
|
||||
Literal[
|
||||
1,
|
||||
137,
|
||||
8453,
|
||||
],
|
||||
UnrecognizedInt,
|
||||
]
|
||||
|
||||
|
||||
class CreateChargeRequestTypedDict(TypedDict):
|
||||
r"""Create a Coinbase charge for crypto payment"""
|
||||
|
||||
amount: float
|
||||
sender: str
|
||||
chain_id: ChainID
|
||||
|
||||
|
||||
class CreateChargeRequest(BaseModel):
|
||||
r"""Create a Coinbase charge for crypto payment"""
|
||||
|
||||
amount: float
|
||||
|
||||
sender: str
|
||||
|
||||
chain_id: Annotated[ChainID, PlainValidator(validate_open_enum(True))]
|
||||
@@ -0,0 +1,60 @@
|
||||
"""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_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class DefaultParametersTypedDict(TypedDict):
|
||||
r"""Default parameters for this model"""
|
||||
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
frequency_penalty: NotRequired[Nullable[float]]
|
||||
|
||||
|
||||
class DefaultParameters(BaseModel):
|
||||
r"""Default parameters for this model"""
|
||||
|
||||
temperature: OptionalNullable[float] = UNSET
|
||||
|
||||
top_p: OptionalNullable[float] = UNSET
|
||||
|
||||
frequency_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"]
|
||||
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,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 EdgeNetworkTimeoutResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for EdgeNetworkTimeoutResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class EdgeNetworkTimeoutResponseErrorData(BaseModel):
|
||||
r"""Error data for EdgeNetworkTimeoutResponse"""
|
||||
|
||||
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,18 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedInt
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
EndpointStatus = Union[
|
||||
Literal[
|
||||
0,
|
||||
-1,
|
||||
-2,
|
||||
-3,
|
||||
-5,
|
||||
-10,
|
||||
],
|
||||
UnrecognizedInt,
|
||||
]
|
||||
@@ -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
|
||||
|
||||
|
||||
FileCitationType = Literal["file_citation",]
|
||||
|
||||
|
||||
class FileCitationTypedDict(TypedDict):
|
||||
type: FileCitationType
|
||||
file_id: str
|
||||
filename: str
|
||||
index: float
|
||||
|
||||
|
||||
class FileCitation(BaseModel):
|
||||
type: FileCitationType
|
||||
|
||||
file_id: str
|
||||
|
||||
filename: str
|
||||
|
||||
index: float
|
||||
@@ -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 import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
FilePathType = Literal["file_path",]
|
||||
|
||||
|
||||
class FilePathTypedDict(TypedDict):
|
||||
type: FilePathType
|
||||
file_id: str
|
||||
index: float
|
||||
|
||||
|
||||
class FilePath(BaseModel):
|
||||
type: FilePathType
|
||||
|
||||
file_id: str
|
||||
|
||||
index: float
|
||||
@@ -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 ForbiddenResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for ForbiddenResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class ForbiddenResponseErrorData(BaseModel):
|
||||
r"""Error data for ForbiddenResponse"""
|
||||
|
||||
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,16 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ImageGenerationStatus = Union[
|
||||
Literal[
|
||||
"in_progress",
|
||||
"completed",
|
||||
"generating",
|
||||
"failed",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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
|
||||
|
||||
|
||||
InputModality = Union[
|
||||
Literal[
|
||||
"text",
|
||||
"image",
|
||||
"file",
|
||||
"audio",
|
||||
"video",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
InstructType = Union[
|
||||
Literal[
|
||||
"none",
|
||||
"airoboros",
|
||||
"alpaca",
|
||||
"alpaca-modif",
|
||||
"chatml",
|
||||
"claude",
|
||||
"code-llama",
|
||||
"gemma",
|
||||
"llama2",
|
||||
"llama3",
|
||||
"mistral",
|
||||
"nemotron",
|
||||
"neural",
|
||||
"openchat",
|
||||
"phi3",
|
||||
"rwkv",
|
||||
"vicuna",
|
||||
"zephyr",
|
||||
"deepseek-r1",
|
||||
"deepseek-v3.1",
|
||||
"qwq",
|
||||
"qwen3",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Instruction format type"""
|
||||
@@ -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 InternalServerResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for InternalServerResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class InternalServerResponseErrorData(BaseModel):
|
||||
r"""Error data for InternalServerResponse"""
|
||||
|
||||
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,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,
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing import Any, Dict, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class JSONSchemaConfigTypedDict(TypedDict):
|
||||
name: str
|
||||
description: NotRequired[str]
|
||||
schema_: NotRequired[Dict[str, Any]]
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class JSONSchemaConfig(BaseModel):
|
||||
name: str
|
||||
|
||||
description: Optional[str] = None
|
||||
|
||||
schema_: Annotated[Optional[Dict[str, Any]], pydantic.Field(alias="schema")] = None
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
|
||||
@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
|
||||
@@ -0,0 +1,145 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputmodality import InputModality
|
||||
from .instructtype import InstructType
|
||||
from .outputmodality import OutputModality
|
||||
from .publicendpoint import PublicEndpoint, PublicEndpointTypedDict
|
||||
from openrouter.types import BaseModel, Nullable, 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, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
Tokenizer = Union[
|
||||
Literal[
|
||||
"Router",
|
||||
"Media",
|
||||
"Other",
|
||||
"GPT",
|
||||
"Claude",
|
||||
"Gemini",
|
||||
"Grok",
|
||||
"Cohere",
|
||||
"Nova",
|
||||
"Qwen",
|
||||
"Yi",
|
||||
"DeepSeek",
|
||||
"Mistral",
|
||||
"Llama2",
|
||||
"Llama3",
|
||||
"Llama4",
|
||||
"PaLM",
|
||||
"RWKV",
|
||||
"Qwen3",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Tokenizer type used by the model"""
|
||||
|
||||
|
||||
class ArchitectureTypedDict(TypedDict):
|
||||
r"""Model architecture information"""
|
||||
|
||||
tokenizer: Nullable[Tokenizer]
|
||||
instruct_type: Nullable[InstructType]
|
||||
r"""Instruction format type"""
|
||||
modality: Nullable[str]
|
||||
r"""Primary modality of the model"""
|
||||
input_modalities: List[InputModality]
|
||||
r"""Supported input modalities"""
|
||||
output_modalities: List[OutputModality]
|
||||
r"""Supported output modalities"""
|
||||
|
||||
|
||||
class Architecture(BaseModel):
|
||||
r"""Model architecture information"""
|
||||
|
||||
tokenizer: Annotated[Nullable[Tokenizer], PlainValidator(validate_open_enum(False))]
|
||||
|
||||
instruct_type: Annotated[
|
||||
Nullable[InstructType], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
r"""Instruction format type"""
|
||||
|
||||
modality: Nullable[str]
|
||||
r"""Primary modality of the model"""
|
||||
|
||||
input_modalities: List[
|
||||
Annotated[InputModality, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""Supported input modalities"""
|
||||
|
||||
output_modalities: List[
|
||||
Annotated[OutputModality, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""Supported output modalities"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["tokenizer", "instruct_type", "modality"]
|
||||
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 ListEndpointsResponseTypedDict(TypedDict):
|
||||
r"""List of available endpoints for a model"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the model"""
|
||||
name: str
|
||||
r"""Display name of the model"""
|
||||
created: float
|
||||
r"""Unix timestamp of when the model was created"""
|
||||
description: str
|
||||
r"""Description of the model"""
|
||||
architecture: ArchitectureTypedDict
|
||||
endpoints: List[PublicEndpointTypedDict]
|
||||
r"""List of available endpoints for this model"""
|
||||
|
||||
|
||||
class ListEndpointsResponse(BaseModel):
|
||||
r"""List of available endpoints for a model"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the model"""
|
||||
|
||||
name: str
|
||||
r"""Display name of the model"""
|
||||
|
||||
created: float
|
||||
r"""Unix timestamp of when the model was created"""
|
||||
|
||||
description: str
|
||||
r"""Description of the model"""
|
||||
|
||||
architecture: Architecture
|
||||
|
||||
endpoints: List[PublicEndpoint]
|
||||
r"""List of available endpoints for this model"""
|
||||
@@ -0,0 +1,68 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||
from .chatmessagecontentitemtext import (
|
||||
ChatMessageContentItemText,
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
)
|
||||
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
||||
from .toolresponsemessage import ToolResponseMessage, ToolResponseMessageTypedDict
|
||||
from .usermessage import UserMessage, UserMessageTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
MessageContentTypedDict = TypeAliasType(
|
||||
"MessageContentTypedDict", Union[str, List[ChatMessageContentItemTextTypedDict]]
|
||||
)
|
||||
|
||||
|
||||
MessageContent = TypeAliasType(
|
||||
"MessageContent", Union[str, List[ChatMessageContentItemText]]
|
||||
)
|
||||
|
||||
|
||||
class MessageDeveloperTypedDict(TypedDict):
|
||||
content: MessageContentTypedDict
|
||||
role: Literal["developer"]
|
||||
name: NotRequired[str]
|
||||
|
||||
|
||||
class MessageDeveloper(BaseModel):
|
||||
content: MessageContent
|
||||
|
||||
ROLE: Annotated[
|
||||
Annotated[Literal["developer"], AfterValidator(validate_const("developer"))],
|
||||
pydantic.Field(alias="role"),
|
||||
] = "developer"
|
||||
|
||||
name: Optional[str] = None
|
||||
|
||||
|
||||
MessageTypedDict = TypeAliasType(
|
||||
"MessageTypedDict",
|
||||
Union[
|
||||
SystemMessageTypedDict,
|
||||
UserMessageTypedDict,
|
||||
MessageDeveloperTypedDict,
|
||||
ToolResponseMessageTypedDict,
|
||||
AssistantMessageTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Message = TypeAliasType(
|
||||
"Message",
|
||||
Union[
|
||||
SystemMessage,
|
||||
UserMessage,
|
||||
MessageDeveloper,
|
||||
ToolResponseMessage,
|
||||
AssistantMessage,
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,132 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .defaultparameters import DefaultParameters, DefaultParametersTypedDict
|
||||
from .modelarchitecture import ModelArchitecture, ModelArchitectureTypedDict
|
||||
from .parameter import Parameter
|
||||
from .perrequestlimits import PerRequestLimits, PerRequestLimitsTypedDict
|
||||
from .publicpricing import PublicPricing, PublicPricingTypedDict
|
||||
from .topproviderinfo import TopProviderInfo, TopProviderInfoTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ModelTypedDict(TypedDict):
|
||||
r"""Information about an AI model available on OpenRouter"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the model"""
|
||||
canonical_slug: str
|
||||
r"""Canonical slug for the model"""
|
||||
name: str
|
||||
r"""Display name of the model"""
|
||||
created: float
|
||||
r"""Unix timestamp of when the model was created"""
|
||||
pricing: PublicPricingTypedDict
|
||||
r"""Pricing information for the model"""
|
||||
context_length: Nullable[float]
|
||||
r"""Maximum context length in tokens"""
|
||||
architecture: ModelArchitectureTypedDict
|
||||
r"""Model architecture information"""
|
||||
top_provider: TopProviderInfoTypedDict
|
||||
r"""Information about the top provider for this model"""
|
||||
per_request_limits: Nullable[PerRequestLimitsTypedDict]
|
||||
r"""Per-request token limits"""
|
||||
supported_parameters: List[Parameter]
|
||||
r"""List of supported parameters for this model"""
|
||||
default_parameters: Nullable[DefaultParametersTypedDict]
|
||||
r"""Default parameters for this model"""
|
||||
hugging_face_id: NotRequired[Nullable[str]]
|
||||
r"""Hugging Face model identifier, if applicable"""
|
||||
description: NotRequired[str]
|
||||
r"""Description of the model"""
|
||||
|
||||
|
||||
class Model(BaseModel):
|
||||
r"""Information about an AI model available on OpenRouter"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the model"""
|
||||
|
||||
canonical_slug: str
|
||||
r"""Canonical slug for the model"""
|
||||
|
||||
name: str
|
||||
r"""Display name of the model"""
|
||||
|
||||
created: float
|
||||
r"""Unix timestamp of when the model was created"""
|
||||
|
||||
pricing: PublicPricing
|
||||
r"""Pricing information for the model"""
|
||||
|
||||
context_length: Nullable[float]
|
||||
r"""Maximum context length in tokens"""
|
||||
|
||||
architecture: ModelArchitecture
|
||||
r"""Model architecture information"""
|
||||
|
||||
top_provider: TopProviderInfo
|
||||
r"""Information about the top provider for this model"""
|
||||
|
||||
per_request_limits: Nullable[PerRequestLimits]
|
||||
r"""Per-request token limits"""
|
||||
|
||||
supported_parameters: List[
|
||||
Annotated[Parameter, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""List of supported parameters for this model"""
|
||||
|
||||
default_parameters: Nullable[DefaultParameters]
|
||||
r"""Default parameters for this model"""
|
||||
|
||||
hugging_face_id: OptionalNullable[str] = UNSET
|
||||
r"""Hugging Face model identifier, if applicable"""
|
||||
|
||||
description: Optional[str] = None
|
||||
r"""Description of the model"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["hugging_face_id", "description"]
|
||||
nullable_fields = [
|
||||
"hugging_face_id",
|
||||
"context_length",
|
||||
"per_request_limits",
|
||||
"default_parameters",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,122 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .inputmodality import InputModality
|
||||
from .modelgroup import ModelGroup
|
||||
from .outputmodality import OutputModality
|
||||
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
|
||||
|
||||
|
||||
ModelArchitectureInstructType = Union[
|
||||
Literal[
|
||||
"none",
|
||||
"airoboros",
|
||||
"alpaca",
|
||||
"alpaca-modif",
|
||||
"chatml",
|
||||
"claude",
|
||||
"code-llama",
|
||||
"gemma",
|
||||
"llama2",
|
||||
"llama3",
|
||||
"mistral",
|
||||
"nemotron",
|
||||
"neural",
|
||||
"openchat",
|
||||
"phi3",
|
||||
"rwkv",
|
||||
"vicuna",
|
||||
"zephyr",
|
||||
"deepseek-r1",
|
||||
"deepseek-v3.1",
|
||||
"qwq",
|
||||
"qwen3",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Instruction format type"""
|
||||
|
||||
|
||||
class ModelArchitectureTypedDict(TypedDict):
|
||||
r"""Model architecture information"""
|
||||
|
||||
modality: Nullable[str]
|
||||
r"""Primary modality of the model"""
|
||||
input_modalities: List[InputModality]
|
||||
r"""Supported input modalities"""
|
||||
output_modalities: List[OutputModality]
|
||||
r"""Supported output modalities"""
|
||||
tokenizer: NotRequired[ModelGroup]
|
||||
r"""Tokenizer type used by the model"""
|
||||
instruct_type: NotRequired[Nullable[ModelArchitectureInstructType]]
|
||||
r"""Instruction format type"""
|
||||
|
||||
|
||||
class ModelArchitecture(BaseModel):
|
||||
r"""Model architecture information"""
|
||||
|
||||
modality: Nullable[str]
|
||||
r"""Primary modality of the model"""
|
||||
|
||||
input_modalities: List[
|
||||
Annotated[InputModality, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""Supported input modalities"""
|
||||
|
||||
output_modalities: List[
|
||||
Annotated[OutputModality, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""Supported output modalities"""
|
||||
|
||||
tokenizer: Annotated[
|
||||
Optional[ModelGroup], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Tokenizer type used by the model"""
|
||||
|
||||
instruct_type: Annotated[
|
||||
OptionalNullable[ModelArchitectureInstructType],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Instruction format type"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["tokenizer", "instruct_type"]
|
||||
nullable_fields = ["instruct_type", "modality"]
|
||||
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,32 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ModelGroup = Union[
|
||||
Literal[
|
||||
"Router",
|
||||
"Media",
|
||||
"Other",
|
||||
"GPT",
|
||||
"Claude",
|
||||
"Gemini",
|
||||
"Grok",
|
||||
"Cohere",
|
||||
"Nova",
|
||||
"Qwen",
|
||||
"Yi",
|
||||
"DeepSeek",
|
||||
"Mistral",
|
||||
"Llama2",
|
||||
"Llama3",
|
||||
"Llama4",
|
||||
"PaLM",
|
||||
"RWKV",
|
||||
"Qwen3",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Tokenizer type used by the model"""
|
||||
@@ -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_extensions import TypedDict
|
||||
|
||||
|
||||
class ModelsCountResponseDataTypedDict(TypedDict):
|
||||
r"""Model count data"""
|
||||
|
||||
count: float
|
||||
r"""Total number of available models"""
|
||||
|
||||
|
||||
class ModelsCountResponseData(BaseModel):
|
||||
r"""Model count data"""
|
||||
|
||||
count: float
|
||||
r"""Total number of available models"""
|
||||
|
||||
|
||||
class ModelsCountResponseTypedDict(TypedDict):
|
||||
r"""Model count data"""
|
||||
|
||||
data: ModelsCountResponseDataTypedDict
|
||||
r"""Model count data"""
|
||||
|
||||
|
||||
class ModelsCountResponse(BaseModel):
|
||||
r"""Model count data"""
|
||||
|
||||
data: ModelsCountResponseData
|
||||
r"""Model count data"""
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .model import Model, ModelTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ModelsListResponseTypedDict(TypedDict):
|
||||
r"""List of available models"""
|
||||
|
||||
data: List[ModelTypedDict]
|
||||
r"""List of available models"""
|
||||
|
||||
|
||||
class ModelsListResponse(BaseModel):
|
||||
r"""List of available models"""
|
||||
|
||||
data: List[Model]
|
||||
r"""List of available models"""
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class NamedToolChoiceFunctionTypedDict(TypedDict):
|
||||
name: str
|
||||
|
||||
|
||||
class NamedToolChoiceFunction(BaseModel):
|
||||
name: str
|
||||
|
||||
|
||||
class NamedToolChoiceTypedDict(TypedDict):
|
||||
function: NamedToolChoiceFunctionTypedDict
|
||||
type: Literal["function"]
|
||||
|
||||
|
||||
class NamedToolChoice(BaseModel):
|
||||
function: NamedToolChoiceFunction
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["function"], AfterValidator(validate_const("function"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "function"
|
||||
@@ -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 NotFoundResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for NotFoundResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class NotFoundResponseErrorData(BaseModel):
|
||||
r"""Error data for NotFoundResponse"""
|
||||
|
||||
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,19 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .filecitation import FileCitation, FileCitationTypedDict
|
||||
from .filepath import FilePath, FilePathTypedDict
|
||||
from .urlcitation import URLCitation, URLCitationTypedDict
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
OpenAIResponsesAnnotationTypedDict = TypeAliasType(
|
||||
"OpenAIResponsesAnnotationTypedDict",
|
||||
Union[FilePathTypedDict, FileCitationTypedDict, URLCitationTypedDict],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesAnnotation = TypeAliasType(
|
||||
"OpenAIResponsesAnnotation", Union[FilePath, FileCitation, URLCitation]
|
||||
)
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenAIResponsesIncludable = Union[
|
||||
Literal[
|
||||
"file_search_call.results",
|
||||
"message.input_image.image_url",
|
||||
"computer_call_output.output.image_url",
|
||||
"reasoning.encrypted_content",
|
||||
"code_interpreter_call.outputs",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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 OpenAIResponsesIncompleteDetailsTypedDict(TypedDict):
|
||||
reason: NotRequired[Reason]
|
||||
|
||||
|
||||
class OpenAIResponsesIncompleteDetails(BaseModel):
|
||||
reason: Annotated[Optional[Reason], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
@@ -0,0 +1,330 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .outputitemimagegenerationcall import (
|
||||
OutputItemImageGenerationCall,
|
||||
OutputItemImageGenerationCallTypedDict,
|
||||
)
|
||||
from .outputmessage import OutputMessage, OutputMessageTypedDict
|
||||
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
|
||||
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
|
||||
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
|
||||
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
|
||||
from .toolcallstatus import ToolCallStatus
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenAIResponsesInputTypeFunctionCall = Literal["function_call",]
|
||||
|
||||
|
||||
class OpenAIResponsesInputFunctionCallTypedDict(TypedDict):
|
||||
type: OpenAIResponsesInputTypeFunctionCall
|
||||
call_id: str
|
||||
name: str
|
||||
arguments: str
|
||||
id: NotRequired[str]
|
||||
status: NotRequired[Nullable[ToolCallStatus]]
|
||||
|
||||
|
||||
class OpenAIResponsesInputFunctionCall(BaseModel):
|
||||
type: OpenAIResponsesInputTypeFunctionCall
|
||||
|
||||
call_id: str
|
||||
|
||||
name: str
|
||||
|
||||
arguments: str
|
||||
|
||||
id: Optional[str] = None
|
||||
|
||||
status: Annotated[
|
||||
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "status"]
|
||||
nullable_fields = ["status"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
OpenAIResponsesInputTypeFunctionCallOutput = Literal["function_call_output",]
|
||||
|
||||
|
||||
class OpenAIResponsesInputFunctionCallOutputTypedDict(TypedDict):
|
||||
type: OpenAIResponsesInputTypeFunctionCallOutput
|
||||
call_id: str
|
||||
output: str
|
||||
id: NotRequired[Nullable[str]]
|
||||
status: NotRequired[Nullable[ToolCallStatus]]
|
||||
|
||||
|
||||
class OpenAIResponsesInputFunctionCallOutput(BaseModel):
|
||||
type: OpenAIResponsesInputTypeFunctionCallOutput
|
||||
|
||||
call_id: str
|
||||
|
||||
output: str
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
status: Annotated[
|
||||
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "status"]
|
||||
nullable_fields = ["id", "status"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
OpenAIResponsesInputTypeMessage2 = Literal["message",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleDeveloper2 = Literal["developer",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleSystem2 = Literal["system",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUser2 = Literal["user",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUnion2TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputRoleUnion2TypedDict",
|
||||
Union[
|
||||
OpenAIResponsesInputRoleUser2,
|
||||
OpenAIResponsesInputRoleSystem2,
|
||||
OpenAIResponsesInputRoleDeveloper2,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUnion2 = TypeAliasType(
|
||||
"OpenAIResponsesInputRoleUnion2",
|
||||
Union[
|
||||
OpenAIResponsesInputRoleUser2,
|
||||
OpenAIResponsesInputRoleSystem2,
|
||||
OpenAIResponsesInputRoleDeveloper2,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputContent3TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputContent3TypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputAudioTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputContent3 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseInputText, Tag("input_text")],
|
||||
Annotated[ResponseInputImage, Tag("input_image")],
|
||||
Annotated[ResponseInputFile, Tag("input_file")],
|
||||
Annotated[ResponseInputAudio, Tag("input_audio")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage2TypedDict(TypedDict):
|
||||
id: str
|
||||
role: OpenAIResponsesInputRoleUnion2TypedDict
|
||||
content: List[OpenAIResponsesInputContent3TypedDict]
|
||||
type: NotRequired[OpenAIResponsesInputTypeMessage2]
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage2(BaseModel):
|
||||
id: str
|
||||
|
||||
role: OpenAIResponsesInputRoleUnion2
|
||||
|
||||
content: List[OpenAIResponsesInputContent3]
|
||||
|
||||
type: Optional[OpenAIResponsesInputTypeMessage2] = None
|
||||
|
||||
|
||||
OpenAIResponsesInputTypeMessage1 = Literal["message",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleDeveloper1 = Literal["developer",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleAssistant = Literal["assistant",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleSystem1 = Literal["system",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUser1 = Literal["user",]
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUnion1TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputRoleUnion1TypedDict",
|
||||
Union[
|
||||
OpenAIResponsesInputRoleUser1,
|
||||
OpenAIResponsesInputRoleSystem1,
|
||||
OpenAIResponsesInputRoleAssistant,
|
||||
OpenAIResponsesInputRoleDeveloper1,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputRoleUnion1 = TypeAliasType(
|
||||
"OpenAIResponsesInputRoleUnion1",
|
||||
Union[
|
||||
OpenAIResponsesInputRoleUser1,
|
||||
OpenAIResponsesInputRoleSystem1,
|
||||
OpenAIResponsesInputRoleAssistant,
|
||||
OpenAIResponsesInputRoleDeveloper1,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputContent1TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputContent1TypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputAudioTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputContent1 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseInputText, Tag("input_text")],
|
||||
Annotated[ResponseInputImage, Tag("input_image")],
|
||||
Annotated[ResponseInputFile, Tag("input_file")],
|
||||
Annotated[ResponseInputAudio, Tag("input_audio")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
OpenAIResponsesInputContent2TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputContent2TypedDict",
|
||||
Union[List[OpenAIResponsesInputContent1TypedDict], str],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputContent2 = TypeAliasType(
|
||||
"OpenAIResponsesInputContent2", Union[List[OpenAIResponsesInputContent1], str]
|
||||
)
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage1TypedDict(TypedDict):
|
||||
role: OpenAIResponsesInputRoleUnion1TypedDict
|
||||
content: OpenAIResponsesInputContent2TypedDict
|
||||
type: NotRequired[OpenAIResponsesInputTypeMessage1]
|
||||
|
||||
|
||||
class OpenAIResponsesInputMessage1(BaseModel):
|
||||
role: OpenAIResponsesInputRoleUnion1
|
||||
|
||||
content: OpenAIResponsesInputContent2
|
||||
|
||||
type: Optional[OpenAIResponsesInputTypeMessage1] = None
|
||||
|
||||
|
||||
OpenAIResponsesInputUnion1TypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputUnion1TypedDict",
|
||||
Union[
|
||||
OpenAIResponsesInputMessage1TypedDict,
|
||||
OpenAIResponsesInputMessage2TypedDict,
|
||||
OutputItemImageGenerationCallTypedDict,
|
||||
OpenAIResponsesInputFunctionCallOutputTypedDict,
|
||||
OutputMessageTypedDict,
|
||||
OpenAIResponsesInputFunctionCallTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputUnion1 = TypeAliasType(
|
||||
"OpenAIResponsesInputUnion1",
|
||||
Union[
|
||||
OpenAIResponsesInputMessage1,
|
||||
OpenAIResponsesInputMessage2,
|
||||
OutputItemImageGenerationCall,
|
||||
OpenAIResponsesInputFunctionCallOutput,
|
||||
OutputMessage,
|
||||
OpenAIResponsesInputFunctionCall,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputUnionTypedDict = TypeAliasType(
|
||||
"OpenAIResponsesInputUnionTypedDict",
|
||||
Union[str, List[OpenAIResponsesInputUnion1TypedDict], Any],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesInputUnion = TypeAliasType(
|
||||
"OpenAIResponsesInputUnion", Union[str, List[OpenAIResponsesInputUnion1], Any]
|
||||
)
|
||||
@@ -0,0 +1,73 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
|
||||
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
|
||||
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Dict, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
VariablesTypedDict = TypeAliasType(
|
||||
"VariablesTypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
str,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Variables = TypeAliasType(
|
||||
"Variables", Union[ResponseInputText, ResponseInputImage, ResponseInputFile, str]
|
||||
)
|
||||
|
||||
|
||||
class OpenAIResponsesPromptTypedDict(TypedDict):
|
||||
id: str
|
||||
variables: NotRequired[Nullable[Dict[str, VariablesTypedDict]]]
|
||||
|
||||
|
||||
class OpenAIResponsesPrompt(BaseModel):
|
||||
id: str
|
||||
|
||||
variables: OptionalNullable[Dict[str, Variables]] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["variables"]
|
||||
nullable_fields = ["variables"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesreasoningeffort import OpenAIResponsesReasoningEffort
|
||||
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class OpenAIResponsesReasoningConfigTypedDict(TypedDict):
|
||||
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
|
||||
summary: NotRequired[ReasoningSummaryVerbosity]
|
||||
|
||||
|
||||
class OpenAIResponsesReasoningConfig(BaseModel):
|
||||
effort: Annotated[
|
||||
OptionalNullable[OpenAIResponsesReasoningEffort],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
Optional[ReasoningSummaryVerbosity], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary"]
|
||||
nullable_fields = ["effort"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,16 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
OpenAIResponsesReasoningEffort = Union[
|
||||
Literal[
|
||||
"high",
|
||||
"medium",
|
||||
"low",
|
||||
"minimal",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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 Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenAIResponsesRefusalContentType = Literal["refusal",]
|
||||
|
||||
|
||||
class OpenAIResponsesRefusalContentTypedDict(TypedDict):
|
||||
type: OpenAIResponsesRefusalContentType
|
||||
refusal: str
|
||||
|
||||
|
||||
class OpenAIResponsesRefusalContent(BaseModel):
|
||||
type: OpenAIResponsesRefusalContentType
|
||||
|
||||
refusal: str
|
||||
@@ -0,0 +1,18 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
OpenAIResponsesResponseStatus = Union[
|
||||
Literal[
|
||||
"completed",
|
||||
"incomplete",
|
||||
"in_progress",
|
||||
"failed",
|
||||
"cancelled",
|
||||
"queued",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenAIResponsesServiceTier = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"default",
|
||||
"flex",
|
||||
"priority",
|
||||
"scale",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,87 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview = Literal["web_search_preview",]
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview20250311 = Literal[
|
||||
"web_search_preview_2025_03_11",
|
||||
]
|
||||
|
||||
|
||||
TypeTypedDict = TypeAliasType(
|
||||
"TypeTypedDict",
|
||||
Union[
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview20250311,
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Type = TypeAliasType(
|
||||
"Type",
|
||||
Union[
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview20250311,
|
||||
OpenAIResponsesToolChoiceTypeWebSearchPreview,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class OpenAIResponsesToolChoiceTypedDict(TypedDict):
|
||||
type: TypeTypedDict
|
||||
|
||||
|
||||
class OpenAIResponsesToolChoice(BaseModel):
|
||||
type: Type
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceTypeFunction = Literal["function",]
|
||||
|
||||
|
||||
class OpenAIResponsesToolChoiceFunctionTypedDict(TypedDict):
|
||||
type: OpenAIResponsesToolChoiceTypeFunction
|
||||
name: str
|
||||
|
||||
|
||||
class OpenAIResponsesToolChoiceFunction(BaseModel):
|
||||
type: OpenAIResponsesToolChoiceTypeFunction
|
||||
|
||||
name: str
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceRequired = Literal["required",]
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceNone = Literal["none",]
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceAuto = Literal["auto",]
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceUnionTypedDict = TypeAliasType(
|
||||
"OpenAIResponsesToolChoiceUnionTypedDict",
|
||||
Union[
|
||||
OpenAIResponsesToolChoiceTypedDict,
|
||||
OpenAIResponsesToolChoiceFunctionTypedDict,
|
||||
OpenAIResponsesToolChoiceAuto,
|
||||
OpenAIResponsesToolChoiceNone,
|
||||
OpenAIResponsesToolChoiceRequired,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenAIResponsesToolChoiceUnion = TypeAliasType(
|
||||
"OpenAIResponsesToolChoiceUnion",
|
||||
Union[
|
||||
OpenAIResponsesToolChoice,
|
||||
OpenAIResponsesToolChoiceFunction,
|
||||
OpenAIResponsesToolChoiceAuto,
|
||||
OpenAIResponsesToolChoiceNone,
|
||||
OpenAIResponsesToolChoiceRequired,
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
OpenAIResponsesTruncation = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"disabled",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,97 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
|
||||
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
|
||||
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
|
||||
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageType = Literal["message",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleDeveloper = Literal["developer",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleAssistant = Literal["assistant",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleSystem = Literal["system",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleUser = Literal["user",]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageRoleUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessageRoleUser,
|
||||
OpenResponsesEasyInputMessageRoleSystem,
|
||||
OpenResponsesEasyInputMessageRoleAssistant,
|
||||
OpenResponsesEasyInputMessageRoleDeveloper,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageRoleUnion = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageRoleUnion",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessageRoleUser,
|
||||
OpenResponsesEasyInputMessageRoleSystem,
|
||||
OpenResponsesEasyInputMessageRoleAssistant,
|
||||
OpenResponsesEasyInputMessageRoleDeveloper,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageContent1TypedDict = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageContent1TypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputAudioTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageContent1 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseInputText, Tag("input_text")],
|
||||
Annotated[ResponseInputImage, Tag("input_image")],
|
||||
Annotated[ResponseInputFile, Tag("input_file")],
|
||||
Annotated[ResponseInputAudio, Tag("input_audio")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageContent2TypedDict = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageContent2TypedDict",
|
||||
Union[List[OpenResponsesEasyInputMessageContent1TypedDict], str],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesEasyInputMessageContent2 = TypeAliasType(
|
||||
"OpenResponsesEasyInputMessageContent2",
|
||||
Union[List[OpenResponsesEasyInputMessageContent1], str],
|
||||
)
|
||||
|
||||
|
||||
class OpenResponsesEasyInputMessageTypedDict(TypedDict):
|
||||
role: OpenResponsesEasyInputMessageRoleUnionTypedDict
|
||||
content: OpenResponsesEasyInputMessageContent2TypedDict
|
||||
type: NotRequired[OpenResponsesEasyInputMessageType]
|
||||
|
||||
|
||||
class OpenResponsesEasyInputMessage(BaseModel):
|
||||
role: OpenResponsesEasyInputMessageRoleUnion
|
||||
|
||||
content: OpenResponsesEasyInputMessageContent2
|
||||
|
||||
type: Optional[OpenResponsesEasyInputMessageType] = None
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesErrorEventType = Literal["error",]
|
||||
|
||||
|
||||
class OpenResponsesErrorEventTypedDict(TypedDict):
|
||||
r"""Event emitted when an error occurs during streaming"""
|
||||
|
||||
type: OpenResponsesErrorEventType
|
||||
code: Nullable[str]
|
||||
message: str
|
||||
param: Nullable[str]
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesErrorEvent(BaseModel):
|
||||
r"""Event emitted when an error occurs during streaming"""
|
||||
|
||||
type: OpenResponsesErrorEventType
|
||||
|
||||
code: Nullable[str]
|
||||
|
||||
message: str
|
||||
|
||||
param: Nullable[str]
|
||||
|
||||
sequence_number: float
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["code", "param"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .toolcallstatus import ToolCallStatus
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesFunctionCallOutputType = Literal["function_call_output",]
|
||||
|
||||
|
||||
class OpenResponsesFunctionCallOutputTypedDict(TypedDict):
|
||||
r"""The output from a function call execution"""
|
||||
|
||||
type: OpenResponsesFunctionCallOutputType
|
||||
call_id: str
|
||||
output: str
|
||||
id: NotRequired[Nullable[str]]
|
||||
status: NotRequired[Nullable[ToolCallStatus]]
|
||||
|
||||
|
||||
class OpenResponsesFunctionCallOutput(BaseModel):
|
||||
r"""The output from a function call execution"""
|
||||
|
||||
type: OpenResponsesFunctionCallOutputType
|
||||
|
||||
call_id: str
|
||||
|
||||
output: str
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
status: Annotated[
|
||||
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "status"]
|
||||
nullable_fields = ["id", "status"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,78 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .toolcallstatus import ToolCallStatus
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesFunctionToolCallType = Literal["function_call",]
|
||||
|
||||
|
||||
class OpenResponsesFunctionToolCallTypedDict(TypedDict):
|
||||
r"""A function call initiated by the model"""
|
||||
|
||||
type: OpenResponsesFunctionToolCallType
|
||||
call_id: str
|
||||
name: str
|
||||
arguments: str
|
||||
id: str
|
||||
status: NotRequired[Nullable[ToolCallStatus]]
|
||||
|
||||
|
||||
class OpenResponsesFunctionToolCall(BaseModel):
|
||||
r"""A function call initiated by the model"""
|
||||
|
||||
type: OpenResponsesFunctionToolCallType
|
||||
|
||||
call_id: str
|
||||
|
||||
name: str
|
||||
|
||||
arguments: str
|
||||
|
||||
id: str
|
||||
|
||||
status: Annotated[
|
||||
OptionalNullable[ToolCallStatus], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["status"]
|
||||
nullable_fields = ["status"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenResponsesImageGenCallCompletedType = Literal[
|
||||
"response.image_generation_call.completed",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallCompletedTypedDict(TypedDict):
|
||||
r"""Image generation call completed"""
|
||||
|
||||
type: OpenResponsesImageGenCallCompletedType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallCompleted(BaseModel):
|
||||
r"""Image generation call completed"""
|
||||
|
||||
type: OpenResponsesImageGenCallCompletedType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenResponsesImageGenCallGeneratingType = Literal[
|
||||
"response.image_generation_call.generating",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallGeneratingTypedDict(TypedDict):
|
||||
r"""Image generation call is generating"""
|
||||
|
||||
type: OpenResponsesImageGenCallGeneratingType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallGenerating(BaseModel):
|
||||
r"""Image generation call is generating"""
|
||||
|
||||
type: OpenResponsesImageGenCallGeneratingType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,32 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenResponsesImageGenCallInProgressType = Literal[
|
||||
"response.image_generation_call.in_progress",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallInProgressTypedDict(TypedDict):
|
||||
r"""Image generation call in progress"""
|
||||
|
||||
type: OpenResponsesImageGenCallInProgressType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallInProgress(BaseModel):
|
||||
r"""Image generation call in progress"""
|
||||
|
||||
type: OpenResponsesImageGenCallInProgressType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesImageGenCallPartialImageType = Literal[
|
||||
"response.image_generation_call.partial_image",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallPartialImageTypedDict(TypedDict):
|
||||
r"""Image generation call with partial image"""
|
||||
|
||||
type: OpenResponsesImageGenCallPartialImageType
|
||||
item_id: str
|
||||
output_index: float
|
||||
sequence_number: float
|
||||
partial_image_b64: str
|
||||
partial_image_index: float
|
||||
|
||||
|
||||
class OpenResponsesImageGenCallPartialImage(BaseModel):
|
||||
r"""Image generation call with partial image"""
|
||||
|
||||
type: OpenResponsesImageGenCallPartialImageType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
sequence_number: float
|
||||
|
||||
partial_image_b64: str
|
||||
|
||||
partial_image_index: float
|
||||
@@ -0,0 +1,97 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openresponseseasyinputmessage import (
|
||||
OpenResponsesEasyInputMessage,
|
||||
OpenResponsesEasyInputMessageTypedDict,
|
||||
)
|
||||
from .openresponsesfunctioncalloutput import (
|
||||
OpenResponsesFunctionCallOutput,
|
||||
OpenResponsesFunctionCallOutputTypedDict,
|
||||
)
|
||||
from .openresponsesfunctiontoolcall import (
|
||||
OpenResponsesFunctionToolCall,
|
||||
OpenResponsesFunctionToolCallTypedDict,
|
||||
)
|
||||
from .openresponsesinputmessageitem import (
|
||||
OpenResponsesInputMessageItem,
|
||||
OpenResponsesInputMessageItemTypedDict,
|
||||
)
|
||||
from .openresponsesreasoning import (
|
||||
OpenResponsesReasoning,
|
||||
OpenResponsesReasoningTypedDict,
|
||||
)
|
||||
from .responsesimagegenerationcall import (
|
||||
ResponsesImageGenerationCall,
|
||||
ResponsesImageGenerationCallTypedDict,
|
||||
)
|
||||
from .responsesoutputitemfilesearchcall import (
|
||||
ResponsesOutputItemFileSearchCall,
|
||||
ResponsesOutputItemFileSearchCallTypedDict,
|
||||
)
|
||||
from .responsesoutputitemfunctioncall import (
|
||||
ResponsesOutputItemFunctionCall,
|
||||
ResponsesOutputItemFunctionCallTypedDict,
|
||||
)
|
||||
from .responsesoutputitemreasoning import (
|
||||
ResponsesOutputItemReasoning,
|
||||
ResponsesOutputItemReasoningTypedDict,
|
||||
)
|
||||
from .responsesoutputmessage import (
|
||||
ResponsesOutputMessage,
|
||||
ResponsesOutputMessageTypedDict,
|
||||
)
|
||||
from .responseswebsearchcalloutput import (
|
||||
ResponsesWebSearchCallOutput,
|
||||
ResponsesWebSearchCallOutputTypedDict,
|
||||
)
|
||||
from typing import List, Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
OpenResponsesInput1TypedDict = TypeAliasType(
|
||||
"OpenResponsesInput1TypedDict",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessageTypedDict,
|
||||
ResponsesWebSearchCallOutputTypedDict,
|
||||
OpenResponsesInputMessageItemTypedDict,
|
||||
ResponsesOutputItemFileSearchCallTypedDict,
|
||||
ResponsesImageGenerationCallTypedDict,
|
||||
OpenResponsesFunctionCallOutputTypedDict,
|
||||
ResponsesOutputMessageTypedDict,
|
||||
OpenResponsesFunctionToolCallTypedDict,
|
||||
ResponsesOutputItemReasoningTypedDict,
|
||||
ResponsesOutputItemFunctionCallTypedDict,
|
||||
OpenResponsesReasoningTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesInput1 = TypeAliasType(
|
||||
"OpenResponsesInput1",
|
||||
Union[
|
||||
OpenResponsesEasyInputMessage,
|
||||
ResponsesWebSearchCallOutput,
|
||||
OpenResponsesInputMessageItem,
|
||||
ResponsesOutputItemFileSearchCall,
|
||||
ResponsesImageGenerationCall,
|
||||
OpenResponsesFunctionCallOutput,
|
||||
ResponsesOutputMessage,
|
||||
OpenResponsesFunctionToolCall,
|
||||
ResponsesOutputItemReasoning,
|
||||
ResponsesOutputItemFunctionCall,
|
||||
OpenResponsesReasoning,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesInputTypedDict = TypeAliasType(
|
||||
"OpenResponsesInputTypedDict", Union[str, List[OpenResponsesInput1TypedDict]]
|
||||
)
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
|
||||
|
||||
OpenResponsesInput = TypeAliasType(
|
||||
"OpenResponsesInput", Union[str, List[OpenResponsesInput1]]
|
||||
)
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
@@ -0,0 +1,83 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responseinputaudio import ResponseInputAudio, ResponseInputAudioTypedDict
|
||||
from .responseinputfile import ResponseInputFile, ResponseInputFileTypedDict
|
||||
from .responseinputimage import ResponseInputImage, ResponseInputImageTypedDict
|
||||
from .responseinputtext import ResponseInputText, ResponseInputTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator
|
||||
from pydantic import Discriminator, Tag
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemType = Literal["message",]
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemRoleDeveloper = Literal["developer",]
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemRoleSystem = Literal["system",]
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemRoleUser = Literal["user",]
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemRoleUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesInputMessageItemRoleUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesInputMessageItemRoleUser,
|
||||
OpenResponsesInputMessageItemRoleSystem,
|
||||
OpenResponsesInputMessageItemRoleDeveloper,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemRoleUnion = TypeAliasType(
|
||||
"OpenResponsesInputMessageItemRoleUnion",
|
||||
Union[
|
||||
OpenResponsesInputMessageItemRoleUser,
|
||||
OpenResponsesInputMessageItemRoleSystem,
|
||||
OpenResponsesInputMessageItemRoleDeveloper,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemContentTypedDict = TypeAliasType(
|
||||
"OpenResponsesInputMessageItemContentTypedDict",
|
||||
Union[
|
||||
ResponseInputTextTypedDict,
|
||||
ResponseInputAudioTypedDict,
|
||||
ResponseInputImageTypedDict,
|
||||
ResponseInputFileTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesInputMessageItemContent = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseInputText, Tag("input_text")],
|
||||
Annotated[ResponseInputImage, Tag("input_image")],
|
||||
Annotated[ResponseInputFile, Tag("input_file")],
|
||||
Annotated[ResponseInputAudio, Tag("input_audio")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesInputMessageItemTypedDict(TypedDict):
|
||||
role: OpenResponsesInputMessageItemRoleUnionTypedDict
|
||||
content: List[OpenResponsesInputMessageItemContentTypedDict]
|
||||
id: NotRequired[str]
|
||||
type: NotRequired[OpenResponsesInputMessageItemType]
|
||||
|
||||
|
||||
class OpenResponsesInputMessageItem(BaseModel):
|
||||
role: OpenResponsesInputMessageItemRoleUnion
|
||||
|
||||
content: List[OpenResponsesInputMessageItemContent]
|
||||
|
||||
id: Optional[str] = None
|
||||
|
||||
type: Optional[OpenResponsesInputMessageItemType] = None
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openresponsestoplogprobs import (
|
||||
OpenResponsesTopLogprobs,
|
||||
OpenResponsesTopLogprobsTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class OpenResponsesLogProbsTypedDict(TypedDict):
|
||||
r"""Log probability information for a token"""
|
||||
|
||||
logprob: float
|
||||
token: str
|
||||
top_logprobs: NotRequired[List[OpenResponsesTopLogprobsTypedDict]]
|
||||
|
||||
|
||||
class OpenResponsesLogProbs(BaseModel):
|
||||
r"""Log probability information for a token"""
|
||||
|
||||
logprob: float
|
||||
|
||||
token: str
|
||||
|
||||
top_logprobs: Optional[List[OpenResponsesTopLogprobs]] = None
|
||||
@@ -0,0 +1,324 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesincompletedetails import (
|
||||
OpenAIResponsesIncompleteDetails,
|
||||
OpenAIResponsesIncompleteDetailsTypedDict,
|
||||
)
|
||||
from .openairesponsesinput_union import (
|
||||
OpenAIResponsesInputUnion,
|
||||
OpenAIResponsesInputUnionTypedDict,
|
||||
)
|
||||
from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict
|
||||
from .openairesponsesreasoningconfig import (
|
||||
OpenAIResponsesReasoningConfig,
|
||||
OpenAIResponsesReasoningConfigTypedDict,
|
||||
)
|
||||
from .openairesponsesresponsestatus import OpenAIResponsesResponseStatus
|
||||
from .openairesponsesservicetier import OpenAIResponsesServiceTier
|
||||
from .openairesponsestoolchoice_union import (
|
||||
OpenAIResponsesToolChoiceUnion,
|
||||
OpenAIResponsesToolChoiceUnionTypedDict,
|
||||
)
|
||||
from .openairesponsestruncation import OpenAIResponsesTruncation
|
||||
from .openresponsesusage import OpenResponsesUsage, OpenResponsesUsageTypedDict
|
||||
from .openresponseswebsearch20250826tool import (
|
||||
OpenResponsesWebSearch20250826Tool,
|
||||
OpenResponsesWebSearch20250826ToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchpreview20250311tool import (
|
||||
OpenResponsesWebSearchPreview20250311Tool,
|
||||
OpenResponsesWebSearchPreview20250311ToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchpreviewtool import (
|
||||
OpenResponsesWebSearchPreviewTool,
|
||||
OpenResponsesWebSearchPreviewToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchtool import (
|
||||
OpenResponsesWebSearchTool,
|
||||
OpenResponsesWebSearchToolTypedDict,
|
||||
)
|
||||
from .responseserrorfield import ResponsesErrorField, ResponsesErrorFieldTypedDict
|
||||
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
|
||||
from .responsetextconfig import ResponseTextConfig, ResponseTextConfigTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import 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, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Object = Literal["response",]
|
||||
|
||||
|
||||
OpenResponsesNonStreamingResponseType = Literal["function",]
|
||||
|
||||
|
||||
class OpenResponsesNonStreamingResponseToolFunctionTypedDict(TypedDict):
|
||||
r"""Function tool definition"""
|
||||
|
||||
type: OpenResponsesNonStreamingResponseType
|
||||
name: str
|
||||
parameters: Nullable[Dict[str, Nullable[Any]]]
|
||||
description: NotRequired[Nullable[str]]
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class OpenResponsesNonStreamingResponseToolFunction(BaseModel):
|
||||
r"""Function tool definition"""
|
||||
|
||||
type: OpenResponsesNonStreamingResponseType
|
||||
|
||||
name: str
|
||||
|
||||
parameters: Nullable[Dict[str, Nullable[Any]]]
|
||||
|
||||
description: OptionalNullable[str] = UNSET
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["description", "strict"]
|
||||
nullable_fields = ["description", "strict", "parameters"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
OpenResponsesNonStreamingResponseToolUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesNonStreamingResponseToolUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesWebSearchPreviewToolTypedDict,
|
||||
OpenResponsesWebSearchPreview20250311ToolTypedDict,
|
||||
OpenResponsesWebSearchToolTypedDict,
|
||||
OpenResponsesWebSearch20250826ToolTypedDict,
|
||||
OpenResponsesNonStreamingResponseToolFunctionTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesNonStreamingResponseToolUnion = TypeAliasType(
|
||||
"OpenResponsesNonStreamingResponseToolUnion",
|
||||
Union[
|
||||
OpenResponsesWebSearchPreviewTool,
|
||||
OpenResponsesWebSearchPreview20250311Tool,
|
||||
OpenResponsesWebSearchTool,
|
||||
OpenResponsesWebSearch20250826Tool,
|
||||
OpenResponsesNonStreamingResponseToolFunction,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class OpenResponsesNonStreamingResponseTypedDict(TypedDict):
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
id: str
|
||||
object: Object
|
||||
created_at: float
|
||||
model: str
|
||||
output: List[ResponsesOutputItemTypedDict]
|
||||
error: Nullable[ResponsesErrorFieldTypedDict]
|
||||
r"""Error information returned from the API"""
|
||||
incomplete_details: Nullable[OpenAIResponsesIncompleteDetailsTypedDict]
|
||||
temperature: Nullable[float]
|
||||
top_p: Nullable[float]
|
||||
instructions: Nullable[OpenAIResponsesInputUnionTypedDict]
|
||||
metadata: Nullable[Dict[str, str]]
|
||||
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
|
||||
tools: List[OpenResponsesNonStreamingResponseToolUnionTypedDict]
|
||||
tool_choice: OpenAIResponsesToolChoiceUnionTypedDict
|
||||
parallel_tool_calls: bool
|
||||
status: NotRequired[OpenAIResponsesResponseStatus]
|
||||
user: NotRequired[Nullable[str]]
|
||||
output_text: NotRequired[str]
|
||||
prompt_cache_key: NotRequired[Nullable[str]]
|
||||
safety_identifier: NotRequired[Nullable[str]]
|
||||
usage: NotRequired[OpenResponsesUsageTypedDict]
|
||||
r"""Token usage information for the response"""
|
||||
max_tool_calls: NotRequired[Nullable[float]]
|
||||
top_logprobs: NotRequired[float]
|
||||
max_output_tokens: NotRequired[Nullable[float]]
|
||||
prompt: NotRequired[Nullable[OpenAIResponsesPromptTypedDict]]
|
||||
background: NotRequired[Nullable[bool]]
|
||||
previous_response_id: NotRequired[Nullable[str]]
|
||||
reasoning: NotRequired[Nullable[OpenAIResponsesReasoningConfigTypedDict]]
|
||||
service_tier: NotRequired[Nullable[OpenAIResponsesServiceTier]]
|
||||
store: NotRequired[bool]
|
||||
truncation: NotRequired[Nullable[OpenAIResponsesTruncation]]
|
||||
text: NotRequired[ResponseTextConfigTypedDict]
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
|
||||
|
||||
class OpenResponsesNonStreamingResponse(BaseModel):
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
id: str
|
||||
|
||||
object: Object
|
||||
|
||||
created_at: float
|
||||
|
||||
model: str
|
||||
|
||||
output: List[ResponsesOutputItem]
|
||||
|
||||
error: Nullable[ResponsesErrorField]
|
||||
r"""Error information returned from the API"""
|
||||
|
||||
incomplete_details: Nullable[OpenAIResponsesIncompleteDetails]
|
||||
|
||||
temperature: Nullable[float]
|
||||
|
||||
top_p: Nullable[float]
|
||||
|
||||
instructions: Nullable[OpenAIResponsesInputUnion]
|
||||
|
||||
metadata: Nullable[Dict[str, str]]
|
||||
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
|
||||
|
||||
tools: List[OpenResponsesNonStreamingResponseToolUnion]
|
||||
|
||||
tool_choice: OpenAIResponsesToolChoiceUnion
|
||||
|
||||
parallel_tool_calls: bool
|
||||
|
||||
status: Annotated[
|
||||
Optional[OpenAIResponsesResponseStatus],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
|
||||
user: OptionalNullable[str] = UNSET
|
||||
|
||||
output_text: Optional[str] = None
|
||||
|
||||
prompt_cache_key: OptionalNullable[str] = UNSET
|
||||
|
||||
safety_identifier: OptionalNullable[str] = UNSET
|
||||
|
||||
usage: Optional[OpenResponsesUsage] = None
|
||||
r"""Token usage information for the response"""
|
||||
|
||||
max_tool_calls: OptionalNullable[float] = UNSET
|
||||
|
||||
top_logprobs: Optional[float] = None
|
||||
|
||||
max_output_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
prompt: OptionalNullable[OpenAIResponsesPrompt] = UNSET
|
||||
|
||||
background: OptionalNullable[bool] = UNSET
|
||||
|
||||
previous_response_id: OptionalNullable[str] = UNSET
|
||||
|
||||
reasoning: OptionalNullable[OpenAIResponsesReasoningConfig] = UNSET
|
||||
|
||||
service_tier: Annotated[
|
||||
OptionalNullable[OpenAIResponsesServiceTier],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
store: Optional[bool] = None
|
||||
|
||||
truncation: Annotated[
|
||||
OptionalNullable[OpenAIResponsesTruncation],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
text: Optional[ResponseTextConfig] = None
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"status",
|
||||
"user",
|
||||
"output_text",
|
||||
"prompt_cache_key",
|
||||
"safety_identifier",
|
||||
"usage",
|
||||
"max_tool_calls",
|
||||
"top_logprobs",
|
||||
"max_output_tokens",
|
||||
"prompt",
|
||||
"background",
|
||||
"previous_response_id",
|
||||
"reasoning",
|
||||
"service_tier",
|
||||
"store",
|
||||
"truncation",
|
||||
"text",
|
||||
]
|
||||
nullable_fields = [
|
||||
"user",
|
||||
"prompt_cache_key",
|
||||
"safety_identifier",
|
||||
"error",
|
||||
"incomplete_details",
|
||||
"max_tool_calls",
|
||||
"max_output_tokens",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"instructions",
|
||||
"metadata",
|
||||
"prompt",
|
||||
"background",
|
||||
"previous_response_id",
|
||||
"reasoning",
|
||||
"service_tier",
|
||||
"truncation",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,137 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenResponsesReasoningType = Literal["reasoning",]
|
||||
|
||||
|
||||
OpenResponsesReasoningStatusInProgress = Literal["in_progress",]
|
||||
|
||||
|
||||
OpenResponsesReasoningStatusIncomplete = Literal["incomplete",]
|
||||
|
||||
|
||||
OpenResponsesReasoningStatusCompleted = Literal["completed",]
|
||||
|
||||
|
||||
OpenResponsesReasoningStatusUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesReasoningStatusUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesReasoningStatusCompleted,
|
||||
OpenResponsesReasoningStatusIncomplete,
|
||||
OpenResponsesReasoningStatusInProgress,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesReasoningStatusUnion = TypeAliasType(
|
||||
"OpenResponsesReasoningStatusUnion",
|
||||
Union[
|
||||
OpenResponsesReasoningStatusCompleted,
|
||||
OpenResponsesReasoningStatusIncomplete,
|
||||
OpenResponsesReasoningStatusInProgress,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesReasoningFormat = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesReasoningTypedDict(TypedDict):
|
||||
r"""Reasoning output item with signature and format extensions"""
|
||||
|
||||
type: OpenResponsesReasoningType
|
||||
id: str
|
||||
summary: List[ReasoningSummaryTextTypedDict]
|
||||
content: NotRequired[List[ReasoningTextContentTypedDict]]
|
||||
encrypted_content: NotRequired[Nullable[str]]
|
||||
status: NotRequired[OpenResponsesReasoningStatusUnionTypedDict]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[OpenResponsesReasoningFormat]]
|
||||
|
||||
|
||||
class OpenResponsesReasoning(BaseModel):
|
||||
r"""Reasoning output item with signature and format extensions"""
|
||||
|
||||
type: OpenResponsesReasoningType
|
||||
|
||||
id: str
|
||||
|
||||
summary: List[ReasoningSummaryText]
|
||||
|
||||
content: Optional[List[ReasoningTextContent]] = None
|
||||
|
||||
encrypted_content: OptionalNullable[str] = UNSET
|
||||
|
||||
status: Optional[OpenResponsesReasoningStatusUnion] = None
|
||||
|
||||
signature: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[OpenResponsesReasoningFormat],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"content",
|
||||
"encrypted_content",
|
||||
"status",
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
nullable_fields = ["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
|
||||
@@ -0,0 +1,73 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesreasoningeffort import OpenAIResponsesReasoningEffort
|
||||
from .reasoningsummaryverbosity import ReasoningSummaryVerbosity
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class OpenResponsesReasoningConfigTypedDict(TypedDict):
|
||||
r"""Configuration for reasoning mode in the response"""
|
||||
|
||||
effort: NotRequired[Nullable[OpenAIResponsesReasoningEffort]]
|
||||
summary: NotRequired[ReasoningSummaryVerbosity]
|
||||
max_tokens: NotRequired[Nullable[float]]
|
||||
enabled: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class OpenResponsesReasoningConfig(BaseModel):
|
||||
r"""Configuration for reasoning mode in the response"""
|
||||
|
||||
effort: Annotated[
|
||||
OptionalNullable[OpenAIResponsesReasoningEffort],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
summary: Annotated[
|
||||
Optional[ReasoningSummaryVerbosity], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
max_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
enabled: OptionalNullable[bool] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["effort", "summary", "max_tokens", "enabled"]
|
||||
nullable_fields = ["effort", "max_tokens", "enabled"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesReasoningDeltaEventType = Literal["response.reasoning_text.delta",]
|
||||
|
||||
|
||||
class OpenResponsesReasoningDeltaEventTypedDict(TypedDict):
|
||||
r"""Event emitted when reasoning text delta is streamed"""
|
||||
|
||||
type: OpenResponsesReasoningDeltaEventType
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
delta: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesReasoningDeltaEvent(BaseModel):
|
||||
r"""Event emitted when reasoning text delta is streamed"""
|
||||
|
||||
type: OpenResponsesReasoningDeltaEventType
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesReasoningDoneEventType = Literal["response.reasoning_text.done",]
|
||||
|
||||
|
||||
class OpenResponsesReasoningDoneEventTypedDict(TypedDict):
|
||||
r"""Event emitted when reasoning text streaming is complete"""
|
||||
|
||||
type: OpenResponsesReasoningDoneEventType
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
text: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesReasoningDoneEvent(BaseModel):
|
||||
r"""Event emitted when reasoning text streaming is complete"""
|
||||
|
||||
type: OpenResponsesReasoningDoneEventType
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
text: str
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,39 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import Literal
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
OpenResponsesReasoningSummaryPartAddedEventType = Literal[
|
||||
"response.reasoning_summary_part.added",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryPartAddedEventTypedDict(TypedDict):
|
||||
r"""Event emitted when a reasoning summary part is added"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryPartAddedEventType
|
||||
output_index: float
|
||||
item_id: str
|
||||
summary_index: float
|
||||
part: ReasoningSummaryTextTypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryPartAddedEvent(BaseModel):
|
||||
r"""Event emitted when a reasoning summary part is added"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryPartAddedEventType
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
summary_index: float
|
||||
|
||||
part: ReasoningSummaryText
|
||||
|
||||
sequence_number: float
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesReasoningSummaryTextDeltaEventType = Literal[
|
||||
"response.reasoning_summary_text.delta",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryTextDeltaEventTypedDict(TypedDict):
|
||||
r"""Event emitted when reasoning summary text delta is streamed"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryTextDeltaEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
summary_index: float
|
||||
delta: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryTextDeltaEvent(BaseModel):
|
||||
r"""Event emitted when reasoning summary text delta is streamed"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryTextDeltaEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
summary_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
@@ -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
|
||||
|
||||
|
||||
OpenResponsesReasoningSummaryTextDoneEventType = Literal[
|
||||
"response.reasoning_summary_text.done",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryTextDoneEventTypedDict(TypedDict):
|
||||
r"""Event emitted when reasoning summary text streaming is complete"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryTextDoneEventType
|
||||
item_id: str
|
||||
output_index: float
|
||||
summary_index: float
|
||||
text: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesReasoningSummaryTextDoneEvent(BaseModel):
|
||||
r"""Event emitted when reasoning summary text streaming is complete"""
|
||||
|
||||
type: OpenResponsesReasoningSummaryTextDoneEventType
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
summary_index: float
|
||||
|
||||
text: str
|
||||
|
||||
sequence_number: float
|
||||
@@ -0,0 +1,654 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesincludable import OpenAIResponsesIncludable
|
||||
from .openairesponsesprompt import OpenAIResponsesPrompt, OpenAIResponsesPromptTypedDict
|
||||
from .openairesponsestoolchoice_union import (
|
||||
OpenAIResponsesToolChoiceUnion,
|
||||
OpenAIResponsesToolChoiceUnionTypedDict,
|
||||
)
|
||||
from .openresponsesinput import OpenResponsesInput, OpenResponsesInputTypedDict
|
||||
from .openresponsesreasoningconfig import (
|
||||
OpenResponsesReasoningConfig,
|
||||
OpenResponsesReasoningConfigTypedDict,
|
||||
)
|
||||
from .openresponsesresponsetext import (
|
||||
OpenResponsesResponseText,
|
||||
OpenResponsesResponseTextTypedDict,
|
||||
)
|
||||
from .openresponseswebsearch20250826tool import (
|
||||
OpenResponsesWebSearch20250826Tool,
|
||||
OpenResponsesWebSearch20250826ToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchpreview20250311tool import (
|
||||
OpenResponsesWebSearchPreview20250311Tool,
|
||||
OpenResponsesWebSearchPreview20250311ToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchpreviewtool import (
|
||||
OpenResponsesWebSearchPreviewTool,
|
||||
OpenResponsesWebSearchPreviewToolTypedDict,
|
||||
)
|
||||
from .openresponseswebsearchtool import (
|
||||
OpenResponsesWebSearchTool,
|
||||
OpenResponsesWebSearchToolTypedDict,
|
||||
)
|
||||
from .providername import ProviderName
|
||||
from .quantization import Quantization
|
||||
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, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OpenResponsesRequestType = Literal["function",]
|
||||
|
||||
|
||||
class OpenResponsesRequestToolFunctionTypedDict(TypedDict):
|
||||
r"""Function tool definition"""
|
||||
|
||||
type: OpenResponsesRequestType
|
||||
name: str
|
||||
parameters: Nullable[Dict[str, Nullable[Any]]]
|
||||
description: NotRequired[Nullable[str]]
|
||||
strict: NotRequired[Nullable[bool]]
|
||||
|
||||
|
||||
class OpenResponsesRequestToolFunction(BaseModel):
|
||||
r"""Function tool definition"""
|
||||
|
||||
type: OpenResponsesRequestType
|
||||
|
||||
name: str
|
||||
|
||||
parameters: Nullable[Dict[str, Nullable[Any]]]
|
||||
|
||||
description: OptionalNullable[str] = UNSET
|
||||
|
||||
strict: OptionalNullable[bool] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["description", "strict"]
|
||||
nullable_fields = ["description", "strict", "parameters"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
OpenResponsesRequestToolUnionTypedDict = TypeAliasType(
|
||||
"OpenResponsesRequestToolUnionTypedDict",
|
||||
Union[
|
||||
OpenResponsesWebSearchPreviewToolTypedDict,
|
||||
OpenResponsesWebSearchPreview20250311ToolTypedDict,
|
||||
OpenResponsesWebSearchToolTypedDict,
|
||||
OpenResponsesWebSearch20250826ToolTypedDict,
|
||||
OpenResponsesRequestToolFunctionTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OpenResponsesRequestToolUnion = TypeAliasType(
|
||||
"OpenResponsesRequestToolUnion",
|
||||
Union[
|
||||
OpenResponsesWebSearchPreviewTool,
|
||||
OpenResponsesWebSearchPreview20250311Tool,
|
||||
OpenResponsesWebSearchTool,
|
||||
OpenResponsesWebSearch20250826Tool,
|
||||
OpenResponsesRequestToolFunction,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
ServiceTier = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"default",
|
||||
"flex",
|
||||
"priority",
|
||||
"scale",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Truncation = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"disabled",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
DataCollection = Union[
|
||||
Literal[
|
||||
"deny",
|
||||
"allow",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
OrderTypedDict = TypeAliasType("OrderTypedDict", Union[ProviderName, str])
|
||||
|
||||
|
||||
Order = TypeAliasType(
|
||||
"Order",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
OnlyTypedDict = TypeAliasType("OnlyTypedDict", Union[ProviderName, str])
|
||||
|
||||
|
||||
Only = TypeAliasType(
|
||||
"Only",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
IgnoreTypedDict = TypeAliasType("IgnoreTypedDict", Union[ProviderName, str])
|
||||
|
||||
|
||||
Ignore = TypeAliasType(
|
||||
"Ignore",
|
||||
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
|
||||
)
|
||||
|
||||
|
||||
Sort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
class MaxPriceTypedDict(TypedDict):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
completion: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
image: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
audio: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
request: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
|
||||
class MaxPrice(BaseModel):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
completion: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
image: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
audio: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
request: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
|
||||
class ProviderTypedDict(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[OrderTypedDict]]]
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
only: NotRequired[Nullable[List[OnlyTypedDict]]]
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
ignore: NotRequired[Nullable[List[IgnoreTypedDict]]]
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
quantizations: NotRequired[Nullable[List[Quantization]]]
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
sort: NotRequired[Nullable[Sort]]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
max_price: NotRequired[MaxPriceTypedDict]
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
|
||||
class Provider(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[Order]] = UNSET
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
|
||||
only: OptionalNullable[List[Only]] = UNSET
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
|
||||
ignore: OptionalNullable[List[Ignore]] = UNSET
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
|
||||
quantizations: OptionalNullable[
|
||||
List[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: Annotated[
|
||||
OptionalNullable[Sort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
max_price: Optional[MaxPrice] = None
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
]
|
||||
nullable_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
IDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
PdfEngine = Union[
|
||||
Literal[
|
||||
"mistral-ocr",
|
||||
"pdf-text",
|
||||
"native",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class PdfTypedDict(TypedDict):
|
||||
engine: NotRequired[PdfEngine]
|
||||
|
||||
|
||||
class Pdf(BaseModel):
|
||||
engine: Annotated[
|
||||
Optional[PdfEngine], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
|
||||
|
||||
class PluginFileParserTypedDict(TypedDict):
|
||||
id: IDFileParser
|
||||
max_files: NotRequired[float]
|
||||
pdf: NotRequired[PdfTypedDict]
|
||||
|
||||
|
||||
class PluginFileParser(BaseModel):
|
||||
id: IDFileParser
|
||||
|
||||
max_files: Optional[float] = None
|
||||
|
||||
pdf: Optional[Pdf] = None
|
||||
|
||||
|
||||
IDWeb = Literal["web",]
|
||||
|
||||
|
||||
Engine = Union[
|
||||
Literal[
|
||||
"native",
|
||||
"exa",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class PluginWebTypedDict(TypedDict):
|
||||
id: IDWeb
|
||||
max_results: NotRequired[float]
|
||||
search_prompt: NotRequired[str]
|
||||
engine: NotRequired[Engine]
|
||||
|
||||
|
||||
class PluginWeb(BaseModel):
|
||||
id: IDWeb
|
||||
|
||||
max_results: Optional[float] = None
|
||||
|
||||
search_prompt: Optional[str] = None
|
||||
|
||||
engine: Annotated[Optional[Engine], PlainValidator(validate_open_enum(False))] = (
|
||||
None
|
||||
)
|
||||
|
||||
|
||||
IDModeration = Literal["moderation",]
|
||||
|
||||
|
||||
class PluginModerationTypedDict(TypedDict):
|
||||
id: IDModeration
|
||||
|
||||
|
||||
class PluginModeration(BaseModel):
|
||||
id: IDModeration
|
||||
|
||||
|
||||
PluginTypedDict = TypeAliasType(
|
||||
"PluginTypedDict",
|
||||
Union[PluginModerationTypedDict, PluginFileParserTypedDict, PluginWebTypedDict],
|
||||
)
|
||||
|
||||
|
||||
Plugin = TypeAliasType("Plugin", Union[PluginModeration, PluginFileParser, PluginWeb])
|
||||
|
||||
|
||||
class OpenResponsesRequestTypedDict(TypedDict):
|
||||
r"""Request schema for Responses endpoint"""
|
||||
|
||||
input: NotRequired[OpenResponsesInputTypedDict]
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
instructions: NotRequired[Nullable[str]]
|
||||
metadata: NotRequired[Nullable[Dict[str, str]]]
|
||||
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
|
||||
tools: NotRequired[List[OpenResponsesRequestToolUnionTypedDict]]
|
||||
tool_choice: NotRequired[OpenAIResponsesToolChoiceUnionTypedDict]
|
||||
parallel_tool_calls: NotRequired[Nullable[bool]]
|
||||
model: NotRequired[str]
|
||||
models: NotRequired[List[str]]
|
||||
text: NotRequired[OpenResponsesResponseTextTypedDict]
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
reasoning: NotRequired[Nullable[OpenResponsesReasoningConfigTypedDict]]
|
||||
r"""Configuration for reasoning mode in the response"""
|
||||
max_output_tokens: NotRequired[Nullable[float]]
|
||||
temperature: NotRequired[Nullable[float]]
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
top_k: NotRequired[float]
|
||||
prompt_cache_key: NotRequired[Nullable[str]]
|
||||
previous_response_id: NotRequired[Nullable[str]]
|
||||
prompt: NotRequired[Nullable[OpenAIResponsesPromptTypedDict]]
|
||||
include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]]
|
||||
background: NotRequired[Nullable[bool]]
|
||||
safety_identifier: NotRequired[Nullable[str]]
|
||||
store: NotRequired[Nullable[bool]]
|
||||
service_tier: NotRequired[Nullable[ServiceTier]]
|
||||
truncation: NotRequired[Nullable[Truncation]]
|
||||
stream: NotRequired[bool]
|
||||
provider: NotRequired[Nullable[ProviderTypedDict]]
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
plugins: NotRequired[List[PluginTypedDict]]
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
user: NotRequired[str]
|
||||
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
|
||||
|
||||
|
||||
class OpenResponsesRequest(BaseModel):
|
||||
r"""Request schema for Responses endpoint"""
|
||||
|
||||
input: Optional[OpenResponsesInput] = None
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
|
||||
instructions: OptionalNullable[str] = UNSET
|
||||
|
||||
metadata: OptionalNullable[Dict[str, str]] = UNSET
|
||||
r"""Metadata key-value pairs for the request. Keys must be ≤64 characters and cannot contain brackets. Values must be ≤512 characters. Maximum 16 pairs allowed."""
|
||||
|
||||
tools: Optional[List[OpenResponsesRequestToolUnion]] = None
|
||||
|
||||
tool_choice: Optional[OpenAIResponsesToolChoiceUnion] = None
|
||||
|
||||
parallel_tool_calls: OptionalNullable[bool] = UNSET
|
||||
|
||||
model: Optional[str] = None
|
||||
|
||||
models: Optional[List[str]] = None
|
||||
|
||||
text: Optional[OpenResponsesResponseText] = None
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
|
||||
reasoning: OptionalNullable[OpenResponsesReasoningConfig] = UNSET
|
||||
r"""Configuration for reasoning mode in the response"""
|
||||
|
||||
max_output_tokens: OptionalNullable[float] = UNSET
|
||||
|
||||
temperature: OptionalNullable[float] = UNSET
|
||||
|
||||
top_p: OptionalNullable[float] = UNSET
|
||||
|
||||
top_k: Optional[float] = None
|
||||
|
||||
prompt_cache_key: OptionalNullable[str] = UNSET
|
||||
|
||||
previous_response_id: OptionalNullable[str] = UNSET
|
||||
|
||||
prompt: OptionalNullable[OpenAIResponsesPrompt] = UNSET
|
||||
|
||||
include: OptionalNullable[
|
||||
List[
|
||||
Annotated[
|
||||
OpenAIResponsesIncludable, PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
]
|
||||
] = UNSET
|
||||
|
||||
background: OptionalNullable[bool] = UNSET
|
||||
|
||||
safety_identifier: OptionalNullable[str] = UNSET
|
||||
|
||||
store: OptionalNullable[bool] = UNSET
|
||||
|
||||
service_tier: Annotated[
|
||||
OptionalNullable[ServiceTier], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
truncation: Annotated[
|
||||
OptionalNullable[Truncation], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
stream: Optional[bool] = False
|
||||
|
||||
provider: OptionalNullable[Provider] = UNSET
|
||||
r"""When multiple model providers are available, optionally indicate your routing preference."""
|
||||
|
||||
plugins: Optional[List[Plugin]] = None
|
||||
r"""Plugins you want to enable for this request, including their settings."""
|
||||
|
||||
user: Optional[str] = None
|
||||
r"""A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 128 characters."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"input",
|
||||
"instructions",
|
||||
"metadata",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"parallel_tool_calls",
|
||||
"model",
|
||||
"models",
|
||||
"text",
|
||||
"reasoning",
|
||||
"max_output_tokens",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"prompt_cache_key",
|
||||
"previous_response_id",
|
||||
"prompt",
|
||||
"include",
|
||||
"background",
|
||||
"safety_identifier",
|
||||
"store",
|
||||
"service_tier",
|
||||
"truncation",
|
||||
"stream",
|
||||
"provider",
|
||||
"plugins",
|
||||
"user",
|
||||
]
|
||||
nullable_fields = [
|
||||
"instructions",
|
||||
"metadata",
|
||||
"parallel_tool_calls",
|
||||
"reasoning",
|
||||
"max_output_tokens",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"prompt_cache_key",
|
||||
"previous_response_id",
|
||||
"prompt",
|
||||
"include",
|
||||
"background",
|
||||
"safety_identifier",
|
||||
"store",
|
||||
"service_tier",
|
||||
"truncation",
|
||||
"provider",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,83 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responseformattextconfig import (
|
||||
ResponseFormatTextConfig,
|
||||
ResponseFormatTextConfigTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesResponseTextVerbosity = Union[
|
||||
Literal[
|
||||
"high",
|
||||
"low",
|
||||
"medium",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesResponseTextTypedDict(TypedDict):
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
|
||||
format_: NotRequired[ResponseFormatTextConfigTypedDict]
|
||||
r"""Text response format configuration"""
|
||||
verbosity: NotRequired[Nullable[OpenResponsesResponseTextVerbosity]]
|
||||
|
||||
|
||||
class OpenResponsesResponseText(BaseModel):
|
||||
r"""Text output configuration including format and verbosity"""
|
||||
|
||||
format_: Annotated[
|
||||
Optional[ResponseFormatTextConfig], pydantic.Field(alias="format")
|
||||
] = None
|
||||
r"""Text response format configuration"""
|
||||
|
||||
verbosity: Annotated[
|
||||
OptionalNullable[OpenResponsesResponseTextVerbosity],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["format", "verbosity"]
|
||||
nullable_fields = ["verbosity"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,644 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesannotation import (
|
||||
OpenAIResponsesAnnotation,
|
||||
OpenAIResponsesAnnotationTypedDict,
|
||||
)
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .openresponseserrorevent import (
|
||||
OpenResponsesErrorEvent,
|
||||
OpenResponsesErrorEventTypedDict,
|
||||
)
|
||||
from .openresponsesimagegencallcompleted import (
|
||||
OpenResponsesImageGenCallCompleted,
|
||||
OpenResponsesImageGenCallCompletedTypedDict,
|
||||
)
|
||||
from .openresponsesimagegencallgenerating import (
|
||||
OpenResponsesImageGenCallGenerating,
|
||||
OpenResponsesImageGenCallGeneratingTypedDict,
|
||||
)
|
||||
from .openresponsesimagegencallinprogress import (
|
||||
OpenResponsesImageGenCallInProgress,
|
||||
OpenResponsesImageGenCallInProgressTypedDict,
|
||||
)
|
||||
from .openresponsesimagegencallpartialimage import (
|
||||
OpenResponsesImageGenCallPartialImage,
|
||||
OpenResponsesImageGenCallPartialImageTypedDict,
|
||||
)
|
||||
from .openresponseslogprobs import OpenResponsesLogProbs, OpenResponsesLogProbsTypedDict
|
||||
from .openresponsesnonstreamingresponse import (
|
||||
OpenResponsesNonStreamingResponse,
|
||||
OpenResponsesNonStreamingResponseTypedDict,
|
||||
)
|
||||
from .openresponsesreasoningdeltaevent import (
|
||||
OpenResponsesReasoningDeltaEvent,
|
||||
OpenResponsesReasoningDeltaEventTypedDict,
|
||||
)
|
||||
from .openresponsesreasoningdoneevent import (
|
||||
OpenResponsesReasoningDoneEvent,
|
||||
OpenResponsesReasoningDoneEventTypedDict,
|
||||
)
|
||||
from .openresponsesreasoningsummarypartaddedevent import (
|
||||
OpenResponsesReasoningSummaryPartAddedEvent,
|
||||
OpenResponsesReasoningSummaryPartAddedEventTypedDict,
|
||||
)
|
||||
from .openresponsesreasoningsummarytextdeltaevent import (
|
||||
OpenResponsesReasoningSummaryTextDeltaEvent,
|
||||
OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
|
||||
)
|
||||
from .openresponsesreasoningsummarytextdoneevent import (
|
||||
OpenResponsesReasoningSummaryTextDoneEvent,
|
||||
OpenResponsesReasoningSummaryTextDoneEventTypedDict,
|
||||
)
|
||||
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from .responsesoutputitem import ResponsesOutputItem, ResponsesOutputItemTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Union
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
TypeResponseReasoningSummaryPartDone = Literal["response.reasoning_summary_part.done",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when a reasoning summary part is complete"""
|
||||
|
||||
type: TypeResponseReasoningSummaryPartDone
|
||||
output_index: float
|
||||
item_id: str
|
||||
summary_index: float
|
||||
part: ReasoningSummaryTextTypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseReasoningSummaryPartDone(BaseModel):
|
||||
r"""Event emitted when a reasoning summary part is complete"""
|
||||
|
||||
type: TypeResponseReasoningSummaryPartDone
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
summary_index: float
|
||||
|
||||
part: ReasoningSummaryText
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseFunctionCallArgumentsDone = Literal[
|
||||
"response.function_call_arguments.done",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when function call arguments streaming is complete"""
|
||||
|
||||
type: TypeResponseFunctionCallArgumentsDone
|
||||
item_id: str
|
||||
output_index: float
|
||||
name: str
|
||||
arguments: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFunctionCallArgumentsDone(BaseModel):
|
||||
r"""Event emitted when function call arguments streaming is complete"""
|
||||
|
||||
type: TypeResponseFunctionCallArgumentsDone
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
name: str
|
||||
|
||||
arguments: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseFunctionCallArgumentsDelta = Literal[
|
||||
"response.function_call_arguments.delta",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict(TypedDict):
|
||||
r"""Event emitted when function call arguments are being streamed"""
|
||||
|
||||
type: TypeResponseFunctionCallArgumentsDelta
|
||||
item_id: str
|
||||
output_index: float
|
||||
delta: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFunctionCallArgumentsDelta(BaseModel):
|
||||
r"""Event emitted when function call arguments are being streamed"""
|
||||
|
||||
type: TypeResponseFunctionCallArgumentsDelta
|
||||
|
||||
item_id: str
|
||||
|
||||
output_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseOutputTextAnnotationAdded = Literal[
|
||||
"response.output_text.annotation.added",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict(TypedDict):
|
||||
r"""Event emitted when a text annotation is added to output"""
|
||||
|
||||
type: TypeResponseOutputTextAnnotationAdded
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
sequence_number: float
|
||||
annotation_index: float
|
||||
annotation: OpenAIResponsesAnnotationTypedDict
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextAnnotationAdded(BaseModel):
|
||||
r"""Event emitted when a text annotation is added to output"""
|
||||
|
||||
type: TypeResponseOutputTextAnnotationAdded
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
sequence_number: float
|
||||
|
||||
annotation_index: float
|
||||
|
||||
annotation: OpenAIResponsesAnnotation
|
||||
|
||||
|
||||
TypeResponseRefusalDone = Literal["response.refusal.done",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseRefusalDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when refusal streaming is complete"""
|
||||
|
||||
type: TypeResponseRefusalDone
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
refusal: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseRefusalDone(BaseModel):
|
||||
r"""Event emitted when refusal streaming is complete"""
|
||||
|
||||
type: TypeResponseRefusalDone
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
refusal: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseRefusalDelta = Literal["response.refusal.delta",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseRefusalDeltaTypedDict(TypedDict):
|
||||
r"""Event emitted when a refusal delta is streamed"""
|
||||
|
||||
type: TypeResponseRefusalDelta
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
delta: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseRefusalDelta(BaseModel):
|
||||
r"""Event emitted when a refusal delta is streamed"""
|
||||
|
||||
type: TypeResponseRefusalDelta
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseOutputTextDone = Literal["response.output_text.done",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when text streaming is complete"""
|
||||
|
||||
type: TypeResponseOutputTextDone
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
text: str
|
||||
sequence_number: float
|
||||
logprobs: List[OpenResponsesLogProbsTypedDict]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextDone(BaseModel):
|
||||
r"""Event emitted when text streaming is complete"""
|
||||
|
||||
type: TypeResponseOutputTextDone
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
text: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
logprobs: List[OpenResponsesLogProbs]
|
||||
|
||||
|
||||
TypeResponseOutputTextDelta = Literal["response.output_text.delta",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextDeltaTypedDict(TypedDict):
|
||||
r"""Event emitted when a text delta is streamed"""
|
||||
|
||||
type: TypeResponseOutputTextDelta
|
||||
logprobs: List[OpenResponsesLogProbsTypedDict]
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
delta: str
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputTextDelta(BaseModel):
|
||||
r"""Event emitted when a text delta is streamed"""
|
||||
|
||||
type: TypeResponseOutputTextDelta
|
||||
|
||||
logprobs: List[OpenResponsesLogProbs]
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
delta: str
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseContentPartDone = Literal["response.content_part.done",]
|
||||
|
||||
|
||||
Part2TypedDict = TypeAliasType(
|
||||
"Part2TypedDict",
|
||||
Union[
|
||||
ReasoningTextContentTypedDict,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
ResponseOutputTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Part2 = TypeAliasType(
|
||||
"Part2",
|
||||
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
|
||||
)
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseContentPartDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when a content part is complete"""
|
||||
|
||||
type: TypeResponseContentPartDone
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
part: Part2TypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseContentPartDone(BaseModel):
|
||||
r"""Event emitted when a content part is complete"""
|
||||
|
||||
type: TypeResponseContentPartDone
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
part: Part2
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseContentPartAdded = Literal["response.content_part.added",]
|
||||
|
||||
|
||||
Part1TypedDict = TypeAliasType(
|
||||
"Part1TypedDict",
|
||||
Union[
|
||||
ReasoningTextContentTypedDict,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
ResponseOutputTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Part1 = TypeAliasType(
|
||||
"Part1",
|
||||
Union[ReasoningTextContent, OpenAIResponsesRefusalContent, ResponseOutputText],
|
||||
)
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseContentPartAddedTypedDict(TypedDict):
|
||||
r"""Event emitted when a new content part is added to an output item"""
|
||||
|
||||
type: TypeResponseContentPartAdded
|
||||
output_index: float
|
||||
item_id: str
|
||||
content_index: float
|
||||
part: Part1TypedDict
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseContentPartAdded(BaseModel):
|
||||
r"""Event emitted when a new content part is added to an output item"""
|
||||
|
||||
type: TypeResponseContentPartAdded
|
||||
|
||||
output_index: float
|
||||
|
||||
item_id: str
|
||||
|
||||
content_index: float
|
||||
|
||||
part: Part1
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseOutputItemDone = Literal["response.output_item.done",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputItemDoneTypedDict(TypedDict):
|
||||
r"""Event emitted when an output item is complete"""
|
||||
|
||||
type: TypeResponseOutputItemDone
|
||||
output_index: float
|
||||
item: ResponsesOutputItemTypedDict
|
||||
r"""An output item from the response"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputItemDone(BaseModel):
|
||||
r"""Event emitted when an output item is complete"""
|
||||
|
||||
type: TypeResponseOutputItemDone
|
||||
|
||||
output_index: float
|
||||
|
||||
item: ResponsesOutputItem
|
||||
r"""An output item from the response"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseOutputItemAdded = Literal["response.output_item.added",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputItemAddedTypedDict(TypedDict):
|
||||
r"""Event emitted when a new output item is added to the response"""
|
||||
|
||||
type: TypeResponseOutputItemAdded
|
||||
output_index: float
|
||||
item: ResponsesOutputItemTypedDict
|
||||
r"""An output item from the response"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseOutputItemAdded(BaseModel):
|
||||
r"""Event emitted when a new output item is added to the response"""
|
||||
|
||||
type: TypeResponseOutputItemAdded
|
||||
|
||||
output_index: float
|
||||
|
||||
item: ResponsesOutputItem
|
||||
r"""An output item from the response"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseFailed = Literal["response.failed",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFailedTypedDict(TypedDict):
|
||||
r"""Event emitted when a response has failed"""
|
||||
|
||||
type: TypeResponseFailed
|
||||
response: OpenResponsesNonStreamingResponseTypedDict
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseFailed(BaseModel):
|
||||
r"""Event emitted when a response has failed"""
|
||||
|
||||
type: TypeResponseFailed
|
||||
|
||||
response: OpenResponsesNonStreamingResponse
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseIncomplete = Literal["response.incomplete",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseIncompleteTypedDict(TypedDict):
|
||||
r"""Event emitted when a response is incomplete"""
|
||||
|
||||
type: TypeResponseIncomplete
|
||||
response: OpenResponsesNonStreamingResponseTypedDict
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseIncomplete(BaseModel):
|
||||
r"""Event emitted when a response is incomplete"""
|
||||
|
||||
type: TypeResponseIncomplete
|
||||
|
||||
response: OpenResponsesNonStreamingResponse
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseCompleted = Literal["response.completed",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseCompletedTypedDict(TypedDict):
|
||||
r"""Event emitted when a response has completed successfully"""
|
||||
|
||||
type: TypeResponseCompleted
|
||||
response: OpenResponsesNonStreamingResponseTypedDict
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseCompleted(BaseModel):
|
||||
r"""Event emitted when a response has completed successfully"""
|
||||
|
||||
type: TypeResponseCompleted
|
||||
|
||||
response: OpenResponsesNonStreamingResponse
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseInProgress = Literal["response.in_progress",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseInProgressTypedDict(TypedDict):
|
||||
r"""Event emitted when a response is in progress"""
|
||||
|
||||
type: TypeResponseInProgress
|
||||
response: OpenResponsesNonStreamingResponseTypedDict
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseInProgress(BaseModel):
|
||||
r"""Event emitted when a response is in progress"""
|
||||
|
||||
type: TypeResponseInProgress
|
||||
|
||||
response: OpenResponsesNonStreamingResponse
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
TypeResponseCreated = Literal["response.created",]
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseCreatedTypedDict(TypedDict):
|
||||
r"""Event emitted when a response is created"""
|
||||
|
||||
type: TypeResponseCreated
|
||||
response: OpenResponsesNonStreamingResponseTypedDict
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
sequence_number: float
|
||||
|
||||
|
||||
class OpenResponsesStreamEventResponseCreated(BaseModel):
|
||||
r"""Event emitted when a response is created"""
|
||||
|
||||
type: TypeResponseCreated
|
||||
|
||||
response: OpenResponsesNonStreamingResponse
|
||||
r"""Complete non-streaming response from the Responses API"""
|
||||
|
||||
sequence_number: float
|
||||
|
||||
|
||||
OpenResponsesStreamEventTypedDict = TypeAliasType(
|
||||
"OpenResponsesStreamEventTypedDict",
|
||||
Union[
|
||||
OpenResponsesStreamEventResponseCreatedTypedDict,
|
||||
OpenResponsesStreamEventResponseInProgressTypedDict,
|
||||
OpenResponsesStreamEventResponseCompletedTypedDict,
|
||||
OpenResponsesStreamEventResponseIncompleteTypedDict,
|
||||
OpenResponsesStreamEventResponseFailedTypedDict,
|
||||
OpenResponsesStreamEventResponseOutputItemAddedTypedDict,
|
||||
OpenResponsesStreamEventResponseOutputItemDoneTypedDict,
|
||||
OpenResponsesImageGenCallCompletedTypedDict,
|
||||
OpenResponsesImageGenCallGeneratingTypedDict,
|
||||
OpenResponsesImageGenCallInProgressTypedDict,
|
||||
OpenResponsesErrorEventTypedDict,
|
||||
OpenResponsesStreamEventResponseFunctionCallArgumentsDeltaTypedDict,
|
||||
OpenResponsesStreamEventResponseRefusalDeltaTypedDict,
|
||||
OpenResponsesReasoningSummaryPartAddedEventTypedDict,
|
||||
OpenResponsesStreamEventResponseContentPartAddedTypedDict,
|
||||
OpenResponsesImageGenCallPartialImageTypedDict,
|
||||
OpenResponsesStreamEventResponseFunctionCallArgumentsDoneTypedDict,
|
||||
OpenResponsesReasoningDeltaEventTypedDict,
|
||||
OpenResponsesReasoningDoneEventTypedDict,
|
||||
OpenResponsesStreamEventResponseRefusalDoneTypedDict,
|
||||
OpenResponsesStreamEventResponseReasoningSummaryPartDoneTypedDict,
|
||||
OpenResponsesReasoningSummaryTextDeltaEventTypedDict,
|
||||
OpenResponsesReasoningSummaryTextDoneEventTypedDict,
|
||||
OpenResponsesStreamEventResponseContentPartDoneTypedDict,
|
||||
OpenResponsesStreamEventResponseOutputTextDeltaTypedDict,
|
||||
OpenResponsesStreamEventResponseOutputTextDoneTypedDict,
|
||||
OpenResponsesStreamEventResponseOutputTextAnnotationAddedTypedDict,
|
||||
],
|
||||
)
|
||||
r"""Union of all possible event types emitted during response streaming"""
|
||||
|
||||
|
||||
OpenResponsesStreamEvent = TypeAliasType(
|
||||
"OpenResponsesStreamEvent",
|
||||
Union[
|
||||
OpenResponsesStreamEventResponseCreated,
|
||||
OpenResponsesStreamEventResponseInProgress,
|
||||
OpenResponsesStreamEventResponseCompleted,
|
||||
OpenResponsesStreamEventResponseIncomplete,
|
||||
OpenResponsesStreamEventResponseFailed,
|
||||
OpenResponsesStreamEventResponseOutputItemAdded,
|
||||
OpenResponsesStreamEventResponseOutputItemDone,
|
||||
OpenResponsesImageGenCallCompleted,
|
||||
OpenResponsesImageGenCallGenerating,
|
||||
OpenResponsesImageGenCallInProgress,
|
||||
OpenResponsesErrorEvent,
|
||||
OpenResponsesStreamEventResponseFunctionCallArgumentsDelta,
|
||||
OpenResponsesStreamEventResponseRefusalDelta,
|
||||
OpenResponsesReasoningSummaryPartAddedEvent,
|
||||
OpenResponsesStreamEventResponseContentPartAdded,
|
||||
OpenResponsesImageGenCallPartialImage,
|
||||
OpenResponsesStreamEventResponseFunctionCallArgumentsDone,
|
||||
OpenResponsesReasoningDeltaEvent,
|
||||
OpenResponsesReasoningDoneEvent,
|
||||
OpenResponsesStreamEventResponseRefusalDone,
|
||||
OpenResponsesStreamEventResponseReasoningSummaryPartDone,
|
||||
OpenResponsesReasoningSummaryTextDeltaEvent,
|
||||
OpenResponsesReasoningSummaryTextDoneEvent,
|
||||
OpenResponsesStreamEventResponseContentPartDone,
|
||||
OpenResponsesStreamEventResponseOutputTextDelta,
|
||||
OpenResponsesStreamEventResponseOutputTextDone,
|
||||
OpenResponsesStreamEventResponseOutputTextAnnotationAdded,
|
||||
],
|
||||
)
|
||||
r"""Union of all possible event types emitted during response streaming"""
|
||||
@@ -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 Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class OpenResponsesTopLogprobsTypedDict(TypedDict):
|
||||
r"""Alternative token with its log probability"""
|
||||
|
||||
token: NotRequired[str]
|
||||
logprob: NotRequired[float]
|
||||
|
||||
|
||||
class OpenResponsesTopLogprobs(BaseModel):
|
||||
r"""Alternative token with its log probability"""
|
||||
|
||||
token: Optional[str] = None
|
||||
|
||||
logprob: Optional[float] = None
|
||||
@@ -0,0 +1,140 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import Optional
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class InputTokensDetailsTypedDict(TypedDict):
|
||||
cached_tokens: float
|
||||
|
||||
|
||||
class InputTokensDetails(BaseModel):
|
||||
cached_tokens: float
|
||||
|
||||
|
||||
class OutputTokensDetailsTypedDict(TypedDict):
|
||||
reasoning_tokens: float
|
||||
|
||||
|
||||
class OutputTokensDetails(BaseModel):
|
||||
reasoning_tokens: float
|
||||
|
||||
|
||||
class CostDetailsTypedDict(TypedDict):
|
||||
upstream_inference_input_cost: float
|
||||
upstream_inference_output_cost: float
|
||||
upstream_inference_cost: NotRequired[Nullable[float]]
|
||||
|
||||
|
||||
class CostDetails(BaseModel):
|
||||
upstream_inference_input_cost: float
|
||||
|
||||
upstream_inference_output_cost: float
|
||||
|
||||
upstream_inference_cost: OptionalNullable[float] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["upstream_inference_cost"]
|
||||
nullable_fields = ["upstream_inference_cost"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class OpenResponsesUsageTypedDict(TypedDict):
|
||||
r"""Token usage information for the response"""
|
||||
|
||||
input_tokens: float
|
||||
input_tokens_details: InputTokensDetailsTypedDict
|
||||
output_tokens: float
|
||||
output_tokens_details: OutputTokensDetailsTypedDict
|
||||
total_tokens: float
|
||||
cost: NotRequired[Nullable[float]]
|
||||
r"""Cost of the completion"""
|
||||
is_byok: NotRequired[bool]
|
||||
r"""Whether a request was made using a Bring Your Own Key configuration"""
|
||||
cost_details: NotRequired[CostDetailsTypedDict]
|
||||
|
||||
|
||||
class OpenResponsesUsage(BaseModel):
|
||||
r"""Token usage information for the response"""
|
||||
|
||||
input_tokens: float
|
||||
|
||||
input_tokens_details: InputTokensDetails
|
||||
|
||||
output_tokens: float
|
||||
|
||||
output_tokens_details: OutputTokensDetails
|
||||
|
||||
total_tokens: float
|
||||
|
||||
cost: OptionalNullable[float] = UNSET
|
||||
r"""Cost of the completion"""
|
||||
|
||||
is_byok: Optional[bool] = None
|
||||
r"""Whether a request was made using a Bring Your Own Key configuration"""
|
||||
|
||||
cost_details: Optional[CostDetails] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["cost", "is_byok", "cost_details"]
|
||||
nullable_fields = ["cost"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,118 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responsessearchcontextsize import ResponsesSearchContextSize
|
||||
from .responseswebsearchuserlocation import (
|
||||
ResponsesWebSearchUserLocation,
|
||||
ResponsesWebSearchUserLocationTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesWebSearch20250826ToolType = Literal["web_search_2025_08_26",]
|
||||
|
||||
|
||||
class OpenResponsesWebSearch20250826ToolFiltersTypedDict(TypedDict):
|
||||
allowed_domains: NotRequired[Nullable[List[str]]]
|
||||
|
||||
|
||||
class OpenResponsesWebSearch20250826ToolFilters(BaseModel):
|
||||
allowed_domains: OptionalNullable[List[str]] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["allowed_domains"]
|
||||
nullable_fields = ["allowed_domains"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class OpenResponsesWebSearch20250826ToolTypedDict(TypedDict):
|
||||
r"""Web search tool configuration (2025-08-26 version)"""
|
||||
|
||||
type: OpenResponsesWebSearch20250826ToolType
|
||||
filters: NotRequired[Nullable[OpenResponsesWebSearch20250826ToolFiltersTypedDict]]
|
||||
search_context_size: NotRequired[ResponsesSearchContextSize]
|
||||
r"""Size of the search context for web search tools"""
|
||||
user_location: NotRequired[Nullable[ResponsesWebSearchUserLocationTypedDict]]
|
||||
r"""User location information for web search"""
|
||||
|
||||
|
||||
class OpenResponsesWebSearch20250826Tool(BaseModel):
|
||||
r"""Web search tool configuration (2025-08-26 version)"""
|
||||
|
||||
type: OpenResponsesWebSearch20250826ToolType
|
||||
|
||||
filters: OptionalNullable[OpenResponsesWebSearch20250826ToolFilters] = UNSET
|
||||
|
||||
search_context_size: Annotated[
|
||||
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Size of the search context for web search tools"""
|
||||
|
||||
user_location: OptionalNullable[ResponsesWebSearchUserLocation] = UNSET
|
||||
r"""User location information for web search"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["filters", "search_context_size", "user_location"]
|
||||
nullable_fields = ["filters", "user_location"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responsessearchcontextsize import ResponsesSearchContextSize
|
||||
from .websearchpreviewtooluserlocation import (
|
||||
WebSearchPreviewToolUserLocation,
|
||||
WebSearchPreviewToolUserLocationTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesWebSearchPreview20250311ToolType = Literal[
|
||||
"web_search_preview_2025_03_11",
|
||||
]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchPreview20250311ToolTypedDict(TypedDict):
|
||||
r"""Web search preview tool configuration (2025-03-11 version)"""
|
||||
|
||||
type: OpenResponsesWebSearchPreview20250311ToolType
|
||||
search_context_size: NotRequired[ResponsesSearchContextSize]
|
||||
r"""Size of the search context for web search tools"""
|
||||
user_location: NotRequired[Nullable[WebSearchPreviewToolUserLocationTypedDict]]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchPreview20250311Tool(BaseModel):
|
||||
r"""Web search preview tool configuration (2025-03-11 version)"""
|
||||
|
||||
type: OpenResponsesWebSearchPreview20250311ToolType
|
||||
|
||||
search_context_size: Annotated[
|
||||
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Size of the search context for web search tools"""
|
||||
|
||||
user_location: OptionalNullable[WebSearchPreviewToolUserLocation] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["search_context_size", "user_location"]
|
||||
nullable_fields = ["user_location"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,75 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responsessearchcontextsize import ResponsesSearchContextSize
|
||||
from .websearchpreviewtooluserlocation import (
|
||||
WebSearchPreviewToolUserLocation,
|
||||
WebSearchPreviewToolUserLocationTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesWebSearchPreviewToolType = Literal["web_search_preview",]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchPreviewToolTypedDict(TypedDict):
|
||||
r"""Web search preview tool configuration"""
|
||||
|
||||
type: OpenResponsesWebSearchPreviewToolType
|
||||
search_context_size: NotRequired[ResponsesSearchContextSize]
|
||||
r"""Size of the search context for web search tools"""
|
||||
user_location: NotRequired[Nullable[WebSearchPreviewToolUserLocationTypedDict]]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchPreviewTool(BaseModel):
|
||||
r"""Web search preview tool configuration"""
|
||||
|
||||
type: OpenResponsesWebSearchPreviewToolType
|
||||
|
||||
search_context_size: Annotated[
|
||||
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Size of the search context for web search tools"""
|
||||
|
||||
user_location: OptionalNullable[WebSearchPreviewToolUserLocation] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["search_context_size", "user_location"]
|
||||
nullable_fields = ["user_location"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,118 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .responsessearchcontextsize import ResponsesSearchContextSize
|
||||
from .responseswebsearchuserlocation import (
|
||||
ResponsesWebSearchUserLocation,
|
||||
ResponsesWebSearchUserLocationTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OpenResponsesWebSearchToolType = Literal["web_search",]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchToolFiltersTypedDict(TypedDict):
|
||||
allowed_domains: NotRequired[Nullable[List[str]]]
|
||||
|
||||
|
||||
class OpenResponsesWebSearchToolFilters(BaseModel):
|
||||
allowed_domains: OptionalNullable[List[str]] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["allowed_domains"]
|
||||
nullable_fields = ["allowed_domains"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class OpenResponsesWebSearchToolTypedDict(TypedDict):
|
||||
r"""Web search tool configuration"""
|
||||
|
||||
type: OpenResponsesWebSearchToolType
|
||||
filters: NotRequired[Nullable[OpenResponsesWebSearchToolFiltersTypedDict]]
|
||||
search_context_size: NotRequired[ResponsesSearchContextSize]
|
||||
r"""Size of the search context for web search tools"""
|
||||
user_location: NotRequired[Nullable[ResponsesWebSearchUserLocationTypedDict]]
|
||||
r"""User location information for web search"""
|
||||
|
||||
|
||||
class OpenResponsesWebSearchTool(BaseModel):
|
||||
r"""Web search tool configuration"""
|
||||
|
||||
type: OpenResponsesWebSearchToolType
|
||||
|
||||
filters: OptionalNullable[OpenResponsesWebSearchToolFilters] = UNSET
|
||||
|
||||
search_context_size: Annotated[
|
||||
Optional[ResponsesSearchContextSize], PlainValidator(validate_open_enum(False))
|
||||
] = None
|
||||
r"""Size of the search context for web search tools"""
|
||||
|
||||
user_location: OptionalNullable[ResponsesWebSearchUserLocation] = UNSET
|
||||
r"""User location information for web search"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["filters", "search_context_size", "user_location"]
|
||||
nullable_fields = ["filters", "user_location"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,60 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .imagegenerationstatus import ImageGenerationStatus
|
||||
from openrouter.types import BaseModel, Nullable, OptionalNullable, UNSET_SENTINEL
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
OutputItemImageGenerationCallType = Literal["image_generation_call",]
|
||||
|
||||
|
||||
class OutputItemImageGenerationCallTypedDict(TypedDict):
|
||||
type: OutputItemImageGenerationCallType
|
||||
id: str
|
||||
status: ImageGenerationStatus
|
||||
result: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class OutputItemImageGenerationCall(BaseModel):
|
||||
type: OutputItemImageGenerationCallType
|
||||
|
||||
id: str
|
||||
|
||||
status: Annotated[ImageGenerationStatus, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
result: OptionalNullable[str] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["result"]
|
||||
nullable_fields = ["result"]
|
||||
null_default_fields = ["result"]
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
OutputMessageRole = Literal["assistant",]
|
||||
|
||||
|
||||
OutputMessageType = Literal["message",]
|
||||
|
||||
|
||||
OutputMessageStatusInProgress = Literal["in_progress",]
|
||||
|
||||
|
||||
OutputMessageStatusIncomplete = Literal["incomplete",]
|
||||
|
||||
|
||||
OutputMessageStatusCompleted = Literal["completed",]
|
||||
|
||||
|
||||
OutputMessageStatusUnionTypedDict = TypeAliasType(
|
||||
"OutputMessageStatusUnionTypedDict",
|
||||
Union[
|
||||
OutputMessageStatusCompleted,
|
||||
OutputMessageStatusIncomplete,
|
||||
OutputMessageStatusInProgress,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OutputMessageStatusUnion = TypeAliasType(
|
||||
"OutputMessageStatusUnion",
|
||||
Union[
|
||||
OutputMessageStatusCompleted,
|
||||
OutputMessageStatusIncomplete,
|
||||
OutputMessageStatusInProgress,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OutputMessageContentTypedDict = TypeAliasType(
|
||||
"OutputMessageContentTypedDict",
|
||||
Union[OpenAIResponsesRefusalContentTypedDict, ResponseOutputTextTypedDict],
|
||||
)
|
||||
|
||||
|
||||
OutputMessageContent = TypeAliasType(
|
||||
"OutputMessageContent", Union[OpenAIResponsesRefusalContent, ResponseOutputText]
|
||||
)
|
||||
|
||||
|
||||
class OutputMessageTypedDict(TypedDict):
|
||||
id: str
|
||||
role: OutputMessageRole
|
||||
type: OutputMessageType
|
||||
content: List[OutputMessageContentTypedDict]
|
||||
status: NotRequired[OutputMessageStatusUnionTypedDict]
|
||||
|
||||
|
||||
class OutputMessage(BaseModel):
|
||||
id: str
|
||||
|
||||
role: OutputMessageRole
|
||||
|
||||
type: OutputMessageType
|
||||
|
||||
content: List[OutputMessageContent]
|
||||
|
||||
status: Optional[OutputMessageStatusUnion] = None
|
||||
@@ -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
|
||||
|
||||
|
||||
OutputModality = Union[
|
||||
Literal[
|
||||
"text",
|
||||
"image",
|
||||
"embeddings",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
Parameter = Union[
|
||||
Literal[
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"min_p",
|
||||
"top_a",
|
||||
"frequency_penalty",
|
||||
"presence_penalty",
|
||||
"repetition_penalty",
|
||||
"max_tokens",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"top_logprobs",
|
||||
"seed",
|
||||
"response_format",
|
||||
"structured_outputs",
|
||||
"stop",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"parallel_tool_calls",
|
||||
"include_reasoning",
|
||||
"reasoning",
|
||||
"web_search_options",
|
||||
"verbosity",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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 PayloadTooLargeResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for PayloadTooLargeResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class PayloadTooLargeResponseErrorData(BaseModel):
|
||||
r"""Error data for PayloadTooLargeResponse"""
|
||||
|
||||
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,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 PaymentRequiredResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for PaymentRequiredResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class PaymentRequiredResponseErrorData(BaseModel):
|
||||
r"""Error data for PaymentRequiredResponse"""
|
||||
|
||||
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,24 @@
|
||||
"""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 PerRequestLimitsTypedDict(TypedDict):
|
||||
r"""Per-request token limits"""
|
||||
|
||||
prompt_tokens: float
|
||||
r"""Maximum prompt tokens per request"""
|
||||
completion_tokens: float
|
||||
r"""Maximum completion tokens per request"""
|
||||
|
||||
|
||||
class PerRequestLimits(BaseModel):
|
||||
r"""Per-request token limits"""
|
||||
|
||||
prompt_tokens: float
|
||||
r"""Maximum prompt tokens per request"""
|
||||
|
||||
completion_tokens: float
|
||||
r"""Maximum completion tokens per request"""
|
||||
@@ -0,0 +1,98 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ProviderName = Union[
|
||||
Literal[
|
||||
"AnyScale",
|
||||
"Cent-ML",
|
||||
"HuggingFace",
|
||||
"Hyperbolic 2",
|
||||
"Lepton",
|
||||
"Lynn 2",
|
||||
"Lynn",
|
||||
"Mancer",
|
||||
"Modal",
|
||||
"OctoAI",
|
||||
"Recursal",
|
||||
"Reflection",
|
||||
"Replicate",
|
||||
"SambaNova 2",
|
||||
"SF Compute",
|
||||
"Together 2",
|
||||
"01.AI",
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cirrascale",
|
||||
"Clarifai",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"InoCloud",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"ModelRun",
|
||||
"Mistral",
|
||||
"Modular",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"Nvidia",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"Relace",
|
||||
"SambaNova",
|
||||
"SiliconFlow",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
"FakeProvider",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -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 ProviderOverloadedResponseErrorDataTypedDict(TypedDict):
|
||||
r"""Error data for ProviderOverloadedResponse"""
|
||||
|
||||
code: int
|
||||
message: str
|
||||
metadata: NotRequired[Nullable[Dict[str, Nullable[Any]]]]
|
||||
|
||||
|
||||
class ProviderOverloadedResponseErrorData(BaseModel):
|
||||
r"""Error data for ProviderOverloadedResponse"""
|
||||
|
||||
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,180 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .endpointstatus import EndpointStatus
|
||||
from .parameter import Parameter
|
||||
from .providername import ProviderName
|
||||
from openrouter.types import BaseModel, Nullable, 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, TypedDict
|
||||
|
||||
|
||||
class PricingTypedDict(TypedDict):
|
||||
prompt: Any
|
||||
r"""A value in string or number format that is a large number"""
|
||||
completion: Any
|
||||
r"""A value in string or number format that is a large number"""
|
||||
request: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
image: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
image_output: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
audio: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
input_audio_cache: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
web_search: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
internal_reasoning: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
input_cache_read: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
input_cache_write: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
discount: NotRequired[float]
|
||||
|
||||
|
||||
class Pricing(BaseModel):
|
||||
prompt: Any
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
completion: Any
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
request: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
image: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
image_output: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
audio: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
input_audio_cache: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
web_search: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
internal_reasoning: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
input_cache_read: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
input_cache_write: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
discount: Optional[float] = None
|
||||
|
||||
|
||||
PublicEndpointQuantization = Union[
|
||||
Literal[
|
||||
"int4",
|
||||
"int8",
|
||||
"fp4",
|
||||
"fp6",
|
||||
"fp8",
|
||||
"fp16",
|
||||
"bf16",
|
||||
"fp32",
|
||||
"unknown",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class PublicEndpointTypedDict(TypedDict):
|
||||
r"""Information about a specific model endpoint"""
|
||||
|
||||
name: str
|
||||
model_name: str
|
||||
context_length: float
|
||||
pricing: PricingTypedDict
|
||||
provider_name: ProviderName
|
||||
tag: str
|
||||
quantization: Nullable[PublicEndpointQuantization]
|
||||
max_completion_tokens: Nullable[float]
|
||||
max_prompt_tokens: Nullable[float]
|
||||
supported_parameters: List[Parameter]
|
||||
uptime_last_30m: Nullable[float]
|
||||
supports_implicit_caching: bool
|
||||
status: NotRequired[EndpointStatus]
|
||||
|
||||
|
||||
class PublicEndpoint(BaseModel):
|
||||
r"""Information about a specific model endpoint"""
|
||||
|
||||
name: str
|
||||
|
||||
model_name: str
|
||||
|
||||
context_length: float
|
||||
|
||||
pricing: Pricing
|
||||
|
||||
provider_name: Annotated[ProviderName, PlainValidator(validate_open_enum(False))]
|
||||
|
||||
tag: str
|
||||
|
||||
quantization: Annotated[
|
||||
Nullable[PublicEndpointQuantization], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
max_completion_tokens: Nullable[float]
|
||||
|
||||
max_prompt_tokens: Nullable[float]
|
||||
|
||||
supported_parameters: List[
|
||||
Annotated[Parameter, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
|
||||
uptime_last_30m: Nullable[float]
|
||||
|
||||
supports_implicit_caching: bool
|
||||
|
||||
status: Annotated[
|
||||
Optional[EndpointStatus], PlainValidator(validate_open_enum(True))
|
||||
] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["status"]
|
||||
nullable_fields = [
|
||||
"quantization",
|
||||
"max_completion_tokens",
|
||||
"max_prompt_tokens",
|
||||
"uptime_last_30m",
|
||||
]
|
||||
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