Files
openrouter-python-sdk-retry…/src/openrouter/operations/getcurrentkey.py
T

330 lines
11 KiB
Python

"""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, HeaderMetadata
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict, deprecated
class GetCurrentKeyGlobalsTypedDict(TypedDict):
http_referer: NotRequired[str]
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
"""
x_open_router_title: NotRequired[str]
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
"""
x_open_router_categories: NotRequired[str]
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
"""
class GetCurrentKeyGlobals(BaseModel):
http_referer: Annotated[
Optional[str],
pydantic.Field(alias="HTTP-Referer"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
"""
x_open_router_title: Annotated[
Optional[str],
pydantic.Field(alias="X-OpenRouter-Title"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
"""
x_open_router_categories: Annotated[
Optional[str],
pydantic.Field(alias="X-OpenRouter-Categories"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(
["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"]
)
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
class GetCurrentKeyRequestTypedDict(TypedDict):
http_referer: NotRequired[str]
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
"""
x_open_router_title: NotRequired[str]
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
"""
x_open_router_categories: NotRequired[str]
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
"""
class GetCurrentKeyRequest(BaseModel):
http_referer: Annotated[
Optional[str],
pydantic.Field(alias="HTTP-Referer"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
"""
x_open_router_title: Annotated[
Optional[str],
pydantic.Field(alias="X-OpenRouter-Title"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The app display name allows you to customize how your app appears in OpenRouter's dashboard.
"""
x_open_router_categories: Annotated[
Optional[str],
pydantic.Field(alias="X-OpenRouter-Categories"),
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
"""
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(
["HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories"]
)
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
if val != UNSET_SENTINEL:
if val is not None or k not in optional_fields:
m[k] = val
return m
@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."""
interval: str
r"""Rate limit interval"""
note: str
r"""Note about the rate limit"""
requests: int
r"""Number of requests allowed per interval"""
@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."""
interval: str
r"""Rate limit interval"""
note: str
r"""Note about the rate limit"""
requests: int
r"""Number of requests allowed per interval"""
class GetCurrentKeyDataTypedDict(TypedDict):
r"""Current API key information"""
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_monthly: float
r"""External BYOK usage (in USD) for current UTC month"""
byok_usage_weekly: float
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
creator_user_id: Nullable[str]
r"""The user ID of the key creator. For organization-owned keys, this is the member who created the key. For individual users, this is the user's own ID."""
include_byok_in_limit: bool
r"""Whether to include external BYOK usage in the credit limit"""
is_free_tier: bool
r"""Whether this is a free tier API key"""
is_management_key: bool
r"""Whether this is a management key"""
is_provisioning_key: bool
r"""Whether this is a management key"""
label: str
r"""Human-readable label for the API key"""
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"""
rate_limit: RateLimitTypedDict
r"""Legacy rate limit information about a key. Will always return -1."""
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_monthly: float
r"""OpenRouter credit usage (in USD) for the current UTC month"""
usage_weekly: float
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
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"""
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_monthly: float
r"""External BYOK usage (in USD) for current UTC month"""
byok_usage_weekly: float
r"""External BYOK usage (in USD) for the current UTC week (Monday-Sunday)"""
creator_user_id: Nullable[str]
r"""The user ID of the key creator. For organization-owned keys, this is the member who created the key. For individual users, this is the user's own ID."""
include_byok_in_limit: bool
r"""Whether to include external BYOK usage in the credit limit"""
is_free_tier: bool
r"""Whether this is a free tier API key"""
is_management_key: bool
r"""Whether this is a management key"""
is_provisioning_key: Annotated[
bool,
pydantic.Field(
deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
),
]
r"""Whether this is a management key"""
label: str
r"""Human-readable label for the API key"""
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"""
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."""
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_monthly: float
r"""OpenRouter credit usage (in USD) for the current UTC month"""
usage_weekly: float
r"""OpenRouter credit usage (in USD) for the current UTC week (Monday-Sunday)"""
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 = set(["expires_at"])
nullable_fields = set(
["creator_user_id", "expires_at", "limit", "limit_remaining", "limit_reset"]
)
serialized = handler(self)
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
val = serialized.get(k, serialized.get(n))
is_nullable_and_explicitly_set = (
k in nullable_fields
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
)
if val != UNSET_SENTINEL:
if (
val is not None
or k not in optional_fields
or is_nullable_and_explicitly_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"""