"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations import io from openrouter.types import BaseModel, UNSET_SENTINEL from openrouter.utils import ( FieldMetadata, HeaderMetadata, MultipartFormMetadata, QueryParamMetadata, RequestMetadata, ) import pydantic from pydantic import model_serializer from typing import IO, Optional, Union from typing_extensions import Annotated, NotRequired, TypedDict class UploadFileGlobalsTypedDict(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 UploadFileGlobals(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 UploadFileFileTypedDict(TypedDict): file_name: str content: Union[bytes, IO[bytes], io.IOBase] content_type: NotRequired[str] class UploadFileFile(BaseModel): file_name: Annotated[ str, pydantic.Field(alias="fileName"), FieldMetadata(multipart=True) ] content: Annotated[ Union[bytes, IO[bytes], io.IOBase], pydantic.Field(alias=""), FieldMetadata(multipart=MultipartFormMetadata(content=True)), ] content_type: Annotated[ Optional[str], pydantic.Field(alias="Content-Type"), FieldMetadata(multipart=True), ] = None @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["contentType"]) 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 UploadFileRequestBodyTypedDict(TypedDict): file: UploadFileFileTypedDict class UploadFileRequestBody(BaseModel): file: Annotated[ UploadFileFile, FieldMetadata(multipart=MultipartFormMetadata(file=True)) ] class UploadFileRequestTypedDict(TypedDict): request_body: UploadFileRequestBodyTypedDict 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. """ workspace_id: NotRequired[str] r"""Workspace to scope the request to. Defaults to the caller’s default workspace.""" class UploadFileRequest(BaseModel): request_body: Annotated[ UploadFileRequestBody, FieldMetadata(request=RequestMetadata(media_type="multipart/form-data")), ] 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. """ workspace_id: Annotated[ Optional[str], FieldMetadata(query=QueryParamMetadata(style="form", explode=True)), ] = None r"""Workspace to scope the request to. Defaults to the caller’s default workspace.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "HTTP-Referer", "X-OpenRouter-Title", "X-OpenRouter-Categories", "workspace_id", ] ) 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