mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
50 lines
2.3 KiB
Python
50 lines
2.3 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||
|
||
from __future__ import annotations
|
||
from openrouter.types import BaseModel, UNSET_SENTINEL
|
||
from pydantic import model_serializer
|
||
from typing import List, Literal, Optional
|
||
from typing_extensions import NotRequired, TypedDict
|
||
|
||
|
||
AutoRouterPluginID = Literal["auto-router",]
|
||
|
||
|
||
class AutoRouterPluginTypedDict(TypedDict):
|
||
id: AutoRouterPluginID
|
||
allowed_models: NotRequired[List[str]]
|
||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||
cost_quality_tradeoff: NotRequired[int]
|
||
r"""Controls cost vs. quality routing tradeoff (0–10). 0 = pure quality (best model regardless of cost), 10 = maximize for cost (cheapest model wins). Intermediate values blend quality and cost signals continuously. Defaults to 7."""
|
||
enabled: NotRequired[bool]
|
||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||
|
||
|
||
class AutoRouterPlugin(BaseModel):
|
||
id: AutoRouterPluginID
|
||
|
||
allowed_models: Optional[List[str]] = None
|
||
r"""List of model patterns to filter which models the auto-router can route between. Supports wildcards (e.g., \"anthropic/*\" matches all Anthropic models). When not specified, uses the default supported models list."""
|
||
|
||
cost_quality_tradeoff: Optional[int] = None
|
||
r"""Controls cost vs. quality routing tradeoff (0–10). 0 = pure quality (best model regardless of cost), 10 = maximize for cost (cheapest model wins). Intermediate values blend quality and cost signals continuously. Defaults to 7."""
|
||
|
||
enabled: Optional[bool] = None
|
||
r"""Set to false to disable the auto-router plugin for this request. Defaults to true."""
|
||
|
||
@model_serializer(mode="wrap")
|
||
def serialize_model(self, handler):
|
||
optional_fields = set(["allowed_models", "cost_quality_tradeoff", "enabled"])
|
||
serialized = handler(self)
|
||
m = {}
|
||
|
||
for n, f in type(self).model_fields.items():
|
||
k = f.alias or n
|
||
val = serialized.get(k, serialized.get(n))
|
||
|
||
if val != UNSET_SENTINEL:
|
||
if val is not None or k not in optional_fields:
|
||
m[k] = val
|
||
|
||
return m
|