Skip to content

Commit 9048173

Browse files
feat(api): add URL source blocks for images and PDFs (#884)
1 parent b5aaa3c commit 9048173

21 files changed

+347
-87
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-e1328d31b4446324096fb948bd5074b5ac00d7c7e3ce89b6974a1c5aebf5a64d.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-129d8719c17bc9ea6e310a63400f60e7ad3ef828e54265eb8a8035684187210b.yml

api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Types:
2222

2323
```python
2424
from anthropic.types import (
25+
Base64ImageSource,
2526
Base64PDFSource,
2627
CacheControlEphemeral,
2728
CitationCharLocation,
@@ -86,6 +87,8 @@ from anthropic.types import (
8687
ToolUnion,
8788
ToolUseBlock,
8889
ToolUseBlockParam,
90+
URLImageSource,
91+
URLPDFSource,
8992
Usage,
9093
)
9194
```
@@ -176,6 +179,7 @@ Types:
176179

177180
```python
178181
from anthropic.types.beta import (
182+
BetaBase64ImageSource,
179183
BetaBase64PDFBlock,
180184
BetaBase64PDFSource,
181185
BetaCacheControlEphemeral,
@@ -235,6 +239,8 @@ from anthropic.types.beta import (
235239
BetaToolUnion,
236240
BetaToolUseBlock,
237241
BetaToolUseBlockParam,
242+
BetaURLImageSource,
243+
BetaURLPDFSource,
238244
BetaUsage,
239245
)
240246
```

src/anthropic/types/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
from .message_tokens_count import MessageTokensCount as MessageTokensCount
5757
from .thinking_block_param import ThinkingBlockParam as ThinkingBlockParam
5858
from .tool_use_block_param import ToolUseBlockParam as ToolUseBlockParam
59+
from .url_pdf_source_param import URLPDFSourceParam as URLPDFSourceParam
5960
from .beta_overloaded_error import BetaOverloadedError as BetaOverloadedError
6061
from .beta_permission_error import BetaPermissionError as BetaPermissionError
6162
from .beta_rate_limit_error import BetaRateLimitError as BetaRateLimitError
@@ -68,6 +69,7 @@
6869
from .raw_message_stop_event import RawMessageStopEvent as RawMessageStopEvent
6970
from .tool_choice_auto_param import ToolChoiceAutoParam as ToolChoiceAutoParam
7071
from .tool_choice_tool_param import ToolChoiceToolParam as ToolChoiceToolParam
72+
from .url_image_source_param import URLImageSourceParam as URLImageSourceParam
7173
from .base64_pdf_source_param import Base64PDFSourceParam as Base64PDFSourceParam
7274
from .plain_text_source_param import PlainTextSourceParam as PlainTextSourceParam
7375
from .raw_message_delta_event import RawMessageDeltaEvent as RawMessageDeltaEvent
@@ -78,6 +80,7 @@
7880
from .content_block_stop_event import ContentBlockStopEvent as ContentBlockStopEvent
7981
from .raw_message_stream_event import RawMessageStreamEvent as RawMessageStreamEvent
8082
from .tool_bash_20250124_param import ToolBash20250124Param as ToolBash20250124Param
83+
from .base64_image_source_param import Base64ImageSourceParam as Base64ImageSourceParam
8184
from .beta_authentication_error import BetaAuthenticationError as BetaAuthenticationError
8285
from .content_block_delta_event import ContentBlockDeltaEvent as ContentBlockDeltaEvent
8386
from .content_block_start_event import ContentBlockStartEvent as ContentBlockStartEvent
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Union
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
7+
8+
from .._types import Base64FileInput
9+
from .._utils import PropertyInfo
10+
from .._models import set_pydantic_config
11+
12+
__all__ = ["Base64ImageSourceParam"]
13+
14+
15+
class Base64ImageSourceParam(TypedDict, total=False):
16+
data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]]
17+
18+
media_type: Required[Literal["image/jpeg", "image/png", "image/gif", "image/webp"]]
19+
20+
type: Required[Literal["base64"]]
21+
22+
23+
set_pydantic_config(Base64ImageSourceParam, {"arbitrary_types_allowed": True})

src/anthropic/types/beta/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .beta_message_tokens_count import BetaMessageTokensCount as BetaMessageTokensCount
3131
from .beta_thinking_block_param import BetaThinkingBlockParam as BetaThinkingBlockParam
3232
from .beta_tool_use_block_param import BetaToolUseBlockParam as BetaToolUseBlockParam
33+
from .beta_url_pdf_source_param import BetaURLPDFSourceParam as BetaURLPDFSourceParam
3334
from .beta_thinking_config_param import BetaThinkingConfigParam as BetaThinkingConfigParam
3435
from .beta_tool_choice_any_param import BetaToolChoiceAnyParam as BetaToolChoiceAnyParam
3536
from .beta_base64_pdf_block_param import BetaBase64PDFBlockParam as BetaBase64PDFBlockParam
@@ -39,6 +40,7 @@
3940
from .beta_raw_message_stop_event import BetaRawMessageStopEvent as BetaRawMessageStopEvent
4041
from .beta_tool_choice_auto_param import BetaToolChoiceAutoParam as BetaToolChoiceAutoParam
4142
from .beta_tool_choice_tool_param import BetaToolChoiceToolParam as BetaToolChoiceToolParam
43+
from .beta_url_image_source_param import BetaURLImageSourceParam as BetaURLImageSourceParam
4244
from .message_count_tokens_params import MessageCountTokensParams as MessageCountTokensParams
4345
from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam as BetaBase64PDFSourceParam
4446
from .beta_plain_text_source_param import BetaPlainTextSourceParam as BetaPlainTextSourceParam
@@ -49,6 +51,7 @@
4951
from .beta_raw_message_stream_event import BetaRawMessageStreamEvent as BetaRawMessageStreamEvent
5052
from .beta_tool_bash_20241022_param import BetaToolBash20241022Param as BetaToolBash20241022Param
5153
from .beta_tool_bash_20250124_param import BetaToolBash20250124Param as BetaToolBash20250124Param
54+
from .beta_base64_image_source_param import BetaBase64ImageSourceParam as BetaBase64ImageSourceParam
5255
from .beta_content_block_source_param import BetaContentBlockSourceParam as BetaContentBlockSourceParam
5356
from .beta_citation_char_location_param import BetaCitationCharLocationParam as BetaCitationCharLocationParam
5457
from .beta_citation_page_location_param import BetaCitationPageLocationParam as BetaCitationPageLocationParam
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Union
6+
from typing_extensions import Literal, Required, Annotated, TypedDict
7+
8+
from ..._types import Base64FileInput
9+
from ..._utils import PropertyInfo
10+
from ..._models import set_pydantic_config
11+
12+
__all__ = ["BetaBase64ImageSourceParam"]
13+
14+
15+
class BetaBase64ImageSourceParam(TypedDict, total=False):
16+
data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]]
17+
18+
media_type: Required[Literal["image/jpeg", "image/png", "image/gif", "image/webp"]]
19+
20+
type: Required[Literal["base64"]]
21+
22+
23+
set_pydantic_config(BetaBase64ImageSourceParam, {"arbitrary_types_allowed": True})

src/anthropic/types/beta/beta_base64_pdf_block_param.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Union, Optional
66
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

8+
from .beta_url_pdf_source_param import BetaURLPDFSourceParam
89
from .beta_citations_config_param import BetaCitationsConfigParam
910
from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam
1011
from .beta_plain_text_source_param import BetaPlainTextSourceParam
@@ -13,7 +14,9 @@
1314

1415
__all__ = ["BetaBase64PDFBlockParam", "Source"]
1516

16-
Source: TypeAlias = Union[BetaBase64PDFSourceParam, BetaPlainTextSourceParam, BetaContentBlockSourceParam]
17+
Source: TypeAlias = Union[
18+
BetaBase64PDFSourceParam, BetaPlainTextSourceParam, BetaContentBlockSourceParam, BetaURLPDFSourceParam
19+
]
1720

1821

1922
class BetaBase64PDFBlockParam(TypedDict, total=False):

src/anthropic/types/beta/beta_image_block_param.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,15 @@
33
from __future__ import annotations
44

55
from typing import Union, Optional
6-
from typing_extensions import Literal, Required, Annotated, TypedDict
6+
from typing_extensions import Literal, Required, TypeAlias, TypedDict
77

8-
from ..._types import Base64FileInput
9-
from ..._utils import PropertyInfo
10-
from ..._models import set_pydantic_config
8+
from .beta_url_image_source_param import BetaURLImageSourceParam
9+
from .beta_base64_image_source_param import BetaBase64ImageSourceParam
1110
from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam
1211

1312
__all__ = ["BetaImageBlockParam", "Source"]
1413

15-
16-
class Source(TypedDict, total=False):
17-
data: Required[Annotated[Union[str, Base64FileInput], PropertyInfo(format="base64")]]
18-
19-
media_type: Required[Literal["image/jpeg", "image/png", "image/gif", "image/webp"]]
20-
21-
type: Required[Literal["base64"]]
22-
23-
24-
set_pydantic_config(Source, {"arbitrary_types_allowed": True})
14+
Source: TypeAlias = Union[BetaBase64ImageSourceParam, BetaURLImageSourceParam]
2515

2616

2717
class BetaImageBlockParam(TypedDict, total=False):

src/anthropic/types/beta/beta_tool_union_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
__all__ = ["BetaToolUnionParam"]
1717

1818
BetaToolUnionParam: TypeAlias = Union[
19+
BetaToolParam,
1920
BetaToolComputerUse20241022Param,
2021
BetaToolBash20241022Param,
2122
BetaToolTextEditor20241022Param,
2223
BetaToolComputerUse20250124Param,
2324
BetaToolBash20250124Param,
2425
BetaToolTextEditor20250124Param,
25-
BetaToolParam,
2626
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Literal, Required, TypedDict
6+
7+
__all__ = ["BetaURLImageSourceParam"]
8+
9+
10+
class BetaURLImageSourceParam(TypedDict, total=False):
11+
type: Required[Literal["url"]]
12+
13+
url: Required[str]

0 commit comments

Comments
 (0)