Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:

- name: Run lints
run: ./scripts/lint

test:
name: test
runs-on: ubuntu-latest
Expand All @@ -51,4 +52,3 @@ jobs:

- name: Run tests
run: ./scripts/test

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.44.0"
".": "0.45.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-7270ee0a79d885681ee507414608229f61c27f47c40f355dcd210b38aa7cddf1.yml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.45.0 (2025-01-23)

Full Changelog: [v0.44.0...v0.45.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.44.0...v0.45.0)

### Features

* **api:** add citations ([#839](https://github.com/anthropics/anthropic-sdk-python/issues/839)) ([2ec74b6](https://github.com/anthropics/anthropic-sdk-python/commit/2ec74b6ff106c6e3d7d55e3c189e345098f8575e))
* **client:** support results endpoint ([#835](https://github.com/anthropics/anthropic-sdk-python/issues/835)) ([5dd88bf](https://github.com/anthropics/anthropic-sdk-python/commit/5dd88bf2d20b8909736cc0bc1e81296ba6e322a9))


### Chores

* **internal:** minor formatting changes ([#838](https://github.com/anthropics/anthropic-sdk-python/issues/838)) ([31eb826](https://github.com/anthropics/anthropic-sdk-python/commit/31eb826deb96a17d3c0bb953c728f39412c12ada))

## 0.44.0 (2025-01-21)

Full Changelog: [v0.43.1...v0.44.0](https://github.com/anthropics/anthropic-sdk-python/compare/v0.43.1...v0.44.0)
Expand Down
30 changes: 28 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ Types:
from anthropic.types import (
Base64PDFSource,
CacheControlEphemeral,
CitationCharLocation,
CitationCharLocationParam,
CitationContentBlockLocation,
CitationContentBlockLocationParam,
CitationPageLocation,
CitationPageLocationParam,
CitationsConfigParam,
CitationsDelta,
ContentBlock,
ContentBlockDeltaEvent,
ContentBlockParam,
ContentBlockSource,
ContentBlockSourceContent,
ContentBlockStartEvent,
ContentBlockStopEvent,
DocumentBlockParam,
Expand All @@ -42,6 +52,7 @@ from anthropic.types import (
MessageTokensCount,
Metadata,
Model,
PlainTextSource,
RawContentBlockDeltaEvent,
RawContentBlockStartEvent,
RawContentBlockStopEvent,
Expand All @@ -51,6 +62,8 @@ from anthropic.types import (
RawMessageStreamEvent,
TextBlock,
TextBlockParam,
TextCitation,
TextCitationParam,
TextDelta,
Tool,
ToolChoice,
Expand Down Expand Up @@ -95,7 +108,7 @@ Methods:
- <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">list</a>(\*\*<a href="src/anthropic/types/messages/batch_list_params.py">params</a>) -> <a href="./src/anthropic/types/messages/message_batch.py">SyncPage[MessageBatch]</a></code>
- <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">delete</a>(message_batch_id) -> <a href="./src/anthropic/types/messages/deleted_message_batch.py">DeletedMessageBatch</a></code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">cancel</a>(message_batch_id) -> <a href="./src/anthropic/types/messages/message_batch.py">MessageBatch</a></code>
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">results</a>(message_batch_id) -> JSONLDecoder[MessageBatchIndividualResponse]</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">results</a>(message_batch_id) -> <a href="./src/anthropic/types/messages/message_batch_individual_response.py">JSONLDecoder[MessageBatchIndividualResponse]</a></code>

# Models

Expand Down Expand Up @@ -153,15 +166,26 @@ from anthropic.types.beta import (
BetaBase64PDFBlock,
BetaBase64PDFSource,
BetaCacheControlEphemeral,
BetaCitationCharLocation,
BetaCitationCharLocationParam,
BetaCitationContentBlockLocation,
BetaCitationContentBlockLocationParam,
BetaCitationPageLocation,
BetaCitationPageLocationParam,
BetaCitationsConfigParam,
BetaCitationsDelta,
BetaContentBlock,
BetaContentBlockParam,
BetaContentBlockSource,
BetaContentBlockSourceContent,
BetaImageBlockParam,
BetaInputJSONDelta,
BetaMessage,
BetaMessageDeltaUsage,
BetaMessageParam,
BetaMessageTokensCount,
BetaMetadata,
BetaPlainTextSource,
BetaRawContentBlockDeltaEvent,
BetaRawContentBlockStartEvent,
BetaRawContentBlockStopEvent,
Expand All @@ -171,6 +195,8 @@ from anthropic.types.beta import (
BetaRawMessageStreamEvent,
BetaTextBlock,
BetaTextBlockParam,
BetaTextCitation,
BetaTextCitationParam,
BetaTextDelta,
BetaTool,
BetaToolBash20241022,
Expand Down Expand Up @@ -218,4 +244,4 @@ Methods:
- <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/anthropic/resources/beta/messages/batches.py">list</a>(\*\*<a href="src/anthropic/types/beta/messages/batch_list_params.py">params</a>) -> <a href="./src/anthropic/types/beta/messages/beta_message_batch.py">SyncPage[BetaMessageBatch]</a></code>
- <code title="delete /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/anthropic/resources/beta/messages/batches.py">delete</a>(message_batch_id) -> <a href="./src/anthropic/types/beta/messages/beta_deleted_message_batch.py">BetaDeletedMessageBatch</a></code>
- <code title="post /v1/messages/batches/{message_batch_id}/cancel?beta=true">client.beta.messages.batches.<a href="./src/anthropic/resources/beta/messages/batches.py">cancel</a>(message_batch_id) -> <a href="./src/anthropic/types/beta/messages/beta_message_batch.py">BetaMessageBatch</a></code>
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/anthropic/resources/beta/messages/batches.py">results</a>(message_batch_id) -> JSONLDecoder[MessageBatchIndividualResponse]</code>
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/anthropic/resources/beta/messages/batches.py">results</a>(message_batch_id) -> <a href="./src/anthropic/types/beta/messages/beta_message_batch_individual_response.py">JSONLDecoder[BetaMessageBatchIndividualResponse]</a></code>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "anthropic"
version = "0.44.0"
version = "0.45.0"
description = "The official Python library for the anthropic API"
dynamic = ["readme"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
Expand Down
1 change: 0 additions & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ rye run lint

echo "==> Making sure it imports"
rye run python -c 'import anthropic'

4 changes: 2 additions & 2 deletions src/anthropic/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
origin = get_origin(cast_to) or cast_to

if inspect.isclass(origin):
if issubclass(origin, (JSONLDecoder)):
if issubclass(cast(Any, origin), JSONLDecoder):
return cast(
R,
cast("type[JSONLDecoder[Any]]", cast_to)(
Expand All @@ -150,7 +150,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
),
)

if issubclass(origin, AsyncJSONLDecoder):
if issubclass(cast(Any, origin), AsyncJSONLDecoder):
return cast(
R,
cast("type[AsyncJSONLDecoder[Any]]", cast_to)(
Expand Down
2 changes: 1 addition & 1 deletion src/anthropic/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "anthropic"
__version__ = "0.44.0" # x-release-please-version
__version__ = "0.45.0" # x-release-please-version
20 changes: 10 additions & 10 deletions src/anthropic/resources/beta/messages/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ def delete(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> BetaDeletedMessageBatch:
"""This endpoint is idempotent and can be used to poll for Message Batch
completion.
"""
Delete a Message Batch.

To access the results of a Message Batch, make a request to the
`results_url` field in the response.
Message Batches can only be deleted once they've finished processing. If you'd
like to delete an in-progress batch, you must first cancel it.

Args:
message_batch_id: ID of the Message Batch.
Expand Down Expand Up @@ -395,8 +395,8 @@ def results(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
stream=True,
cast_to=JSONLDecoder[BetaMessageBatchIndividualResponse],
stream=True,
)


Expand Down Expand Up @@ -608,11 +608,11 @@ async def delete(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> BetaDeletedMessageBatch:
"""This endpoint is idempotent and can be used to poll for Message Batch
completion.
"""
Delete a Message Batch.

To access the results of a Message Batch, make a request to the
`results_url` field in the response.
Message Batches can only be deleted once they've finished processing. If you'd
like to delete an in-progress batch, you must first cancel it.

Args:
message_batch_id: ID of the Message Batch.
Expand Down Expand Up @@ -764,8 +764,8 @@ async def results(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
stream=True,
cast_to=AsyncJSONLDecoder[BetaMessageBatchIndividualResponse],
stream=True,
)


Expand Down
52 changes: 13 additions & 39 deletions src/anthropic/resources/messages/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,15 @@
)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
BinaryAPIResponse,
AsyncBinaryAPIResponse,
StreamedBinaryAPIResponse,
AsyncStreamedBinaryAPIResponse,
to_streamed_response_wrapper,
to_custom_raw_response_wrapper,
async_to_streamed_response_wrapper,
to_custom_streamed_response_wrapper,
async_to_custom_raw_response_wrapper,
async_to_custom_streamed_response_wrapper,
)
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...pagination import SyncPage, AsyncPage
from ..._exceptions import AnthropicError
from ..._base_client import AsyncPaginator, make_request_options
from ...types.messages import MessageBatchIndividualResponse, batch_list_params, batch_create_params
from ...types.messages import batch_list_params, batch_create_params
from ..._decoders.jsonl import JSONLDecoder, AsyncJSONLDecoder
from ...types.messages.message_batch import MessageBatch
from ...types.messages.deleted_message_batch import DeletedMessageBatch
from ...types.messages.message_batch_individual_response import MessageBatchIndividualResponse

__all__ = ["Batches", "AsyncBatches"]

Expand Down Expand Up @@ -202,11 +192,11 @@ def delete(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DeletedMessageBatch:
"""This endpoint is idempotent and can be used to poll for Message Batch
completion.
"""
Delete a Message Batch.

To access the results of a Message Batch, make a request to the
`results_url` field in the response.
Message Batches can only be deleted once they've finished processing. If you'd
like to delete an in-progress batch, you must first cancel it.

Args:
message_batch_id: ID of the Message Batch.
Expand Down Expand Up @@ -317,8 +307,8 @@ def results(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
stream=True,
cast_to=JSONLDecoder[MessageBatchIndividualResponse],
stream=True,
)


Expand Down Expand Up @@ -487,11 +477,11 @@ async def delete(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DeletedMessageBatch:
"""This endpoint is idempotent and can be used to poll for Message Batch
completion.
"""
Delete a Message Batch.

To access the results of a Message Batch, make a request to the
`results_url` field in the response.
Message Batches can only be deleted once they've finished processing. If you'd
like to delete an in-progress batch, you must first cancel it.

Args:
message_batch_id: ID of the Message Batch.
Expand Down Expand Up @@ -602,8 +592,8 @@ async def results(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
stream=True,
cast_to=AsyncJSONLDecoder[MessageBatchIndividualResponse],
stream=True,
)


Expand All @@ -626,10 +616,6 @@ def __init__(self, batches: Batches) -> None:
self.cancel = _legacy_response.to_raw_response_wrapper(
batches.cancel,
)
self.results = to_custom_raw_response_wrapper(
batches.results,
BinaryAPIResponse,
)


class AsyncBatchesWithRawResponse:
Expand All @@ -651,10 +637,6 @@ def __init__(self, batches: AsyncBatches) -> None:
self.cancel = _legacy_response.async_to_raw_response_wrapper(
batches.cancel,
)
self.results = async_to_custom_raw_response_wrapper(
batches.results,
AsyncBinaryAPIResponse,
)


class BatchesWithStreamingResponse:
Expand All @@ -676,10 +658,6 @@ def __init__(self, batches: Batches) -> None:
self.cancel = to_streamed_response_wrapper(
batches.cancel,
)
self.results = to_custom_streamed_response_wrapper(
batches.results,
StreamedBinaryAPIResponse,
)


class AsyncBatchesWithStreamingResponse:
Expand All @@ -701,7 +679,3 @@ def __init__(self, batches: AsyncBatches) -> None:
self.cancel = async_to_streamed_response_wrapper(
batches.cancel,
)
self.results = async_to_custom_streamed_response_wrapper(
batches.results,
AsyncStreamedBinaryAPIResponse,
)
Loading
Loading