fix: add overlay to remove nullable from pagination offset params (#121)

This commit is contained in:
Matt Apperson
2026-04-14 12:48:15 -04:00
committed by GitHub
parent 2bba049182
commit b2386114cd
440 changed files with 36150 additions and 32168 deletions
+115 -234
View File
@@ -1,13 +1,14 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .datacollection import DataCollection
from .preferredmaxlatency import PreferredMaxLatency, PreferredMaxLatencyTypedDict
from .preferredminthroughput import (
PreferredMinThroughput,
PreferredMinThroughputTypedDict,
)
from .providername import ProviderName
from .providersort import ProviderSort
from .providersortconfig import ProviderSortConfig, ProviderSortConfigTypedDict
from .quantization import Quantization
from openrouter.types import (
BaseModel,
@@ -20,218 +21,96 @@ from openrouter.types import (
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 import Any, List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
ProviderPreferencesOrderTypedDict = TypeAliasType(
"ProviderPreferencesOrderTypedDict", Union[ProviderName, str]
)
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.
"""
ProviderPreferencesOrder = TypeAliasType(
"ProviderPreferencesOrder",
IgnoreTypedDict = TypeAliasType("IgnoreTypedDict", Union[ProviderName, str])
Ignore = TypeAliasType(
"Ignore",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ProviderPreferencesOnlyTypedDict = TypeAliasType(
"ProviderPreferencesOnlyTypedDict", Union[ProviderName, str]
)
ProviderPreferencesOnly = TypeAliasType(
"ProviderPreferencesOnly",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ProviderPreferencesIgnoreTypedDict = TypeAliasType(
"ProviderPreferencesIgnoreTypedDict", Union[ProviderName, str]
)
ProviderPreferencesIgnore = TypeAliasType(
"ProviderPreferencesIgnore",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
ProviderPreferencesSortEnum = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
ProviderPreferencesProviderSortConfigEnum = Literal[
"price",
"throughput",
"latency",
"exacto",
]
ProviderPreferencesBy = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
r"""The provider sorting strategy (price, throughput, latency)"""
ProviderPreferencesPartition = Union[
Literal[
"model",
"none",
],
UnrecognizedStr,
]
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
class ProviderPreferencesProviderSortConfigTypedDict(TypedDict):
by: NotRequired[Nullable[ProviderPreferencesBy]]
r"""The provider sorting strategy (price, throughput, latency)"""
partition: NotRequired[Nullable[ProviderPreferencesPartition]]
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
class ProviderPreferencesProviderSortConfig(BaseModel):
by: Annotated[
OptionalNullable[ProviderPreferencesBy],
PlainValidator(validate_open_enum(False)),
] = UNSET
r"""The provider sorting strategy (price, throughput, latency)"""
partition: Annotated[
OptionalNullable[ProviderPreferencesPartition],
PlainValidator(validate_open_enum(False)),
] = UNSET
r"""Partitioning strategy for sorting: \"model\" (default) groups endpoints by model before sorting (fallback models remain fallbacks), \"none\" sorts all endpoints together regardless of model."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["by", "partition"]
nullable_fields = ["by", "partition"]
null_default_fields = []
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k)
serialized.pop(k, None)
optional_nullable = k in optional_fields and k in nullable_fields
is_set = (
self.__pydantic_fields_set__.intersection({n})
or k in null_default_fields
) # pylint: disable=no-member
if val is not None and val != UNSET_SENTINEL:
m[k] = val
elif val != UNSET_SENTINEL and (
not k in optional_fields or (optional_nullable and is_set)
):
m[k] = val
return m
ProviderPreferencesProviderSortConfigUnionTypedDict = TypeAliasType(
"ProviderPreferencesProviderSortConfigUnionTypedDict",
Union[
ProviderPreferencesProviderSortConfigTypedDict,
ProviderPreferencesProviderSortConfigEnum,
],
)
ProviderPreferencesProviderSortConfigUnion = TypeAliasType(
"ProviderPreferencesProviderSortConfigUnion",
Union[
ProviderPreferencesProviderSortConfig, ProviderPreferencesProviderSortConfigEnum
],
)
ProviderPreferencesProviderSort = Union[
Literal[
"price",
"throughput",
"latency",
"exacto",
],
UnrecognizedStr,
]
r"""The provider sorting strategy (price, throughput, latency)"""
ProviderPreferencesSortUnionTypedDict = TypeAliasType(
"ProviderPreferencesSortUnionTypedDict",
Union[
ProviderPreferencesProviderSort,
ProviderPreferencesProviderSortConfigUnionTypedDict,
ProviderPreferencesSortEnum,
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
ProviderPreferencesSortUnion = TypeAliasType(
"ProviderPreferencesSortUnion",
Union[
Annotated[
ProviderPreferencesProviderSort, PlainValidator(validate_open_enum(False))
],
ProviderPreferencesProviderSortConfigUnion,
Annotated[
ProviderPreferencesSortEnum, PlainValidator(validate_open_enum(False))
],
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
class ProviderPreferencesMaxPriceTypedDict(TypedDict):
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[str]
r"""Price per million prompt tokens"""
audio: NotRequired[str]
completion: NotRequired[str]
image: NotRequired[str]
audio: NotRequired[str]
prompt: NotRequired[str]
r"""Price per million prompt tokens"""
request: NotRequired[str]
class ProviderPreferencesMaxPrice(BaseModel):
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[str] = None
r"""Price per million prompt tokens"""
audio: Optional[str] = None
completion: Optional[str] = None
image: Optional[str] = None
audio: Optional[str] = None
prompt: Optional[str] = None
r"""Price per million prompt tokens"""
request: Optional[str] = None
OnlyTypedDict = TypeAliasType("OnlyTypedDict", Union[ProviderName, str])
Only = TypeAliasType(
"Only",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
OrderTypedDict = TypeAliasType("OrderTypedDict", Union[ProviderName, str])
Order = TypeAliasType(
"Order",
Union[Annotated[ProviderName, PlainValidator(validate_open_enum(False))], str],
)
SortTypedDict = TypeAliasType(
"SortTypedDict", Union[ProviderSortConfigTypedDict, ProviderSort, Any]
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
Sort = TypeAliasType(
"Sort",
Union[
ProviderSortConfig,
Annotated[ProviderSort, PlainValidator(validate_open_enum(False))],
Any,
],
)
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
class ProviderPreferencesTypedDict(TypedDict):
r"""Provider routing preferences for the request."""
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
@@ -239,37 +118,38 @@ class ProviderPreferencesTypedDict(TypedDict):
- 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[ProviderPreferencesOrderTypedDict]]]
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[ProviderPreferencesOnlyTypedDict]]]
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[ProviderPreferencesIgnoreTypedDict]]]
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[ProviderPreferencesSortUnionTypedDict]]
max_price: NotRequired[ProviderPreferencesMaxPriceTypedDict]
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."""
preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
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."""
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."""
preferred_max_latency: NotRequired[Nullable[PreferredMaxLatencyTypedDict]]
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_min_throughput: NotRequired[Nullable[PreferredMinThroughputTypedDict]]
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
quantizations: NotRequired[Nullable[List[Quantization]]]
r"""A list of quantization levels to filter the provider by."""
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."""
sort: NotRequired[Nullable[SortTypedDict]]
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
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."""
class ProviderPreferences(BaseModel):
r"""Provider routing preferences for the request."""
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
@@ -278,9 +158,6 @@ class ProviderPreferences(BaseModel):
"""
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
@@ -290,67 +167,71 @@ class ProviderPreferences(BaseModel):
- 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[ProviderPreferencesOrder]] = 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."""
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."""
only: OptionalNullable[List[ProviderPreferencesOnly]] = UNSET
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."""
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[ProviderPreferencesIgnore]] = UNSET
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
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."""
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = UNSET
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
quantizations: OptionalNullable[
List[Annotated[Quantization, PlainValidator(validate_open_enum(False))]]
] = UNSET
r"""A list of quantization levels to filter the provider by."""
sort: OptionalNullable[ProviderPreferencesSortUnion] = UNSET
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."""
max_price: Optional[ProviderPreferencesMaxPrice] = None
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
sort: OptionalNullable[Sort] = UNSET
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
preferred_min_throughput: OptionalNullable[PreferredMinThroughput] = UNSET
r"""Preferred minimum throughput (in tokens per second). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints below the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
preferred_max_latency: OptionalNullable[PreferredMaxLatency] = UNSET
r"""Preferred maximum latency (in seconds). Can be a number (applies to p50) or an object with percentile-specific cutoffs. Endpoints above the threshold(s) may still be used, but are deprioritized in routing. When using fallback models, this may cause a fallback model to be used instead of the primary model if it meets the threshold."""
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."""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"max_price",
"preferred_min_throughput",
"only",
"order",
"preferred_max_latency",
"preferred_min_throughput",
"quantizations",
"require_parameters",
"sort",
"zdr",
]
nullable_fields = [
"allow_fallbacks",
"require_parameters",
"data_collection",
"zdr",
"enforce_distillable_text",
"order",
"only",
"ignore",
"quantizations",
"sort",
"preferred_min_throughput",
"only",
"order",
"preferred_max_latency",
"preferred_min_throughput",
"quantizations",
"require_parameters",
"sort",
"zdr",
]
null_default_fields = []