Files
openrouter-python-sdk-retry…/src/openrouter/models/chatstreamcompletioncreateparams.py
T
2025-09-07 21:39:50 +01:00

1098 lines
34 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .chatcompletionmessageparam import (
ChatCompletionMessageParam,
ChatCompletionMessageParamTypedDict,
)
from .chatcompletiontool import ChatCompletionTool, ChatCompletionToolTypedDict
from .chatcompletiontoolchoiceoption import (
ChatCompletionToolChoiceOption,
ChatCompletionToolChoiceOptionTypedDict,
)
from .responseformatjsonschemaschema import (
ResponseFormatJSONSchemaSchema,
ResponseFormatJSONSchemaSchemaTypedDict,
)
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ChatStreamCompletionCreateParamsEffort = Literal["high", "medium", "low", "minimal"]
r"""OpenAI-style reasoning effort setting"""
class ChatStreamCompletionCreateParamsReasoningTypedDict(TypedDict):
r"""Reasoning configuration"""
enabled: NotRequired[bool]
r"""Enables reasoning with default settings. Only work for some models."""
effort: NotRequired[Nullable[ChatStreamCompletionCreateParamsEffort]]
r"""OpenAI-style reasoning effort setting"""
max_tokens: NotRequired[Nullable[float]]
r"""non-OpenAI-style reasoning effort setting"""
exclude: NotRequired[bool]
class ChatStreamCompletionCreateParamsReasoning(BaseModel):
r"""Reasoning configuration"""
enabled: Optional[bool] = None
r"""Enables reasoning with default settings. Only work for some models."""
effort: OptionalNullable[ChatStreamCompletionCreateParamsEffort] = UNSET
r"""OpenAI-style reasoning effort setting"""
max_tokens: OptionalNullable[float] = UNSET
r"""non-OpenAI-style reasoning effort setting"""
exclude: Optional[bool] = False
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["enabled", "effort", "max_tokens", "exclude"]
nullable_fields = ["effort", "max_tokens"]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
ChatStreamCompletionCreateParamsTypePython = Literal["python"]
class ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict(TypedDict):
r"""Python code response format"""
type: ChatStreamCompletionCreateParamsTypePython
class ChatStreamCompletionCreateParamsResponseFormatPython(BaseModel):
r"""Python code response format"""
type: ChatStreamCompletionCreateParamsTypePython
ChatStreamCompletionCreateParamsTypeGrammar = Literal["grammar"]
class ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict(TypedDict):
r"""Custom grammar response format"""
type: ChatStreamCompletionCreateParamsTypeGrammar
grammar: str
r"""Custom grammar for text generation"""
class ChatStreamCompletionCreateParamsResponseFormatGrammar(BaseModel):
r"""Custom grammar response format"""
type: ChatStreamCompletionCreateParamsTypeGrammar
grammar: str
r"""Custom grammar for text generation"""
ChatStreamCompletionCreateParamsTypeJSONSchema = Literal["json_schema"]
class ChatStreamCompletionCreateParamsJSONSchemaTypedDict(TypedDict):
name: str
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
description: NotRequired[str]
r"""Schema description for the model"""
schema_: NotRequired[ResponseFormatJSONSchemaSchemaTypedDict]
r"""The schema for the response format, described as a JSON Schema object"""
strict: NotRequired[Nullable[bool]]
r"""Enable strict schema adherence"""
class ChatStreamCompletionCreateParamsJSONSchema(BaseModel):
name: str
r"""Schema name (a-z, A-Z, 0-9, underscores, dashes, max 64 chars)"""
description: Optional[str] = None
r"""Schema description for the model"""
schema_: Annotated[
Optional[ResponseFormatJSONSchemaSchema], pydantic.Field(alias="schema")
] = None
r"""The schema for the response format, described as a JSON Schema object"""
strict: OptionalNullable[bool] = UNSET
r"""Enable strict schema adherence"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["description", "schema", "strict"]
nullable_fields = ["strict"]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
class ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict(TypedDict):
r"""JSON Schema response format for structured outputs"""
type: ChatStreamCompletionCreateParamsTypeJSONSchema
json_schema: ChatStreamCompletionCreateParamsJSONSchemaTypedDict
class ChatStreamCompletionCreateParamsResponseFormatJSONSchema(BaseModel):
r"""JSON Schema response format for structured outputs"""
type: ChatStreamCompletionCreateParamsTypeJSONSchema
json_schema: ChatStreamCompletionCreateParamsJSONSchema
ChatStreamCompletionCreateParamsTypeJSONObject = Literal["json_object"]
class ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict(TypedDict):
r"""JSON object response format"""
type: ChatStreamCompletionCreateParamsTypeJSONObject
class ChatStreamCompletionCreateParamsResponseFormatJSONObject(BaseModel):
r"""JSON object response format"""
type: ChatStreamCompletionCreateParamsTypeJSONObject
ChatStreamCompletionCreateParamsTypeText = Literal["text"]
class ChatStreamCompletionCreateParamsResponseFormatTextTypedDict(TypedDict):
r"""Default text response format"""
type: ChatStreamCompletionCreateParamsTypeText
class ChatStreamCompletionCreateParamsResponseFormatText(BaseModel):
r"""Default text response format"""
type: ChatStreamCompletionCreateParamsTypeText
ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict",
Union[
ChatStreamCompletionCreateParamsResponseFormatTextTypedDict,
ChatStreamCompletionCreateParamsResponseFormatJSONObjectTypedDict,
ChatStreamCompletionCreateParamsResponseFormatPythonTypedDict,
ChatStreamCompletionCreateParamsResponseFormatJSONSchemaTypedDict,
ChatStreamCompletionCreateParamsResponseFormatGrammarTypedDict,
],
)
r"""Response format configuration"""
ChatStreamCompletionCreateParamsResponseFormatUnion = TypeAliasType(
"ChatStreamCompletionCreateParamsResponseFormatUnion",
Union[
ChatStreamCompletionCreateParamsResponseFormatText,
ChatStreamCompletionCreateParamsResponseFormatJSONObject,
ChatStreamCompletionCreateParamsResponseFormatPython,
ChatStreamCompletionCreateParamsResponseFormatJSONSchema,
ChatStreamCompletionCreateParamsResponseFormatGrammar,
],
)
r"""Response format configuration"""
ChatStreamCompletionCreateParamsStopTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsStopTypedDict", Union[str, List[str], Any]
)
r"""Stop sequences (up to 4)"""
ChatStreamCompletionCreateParamsStop = TypeAliasType(
"ChatStreamCompletionCreateParamsStop", Union[str, List[str], Any]
)
r"""Stop sequences (up to 4)"""
class ChatStreamCompletionCreateParamsStreamOptionsTypedDict(TypedDict):
r"""Streaming configuration options"""
include_usage: NotRequired[bool]
r"""Include usage information in streaming response"""
class ChatStreamCompletionCreateParamsStreamOptions(BaseModel):
r"""Streaming configuration options"""
include_usage: Optional[bool] = None
r"""Include usage information in streaming response"""
ChatStreamCompletionCreateParamsReasoningEffort = Literal[
"high", "medium", "low", "minimal"
]
r"""Reasoning effort"""
ChatStreamCompletionCreateParamsDataCollection = Literal["deny", "allow"]
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.
"""
ChatStreamCompletionCreateParamsOrderEnum = 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",
"Cloudflare",
"Cohere",
"CrofAI",
"Crusoe",
"DeepInfra",
"DeepSeek",
"Enfer",
"Featherless",
"Fireworks",
"Friendli",
"GMICloud",
"Google",
"Google AI Studio",
"Groq",
"Hyperbolic",
"Inception",
"InferenceNet",
"Infermatic",
"Inflection",
"InoCloud",
"Kluster",
"Lambda",
"Liquid",
"Mancer 2",
"Meta",
"Minimax",
"Mistral",
"Moonshot AI",
"Morph",
"NCompass",
"Nebius",
"NextBit",
"Nineteen",
"Novita",
"OpenAI",
"OpenInference",
"Parasail",
"Perplexity",
"Phala",
"SambaNova",
"Stealth",
"Switchpoint",
"Targon",
"Together",
"Ubicloud",
"Venice",
"WandB",
"xAI",
"Z.AI",
]
ChatStreamCompletionCreateParamsOrderUnionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsOrderUnionTypedDict",
Union[ChatStreamCompletionCreateParamsOrderEnum, str],
)
ChatStreamCompletionCreateParamsOrderUnion = TypeAliasType(
"ChatStreamCompletionCreateParamsOrderUnion",
Union[ChatStreamCompletionCreateParamsOrderEnum, str],
)
ChatStreamCompletionCreateParamsOnlyEnum = 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",
"Cloudflare",
"Cohere",
"CrofAI",
"Crusoe",
"DeepInfra",
"DeepSeek",
"Enfer",
"Featherless",
"Fireworks",
"Friendli",
"GMICloud",
"Google",
"Google AI Studio",
"Groq",
"Hyperbolic",
"Inception",
"InferenceNet",
"Infermatic",
"Inflection",
"InoCloud",
"Kluster",
"Lambda",
"Liquid",
"Mancer 2",
"Meta",
"Minimax",
"Mistral",
"Moonshot AI",
"Morph",
"NCompass",
"Nebius",
"NextBit",
"Nineteen",
"Novita",
"OpenAI",
"OpenInference",
"Parasail",
"Perplexity",
"Phala",
"SambaNova",
"Stealth",
"Switchpoint",
"Targon",
"Together",
"Ubicloud",
"Venice",
"WandB",
"xAI",
"Z.AI",
]
ChatStreamCompletionCreateParamsOnlyUnionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsOnlyUnionTypedDict",
Union[ChatStreamCompletionCreateParamsOnlyEnum, str],
)
ChatStreamCompletionCreateParamsOnlyUnion = TypeAliasType(
"ChatStreamCompletionCreateParamsOnlyUnion",
Union[ChatStreamCompletionCreateParamsOnlyEnum, str],
)
ChatStreamCompletionCreateParamsIgnoreEnum = 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",
"Cloudflare",
"Cohere",
"CrofAI",
"Crusoe",
"DeepInfra",
"DeepSeek",
"Enfer",
"Featherless",
"Fireworks",
"Friendli",
"GMICloud",
"Google",
"Google AI Studio",
"Groq",
"Hyperbolic",
"Inception",
"InferenceNet",
"Infermatic",
"Inflection",
"InoCloud",
"Kluster",
"Lambda",
"Liquid",
"Mancer 2",
"Meta",
"Minimax",
"Mistral",
"Moonshot AI",
"Morph",
"NCompass",
"Nebius",
"NextBit",
"Nineteen",
"Novita",
"OpenAI",
"OpenInference",
"Parasail",
"Perplexity",
"Phala",
"SambaNova",
"Stealth",
"Switchpoint",
"Targon",
"Together",
"Ubicloud",
"Venice",
"WandB",
"xAI",
"Z.AI",
]
ChatStreamCompletionCreateParamsIgnoreUnionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsIgnoreUnionTypedDict",
Union[ChatStreamCompletionCreateParamsIgnoreEnum, str],
)
ChatStreamCompletionCreateParamsIgnoreUnion = TypeAliasType(
"ChatStreamCompletionCreateParamsIgnoreUnion",
Union[ChatStreamCompletionCreateParamsIgnoreEnum, str],
)
ChatStreamCompletionCreateParamsQuantization = Literal[
"int4", "int8", "fp4", "fp6", "fp8", "fp16", "bf16", "fp32", "unknown"
]
ChatStreamCompletionCreateParamsSort = Literal["price", "throughput", "latency"]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
ChatStreamCompletionCreateParamsPromptTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsPromptTypedDict", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsPrompt = TypeAliasType(
"ChatStreamCompletionCreateParamsPrompt", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsCompletionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsCompletionTypedDict", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsCompletion = TypeAliasType(
"ChatStreamCompletionCreateParamsCompletion", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsImageTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsImageTypedDict", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsImage = TypeAliasType(
"ChatStreamCompletionCreateParamsImage", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsAudioTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsAudioTypedDict", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsAudio = TypeAliasType(
"ChatStreamCompletionCreateParamsAudio", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsRequestTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsRequestTypedDict", Union[float, str, Any]
)
ChatStreamCompletionCreateParamsRequest = TypeAliasType(
"ChatStreamCompletionCreateParamsRequest", Union[float, str, Any]
)
class ChatStreamCompletionCreateParamsMaxPriceTypedDict(TypedDict):
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
prompt: NotRequired[ChatStreamCompletionCreateParamsPromptTypedDict]
completion: NotRequired[ChatStreamCompletionCreateParamsCompletionTypedDict]
image: NotRequired[ChatStreamCompletionCreateParamsImageTypedDict]
audio: NotRequired[ChatStreamCompletionCreateParamsAudioTypedDict]
request: NotRequired[ChatStreamCompletionCreateParamsRequestTypedDict]
class ChatStreamCompletionCreateParamsMaxPrice(BaseModel):
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
prompt: Optional[ChatStreamCompletionCreateParamsPrompt] = None
completion: Optional[ChatStreamCompletionCreateParamsCompletion] = None
image: Optional[ChatStreamCompletionCreateParamsImage] = None
audio: Optional[ChatStreamCompletionCreateParamsAudio] = None
request: Optional[ChatStreamCompletionCreateParamsRequest] = None
class ChatStreamCompletionCreateParamsProviderTypedDict(TypedDict):
r"""When multiple model providers are available, optionally indicate your routing preference."""
allow_fallbacks: NotRequired[Nullable[bool]]
r"""Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
"""
require_parameters: NotRequired[Nullable[bool]]
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
data_collection: NotRequired[
Nullable[ChatStreamCompletionCreateParamsDataCollection]
]
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
order: NotRequired[
Nullable[List[ChatStreamCompletionCreateParamsOrderUnionTypedDict]]
]
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
only: NotRequired[
Nullable[List[ChatStreamCompletionCreateParamsOnlyUnionTypedDict]]
]
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
ignore: NotRequired[
Nullable[List[ChatStreamCompletionCreateParamsIgnoreUnionTypedDict]]
]
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: NotRequired[
Nullable[List[ChatStreamCompletionCreateParamsQuantization]]
]
r"""A list of quantization levels to filter the provider by."""
sort: NotRequired[Nullable[ChatStreamCompletionCreateParamsSort]]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: NotRequired[ChatStreamCompletionCreateParamsMaxPriceTypedDict]
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
class ChatStreamCompletionCreateParamsProvider(BaseModel):
r"""When multiple model providers are available, optionally indicate your routing preference."""
allow_fallbacks: OptionalNullable[bool] = UNSET
r"""Whether to allow backup providers to serve requests
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
"""
require_parameters: OptionalNullable[bool] = UNSET
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
data_collection: OptionalNullable[
ChatStreamCompletionCreateParamsDataCollection
] = UNSET
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
- allow: (default) allow providers which store user data non-transiently and may train on it
- deny: use only providers which do not collect user data.
"""
order: OptionalNullable[List[ChatStreamCompletionCreateParamsOrderUnion]] = UNSET
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
only: OptionalNullable[List[ChatStreamCompletionCreateParamsOnlyUnion]] = UNSET
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
ignore: OptionalNullable[List[ChatStreamCompletionCreateParamsIgnoreUnion]] = UNSET
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
quantizations: OptionalNullable[
List[ChatStreamCompletionCreateParamsQuantization]
] = UNSET
r"""A list of quantization levels to filter the provider by."""
sort: OptionalNullable[ChatStreamCompletionCreateParamsSort] = UNSET
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
max_price: Optional[ChatStreamCompletionCreateParamsMaxPrice] = None
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"order",
"only",
"ignore",
"quantizations",
"sort",
"max_price",
]
nullable_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"order",
"only",
"ignore",
"quantizations",
"sort",
]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
ChatStreamCompletionCreateParamsIDFileParser = Literal["file-parser"]
ChatStreamCompletionCreateParamsPdfEngine = Literal["mistral-ocr", "pdf-text", "native"]
class ChatStreamCompletionCreateParamsPdfTypedDict(TypedDict):
engine: NotRequired[ChatStreamCompletionCreateParamsPdfEngine]
class ChatStreamCompletionCreateParamsPdf(BaseModel):
engine: Optional[ChatStreamCompletionCreateParamsPdfEngine] = None
class ChatStreamCompletionCreateParamsPluginFileParserTypedDict(TypedDict):
id: ChatStreamCompletionCreateParamsIDFileParser
max_files: NotRequired[float]
pdf: NotRequired[ChatStreamCompletionCreateParamsPdfTypedDict]
class ChatStreamCompletionCreateParamsPluginFileParser(BaseModel):
id: ChatStreamCompletionCreateParamsIDFileParser
max_files: Optional[float] = None
pdf: Optional[ChatStreamCompletionCreateParamsPdf] = None
ChatStreamCompletionCreateParamsIDChainOfThought = Literal["chain-of-thought"]
class ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict(TypedDict):
id: ChatStreamCompletionCreateParamsIDChainOfThought
class ChatStreamCompletionCreateParamsPluginChainOfThought(BaseModel):
id: ChatStreamCompletionCreateParamsIDChainOfThought
ChatStreamCompletionCreateParamsIDWeb = Literal["web"]
ChatStreamCompletionCreateParamsEngine = Literal["native", "exa"]
class ChatStreamCompletionCreateParamsPluginWebTypedDict(TypedDict):
id: ChatStreamCompletionCreateParamsIDWeb
max_results: NotRequired[float]
search_prompt: NotRequired[str]
engine: NotRequired[ChatStreamCompletionCreateParamsEngine]
class ChatStreamCompletionCreateParamsPluginWeb(BaseModel):
id: ChatStreamCompletionCreateParamsIDWeb
max_results: Optional[float] = None
search_prompt: Optional[str] = None
engine: Optional[ChatStreamCompletionCreateParamsEngine] = None
ChatStreamCompletionCreateParamsIDModeration = Literal["moderation"]
class ChatStreamCompletionCreateParamsPluginModerationTypedDict(TypedDict):
id: ChatStreamCompletionCreateParamsIDModeration
class ChatStreamCompletionCreateParamsPluginModeration(BaseModel):
id: ChatStreamCompletionCreateParamsIDModeration
ChatStreamCompletionCreateParamsPluginUnionTypedDict = TypeAliasType(
"ChatStreamCompletionCreateParamsPluginUnionTypedDict",
Union[
ChatStreamCompletionCreateParamsPluginModerationTypedDict,
ChatStreamCompletionCreateParamsPluginChainOfThoughtTypedDict,
ChatStreamCompletionCreateParamsPluginFileParserTypedDict,
ChatStreamCompletionCreateParamsPluginWebTypedDict,
],
)
ChatStreamCompletionCreateParamsPluginUnion = TypeAliasType(
"ChatStreamCompletionCreateParamsPluginUnion",
Union[
ChatStreamCompletionCreateParamsPluginModeration,
ChatStreamCompletionCreateParamsPluginChainOfThought,
ChatStreamCompletionCreateParamsPluginFileParser,
ChatStreamCompletionCreateParamsPluginWeb,
],
)
class ChatStreamCompletionCreateParamsTypedDict(TypedDict):
r"""Chat completion request parameters"""
messages: List[ChatCompletionMessageParamTypedDict]
r"""List of messages for the conversation"""
stream: NotRequired[Nullable[bool]]
r"""Enable streaming response"""
model: NotRequired[str]
r"""Model to use for completion"""
frequency_penalty: NotRequired[Nullable[float]]
r"""Frequency penalty (-2.0 to 2.0)"""
logit_bias: NotRequired[Nullable[Dict[str, float]]]
r"""Token logit bias adjustments"""
logprobs: NotRequired[Nullable[bool]]
r"""Return log probabilities"""
top_logprobs: NotRequired[Nullable[float]]
r"""Number of top log probabilities to return (0-20)"""
max_completion_tokens: NotRequired[Nullable[float]]
r"""Maximum tokens in completion"""
max_tokens: NotRequired[Nullable[float]]
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
metadata: NotRequired[Dict[str, str]]
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
presence_penalty: NotRequired[Nullable[float]]
r"""Presence penalty (-2.0 to 2.0)"""
reasoning: NotRequired[Nullable[ChatStreamCompletionCreateParamsReasoningTypedDict]]
r"""Reasoning configuration"""
response_format: NotRequired[
ChatStreamCompletionCreateParamsResponseFormatUnionTypedDict
]
r"""Response format configuration"""
seed: NotRequired[Nullable[int]]
r"""Random seed for deterministic outputs"""
stop: NotRequired[Nullable[ChatStreamCompletionCreateParamsStopTypedDict]]
r"""Stop sequences (up to 4)"""
stream_options: NotRequired[
Nullable[ChatStreamCompletionCreateParamsStreamOptionsTypedDict]
]
temperature: NotRequired[Nullable[float]]
r"""Sampling temperature (0-2)"""
tool_choice: NotRequired[ChatCompletionToolChoiceOptionTypedDict]
r"""Tool choice configuration"""
tools: NotRequired[List[ChatCompletionToolTypedDict]]
r"""Available tools for function calling"""
top_p: NotRequired[Nullable[float]]
r"""Nucleus sampling parameter (0-1)"""
user: NotRequired[str]
r"""Unique user identifier"""
fallback_models: NotRequired[Nullable[List[str]]]
r"""Order of models to fallback to for this request"""
reasoning_effort: NotRequired[
Nullable[ChatStreamCompletionCreateParamsReasoningEffort]
]
r"""Reasoning effort"""
provider: NotRequired[Nullable[ChatStreamCompletionCreateParamsProviderTypedDict]]
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: NotRequired[List[ChatStreamCompletionCreateParamsPluginUnionTypedDict]]
r"""Plugins you want to enable for this request, including their settings."""
class ChatStreamCompletionCreateParams(BaseModel):
r"""Chat completion request parameters"""
messages: List[ChatCompletionMessageParam]
r"""List of messages for the conversation"""
stream: OptionalNullable[bool] = False
r"""Enable streaming response"""
model: Optional[str] = None
r"""Model to use for completion"""
frequency_penalty: OptionalNullable[float] = UNSET
r"""Frequency penalty (-2.0 to 2.0)"""
logit_bias: OptionalNullable[Dict[str, float]] = UNSET
r"""Token logit bias adjustments"""
logprobs: OptionalNullable[bool] = UNSET
r"""Return log probabilities"""
top_logprobs: OptionalNullable[float] = UNSET
r"""Number of top log probabilities to return (0-20)"""
max_completion_tokens: OptionalNullable[float] = UNSET
r"""Maximum tokens in completion"""
max_tokens: OptionalNullable[float] = UNSET
r"""Maximum tokens (deprecated, use max_completion_tokens)"""
metadata: Optional[Dict[str, str]] = None
r"""Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)"""
presence_penalty: OptionalNullable[float] = UNSET
r"""Presence penalty (-2.0 to 2.0)"""
reasoning: OptionalNullable[ChatStreamCompletionCreateParamsReasoning] = UNSET
r"""Reasoning configuration"""
response_format: Optional[ChatStreamCompletionCreateParamsResponseFormatUnion] = (
None
)
r"""Response format configuration"""
seed: OptionalNullable[int] = UNSET
r"""Random seed for deterministic outputs"""
stop: OptionalNullable[ChatStreamCompletionCreateParamsStop] = UNSET
r"""Stop sequences (up to 4)"""
stream_options: OptionalNullable[ChatStreamCompletionCreateParamsStreamOptions] = (
UNSET
)
temperature: OptionalNullable[float] = 1
r"""Sampling temperature (0-2)"""
tool_choice: Optional[ChatCompletionToolChoiceOption] = None
r"""Tool choice configuration"""
tools: Optional[List[ChatCompletionTool]] = None
r"""Available tools for function calling"""
top_p: OptionalNullable[float] = 1
r"""Nucleus sampling parameter (0-1)"""
user: Optional[str] = None
r"""Unique user identifier"""
fallback_models: Annotated[
OptionalNullable[List[str]], pydantic.Field(alias="models")
] = UNSET
r"""Order of models to fallback to for this request"""
reasoning_effort: OptionalNullable[
ChatStreamCompletionCreateParamsReasoningEffort
] = UNSET
r"""Reasoning effort"""
provider: OptionalNullable[ChatStreamCompletionCreateParamsProvider] = UNSET
r"""When multiple model providers are available, optionally indicate your routing preference."""
plugins: Optional[List[ChatStreamCompletionCreateParamsPluginUnion]] = None
r"""Plugins you want to enable for this request, including their settings."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"stream",
"model",
"frequency_penalty",
"logit_bias",
"logprobs",
"top_logprobs",
"max_completion_tokens",
"max_tokens",
"metadata",
"presence_penalty",
"reasoning",
"response_format",
"seed",
"stop",
"stream_options",
"temperature",
"tool_choice",
"tools",
"top_p",
"user",
"fallback_models",
"reasoning_effort",
"provider",
"plugins",
]
nullable_fields = [
"stream",
"frequency_penalty",
"logit_bias",
"logprobs",
"top_logprobs",
"max_completion_tokens",
"max_tokens",
"presence_penalty",
"reasoning",
"seed",
"stop",
"stream_options",
"temperature",
"top_p",
"fallback_models",
"reasoning_effort",
"provider",
]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m