mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
fixes
This commit is contained in:
@@ -0,0 +1,502 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from importlib import import_module
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .createauthkeyscode import (
|
||||
CreateAuthKeysCodeCodeChallengeMethod,
|
||||
CreateAuthKeysCodeData,
|
||||
CreateAuthKeysCodeDataTypedDict,
|
||||
CreateAuthKeysCodeRequest,
|
||||
CreateAuthKeysCodeRequestTypedDict,
|
||||
CreateAuthKeysCodeResponse,
|
||||
CreateAuthKeysCodeResponseTypedDict,
|
||||
)
|
||||
from .createcoinbasecharge import (
|
||||
CallData,
|
||||
CallDataTypedDict,
|
||||
CreateCoinbaseChargeData,
|
||||
CreateCoinbaseChargeDataTypedDict,
|
||||
CreateCoinbaseChargeResponse,
|
||||
CreateCoinbaseChargeResponseTypedDict,
|
||||
CreateCoinbaseChargeSecurity,
|
||||
CreateCoinbaseChargeSecurityTypedDict,
|
||||
Metadata,
|
||||
MetadataTypedDict,
|
||||
TransferIntent,
|
||||
TransferIntentTypedDict,
|
||||
Web3Data,
|
||||
Web3DataTypedDict,
|
||||
)
|
||||
from .createembeddings import (
|
||||
CreateEmbeddingsData,
|
||||
CreateEmbeddingsDataTypedDict,
|
||||
CreateEmbeddingsProvider,
|
||||
CreateEmbeddingsProviderTypedDict,
|
||||
CreateEmbeddingsRequest,
|
||||
CreateEmbeddingsRequestTypedDict,
|
||||
CreateEmbeddingsResponse,
|
||||
CreateEmbeddingsResponseBody,
|
||||
CreateEmbeddingsResponseBodyTypedDict,
|
||||
CreateEmbeddingsResponseTypedDict,
|
||||
DataCollection,
|
||||
Embedding,
|
||||
EmbeddingTypedDict,
|
||||
EncodingFormat,
|
||||
EncodingFormatBase64,
|
||||
EncodingFormatFloat,
|
||||
EncodingFormatTypedDict,
|
||||
Ignore,
|
||||
IgnoreTypedDict,
|
||||
Input,
|
||||
InputTypedDict,
|
||||
MaxPrice,
|
||||
MaxPriceTypedDict,
|
||||
Object,
|
||||
ObjectEmbedding,
|
||||
Only,
|
||||
OnlyTypedDict,
|
||||
Order,
|
||||
OrderTypedDict,
|
||||
Sort,
|
||||
Usage,
|
||||
UsageTypedDict,
|
||||
)
|
||||
from .createkeys import (
|
||||
CreateKeysData,
|
||||
CreateKeysDataTypedDict,
|
||||
CreateKeysLimitReset,
|
||||
CreateKeysRequest,
|
||||
CreateKeysRequestTypedDict,
|
||||
CreateKeysResponse,
|
||||
CreateKeysResponseTypedDict,
|
||||
)
|
||||
from .createresponses import (
|
||||
CreateResponsesResponse,
|
||||
CreateResponsesResponseBody,
|
||||
CreateResponsesResponseBodyTypedDict,
|
||||
CreateResponsesResponseTypedDict,
|
||||
)
|
||||
from .deletekeys import (
|
||||
DeleteKeysRequest,
|
||||
DeleteKeysRequestTypedDict,
|
||||
DeleteKeysResponse,
|
||||
DeleteKeysResponseTypedDict,
|
||||
)
|
||||
from .exchangeauthcodeforapikey import (
|
||||
ExchangeAuthCodeForAPIKeyCodeChallengeMethod,
|
||||
ExchangeAuthCodeForAPIKeyRequest,
|
||||
ExchangeAuthCodeForAPIKeyRequestTypedDict,
|
||||
ExchangeAuthCodeForAPIKeyResponse,
|
||||
ExchangeAuthCodeForAPIKeyResponseTypedDict,
|
||||
)
|
||||
from .getcredits import GetCreditsResponse, GetCreditsResponseTypedDict
|
||||
from .getcurrentkey import (
|
||||
GetCurrentKeyData,
|
||||
GetCurrentKeyDataTypedDict,
|
||||
GetCurrentKeyResponse,
|
||||
GetCurrentKeyResponseTypedDict,
|
||||
RateLimit,
|
||||
RateLimitTypedDict,
|
||||
)
|
||||
from .getgeneration import (
|
||||
APIType,
|
||||
GetGenerationData,
|
||||
GetGenerationDataTypedDict,
|
||||
GetGenerationRequest,
|
||||
GetGenerationRequestTypedDict,
|
||||
GetGenerationResponse,
|
||||
GetGenerationResponseTypedDict,
|
||||
)
|
||||
from .getkey import (
|
||||
GetKeyData,
|
||||
GetKeyDataTypedDict,
|
||||
GetKeyRequest,
|
||||
GetKeyRequestTypedDict,
|
||||
GetKeyResponse,
|
||||
GetKeyResponseTypedDict,
|
||||
)
|
||||
from .getmodels import GetModelsRequest, GetModelsRequestTypedDict
|
||||
from .getparameters import (
|
||||
GetParametersData,
|
||||
GetParametersDataTypedDict,
|
||||
GetParametersProvider,
|
||||
GetParametersRequest,
|
||||
GetParametersRequestTypedDict,
|
||||
GetParametersResponse,
|
||||
GetParametersResponseTypedDict,
|
||||
GetParametersSecurity,
|
||||
GetParametersSecurityTypedDict,
|
||||
SupportedParameter,
|
||||
)
|
||||
from .getuseractivity import (
|
||||
GetUserActivityRequest,
|
||||
GetUserActivityRequestTypedDict,
|
||||
GetUserActivityResponse,
|
||||
GetUserActivityResponseTypedDict,
|
||||
)
|
||||
from .list import (
|
||||
ListData,
|
||||
ListDataTypedDict,
|
||||
ListRequest,
|
||||
ListRequestTypedDict,
|
||||
ListResponse,
|
||||
ListResponseTypedDict,
|
||||
)
|
||||
from .listendpoints import (
|
||||
ListEndpointsRequest,
|
||||
ListEndpointsRequestTypedDict,
|
||||
ListEndpointsResponse,
|
||||
ListEndpointsResponseTypedDict,
|
||||
)
|
||||
from .listendpointszdr import (
|
||||
ListEndpointsZdrResponse,
|
||||
ListEndpointsZdrResponseTypedDict,
|
||||
)
|
||||
from .listmodelsuser import ListModelsUserSecurity, ListModelsUserSecurityTypedDict
|
||||
from .listproviders import (
|
||||
ListProvidersData,
|
||||
ListProvidersDataTypedDict,
|
||||
ListProvidersResponse,
|
||||
ListProvidersResponseTypedDict,
|
||||
)
|
||||
from .sendchatcompletionrequest import (
|
||||
SendChatCompletionRequestResponse,
|
||||
SendChatCompletionRequestResponseTypedDict,
|
||||
)
|
||||
from .updatekeys import (
|
||||
UpdateKeysData,
|
||||
UpdateKeysDataTypedDict,
|
||||
UpdateKeysLimitReset,
|
||||
UpdateKeysRequest,
|
||||
UpdateKeysRequestBody,
|
||||
UpdateKeysRequestBodyTypedDict,
|
||||
UpdateKeysRequestTypedDict,
|
||||
UpdateKeysResponse,
|
||||
UpdateKeysResponseTypedDict,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"APIType",
|
||||
"CallData",
|
||||
"CallDataTypedDict",
|
||||
"CreateAuthKeysCodeCodeChallengeMethod",
|
||||
"CreateAuthKeysCodeData",
|
||||
"CreateAuthKeysCodeDataTypedDict",
|
||||
"CreateAuthKeysCodeRequest",
|
||||
"CreateAuthKeysCodeRequestTypedDict",
|
||||
"CreateAuthKeysCodeResponse",
|
||||
"CreateAuthKeysCodeResponseTypedDict",
|
||||
"CreateCoinbaseChargeData",
|
||||
"CreateCoinbaseChargeDataTypedDict",
|
||||
"CreateCoinbaseChargeResponse",
|
||||
"CreateCoinbaseChargeResponseTypedDict",
|
||||
"CreateCoinbaseChargeSecurity",
|
||||
"CreateCoinbaseChargeSecurityTypedDict",
|
||||
"CreateEmbeddingsData",
|
||||
"CreateEmbeddingsDataTypedDict",
|
||||
"CreateEmbeddingsProvider",
|
||||
"CreateEmbeddingsProviderTypedDict",
|
||||
"CreateEmbeddingsRequest",
|
||||
"CreateEmbeddingsRequestTypedDict",
|
||||
"CreateEmbeddingsResponse",
|
||||
"CreateEmbeddingsResponseBody",
|
||||
"CreateEmbeddingsResponseBodyTypedDict",
|
||||
"CreateEmbeddingsResponseTypedDict",
|
||||
"CreateKeysData",
|
||||
"CreateKeysDataTypedDict",
|
||||
"CreateKeysLimitReset",
|
||||
"CreateKeysRequest",
|
||||
"CreateKeysRequestTypedDict",
|
||||
"CreateKeysResponse",
|
||||
"CreateKeysResponseTypedDict",
|
||||
"CreateResponsesResponse",
|
||||
"CreateResponsesResponseBody",
|
||||
"CreateResponsesResponseBodyTypedDict",
|
||||
"CreateResponsesResponseTypedDict",
|
||||
"DataCollection",
|
||||
"DeleteKeysRequest",
|
||||
"DeleteKeysRequestTypedDict",
|
||||
"DeleteKeysResponse",
|
||||
"DeleteKeysResponseTypedDict",
|
||||
"Embedding",
|
||||
"EmbeddingTypedDict",
|
||||
"EncodingFormat",
|
||||
"EncodingFormatBase64",
|
||||
"EncodingFormatFloat",
|
||||
"EncodingFormatTypedDict",
|
||||
"ExchangeAuthCodeForAPIKeyCodeChallengeMethod",
|
||||
"ExchangeAuthCodeForAPIKeyRequest",
|
||||
"ExchangeAuthCodeForAPIKeyRequestTypedDict",
|
||||
"ExchangeAuthCodeForAPIKeyResponse",
|
||||
"ExchangeAuthCodeForAPIKeyResponseTypedDict",
|
||||
"GetCreditsResponse",
|
||||
"GetCreditsResponseTypedDict",
|
||||
"GetCurrentKeyData",
|
||||
"GetCurrentKeyDataTypedDict",
|
||||
"GetCurrentKeyResponse",
|
||||
"GetCurrentKeyResponseTypedDict",
|
||||
"GetGenerationData",
|
||||
"GetGenerationDataTypedDict",
|
||||
"GetGenerationRequest",
|
||||
"GetGenerationRequestTypedDict",
|
||||
"GetGenerationResponse",
|
||||
"GetGenerationResponseTypedDict",
|
||||
"GetKeyData",
|
||||
"GetKeyDataTypedDict",
|
||||
"GetKeyRequest",
|
||||
"GetKeyRequestTypedDict",
|
||||
"GetKeyResponse",
|
||||
"GetKeyResponseTypedDict",
|
||||
"GetModelsRequest",
|
||||
"GetModelsRequestTypedDict",
|
||||
"GetParametersData",
|
||||
"GetParametersDataTypedDict",
|
||||
"GetParametersProvider",
|
||||
"GetParametersRequest",
|
||||
"GetParametersRequestTypedDict",
|
||||
"GetParametersResponse",
|
||||
"GetParametersResponseTypedDict",
|
||||
"GetParametersSecurity",
|
||||
"GetParametersSecurityTypedDict",
|
||||
"GetUserActivityRequest",
|
||||
"GetUserActivityRequestTypedDict",
|
||||
"GetUserActivityResponse",
|
||||
"GetUserActivityResponseTypedDict",
|
||||
"Ignore",
|
||||
"IgnoreTypedDict",
|
||||
"Input",
|
||||
"InputTypedDict",
|
||||
"ListData",
|
||||
"ListDataTypedDict",
|
||||
"ListEndpointsRequest",
|
||||
"ListEndpointsRequestTypedDict",
|
||||
"ListEndpointsResponse",
|
||||
"ListEndpointsResponseTypedDict",
|
||||
"ListEndpointsZdrResponse",
|
||||
"ListEndpointsZdrResponseTypedDict",
|
||||
"ListModelsUserSecurity",
|
||||
"ListModelsUserSecurityTypedDict",
|
||||
"ListProvidersData",
|
||||
"ListProvidersDataTypedDict",
|
||||
"ListProvidersResponse",
|
||||
"ListProvidersResponseTypedDict",
|
||||
"ListRequest",
|
||||
"ListRequestTypedDict",
|
||||
"ListResponse",
|
||||
"ListResponseTypedDict",
|
||||
"MaxPrice",
|
||||
"MaxPriceTypedDict",
|
||||
"Metadata",
|
||||
"MetadataTypedDict",
|
||||
"Object",
|
||||
"ObjectEmbedding",
|
||||
"Only",
|
||||
"OnlyTypedDict",
|
||||
"Order",
|
||||
"OrderTypedDict",
|
||||
"RateLimit",
|
||||
"RateLimitTypedDict",
|
||||
"SendChatCompletionRequestResponse",
|
||||
"SendChatCompletionRequestResponseTypedDict",
|
||||
"Sort",
|
||||
"SupportedParameter",
|
||||
"TransferIntent",
|
||||
"TransferIntentTypedDict",
|
||||
"UpdateKeysData",
|
||||
"UpdateKeysDataTypedDict",
|
||||
"UpdateKeysLimitReset",
|
||||
"UpdateKeysRequest",
|
||||
"UpdateKeysRequestBody",
|
||||
"UpdateKeysRequestBodyTypedDict",
|
||||
"UpdateKeysRequestTypedDict",
|
||||
"UpdateKeysResponse",
|
||||
"UpdateKeysResponseTypedDict",
|
||||
"Usage",
|
||||
"UsageTypedDict",
|
||||
"Web3Data",
|
||||
"Web3DataTypedDict",
|
||||
]
|
||||
|
||||
_dynamic_imports: dict[str, str] = {
|
||||
"CreateAuthKeysCodeCodeChallengeMethod": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeData": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeDataTypedDict": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeRequest": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeRequestTypedDict": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeResponse": ".createauthkeyscode",
|
||||
"CreateAuthKeysCodeResponseTypedDict": ".createauthkeyscode",
|
||||
"CallData": ".createcoinbasecharge",
|
||||
"CallDataTypedDict": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeData": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeDataTypedDict": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeResponse": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeResponseTypedDict": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeSecurity": ".createcoinbasecharge",
|
||||
"CreateCoinbaseChargeSecurityTypedDict": ".createcoinbasecharge",
|
||||
"Metadata": ".createcoinbasecharge",
|
||||
"MetadataTypedDict": ".createcoinbasecharge",
|
||||
"TransferIntent": ".createcoinbasecharge",
|
||||
"TransferIntentTypedDict": ".createcoinbasecharge",
|
||||
"Web3Data": ".createcoinbasecharge",
|
||||
"Web3DataTypedDict": ".createcoinbasecharge",
|
||||
"CreateEmbeddingsData": ".createembeddings",
|
||||
"CreateEmbeddingsDataTypedDict": ".createembeddings",
|
||||
"CreateEmbeddingsProvider": ".createembeddings",
|
||||
"CreateEmbeddingsProviderTypedDict": ".createembeddings",
|
||||
"CreateEmbeddingsRequest": ".createembeddings",
|
||||
"CreateEmbeddingsRequestTypedDict": ".createembeddings",
|
||||
"CreateEmbeddingsResponse": ".createembeddings",
|
||||
"CreateEmbeddingsResponseBody": ".createembeddings",
|
||||
"CreateEmbeddingsResponseBodyTypedDict": ".createembeddings",
|
||||
"CreateEmbeddingsResponseTypedDict": ".createembeddings",
|
||||
"DataCollection": ".createembeddings",
|
||||
"Embedding": ".createembeddings",
|
||||
"EmbeddingTypedDict": ".createembeddings",
|
||||
"EncodingFormat": ".createembeddings",
|
||||
"EncodingFormatBase64": ".createembeddings",
|
||||
"EncodingFormatFloat": ".createembeddings",
|
||||
"EncodingFormatTypedDict": ".createembeddings",
|
||||
"Ignore": ".createembeddings",
|
||||
"IgnoreTypedDict": ".createembeddings",
|
||||
"Input": ".createembeddings",
|
||||
"InputTypedDict": ".createembeddings",
|
||||
"MaxPrice": ".createembeddings",
|
||||
"MaxPriceTypedDict": ".createembeddings",
|
||||
"Object": ".createembeddings",
|
||||
"ObjectEmbedding": ".createembeddings",
|
||||
"Only": ".createembeddings",
|
||||
"OnlyTypedDict": ".createembeddings",
|
||||
"Order": ".createembeddings",
|
||||
"OrderTypedDict": ".createembeddings",
|
||||
"Sort": ".createembeddings",
|
||||
"Usage": ".createembeddings",
|
||||
"UsageTypedDict": ".createembeddings",
|
||||
"CreateKeysData": ".createkeys",
|
||||
"CreateKeysDataTypedDict": ".createkeys",
|
||||
"CreateKeysLimitReset": ".createkeys",
|
||||
"CreateKeysRequest": ".createkeys",
|
||||
"CreateKeysRequestTypedDict": ".createkeys",
|
||||
"CreateKeysResponse": ".createkeys",
|
||||
"CreateKeysResponseTypedDict": ".createkeys",
|
||||
"CreateResponsesResponse": ".createresponses",
|
||||
"CreateResponsesResponseBody": ".createresponses",
|
||||
"CreateResponsesResponseBodyTypedDict": ".createresponses",
|
||||
"CreateResponsesResponseTypedDict": ".createresponses",
|
||||
"DeleteKeysRequest": ".deletekeys",
|
||||
"DeleteKeysRequestTypedDict": ".deletekeys",
|
||||
"DeleteKeysResponse": ".deletekeys",
|
||||
"DeleteKeysResponseTypedDict": ".deletekeys",
|
||||
"ExchangeAuthCodeForAPIKeyCodeChallengeMethod": ".exchangeauthcodeforapikey",
|
||||
"ExchangeAuthCodeForAPIKeyRequest": ".exchangeauthcodeforapikey",
|
||||
"ExchangeAuthCodeForAPIKeyRequestTypedDict": ".exchangeauthcodeforapikey",
|
||||
"ExchangeAuthCodeForAPIKeyResponse": ".exchangeauthcodeforapikey",
|
||||
"ExchangeAuthCodeForAPIKeyResponseTypedDict": ".exchangeauthcodeforapikey",
|
||||
"GetCreditsResponse": ".getcredits",
|
||||
"GetCreditsResponseTypedDict": ".getcredits",
|
||||
"GetCurrentKeyData": ".getcurrentkey",
|
||||
"GetCurrentKeyDataTypedDict": ".getcurrentkey",
|
||||
"GetCurrentKeyResponse": ".getcurrentkey",
|
||||
"GetCurrentKeyResponseTypedDict": ".getcurrentkey",
|
||||
"RateLimit": ".getcurrentkey",
|
||||
"RateLimitTypedDict": ".getcurrentkey",
|
||||
"APIType": ".getgeneration",
|
||||
"GetGenerationData": ".getgeneration",
|
||||
"GetGenerationDataTypedDict": ".getgeneration",
|
||||
"GetGenerationRequest": ".getgeneration",
|
||||
"GetGenerationRequestTypedDict": ".getgeneration",
|
||||
"GetGenerationResponse": ".getgeneration",
|
||||
"GetGenerationResponseTypedDict": ".getgeneration",
|
||||
"GetKeyData": ".getkey",
|
||||
"GetKeyDataTypedDict": ".getkey",
|
||||
"GetKeyRequest": ".getkey",
|
||||
"GetKeyRequestTypedDict": ".getkey",
|
||||
"GetKeyResponse": ".getkey",
|
||||
"GetKeyResponseTypedDict": ".getkey",
|
||||
"GetModelsRequest": ".getmodels",
|
||||
"GetModelsRequestTypedDict": ".getmodels",
|
||||
"GetParametersData": ".getparameters",
|
||||
"GetParametersDataTypedDict": ".getparameters",
|
||||
"GetParametersProvider": ".getparameters",
|
||||
"GetParametersRequest": ".getparameters",
|
||||
"GetParametersRequestTypedDict": ".getparameters",
|
||||
"GetParametersResponse": ".getparameters",
|
||||
"GetParametersResponseTypedDict": ".getparameters",
|
||||
"GetParametersSecurity": ".getparameters",
|
||||
"GetParametersSecurityTypedDict": ".getparameters",
|
||||
"SupportedParameter": ".getparameters",
|
||||
"GetUserActivityRequest": ".getuseractivity",
|
||||
"GetUserActivityRequestTypedDict": ".getuseractivity",
|
||||
"GetUserActivityResponse": ".getuseractivity",
|
||||
"GetUserActivityResponseTypedDict": ".getuseractivity",
|
||||
"ListData": ".list",
|
||||
"ListDataTypedDict": ".list",
|
||||
"ListRequest": ".list",
|
||||
"ListRequestTypedDict": ".list",
|
||||
"ListResponse": ".list",
|
||||
"ListResponseTypedDict": ".list",
|
||||
"ListEndpointsRequest": ".listendpoints",
|
||||
"ListEndpointsRequestTypedDict": ".listendpoints",
|
||||
"ListEndpointsResponse": ".listendpoints",
|
||||
"ListEndpointsResponseTypedDict": ".listendpoints",
|
||||
"ListEndpointsZdrResponse": ".listendpointszdr",
|
||||
"ListEndpointsZdrResponseTypedDict": ".listendpointszdr",
|
||||
"ListModelsUserSecurity": ".listmodelsuser",
|
||||
"ListModelsUserSecurityTypedDict": ".listmodelsuser",
|
||||
"ListProvidersData": ".listproviders",
|
||||
"ListProvidersDataTypedDict": ".listproviders",
|
||||
"ListProvidersResponse": ".listproviders",
|
||||
"ListProvidersResponseTypedDict": ".listproviders",
|
||||
"SendChatCompletionRequestResponse": ".sendchatcompletionrequest",
|
||||
"SendChatCompletionRequestResponseTypedDict": ".sendchatcompletionrequest",
|
||||
"UpdateKeysData": ".updatekeys",
|
||||
"UpdateKeysDataTypedDict": ".updatekeys",
|
||||
"UpdateKeysLimitReset": ".updatekeys",
|
||||
"UpdateKeysRequest": ".updatekeys",
|
||||
"UpdateKeysRequestBody": ".updatekeys",
|
||||
"UpdateKeysRequestBodyTypedDict": ".updatekeys",
|
||||
"UpdateKeysRequestTypedDict": ".updatekeys",
|
||||
"UpdateKeysResponse": ".updatekeys",
|
||||
"UpdateKeysResponseTypedDict": ".updatekeys",
|
||||
}
|
||||
|
||||
|
||||
def dynamic_import(modname, retries=3):
|
||||
for attempt in range(retries):
|
||||
try:
|
||||
return import_module(modname, __package__)
|
||||
except KeyError:
|
||||
# Clear any half-initialized module and retry
|
||||
sys.modules.pop(modname, None)
|
||||
if attempt == retries - 1:
|
||||
break
|
||||
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
||||
|
||||
|
||||
def __getattr__(attr_name: str) -> object:
|
||||
module_name = _dynamic_imports.get(attr_name)
|
||||
if module_name is None:
|
||||
raise AttributeError(
|
||||
f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
|
||||
)
|
||||
|
||||
try:
|
||||
module = dynamic_import(module_name)
|
||||
result = getattr(module, attr_name)
|
||||
return result
|
||||
except ImportError as e:
|
||||
raise ImportError(
|
||||
f"Failed to import {attr_name} from {module_name}: {e}"
|
||||
) from e
|
||||
except AttributeError as e:
|
||||
raise AttributeError(
|
||||
f"Failed to get {attr_name} from {module_name}: {e}"
|
||||
) from e
|
||||
|
||||
|
||||
def __dir__():
|
||||
lazy_attrs = builtins.list(_dynamic_imports.keys())
|
||||
return builtins.sorted(lazy_attrs)
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
CreateAuthKeysCodeCodeChallengeMethod = Union[
|
||||
Literal[
|
||||
"S256",
|
||||
"plain",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeRequestTypedDict(TypedDict):
|
||||
callback_url: str
|
||||
r"""The callback URL to redirect to after authorization. Note, only https URLs on ports 443 and 3000 are allowed."""
|
||||
code_challenge: NotRequired[str]
|
||||
r"""PKCE code challenge for enhanced security"""
|
||||
code_challenge_method: NotRequired[CreateAuthKeysCodeCodeChallengeMethod]
|
||||
r"""The method used to generate the code challenge"""
|
||||
limit: NotRequired[float]
|
||||
r"""Credit limit for the API key to be created"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""Optional expiration time for the API key to be created"""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeRequest(BaseModel):
|
||||
callback_url: str
|
||||
r"""The callback URL to redirect to after authorization. Note, only https URLs on ports 443 and 3000 are allowed."""
|
||||
|
||||
code_challenge: Optional[str] = None
|
||||
r"""PKCE code challenge for enhanced security"""
|
||||
|
||||
code_challenge_method: Annotated[
|
||||
Optional[CreateAuthKeysCodeCodeChallengeMethod],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = None
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
limit: Optional[float] = None
|
||||
r"""Credit limit for the API key to be created"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""Optional expiration time for the API key to be created"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"code_challenge",
|
||||
"code_challenge_method",
|
||||
"limit",
|
||||
"expires_at",
|
||||
]
|
||||
nullable_fields = ["expires_at"]
|
||||
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 CreateAuthKeysCodeDataTypedDict(TypedDict):
|
||||
r"""Auth code data"""
|
||||
|
||||
id: str
|
||||
r"""The authorization code ID to use in the exchange request"""
|
||||
app_id: float
|
||||
r"""The application ID associated with this auth code"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the auth code was created"""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeData(BaseModel):
|
||||
r"""Auth code data"""
|
||||
|
||||
id: str
|
||||
r"""The authorization code ID to use in the exchange request"""
|
||||
|
||||
app_id: float
|
||||
r"""The application ID associated with this auth code"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the auth code was created"""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeResponseTypedDict(TypedDict):
|
||||
r"""Successfully created authorization code"""
|
||||
|
||||
data: CreateAuthKeysCodeDataTypedDict
|
||||
r"""Auth code data"""
|
||||
|
||||
|
||||
class CreateAuthKeysCodeResponse(BaseModel):
|
||||
r"""Successfully created authorization code"""
|
||||
|
||||
data: CreateAuthKeysCodeData
|
||||
r"""Auth code data"""
|
||||
@@ -0,0 +1,121 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, SecurityMetadata
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class CreateCoinbaseChargeSecurityTypedDict(TypedDict):
|
||||
bearer: str
|
||||
|
||||
|
||||
class CreateCoinbaseChargeSecurity(BaseModel):
|
||||
bearer: Annotated[
|
||||
str,
|
||||
FieldMetadata(
|
||||
security=SecurityMetadata(
|
||||
scheme=True,
|
||||
scheme_type="http",
|
||||
sub_type="bearer",
|
||||
field_name="Authorization",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class CallDataTypedDict(TypedDict):
|
||||
deadline: str
|
||||
fee_amount: str
|
||||
id: str
|
||||
operator: str
|
||||
prefix: str
|
||||
recipient: str
|
||||
recipient_amount: str
|
||||
recipient_currency: str
|
||||
refund_destination: str
|
||||
signature: str
|
||||
|
||||
|
||||
class CallData(BaseModel):
|
||||
deadline: str
|
||||
|
||||
fee_amount: str
|
||||
|
||||
id: str
|
||||
|
||||
operator: str
|
||||
|
||||
prefix: str
|
||||
|
||||
recipient: str
|
||||
|
||||
recipient_amount: str
|
||||
|
||||
recipient_currency: str
|
||||
|
||||
refund_destination: str
|
||||
|
||||
signature: str
|
||||
|
||||
|
||||
class MetadataTypedDict(TypedDict):
|
||||
chain_id: float
|
||||
contract_address: str
|
||||
sender: str
|
||||
|
||||
|
||||
class Metadata(BaseModel):
|
||||
chain_id: float
|
||||
|
||||
contract_address: str
|
||||
|
||||
sender: str
|
||||
|
||||
|
||||
class TransferIntentTypedDict(TypedDict):
|
||||
call_data: CallDataTypedDict
|
||||
metadata: MetadataTypedDict
|
||||
|
||||
|
||||
class TransferIntent(BaseModel):
|
||||
call_data: CallData
|
||||
|
||||
metadata: Metadata
|
||||
|
||||
|
||||
class Web3DataTypedDict(TypedDict):
|
||||
transfer_intent: TransferIntentTypedDict
|
||||
|
||||
|
||||
class Web3Data(BaseModel):
|
||||
transfer_intent: TransferIntent
|
||||
|
||||
|
||||
class CreateCoinbaseChargeDataTypedDict(TypedDict):
|
||||
id: str
|
||||
created_at: str
|
||||
expires_at: str
|
||||
web3_data: Web3DataTypedDict
|
||||
|
||||
|
||||
class CreateCoinbaseChargeData(BaseModel):
|
||||
id: str
|
||||
|
||||
created_at: str
|
||||
|
||||
expires_at: str
|
||||
|
||||
web3_data: Web3Data
|
||||
|
||||
|
||||
class CreateCoinbaseChargeResponseTypedDict(TypedDict):
|
||||
r"""Returns the calldata to fulfill the transaction"""
|
||||
|
||||
data: CreateCoinbaseChargeDataTypedDict
|
||||
|
||||
|
||||
class CreateCoinbaseChargeResponse(BaseModel):
|
||||
r"""Returns the calldata to fulfill the transaction"""
|
||||
|
||||
data: CreateCoinbaseChargeData
|
||||
@@ -0,0 +1,389 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import (
|
||||
providername as components_providername,
|
||||
quantization as components_quantization,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
InputTypedDict = TypeAliasType(
|
||||
"InputTypedDict", Union[str, List[str], List[float], List[List[float]]]
|
||||
)
|
||||
|
||||
|
||||
Input = TypeAliasType("Input", Union[str, List[str], List[float], List[List[float]]])
|
||||
|
||||
|
||||
DataCollection = Union[
|
||||
Literal[
|
||||
"deny",
|
||||
"allow",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
OrderTypedDict = TypeAliasType(
|
||||
"OrderTypedDict", Union[components_providername.ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Order = TypeAliasType(
|
||||
"Order",
|
||||
Union[
|
||||
Annotated[
|
||||
components_providername.ProviderName,
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
str,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
OnlyTypedDict = TypeAliasType(
|
||||
"OnlyTypedDict", Union[components_providername.ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Only = TypeAliasType(
|
||||
"Only",
|
||||
Union[
|
||||
Annotated[
|
||||
components_providername.ProviderName,
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
str,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
IgnoreTypedDict = TypeAliasType(
|
||||
"IgnoreTypedDict", Union[components_providername.ProviderName, str]
|
||||
)
|
||||
|
||||
|
||||
Ignore = TypeAliasType(
|
||||
"Ignore",
|
||||
Union[
|
||||
Annotated[
|
||||
components_providername.ProviderName,
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
],
|
||||
str,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Sort = Union[
|
||||
Literal[
|
||||
"price",
|
||||
"throughput",
|
||||
"latency",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
|
||||
class MaxPriceTypedDict(TypedDict):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
completion: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
image: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
audio: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
request: NotRequired[Any]
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
|
||||
class MaxPrice(BaseModel):
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
prompt: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
completion: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
image: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
audio: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
request: Optional[Any] = None
|
||||
r"""A value in string or number format that is a large number"""
|
||||
|
||||
|
||||
class CreateEmbeddingsProviderTypedDict(TypedDict):
|
||||
allow_fallbacks: NotRequired[Nullable[bool]]
|
||||
r"""Whether to allow backup providers to serve requests
|
||||
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
||||
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
||||
|
||||
"""
|
||||
require_parameters: NotRequired[Nullable[bool]]
|
||||
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
|
||||
data_collection: NotRequired[Nullable[DataCollection]]
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
zdr: NotRequired[Nullable[bool]]
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
enforce_distillable_text: NotRequired[Nullable[bool]]
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
order: NotRequired[Nullable[List[OrderTypedDict]]]
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
only: NotRequired[Nullable[List[OnlyTypedDict]]]
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
ignore: NotRequired[Nullable[List[IgnoreTypedDict]]]
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
quantizations: NotRequired[Nullable[List[components_quantization.Quantization]]]
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
sort: NotRequired[Nullable[Sort]]
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
max_price: NotRequired[MaxPriceTypedDict]
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
|
||||
class CreateEmbeddingsProvider(BaseModel):
|
||||
allow_fallbacks: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to allow backup providers to serve requests
|
||||
- true: (default) when the primary provider (or your custom providers in \"order\") is unavailable, use the next best provider.
|
||||
- false: use only the primary/custom provider, and return the upstream error if it's unavailable.
|
||||
|
||||
"""
|
||||
|
||||
require_parameters: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to filter providers to only those that support the parameters you've provided. If this setting is omitted or set to false, then providers will receive only the parameters they support, and ignore the rest."""
|
||||
|
||||
data_collection: Annotated[
|
||||
OptionalNullable[DataCollection], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""Data collection setting. If no available model provider meets the requirement, your request will return an error.
|
||||
- allow: (default) allow providers which store user data non-transiently and may train on it
|
||||
- deny: use only providers which do not collect user data.
|
||||
|
||||
"""
|
||||
|
||||
zdr: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to restrict routing to only ZDR (Zero Data Retention) endpoints. When true, only endpoints that do not retain prompts will be used."""
|
||||
|
||||
enforce_distillable_text: OptionalNullable[bool] = UNSET
|
||||
r"""Whether to restrict routing to only models that allow text distillation. When true, only models where the author has allowed distillation will be used."""
|
||||
|
||||
order: OptionalNullable[List[Order]] = UNSET
|
||||
r"""An ordered list of provider slugs. The router will attempt to use the first provider in the subset of this list that supports your requested model, and fall back to the next if it is unavailable. If no providers are available, the request will fail with an error message."""
|
||||
|
||||
only: OptionalNullable[List[Only]] = UNSET
|
||||
r"""List of provider slugs to allow. If provided, this list is merged with your account-wide allowed provider settings for this request."""
|
||||
|
||||
ignore: OptionalNullable[List[Ignore]] = UNSET
|
||||
r"""List of provider slugs to ignore. If provided, this list is merged with your account-wide ignored provider settings for this request."""
|
||||
|
||||
quantizations: OptionalNullable[
|
||||
List[
|
||||
Annotated[
|
||||
components_quantization.Quantization,
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
]
|
||||
]
|
||||
] = UNSET
|
||||
r"""A list of quantization levels to filter the provider by."""
|
||||
|
||||
sort: Annotated[
|
||||
OptionalNullable[Sort], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
r"""The sorting strategy to use for this request, if \"order\" is not specified. When set, no load balancing is performed."""
|
||||
|
||||
max_price: Optional[MaxPrice] = None
|
||||
r"""The object specifying the maximum price you want to pay for this request. USD price per million tokens, for prompt and completion."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
"max_price",
|
||||
]
|
||||
nullable_fields = [
|
||||
"allow_fallbacks",
|
||||
"require_parameters",
|
||||
"data_collection",
|
||||
"zdr",
|
||||
"enforce_distillable_text",
|
||||
"order",
|
||||
"only",
|
||||
"ignore",
|
||||
"quantizations",
|
||||
"sort",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
EncodingFormatBase64 = Literal["base64",]
|
||||
|
||||
|
||||
EncodingFormatFloat = Literal["float",]
|
||||
|
||||
|
||||
EncodingFormatTypedDict = TypeAliasType(
|
||||
"EncodingFormatTypedDict", Union[EncodingFormatFloat, EncodingFormatBase64]
|
||||
)
|
||||
|
||||
|
||||
EncodingFormat = TypeAliasType(
|
||||
"EncodingFormat", Union[EncodingFormatFloat, EncodingFormatBase64]
|
||||
)
|
||||
|
||||
|
||||
class CreateEmbeddingsRequestTypedDict(TypedDict):
|
||||
input: InputTypedDict
|
||||
model: str
|
||||
provider: NotRequired[CreateEmbeddingsProviderTypedDict]
|
||||
encoding_format: NotRequired[EncodingFormatTypedDict]
|
||||
user: NotRequired[str]
|
||||
|
||||
|
||||
class CreateEmbeddingsRequest(BaseModel):
|
||||
input: Input
|
||||
|
||||
model: str
|
||||
|
||||
provider: Optional[CreateEmbeddingsProvider] = None
|
||||
|
||||
encoding_format: Optional[EncodingFormat] = None
|
||||
|
||||
user: Optional[str] = None
|
||||
|
||||
|
||||
Object = Literal["list",]
|
||||
|
||||
|
||||
ObjectEmbedding = Literal["embedding",]
|
||||
|
||||
|
||||
EmbeddingTypedDict = TypeAliasType("EmbeddingTypedDict", Union[List[float], str])
|
||||
|
||||
|
||||
Embedding = TypeAliasType("Embedding", Union[List[float], str])
|
||||
|
||||
|
||||
class CreateEmbeddingsDataTypedDict(TypedDict):
|
||||
object: ObjectEmbedding
|
||||
embedding: EmbeddingTypedDict
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class CreateEmbeddingsData(BaseModel):
|
||||
object: ObjectEmbedding
|
||||
|
||||
embedding: Embedding
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
|
||||
class UsageTypedDict(TypedDict):
|
||||
prompt_tokens: float
|
||||
total_tokens: float
|
||||
cost: NotRequired[float]
|
||||
|
||||
|
||||
class Usage(BaseModel):
|
||||
prompt_tokens: float
|
||||
|
||||
total_tokens: float
|
||||
|
||||
cost: Optional[float] = None
|
||||
|
||||
|
||||
class CreateEmbeddingsResponseBodyTypedDict(TypedDict):
|
||||
r"""Embedding response"""
|
||||
|
||||
object: Object
|
||||
data: List[CreateEmbeddingsDataTypedDict]
|
||||
model: str
|
||||
id: NotRequired[str]
|
||||
usage: NotRequired[UsageTypedDict]
|
||||
|
||||
|
||||
class CreateEmbeddingsResponseBody(BaseModel):
|
||||
r"""Embedding response"""
|
||||
|
||||
object: Object
|
||||
|
||||
data: List[CreateEmbeddingsData]
|
||||
|
||||
model: str
|
||||
|
||||
id: Optional[str] = None
|
||||
|
||||
usage: Optional[Usage] = None
|
||||
|
||||
|
||||
CreateEmbeddingsResponseTypedDict = TypeAliasType(
|
||||
"CreateEmbeddingsResponseTypedDict",
|
||||
Union[CreateEmbeddingsResponseBodyTypedDict, str],
|
||||
)
|
||||
|
||||
|
||||
CreateEmbeddingsResponse = TypeAliasType(
|
||||
"CreateEmbeddingsResponse", Union[CreateEmbeddingsResponseBody, str]
|
||||
)
|
||||
@@ -0,0 +1,255 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
CreateKeysLimitReset = Union[
|
||||
Literal[
|
||||
"daily",
|
||||
"weekly",
|
||||
"monthly",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
|
||||
|
||||
class CreateKeysRequestTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Name for the new API key"""
|
||||
limit: NotRequired[Nullable[float]]
|
||||
r"""Optional spending limit for the API key in USD"""
|
||||
limit_reset: NotRequired[Nullable[CreateKeysLimitReset]]
|
||||
r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
include_byok_in_limit: NotRequired[bool]
|
||||
r"""Whether to include BYOK usage in the limit"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""Optional ISO 8601 UTC timestamp when the API key should expire. Must be UTC, other timezones will be rejected"""
|
||||
|
||||
|
||||
class CreateKeysRequest(BaseModel):
|
||||
name: str
|
||||
r"""Name for the new API key"""
|
||||
|
||||
limit: OptionalNullable[float] = UNSET
|
||||
r"""Optional spending limit for the API key in USD"""
|
||||
|
||||
limit_reset: Annotated[
|
||||
OptionalNullable[CreateKeysLimitReset],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
|
||||
include_byok_in_limit: Optional[bool] = None
|
||||
r"""Whether to include BYOK usage in the limit"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""Optional ISO 8601 UTC timestamp when the API key should expire. Must be UTC, other timezones will be rejected"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"limit",
|
||||
"limit_reset",
|
||||
"include_byok_in_limit",
|
||||
"expires_at",
|
||||
]
|
||||
nullable_fields = ["limit", "limit_reset", "expires_at"]
|
||||
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 CreateKeysDataTypedDict(TypedDict):
|
||||
r"""The created API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
|
||||
class CreateKeysData(BaseModel):
|
||||
r"""The created API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["expires_at"]
|
||||
nullable_fields = [
|
||||
"limit",
|
||||
"limit_remaining",
|
||||
"limit_reset",
|
||||
"updated_at",
|
||||
"expires_at",
|
||||
]
|
||||
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 CreateKeysResponseTypedDict(TypedDict):
|
||||
r"""API key created successfully"""
|
||||
|
||||
data: CreateKeysDataTypedDict
|
||||
r"""The created API key information"""
|
||||
key: str
|
||||
r"""The actual API key string (only shown once)"""
|
||||
|
||||
|
||||
class CreateKeysResponse(BaseModel):
|
||||
r"""API key created successfully"""
|
||||
|
||||
data: CreateKeysData
|
||||
r"""The created API key information"""
|
||||
|
||||
key: str
|
||||
r"""The actual API key string (only shown once)"""
|
||||
@@ -0,0 +1,57 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import (
|
||||
openresponsesnonstreamingresponse as components_openresponsesnonstreamingresponse,
|
||||
openresponsesstreamevent as components_openresponsesstreamevent,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import eventstreaming
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class CreateResponsesResponseBodyTypedDict(TypedDict):
|
||||
r"""Successful response"""
|
||||
|
||||
data: components_openresponsesstreamevent.OpenResponsesStreamEventTypedDict
|
||||
r"""Union of all possible event types emitted during response streaming"""
|
||||
|
||||
|
||||
class CreateResponsesResponseBody(BaseModel):
|
||||
r"""Successful response"""
|
||||
|
||||
data: components_openresponsesstreamevent.OpenResponsesStreamEvent
|
||||
r"""Union of all possible event types emitted during response streaming"""
|
||||
|
||||
|
||||
CreateResponsesResponseTypedDict = TypeAliasType(
|
||||
"CreateResponsesResponseTypedDict",
|
||||
Union[
|
||||
components_openresponsesnonstreamingresponse.OpenResponsesNonStreamingResponseTypedDict,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_openresponsesstreamevent.OpenResponsesStreamEventTypedDict
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_openresponsesstreamevent.OpenResponsesStreamEventTypedDict
|
||||
],
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
CreateResponsesResponse = TypeAliasType(
|
||||
"CreateResponsesResponse",
|
||||
Union[
|
||||
components_openresponsesnonstreamingresponse.OpenResponsesNonStreamingResponse,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_openresponsesstreamevent.OpenResponsesStreamEvent
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_openresponsesstreamevent.OpenResponsesStreamEvent
|
||||
],
|
||||
],
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, PathParamMetadata, validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class DeleteKeysRequestTypedDict(TypedDict):
|
||||
hash: str
|
||||
r"""The hash identifier of the API key to delete"""
|
||||
|
||||
|
||||
class DeleteKeysRequest(BaseModel):
|
||||
hash: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
r"""The hash identifier of the API key to delete"""
|
||||
|
||||
|
||||
class DeleteKeysResponseTypedDict(TypedDict):
|
||||
r"""API key deleted successfully"""
|
||||
|
||||
deleted: Literal[True]
|
||||
r"""Confirmation that the API key was deleted"""
|
||||
|
||||
|
||||
class DeleteKeysResponse(BaseModel):
|
||||
r"""API key deleted successfully"""
|
||||
|
||||
DELETED: Annotated[
|
||||
Annotated[Literal[True], AfterValidator(validate_const(True))],
|
||||
pydantic.Field(alias="deleted"),
|
||||
] = True
|
||||
r"""Confirmation that the API key was deleted"""
|
||||
@@ -0,0 +1,130 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ExchangeAuthCodeForAPIKeyCodeChallengeMethod = Union[
|
||||
Literal[
|
||||
"S256",
|
||||
"plain",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
|
||||
class ExchangeAuthCodeForAPIKeyRequestTypedDict(TypedDict):
|
||||
code: str
|
||||
r"""The authorization code received from the OAuth redirect"""
|
||||
code_verifier: NotRequired[str]
|
||||
r"""The code verifier if code_challenge was used in the authorization request"""
|
||||
code_challenge_method: NotRequired[
|
||||
Nullable[ExchangeAuthCodeForAPIKeyCodeChallengeMethod]
|
||||
]
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
|
||||
class ExchangeAuthCodeForAPIKeyRequest(BaseModel):
|
||||
code: str
|
||||
r"""The authorization code received from the OAuth redirect"""
|
||||
|
||||
code_verifier: Optional[str] = None
|
||||
r"""The code verifier if code_challenge was used in the authorization request"""
|
||||
|
||||
code_challenge_method: Annotated[
|
||||
OptionalNullable[ExchangeAuthCodeForAPIKeyCodeChallengeMethod],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""The method used to generate the code challenge"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["code_verifier", "code_challenge_method"]
|
||||
nullable_fields = ["code_challenge_method"]
|
||||
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 ExchangeAuthCodeForAPIKeyResponseTypedDict(TypedDict):
|
||||
r"""Successfully exchanged code for an API key"""
|
||||
|
||||
key: str
|
||||
r"""The API key to use for OpenRouter requests"""
|
||||
user_id: Nullable[str]
|
||||
r"""User ID associated with the API key"""
|
||||
|
||||
|
||||
class ExchangeAuthCodeForAPIKeyResponse(BaseModel):
|
||||
r"""Successfully exchanged code for an API key"""
|
||||
|
||||
key: str
|
||||
r"""The API key to use for OpenRouter requests"""
|
||||
|
||||
user_id: Nullable[str]
|
||||
r"""User ID associated with the API key"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = ["user_id"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class GetCreditsResponseTypedDict(TypedDict):
|
||||
r"""Total credits purchased and used"""
|
||||
|
||||
|
||||
class GetCreditsResponse(BaseModel):
|
||||
r"""Total credits purchased and used"""
|
||||
@@ -0,0 +1,187 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
import pydantic
|
||||
from pydantic import model_serializer
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict, deprecated
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class RateLimitTypedDict(TypedDict):
|
||||
r"""Legacy rate limit information about a key. Will always return -1."""
|
||||
|
||||
requests: float
|
||||
r"""Number of requests allowed per interval"""
|
||||
interval: str
|
||||
r"""Rate limit interval"""
|
||||
note: str
|
||||
r"""Note about the rate limit"""
|
||||
|
||||
|
||||
@deprecated(
|
||||
"warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
)
|
||||
class RateLimit(BaseModel):
|
||||
r"""Legacy rate limit information about a key. Will always return -1."""
|
||||
|
||||
requests: float
|
||||
r"""Number of requests allowed per interval"""
|
||||
|
||||
interval: str
|
||||
r"""Rate limit interval"""
|
||||
|
||||
note: str
|
||||
r"""Note about the rate limit"""
|
||||
|
||||
|
||||
class GetCurrentKeyDataTypedDict(TypedDict):
|
||||
r"""Current API key information"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
is_free_tier: bool
|
||||
r"""Whether this is a free tier API key"""
|
||||
is_provisioning_key: bool
|
||||
r"""Whether this is a provisioning key"""
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
rate_limit: RateLimitTypedDict
|
||||
r"""Legacy rate limit information about a key. Will always return -1."""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
|
||||
class GetCurrentKeyData(BaseModel):
|
||||
r"""Current API key information"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
|
||||
is_free_tier: bool
|
||||
r"""Whether this is a free tier API key"""
|
||||
|
||||
is_provisioning_key: bool
|
||||
r"""Whether this is a provisioning key"""
|
||||
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
|
||||
rate_limit: Annotated[
|
||||
RateLimit,
|
||||
pydantic.Field(
|
||||
deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
|
||||
),
|
||||
]
|
||||
r"""Legacy rate limit information about a key. Will always return -1."""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["expires_at"]
|
||||
nullable_fields = ["limit", "limit_remaining", "limit_reset", "expires_at"]
|
||||
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 GetCurrentKeyResponseTypedDict(TypedDict):
|
||||
r"""API key details"""
|
||||
|
||||
data: GetCurrentKeyDataTypedDict
|
||||
r"""Current API key information"""
|
||||
|
||||
|
||||
class GetCurrentKeyResponse(BaseModel):
|
||||
r"""API key details"""
|
||||
|
||||
data: GetCurrentKeyData
|
||||
r"""Current API key information"""
|
||||
@@ -0,0 +1,268 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
||||
from openrouter.utils import FieldMetadata, QueryParamMetadata, validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class GetGenerationRequestTypedDict(TypedDict):
|
||||
id: str
|
||||
|
||||
|
||||
class GetGenerationRequest(BaseModel):
|
||||
id: Annotated[
|
||||
str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
|
||||
]
|
||||
|
||||
|
||||
APIType = Union[
|
||||
Literal[
|
||||
"completions",
|
||||
"embeddings",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""Type of API used for the generation"""
|
||||
|
||||
|
||||
class GetGenerationDataTypedDict(TypedDict):
|
||||
r"""Generation data"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
cache_discount: Nullable[float]
|
||||
r"""Discount applied due to caching"""
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the generation was created"""
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
app_id: Nullable[float]
|
||||
r"""ID of the app that made the request"""
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
cancelled: Nullable[bool]
|
||||
r"""Whether the generation was cancelled"""
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
finish_reason: Nullable[str]
|
||||
r"""Reason the generation finished"""
|
||||
tokens_prompt: Nullable[float]
|
||||
r"""Number of tokens in the prompt"""
|
||||
tokens_completion: Nullable[float]
|
||||
r"""Number of tokens in the completion"""
|
||||
native_tokens_prompt: Nullable[float]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
native_tokens_completion: Nullable[float]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
native_tokens_completion_images: Nullable[float]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
native_tokens_reasoning: Nullable[float]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
native_tokens_cached: Nullable[float]
|
||||
r"""Native cached tokens as reported by provider"""
|
||||
num_media_prompt: Nullable[float]
|
||||
r"""Number of media items in the prompt"""
|
||||
num_input_audio_prompt: Nullable[float]
|
||||
r"""Number of audio inputs in the prompt"""
|
||||
num_media_completion: Nullable[float]
|
||||
r"""Number of media items in the completion"""
|
||||
num_search_results: Nullable[float]
|
||||
r"""Number of search results included"""
|
||||
origin: str
|
||||
r"""Origin URL of the request"""
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
api_type: Nullable[APIType]
|
||||
r"""Type of API used for the generation"""
|
||||
|
||||
|
||||
class GetGenerationData(BaseModel):
|
||||
r"""Generation data"""
|
||||
|
||||
id: str
|
||||
r"""Unique identifier for the generation"""
|
||||
|
||||
upstream_id: Nullable[str]
|
||||
r"""Upstream provider's identifier for this generation"""
|
||||
|
||||
total_cost: float
|
||||
r"""Total cost of the generation in USD"""
|
||||
|
||||
cache_discount: Nullable[float]
|
||||
r"""Discount applied due to caching"""
|
||||
|
||||
upstream_inference_cost: Nullable[float]
|
||||
r"""Cost charged by the upstream provider"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the generation was created"""
|
||||
|
||||
model: str
|
||||
r"""Model used for the generation"""
|
||||
|
||||
app_id: Nullable[float]
|
||||
r"""ID of the app that made the request"""
|
||||
|
||||
streamed: Nullable[bool]
|
||||
r"""Whether the response was streamed"""
|
||||
|
||||
cancelled: Nullable[bool]
|
||||
r"""Whether the generation was cancelled"""
|
||||
|
||||
provider_name: Nullable[str]
|
||||
r"""Name of the provider that served the request"""
|
||||
|
||||
latency: Nullable[float]
|
||||
r"""Total latency in milliseconds"""
|
||||
|
||||
moderation_latency: Nullable[float]
|
||||
r"""Moderation latency in milliseconds"""
|
||||
|
||||
generation_time: Nullable[float]
|
||||
r"""Time taken for generation in milliseconds"""
|
||||
|
||||
finish_reason: Nullable[str]
|
||||
r"""Reason the generation finished"""
|
||||
|
||||
tokens_prompt: Nullable[float]
|
||||
r"""Number of tokens in the prompt"""
|
||||
|
||||
tokens_completion: Nullable[float]
|
||||
r"""Number of tokens in the completion"""
|
||||
|
||||
native_tokens_prompt: Nullable[float]
|
||||
r"""Native prompt tokens as reported by provider"""
|
||||
|
||||
native_tokens_completion: Nullable[float]
|
||||
r"""Native completion tokens as reported by provider"""
|
||||
|
||||
native_tokens_completion_images: Nullable[float]
|
||||
r"""Native completion image tokens as reported by provider"""
|
||||
|
||||
native_tokens_reasoning: Nullable[float]
|
||||
r"""Native reasoning tokens as reported by provider"""
|
||||
|
||||
native_tokens_cached: Nullable[float]
|
||||
r"""Native cached tokens as reported by provider"""
|
||||
|
||||
num_media_prompt: Nullable[float]
|
||||
r"""Number of media items in the prompt"""
|
||||
|
||||
num_input_audio_prompt: Nullable[float]
|
||||
r"""Number of audio inputs in the prompt"""
|
||||
|
||||
num_media_completion: Nullable[float]
|
||||
r"""Number of media items in the completion"""
|
||||
|
||||
num_search_results: Nullable[float]
|
||||
r"""Number of search results included"""
|
||||
|
||||
origin: str
|
||||
r"""Origin URL of the request"""
|
||||
|
||||
usage: float
|
||||
r"""Usage amount in USD"""
|
||||
|
||||
is_byok: bool
|
||||
r"""Whether this used bring-your-own-key"""
|
||||
|
||||
native_finish_reason: Nullable[str]
|
||||
r"""Native finish reason as reported by provider"""
|
||||
|
||||
external_user: Nullable[str]
|
||||
r"""External user identifier"""
|
||||
|
||||
api_type: Annotated[Nullable[APIType], PlainValidator(validate_open_enum(False))]
|
||||
r"""Type of API used for the generation"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = []
|
||||
nullable_fields = [
|
||||
"upstream_id",
|
||||
"cache_discount",
|
||||
"upstream_inference_cost",
|
||||
"app_id",
|
||||
"streamed",
|
||||
"cancelled",
|
||||
"provider_name",
|
||||
"latency",
|
||||
"moderation_latency",
|
||||
"generation_time",
|
||||
"finish_reason",
|
||||
"tokens_prompt",
|
||||
"tokens_completion",
|
||||
"native_tokens_prompt",
|
||||
"native_tokens_completion",
|
||||
"native_tokens_completion_images",
|
||||
"native_tokens_reasoning",
|
||||
"native_tokens_cached",
|
||||
"num_media_prompt",
|
||||
"num_input_audio_prompt",
|
||||
"num_media_completion",
|
||||
"num_search_results",
|
||||
"native_finish_reason",
|
||||
"external_user",
|
||||
"api_type",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class GetGenerationResponseTypedDict(TypedDict):
|
||||
r"""Generation response"""
|
||||
|
||||
data: GetGenerationDataTypedDict
|
||||
r"""Generation data"""
|
||||
|
||||
|
||||
class GetGenerationResponse(BaseModel):
|
||||
r"""Generation response"""
|
||||
|
||||
data: GetGenerationData
|
||||
r"""Generation data"""
|
||||
@@ -0,0 +1,180 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import FieldMetadata, PathParamMetadata
|
||||
from pydantic import model_serializer
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class GetKeyRequestTypedDict(TypedDict):
|
||||
hash: str
|
||||
r"""The hash identifier of the API key to retrieve"""
|
||||
|
||||
|
||||
class GetKeyRequest(BaseModel):
|
||||
hash: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
r"""The hash identifier of the API key to retrieve"""
|
||||
|
||||
|
||||
class GetKeyDataTypedDict(TypedDict):
|
||||
r"""The API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
|
||||
class GetKeyData(BaseModel):
|
||||
r"""The API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["expires_at"]
|
||||
nullable_fields = [
|
||||
"limit",
|
||||
"limit_remaining",
|
||||
"limit_reset",
|
||||
"updated_at",
|
||||
"expires_at",
|
||||
]
|
||||
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 GetKeyResponseTypedDict(TypedDict):
|
||||
r"""API key details"""
|
||||
|
||||
data: GetKeyDataTypedDict
|
||||
r"""The API key information"""
|
||||
|
||||
|
||||
class GetKeyResponse(BaseModel):
|
||||
r"""API key details"""
|
||||
|
||||
data: GetKeyData
|
||||
r"""The API key information"""
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, QueryParamMetadata
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class GetModelsRequestTypedDict(TypedDict):
|
||||
category: NotRequired[str]
|
||||
supported_parameters: NotRequired[str]
|
||||
|
||||
|
||||
class GetModelsRequest(BaseModel):
|
||||
category: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
|
||||
supported_parameters: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
@@ -0,0 +1,195 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import (
|
||||
FieldMetadata,
|
||||
PathParamMetadata,
|
||||
QueryParamMetadata,
|
||||
SecurityMetadata,
|
||||
validate_open_enum,
|
||||
)
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class GetParametersSecurityTypedDict(TypedDict):
|
||||
bearer: str
|
||||
|
||||
|
||||
class GetParametersSecurity(BaseModel):
|
||||
bearer: Annotated[
|
||||
str,
|
||||
FieldMetadata(
|
||||
security=SecurityMetadata(
|
||||
scheme=True,
|
||||
scheme_type="http",
|
||||
sub_type="bearer",
|
||||
field_name="Authorization",
|
||||
)
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
GetParametersProvider = Union[
|
||||
Literal[
|
||||
"AI21",
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"AtlasCloud",
|
||||
"Atoma",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
"Cirrascale",
|
||||
"Clarifai",
|
||||
"Cloudflare",
|
||||
"Cohere",
|
||||
"CrofAI",
|
||||
"Crusoe",
|
||||
"DeepInfra",
|
||||
"DeepSeek",
|
||||
"Enfer",
|
||||
"Featherless",
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
"Hyperbolic",
|
||||
"Inception",
|
||||
"InferenceNet",
|
||||
"Infermatic",
|
||||
"Inflection",
|
||||
"Kluster",
|
||||
"Lambda",
|
||||
"Liquid",
|
||||
"Mancer 2",
|
||||
"Meta",
|
||||
"Minimax",
|
||||
"ModelRun",
|
||||
"Mistral",
|
||||
"Modular",
|
||||
"Moonshot AI",
|
||||
"Morph",
|
||||
"NCompass",
|
||||
"Nebius",
|
||||
"NextBit",
|
||||
"Nineteen",
|
||||
"Novita",
|
||||
"Nvidia",
|
||||
"OpenAI",
|
||||
"OpenInference",
|
||||
"Parasail",
|
||||
"Perplexity",
|
||||
"Phala",
|
||||
"Relace",
|
||||
"SambaNova",
|
||||
"SiliconFlow",
|
||||
"Stealth",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
"Ubicloud",
|
||||
"Venice",
|
||||
"WandB",
|
||||
"xAI",
|
||||
"Z.AI",
|
||||
"FakeProvider",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class GetParametersRequestTypedDict(TypedDict):
|
||||
author: str
|
||||
slug: str
|
||||
provider: NotRequired[GetParametersProvider]
|
||||
|
||||
|
||||
class GetParametersRequest(BaseModel):
|
||||
author: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
|
||||
slug: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
|
||||
provider: Annotated[
|
||||
Annotated[
|
||||
Optional[GetParametersProvider], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
|
||||
|
||||
SupportedParameter = Union[
|
||||
Literal[
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"min_p",
|
||||
"top_a",
|
||||
"frequency_penalty",
|
||||
"presence_penalty",
|
||||
"repetition_penalty",
|
||||
"max_tokens",
|
||||
"logit_bias",
|
||||
"logprobs",
|
||||
"top_logprobs",
|
||||
"seed",
|
||||
"response_format",
|
||||
"structured_outputs",
|
||||
"stop",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"parallel_tool_calls",
|
||||
"include_reasoning",
|
||||
"reasoning",
|
||||
"web_search_options",
|
||||
"verbosity",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class GetParametersDataTypedDict(TypedDict):
|
||||
r"""Parameter analytics data"""
|
||||
|
||||
model: str
|
||||
r"""Model identifier"""
|
||||
supported_parameters: List[SupportedParameter]
|
||||
r"""List of parameters supported by this model"""
|
||||
|
||||
|
||||
class GetParametersData(BaseModel):
|
||||
r"""Parameter analytics data"""
|
||||
|
||||
model: str
|
||||
r"""Model identifier"""
|
||||
|
||||
supported_parameters: List[
|
||||
Annotated[SupportedParameter, PlainValidator(validate_open_enum(False))]
|
||||
]
|
||||
r"""List of parameters supported by this model"""
|
||||
|
||||
|
||||
class GetParametersResponseTypedDict(TypedDict):
|
||||
r"""Returns the parameters for the specified model"""
|
||||
|
||||
data: GetParametersDataTypedDict
|
||||
r"""Parameter analytics data"""
|
||||
|
||||
|
||||
class GetParametersResponse(BaseModel):
|
||||
r"""Returns the parameters for the specified model"""
|
||||
|
||||
data: GetParametersData
|
||||
r"""Parameter analytics data"""
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import activityitem as components_activityitem
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, QueryParamMetadata
|
||||
import pydantic
|
||||
from typing import List, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class GetUserActivityRequestTypedDict(TypedDict):
|
||||
date_: NotRequired[str]
|
||||
r"""Filter by a single UTC date in the last 30 days (YYYY-MM-DD format)."""
|
||||
|
||||
|
||||
class GetUserActivityRequest(BaseModel):
|
||||
date_: Annotated[
|
||||
Optional[str],
|
||||
pydantic.Field(alias="date"),
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Filter by a single UTC date in the last 30 days (YYYY-MM-DD format)."""
|
||||
|
||||
|
||||
class GetUserActivityResponseTypedDict(TypedDict):
|
||||
r"""Returns user activity data grouped by endpoint"""
|
||||
|
||||
data: List[components_activityitem.ActivityItemTypedDict]
|
||||
r"""List of activity items"""
|
||||
|
||||
|
||||
class GetUserActivityResponse(BaseModel):
|
||||
r"""Returns user activity data grouped by endpoint"""
|
||||
|
||||
data: List[components_activityitem.ActivityItem]
|
||||
r"""List of activity items"""
|
||||
@@ -0,0 +1,186 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import FieldMetadata, QueryParamMetadata
|
||||
from pydantic import model_serializer
|
||||
from typing import List, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ListRequestTypedDict(TypedDict):
|
||||
include_disabled: NotRequired[str]
|
||||
r"""Whether to include disabled API keys in the response"""
|
||||
offset: NotRequired[str]
|
||||
r"""Number of API keys to skip for pagination"""
|
||||
|
||||
|
||||
class ListRequest(BaseModel):
|
||||
include_disabled: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Whether to include disabled API keys in the response"""
|
||||
|
||||
offset: Annotated[
|
||||
Optional[str],
|
||||
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
||||
] = None
|
||||
r"""Number of API keys to skip for pagination"""
|
||||
|
||||
|
||||
class ListDataTypedDict(TypedDict):
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
|
||||
class ListData(BaseModel):
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["expires_at"]
|
||||
nullable_fields = [
|
||||
"limit",
|
||||
"limit_remaining",
|
||||
"limit_reset",
|
||||
"updated_at",
|
||||
"expires_at",
|
||||
]
|
||||
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 ListResponseTypedDict(TypedDict):
|
||||
r"""List of API keys"""
|
||||
|
||||
data: List[ListDataTypedDict]
|
||||
r"""List of API keys"""
|
||||
|
||||
|
||||
class ListResponse(BaseModel):
|
||||
r"""List of API keys"""
|
||||
|
||||
data: List[ListData]
|
||||
r"""List of API keys"""
|
||||
@@ -0,0 +1,38 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import (
|
||||
listendpointsresponse as components_listendpointsresponse,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, PathParamMetadata
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ListEndpointsRequestTypedDict(TypedDict):
|
||||
author: str
|
||||
slug: str
|
||||
|
||||
|
||||
class ListEndpointsRequest(BaseModel):
|
||||
author: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
|
||||
slug: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
|
||||
|
||||
class ListEndpointsResponseTypedDict(TypedDict):
|
||||
r"""Returns a list of endpoints"""
|
||||
|
||||
data: components_listendpointsresponse.ListEndpointsResponseTypedDict
|
||||
r"""List of available endpoints for a model"""
|
||||
|
||||
|
||||
class ListEndpointsResponse(BaseModel):
|
||||
r"""Returns a list of endpoints"""
|
||||
|
||||
data: components_listendpointsresponse.ListEndpointsResponse
|
||||
r"""List of available endpoints for a model"""
|
||||
@@ -0,0 +1,19 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import publicendpoint as components_publicendpoint
|
||||
from openrouter.types import BaseModel
|
||||
from typing import List
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class ListEndpointsZdrResponseTypedDict(TypedDict):
|
||||
r"""Returns a list of endpoints"""
|
||||
|
||||
data: List[components_publicendpoint.PublicEndpointTypedDict]
|
||||
|
||||
|
||||
class ListEndpointsZdrResponse(BaseModel):
|
||||
r"""Returns a list of endpoints"""
|
||||
|
||||
data: List[components_publicendpoint.PublicEndpoint]
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import FieldMetadata, SecurityMetadata
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ListModelsUserSecurityTypedDict(TypedDict):
|
||||
bearer: str
|
||||
|
||||
|
||||
class ListModelsUserSecurity(BaseModel):
|
||||
bearer: Annotated[
|
||||
str,
|
||||
FieldMetadata(
|
||||
security=SecurityMetadata(
|
||||
scheme=True,
|
||||
scheme_type="http",
|
||||
sub_type="bearer",
|
||||
field_name="Authorization",
|
||||
)
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,89 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from typing import List
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
|
||||
|
||||
class ListProvidersDataTypedDict(TypedDict):
|
||||
name: str
|
||||
r"""Display name of the provider"""
|
||||
slug: str
|
||||
r"""URL-friendly identifier for the provider"""
|
||||
privacy_policy_url: Nullable[str]
|
||||
r"""URL to the provider's privacy policy"""
|
||||
terms_of_service_url: NotRequired[Nullable[str]]
|
||||
r"""URL to the provider's terms of service"""
|
||||
status_page_url: NotRequired[Nullable[str]]
|
||||
r"""URL to the provider's status page"""
|
||||
|
||||
|
||||
class ListProvidersData(BaseModel):
|
||||
name: str
|
||||
r"""Display name of the provider"""
|
||||
|
||||
slug: str
|
||||
r"""URL-friendly identifier for the provider"""
|
||||
|
||||
privacy_policy_url: Nullable[str]
|
||||
r"""URL to the provider's privacy policy"""
|
||||
|
||||
terms_of_service_url: OptionalNullable[str] = UNSET
|
||||
r"""URL to the provider's terms of service"""
|
||||
|
||||
status_page_url: OptionalNullable[str] = UNSET
|
||||
r"""URL to the provider's status page"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["terms_of_service_url", "status_page_url"]
|
||||
nullable_fields = [
|
||||
"privacy_policy_url",
|
||||
"terms_of_service_url",
|
||||
"status_page_url",
|
||||
]
|
||||
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 ListProvidersResponseTypedDict(TypedDict):
|
||||
r"""Returns a list of providers"""
|
||||
|
||||
data: List[ListProvidersDataTypedDict]
|
||||
|
||||
|
||||
class ListProvidersResponse(BaseModel):
|
||||
r"""Returns a list of providers"""
|
||||
|
||||
data: List[ListProvidersData]
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.components import (
|
||||
chatresponse as components_chatresponse,
|
||||
chatstreamingresponsechunk as components_chatstreamingresponsechunk,
|
||||
)
|
||||
from openrouter.utils import eventstreaming
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAliasType
|
||||
|
||||
|
||||
SendChatCompletionRequestResponseTypedDict = TypeAliasType(
|
||||
"SendChatCompletionRequestResponseTypedDict",
|
||||
Union[
|
||||
components_chatresponse.ChatResponseTypedDict,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkDataTypedDict
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkDataTypedDict
|
||||
],
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
SendChatCompletionRequestResponse = TypeAliasType(
|
||||
"SendChatCompletionRequestResponse",
|
||||
Union[
|
||||
components_chatresponse.ChatResponse,
|
||||
Union[
|
||||
eventstreaming.EventStream[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkData
|
||||
],
|
||||
eventstreaming.EventStreamAsync[
|
||||
components_chatstreamingresponsechunk.ChatStreamingResponseChunkData
|
||||
],
|
||||
],
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,274 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import (
|
||||
FieldMetadata,
|
||||
PathParamMetadata,
|
||||
RequestMetadata,
|
||||
validate_open_enum,
|
||||
)
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
UpdateKeysLimitReset = Union[
|
||||
Literal[
|
||||
"daily",
|
||||
"weekly",
|
||||
"monthly",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
|
||||
|
||||
class UpdateKeysRequestBodyTypedDict(TypedDict):
|
||||
name: NotRequired[str]
|
||||
r"""New name for the API key"""
|
||||
disabled: NotRequired[bool]
|
||||
r"""Whether to disable the API key"""
|
||||
limit: NotRequired[Nullable[float]]
|
||||
r"""New spending limit for the API key in USD"""
|
||||
limit_reset: NotRequired[Nullable[UpdateKeysLimitReset]]
|
||||
r"""New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
include_byok_in_limit: NotRequired[bool]
|
||||
r"""Whether to include BYOK usage in the limit"""
|
||||
|
||||
|
||||
class UpdateKeysRequestBody(BaseModel):
|
||||
name: Optional[str] = None
|
||||
r"""New name for the API key"""
|
||||
|
||||
disabled: Optional[bool] = None
|
||||
r"""Whether to disable the API key"""
|
||||
|
||||
limit: OptionalNullable[float] = UNSET
|
||||
r"""New spending limit for the API key in USD"""
|
||||
|
||||
limit_reset: Annotated[
|
||||
OptionalNullable[UpdateKeysLimitReset],
|
||||
PlainValidator(validate_open_enum(False)),
|
||||
] = UNSET
|
||||
r"""New limit reset type for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday."""
|
||||
|
||||
include_byok_in_limit: Optional[bool] = None
|
||||
r"""Whether to include BYOK usage in the limit"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"name",
|
||||
"disabled",
|
||||
"limit",
|
||||
"limit_reset",
|
||||
"include_byok_in_limit",
|
||||
]
|
||||
nullable_fields = ["limit", "limit_reset"]
|
||||
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 UpdateKeysRequestTypedDict(TypedDict):
|
||||
hash: str
|
||||
r"""The hash identifier of the API key to update"""
|
||||
body: UpdateKeysRequestBodyTypedDict
|
||||
|
||||
|
||||
class UpdateKeysRequest(BaseModel):
|
||||
hash: Annotated[
|
||||
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
||||
]
|
||||
r"""The hash identifier of the API key to update"""
|
||||
|
||||
body: Annotated[
|
||||
UpdateKeysRequestBody,
|
||||
FieldMetadata(request=RequestMetadata(media_type="application/json")),
|
||||
]
|
||||
|
||||
|
||||
class UpdateKeysDataTypedDict(TypedDict):
|
||||
r"""The updated API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
expires_at: NotRequired[Nullable[datetime]]
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
|
||||
class UpdateKeysData(BaseModel):
|
||||
r"""The updated API key information"""
|
||||
|
||||
hash: str
|
||||
r"""Unique hash identifier for the API key"""
|
||||
|
||||
name: str
|
||||
r"""Name of the API key"""
|
||||
|
||||
label: str
|
||||
r"""Human-readable label for the API key"""
|
||||
|
||||
disabled: bool
|
||||
r"""Whether the API key is disabled"""
|
||||
|
||||
limit: Nullable[float]
|
||||
r"""Spending limit for the API key in USD"""
|
||||
|
||||
limit_remaining: Nullable[float]
|
||||
r"""Remaining spending limit in USD"""
|
||||
|
||||
limit_reset: Nullable[str]
|
||||
r"""Type of limit reset for the API key"""
|
||||
|
||||
include_byok_in_limit: bool
|
||||
r"""Whether to include external BYOK usage in the credit limit"""
|
||||
|
||||
usage: float
|
||||
r"""Total OpenRouter credit usage (in USD) for the API key"""
|
||||
|
||||
usage_daily: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC day"""
|
||||
|
||||
usage_weekly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
usage_monthly: float
|
||||
r"""OpenRouter credit usage (in USD) for the current UTC month"""
|
||||
|
||||
byok_usage: float
|
||||
r"""Total external BYOK usage (in USD) for the API key"""
|
||||
|
||||
byok_usage_daily: float
|
||||
r"""External BYOK usage (in USD) for the current UTC day"""
|
||||
|
||||
byok_usage_weekly: float
|
||||
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
|
||||
|
||||
byok_usage_monthly: float
|
||||
r"""External BYOK usage (in USD) for current UTC month"""
|
||||
|
||||
created_at: str
|
||||
r"""ISO 8601 timestamp of when the API key was created"""
|
||||
|
||||
updated_at: Nullable[str]
|
||||
r"""ISO 8601 timestamp of when the API key was last updated"""
|
||||
|
||||
expires_at: OptionalNullable[datetime] = UNSET
|
||||
r"""ISO 8601 UTC timestamp when the API key expires, or null if no expiration"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["expires_at"]
|
||||
nullable_fields = [
|
||||
"limit",
|
||||
"limit_remaining",
|
||||
"limit_reset",
|
||||
"updated_at",
|
||||
"expires_at",
|
||||
]
|
||||
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 UpdateKeysResponseTypedDict(TypedDict):
|
||||
r"""API key updated successfully"""
|
||||
|
||||
data: UpdateKeysDataTypedDict
|
||||
r"""The updated API key information"""
|
||||
|
||||
|
||||
class UpdateKeysResponse(BaseModel):
|
||||
r"""API key updated successfully"""
|
||||
|
||||
data: UpdateKeysData
|
||||
r"""The updated API key information"""
|
||||
Reference in New Issue
Block a user