feat: regenerate SDK with updated OpenAPI spec

Speakeasy regeneration with latest schema changes including
type renames and new server tool models.
This commit is contained in:
OpenRouter SDK Bot
2026-03-27 15:18:14 -04:00
parent e72a84e82d
commit 5ab44f08f0
375 changed files with 36229 additions and 5480 deletions
+206 -156
View File
@@ -20,28 +20,27 @@ class Chat(BaseSDK):
def send(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -70,30 +69,34 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> components.ChatResponse:
) -> components.ChatResult:
r"""Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
@@ -102,12 +105,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -116,7 +121,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -132,7 +137,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -144,28 +151,27 @@ class Chat(BaseSDK):
def send(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -194,30 +200,34 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> eventstreaming.EventStream[components.ChatStreamingResponseChunk]:
) -> eventstreaming.EventStream[components.ChatStreamChunk]:
r"""Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
@@ -226,12 +236,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -240,7 +252,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -256,7 +268,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -267,28 +281,27 @@ class Chat(BaseSDK):
def send(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -317,25 +330,29 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
@@ -349,12 +366,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -363,7 +382,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -379,7 +398,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -398,20 +419,23 @@ class Chat(BaseSDK):
request = operations.SendChatCompletionRequestRequest(
http_referer=http_referer,
x_title=x_title,
chat_generation_params=components.ChatGenerationParams(
x_open_router_title=x_open_router_title,
x_open_router_categories=x_open_router_categories,
chat_request=components.ChatRequest(
provider=utils.get_pydantic_model(
provider, OptionalNullable[components.ChatGenerationParamsProvider]
provider, OptionalNullable[components.ChatRequestProvider]
),
plugins=utils.get_pydantic_model(
plugins, Optional[List[components.ChatGenerationParamsPluginUnion]]
plugins, Optional[List[components.ChatRequestPluginUnion]]
),
user=user,
session_id=session_id,
trace=utils.get_pydantic_model(
trace, Optional[components.ChatGenerationParamsTrace]
trace, Optional[components.ChatRequestTrace]
),
messages=utils.get_pydantic_model(
messages, List[components.ChatMessages]
),
messages=utils.get_pydantic_model(messages, List[components.Message]),
model=model,
models=models,
frequency_penalty=frequency_penalty,
@@ -437,17 +461,21 @@ class Chat(BaseSDK):
temperature=temperature,
parallel_tool_calls=parallel_tool_calls,
tool_choice=utils.get_pydantic_model(
tool_choice, Optional[components.ToolChoiceOption]
tool_choice, Optional[components.ChatToolChoice]
),
tools=utils.get_pydantic_model(
tools, Optional[List[components.ToolDefinitionJSON]]
tools, Optional[List[components.ChatFunctionTool]]
),
top_p=top_p,
debug=utils.get_pydantic_model(
debug, Optional[components.DebugOptions]
debug, Optional[components.ChatDebugOptions]
),
image_config=image_config,
modalities=modalities,
cache_control=utils.get_pydantic_model(
cache_control, Optional[components.CacheControl]
),
service_tier=service_tier,
),
)
@@ -465,15 +493,12 @@ class Chat(BaseSDK):
http_headers=http_headers,
_globals=operations.SendChatCompletionRequestGlobals(
http_referer=self.sdk_configuration.globals.http_referer,
x_title=self.sdk_configuration.globals.x_title,
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
),
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
request.chat_generation_params,
False,
False,
"json",
components.ChatGenerationParams,
request.chat_request, False, False, "json", components.ChatRequest
),
allow_empty_value=None,
timeout_ms=timeout_ms,
@@ -523,7 +548,7 @@ class Chat(BaseSDK):
if utils.match_response(http_res, "200", "application/json"):
http_res_text = utils.stream_to_text(http_res)
return unmarshal_json_response(
components.ChatResponse, http_res, http_res_text
components.ChatResult, http_res, http_res_text
)
if utils.match_response(http_res, "200", "text/event-stream"):
return eventstreaming.EventStream(
@@ -652,28 +677,27 @@ class Chat(BaseSDK):
async def send_async(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -702,30 +726,34 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> components.ChatResponse:
) -> components.ChatResult:
r"""Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
@@ -734,12 +762,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -748,7 +778,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -764,7 +794,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -776,28 +808,27 @@ class Chat(BaseSDK):
async def send_async(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -826,30 +857,34 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> eventstreaming.EventStreamAsync[components.ChatStreamingResponseChunk]:
) -> eventstreaming.EventStreamAsync[components.ChatStreamChunk]:
r"""Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
@@ -858,12 +893,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -872,7 +909,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -888,7 +925,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -899,28 +938,27 @@ class Chat(BaseSDK):
async def send_async(
self,
*,
messages: Union[List[components.Message], List[components.MessageTypedDict]],
messages: Union[
List[components.ChatMessages], List[components.ChatMessagesTypedDict]
],
http_referer: Optional[str] = None,
x_title: Optional[str] = None,
x_open_router_title: Optional[str] = None,
x_open_router_categories: Optional[str] = None,
provider: OptionalNullable[
Union[
components.ChatGenerationParamsProvider,
components.ChatGenerationParamsProviderTypedDict,
components.ChatRequestProvider, components.ChatRequestProviderTypedDict
]
] = UNSET,
plugins: Optional[
Union[
List[components.ChatGenerationParamsPluginUnion],
List[components.ChatGenerationParamsPluginUnionTypedDict],
List[components.ChatRequestPluginUnion],
List[components.ChatRequestPluginUnionTypedDict],
]
] = None,
user: Optional[str] = None,
session_id: Optional[str] = None,
trace: Optional[
Union[
components.ChatGenerationParamsTrace,
components.ChatGenerationParamsTraceTypedDict,
]
Union[components.ChatRequestTrace, components.ChatRequestTraceTypedDict]
] = None,
model: Optional[str] = None,
models: Optional[List[str]] = None,
@@ -949,25 +987,29 @@ class Chat(BaseSDK):
temperature: OptionalNullable[float] = 1,
parallel_tool_calls: OptionalNullable[bool] = UNSET,
tool_choice: Optional[
Union[components.ToolChoiceOption, components.ToolChoiceOptionTypedDict]
Union[components.ChatToolChoice, components.ChatToolChoiceTypedDict]
] = None,
tools: Optional[
Union[
List[components.ToolDefinitionJSON],
List[components.ToolDefinitionJSONTypedDict],
List[components.ChatFunctionTool],
List[components.ChatFunctionToolTypedDict],
]
] = None,
top_p: OptionalNullable[float] = 1,
debug: Optional[
Union[components.DebugOptions, components.DebugOptionsTypedDict]
Union[components.ChatDebugOptions, components.ChatDebugOptionsTypedDict]
] = None,
image_config: Optional[
Union[
Dict[str, components.ChatGenerationParamsImageConfig],
Dict[str, components.ChatGenerationParamsImageConfigTypedDict],
Dict[str, components.ChatRequestImageConfig],
Dict[str, components.ChatRequestImageConfigTypedDict],
]
] = None,
modalities: Optional[List[components.Modality]] = None,
cache_control: Optional[
Union[components.CacheControl, components.CacheControlTypedDict]
] = None,
service_tier: OptionalNullable[components.ChatRequestServiceTier] = UNSET,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
@@ -981,12 +1023,14 @@ class Chat(BaseSDK):
:param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
:param x_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
:param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
:param provider: When multiple model providers are available, optionally indicate your routing preference.
:param plugins: Plugins you want to enable for this request, including their settings.
:param user: Unique user identifier
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 128 characters.
:param session_id: A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
:param trace: Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
:param model: Model to use for completion
:param models: Models to use for completion
@@ -995,7 +1039,7 @@ class Chat(BaseSDK):
:param logprobs: Return log probabilities
:param top_logprobs: Number of top log probabilities to return (0-20)
:param max_completion_tokens: Maximum tokens in completion
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens)
:param max_tokens: Maximum tokens (deprecated, use max_completion_tokens). Note: some providers enforce a minimum of 16.
:param metadata: Key-value pairs for additional object information (max 16 pairs, 64 char keys, 512 char values)
:param presence_penalty: Presence penalty (-2.0 to 2.0)
:param reasoning: Configuration options for reasoning models
@@ -1011,7 +1055,9 @@ class Chat(BaseSDK):
:param top_p: Nucleus sampling parameter (0-1)
:param debug: Debug options for inspecting request transformations (streaming only)
:param image_config: Provider-specific image configuration options. Keys and values vary by model/provider. See https://openrouter.ai/docs/guides/overview/multimodal/image-generation for more details.
:param modalities: Output modalities for the response. Supported values are \"text\" and \"image\".
:param modalities: Output modalities for the response. Supported values are \"text\", \"image\", and \"audio\".
:param cache_control: Enable automatic prompt caching. When set, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
:param service_tier: The service tier to use for processing this request.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1030,20 +1076,23 @@ class Chat(BaseSDK):
request = operations.SendChatCompletionRequestRequest(
http_referer=http_referer,
x_title=x_title,
chat_generation_params=components.ChatGenerationParams(
x_open_router_title=x_open_router_title,
x_open_router_categories=x_open_router_categories,
chat_request=components.ChatRequest(
provider=utils.get_pydantic_model(
provider, OptionalNullable[components.ChatGenerationParamsProvider]
provider, OptionalNullable[components.ChatRequestProvider]
),
plugins=utils.get_pydantic_model(
plugins, Optional[List[components.ChatGenerationParamsPluginUnion]]
plugins, Optional[List[components.ChatRequestPluginUnion]]
),
user=user,
session_id=session_id,
trace=utils.get_pydantic_model(
trace, Optional[components.ChatGenerationParamsTrace]
trace, Optional[components.ChatRequestTrace]
),
messages=utils.get_pydantic_model(
messages, List[components.ChatMessages]
),
messages=utils.get_pydantic_model(messages, List[components.Message]),
model=model,
models=models,
frequency_penalty=frequency_penalty,
@@ -1069,17 +1118,21 @@ class Chat(BaseSDK):
temperature=temperature,
parallel_tool_calls=parallel_tool_calls,
tool_choice=utils.get_pydantic_model(
tool_choice, Optional[components.ToolChoiceOption]
tool_choice, Optional[components.ChatToolChoice]
),
tools=utils.get_pydantic_model(
tools, Optional[List[components.ToolDefinitionJSON]]
tools, Optional[List[components.ChatFunctionTool]]
),
top_p=top_p,
debug=utils.get_pydantic_model(
debug, Optional[components.DebugOptions]
debug, Optional[components.ChatDebugOptions]
),
image_config=image_config,
modalities=modalities,
cache_control=utils.get_pydantic_model(
cache_control, Optional[components.CacheControl]
),
service_tier=service_tier,
),
)
@@ -1097,15 +1150,12 @@ class Chat(BaseSDK):
http_headers=http_headers,
_globals=operations.SendChatCompletionRequestGlobals(
http_referer=self.sdk_configuration.globals.http_referer,
x_title=self.sdk_configuration.globals.x_title,
x_open_router_title=self.sdk_configuration.globals.x_open_router_title,
x_open_router_categories=self.sdk_configuration.globals.x_open_router_categories,
),
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
request.chat_generation_params,
False,
False,
"json",
components.ChatGenerationParams,
request.chat_request, False, False, "json", components.ChatRequest
),
allow_empty_value=None,
timeout_ms=timeout_ms,
@@ -1155,7 +1205,7 @@ class Chat(BaseSDK):
if utils.match_response(http_res, "200", "application/json"):
http_res_text = await utils.stream_to_text_async(http_res)
return unmarshal_json_response(
components.ChatResponse, http_res, http_res_text
components.ChatResult, http_res, http_res_text
)
if utils.match_response(http_res, "200", "text/event-stream"):
return eventstreaming.EventStreamAsync(