Files
openrouter-python-sdk-retry…/src/openrouter/components/anthropicdocumentblockparam.py
T
speakeasybot 4e789208b4 ## Python SDK Changes:
* `open_router.beta.responses.send()`: 
  *  `request` **Changed** **Breaking** ⚠️
  *  `response` **Changed** **Breaking** ⚠️
* `open_router.presets.create_presets_responses()`:  `request` **Changed** **Breaking** ⚠️
* `open_router.presets.create_presets_chat_completions()`:  `request` **Changed** **Breaking** ⚠️
* `open_router.chat.send()`:  `request` **Changed** **Breaking** ⚠️
* `open_router.workspaces.set_budget()`: **Added**
* `open_router.o_auth.create_auth_code()`: 
  *  `request.workspace_id` **Added**
  *  `error.status[403]` **Added**
* `open_router.files.download()`: **Added**
* `open_router.models.get()`: **Added**
* `open_router.workspaces.list_budgets()`: **Added**
* `open_router.workspaces.delete_budget()`: **Added**
* `open_router.datasets.get_benchmarks_artificial_analysis()`: **Added**
* `open_router.beta.analytics.query_analytics()`:  `response.data.warnings` **Added**
* `open_router.files.delete()`: **Added**
* `open_router.files.retrieve()`: **Added**
* `open_router.files.upload()`: **Added**
* `open_router.embeddings.list_models()`:  `response.data.[].benchmarks` **Added**
* `open_router.models.list()`: 
  *  `request` **Changed**
  *  `response.data.[].benchmarks` **Added**
* `open_router.models.list_for_user()`:  `response.data.[].benchmarks` **Added**
* `open_router.files.list()`: **Added**
* `open_router.presets.create_presets_messages()`:  `request` **Changed**
* `open_router.datasets.get_benchmarks_design_arena()`: **Added**
2026-06-17 01:01:09 +00:00

171 lines
5.3 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .anthropicbase64pdfsource import (
AnthropicBase64PdfSource,
AnthropicBase64PdfSourceTypedDict,
)
from .anthropiccachecontroldirective import (
AnthropicCacheControlDirective,
AnthropicCacheControlDirectiveTypedDict,
)
from .anthropicfiledocumentsource import (
AnthropicFileDocumentSource,
AnthropicFileDocumentSourceTypedDict,
)
from .anthropicimageblockparam import (
AnthropicImageBlockParam,
AnthropicImageBlockParamTypedDict,
)
from .anthropicplaintextsource import (
AnthropicPlainTextSource,
AnthropicPlainTextSourceTypedDict,
)
from .anthropictextblockparam import (
AnthropicTextBlockParam,
AnthropicTextBlockParamTypedDict,
)
from .anthropicurlpdfsource import AnthropicURLPdfSource, AnthropicURLPdfSourceTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
)
from openrouter.utils import get_discriminator
from pydantic import Discriminator, Tag, model_serializer
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
class AnthropicDocumentBlockParamCitationsTypedDict(TypedDict):
enabled: NotRequired[bool]
class AnthropicDocumentBlockParamCitations(BaseModel):
enabled: Optional[bool] = None
AnthropicDocumentBlockParamContent1TypedDict = TypeAliasType(
"AnthropicDocumentBlockParamContent1TypedDict",
Union[AnthropicImageBlockParamTypedDict, AnthropicTextBlockParamTypedDict],
)
AnthropicDocumentBlockParamContent1 = Annotated[
Union[
Annotated[AnthropicImageBlockParam, Tag("image")],
Annotated[AnthropicTextBlockParam, Tag("text")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
AnthropicDocumentBlockParamContent2TypedDict = TypeAliasType(
"AnthropicDocumentBlockParamContent2TypedDict",
Union[str, List[AnthropicDocumentBlockParamContent1TypedDict]],
)
AnthropicDocumentBlockParamContent2 = TypeAliasType(
"AnthropicDocumentBlockParamContent2",
Union[str, List[AnthropicDocumentBlockParamContent1]],
)
SourceType = Literal["content",]
class SourceContentTypedDict(TypedDict):
content: AnthropicDocumentBlockParamContent2TypedDict
type: SourceType
class SourceContent(BaseModel):
content: AnthropicDocumentBlockParamContent2
type: SourceType
AnthropicDocumentBlockParamSourceUnionTypedDict = TypeAliasType(
"AnthropicDocumentBlockParamSourceUnionTypedDict",
Union[
SourceContentTypedDict,
AnthropicURLPdfSourceTypedDict,
AnthropicFileDocumentSourceTypedDict,
AnthropicBase64PdfSourceTypedDict,
AnthropicPlainTextSourceTypedDict,
],
)
AnthropicDocumentBlockParamSourceUnion = Annotated[
Union[
Annotated[AnthropicBase64PdfSource, Tag("base64")],
Annotated[AnthropicPlainTextSource, Tag("text")],
Annotated[SourceContent, Tag("content")],
Annotated[AnthropicURLPdfSource, Tag("url")],
Annotated[AnthropicFileDocumentSource, Tag("file")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
TypeDocument = Literal["document",]
class AnthropicDocumentBlockParamTypedDict(TypedDict):
source: AnthropicDocumentBlockParamSourceUnionTypedDict
type: TypeDocument
cache_control: NotRequired[AnthropicCacheControlDirectiveTypedDict]
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
citations: NotRequired[Nullable[AnthropicDocumentBlockParamCitationsTypedDict]]
context: NotRequired[Nullable[str]]
title: NotRequired[Nullable[str]]
class AnthropicDocumentBlockParam(BaseModel):
source: AnthropicDocumentBlockParamSourceUnion
type: TypeDocument
cache_control: Optional[AnthropicCacheControlDirective] = None
r"""Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models."""
citations: OptionalNullable[AnthropicDocumentBlockParamCitations] = UNSET
context: OptionalNullable[str] = UNSET
title: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = ["cache_control", "citations", "context", "title"]
nullable_fields = ["citations", "context", "title"]
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