Skip to content

Commit

Permalink
feat(api): general availability updates
Browse files Browse the repository at this point in the history
The following APIs are now GA and have been moved out of the beta namespace:

- Prompt caching
- Token counting
- PDF Support
- The Batch API

This commit also adds new endpoints for listing available models.

https://docs.anthropic.com/en/release-notes/api
  • Loading branch information
RobertCraigie committed Dec 17, 2024
1 parent 7cffc99 commit 5db8538
Show file tree
Hide file tree
Showing 82 changed files with 3,631 additions and 3,580 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 10
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-73443ebfebee64b8ec0ebbacd2521d6b6aa900e9526ec97abdcbcff0c0955d9b.yml
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-be055148d227480fcacc9086c37ac8009dcb487731069ada51af35044f65bee4.yml
105 changes: 77 additions & 28 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
# Shared Types

```python
from anthropic.types import (
APIErrorObject,
AuthenticationError,
BillingError,
ErrorObject,
ErrorResponse,
GatewayTimeoutError,
InvalidRequestError,
NotFoundError,
OverloadedError,
PermissionError,
RateLimitError,
)
```

# Messages

Types:

```python
from anthropic.types import (
Base64PDFSource,
CacheControlEphemeral,
ContentBlock,
ContentBlockDeltaEvent,
ContentBlockParam,
ContentBlockStartEvent,
ContentBlockStopEvent,
DocumentBlockParam,
ImageBlockParam,
InputJSONDelta,
Message,
Expand All @@ -18,6 +39,7 @@ from anthropic.types import (
MessageStartEvent,
MessageStopEvent,
MessageStreamEvent,
MessageTokensCount,
Metadata,
Model,
RawContentBlockDeltaEvent,
Expand All @@ -44,8 +66,47 @@ from anthropic.types import (

Methods:

- <code title="post /v1/messages">client.messages.<a href="./src/anthropic/resources/messages.py">create</a>(\*\*<a href="src/anthropic/types/message_create_params.py">params</a>) -> <a href="./src/anthropic/types/message.py">Message</a></code>
- <code title="post /v1/messages">client.messages.<a href="./src/anthropic/resources/messages/messages.py">create</a>(\*\*<a href="src/anthropic/types/message_create_params.py">params</a>) -> <a href="./src/anthropic/types/message.py">Message</a></code>
- <code>client.messages.<a href="./src/anthropic/resources/messages.py">stream</a>(\*args) -> MessageStreamManager[MessageStream] | MessageStreamManager[MessageStreamT]</code>
- <code title="post /v1/messages/count_tokens">client.messages.<a href="./src/anthropic/resources/messages/messages.py">count_tokens</a>(\*\*<a href="src/anthropic/types/message_count_tokens_params.py">params</a>) -> <a href="./src/anthropic/types/message_tokens_count.py">MessageTokensCount</a></code>

## Batches

Types:

```python
from anthropic.types.messages import (
MessageBatch,
MessageBatchCanceledResult,
MessageBatchErroredResult,
MessageBatchExpiredResult,
MessageBatchIndividualResponse,
MessageBatchRequestCounts,
MessageBatchResult,
MessageBatchSucceededResult,
)
```

Methods:

- <code title="post /v1/messages/batches">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">create</a>(\*\*<a href="src/anthropic/types/messages/batch_create_params.py">params</a>) -> <a href="./src/anthropic/types/messages/message_batch.py">MessageBatch</a></code>
- <code title="get /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/anthropic/resources/messages/batches.py">retrieve</a>(message_batch_id) -> <a href="./src/anthropic/types/messages/message_batch.py">MessageBatch</a></code>
- <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="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) -> BinaryAPIResponse</code>

# Models

Types:

```python
from anthropic.types import ModelInfo
```

Methods:

- <code title="get /v1/models/{model_id}">client.models.<a href="./src/anthropic/resources/models.py">retrieve</a>(model_id) -> <a href="./src/anthropic/types/model_info.py">ModelInfo</a></code>
- <code title="get /v1/models">client.models.<a href="./src/anthropic/resources/models.py">list</a>(\*\*<a href="src/anthropic/types/model_list_params.py">params</a>) -> <a href="./src/anthropic/types/model_info.py">SyncPage[ModelInfo]</a></code>

# Beta

Expand All @@ -56,8 +117,10 @@ from anthropic.types import (
AnthropicBeta,
BetaAPIError,
BetaAuthenticationError,
BetaBillingError,
BetaError,
BetaErrorResponse,
BetaGatewayTimeoutError,
BetaInvalidRequestError,
BetaNotFoundError,
BetaOverloadedError,
Expand All @@ -66,6 +129,19 @@ from anthropic.types import (
)
```

## Models

Types:

```python
from anthropic.types.beta import BetaModelInfo
```

Methods:

- <code title="get /v1/models/{model_id}?beta=true">client.beta.models.<a href="./src/anthropic/resources/beta/models.py">retrieve</a>(model_id) -> <a href="./src/anthropic/types/beta/beta_model_info.py">BetaModelInfo</a></code>
- <code title="get /v1/models?beta=true">client.beta.models.<a href="./src/anthropic/resources/beta/models.py">list</a>(\*\*<a href="src/anthropic/types/beta/model_list_params.py">params</a>) -> <a href="./src/anthropic/types/beta/beta_model_info.py">SyncPage[BetaModelInfo]</a></code>

## Messages

Types:
Expand Down Expand Up @@ -139,30 +215,3 @@ 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="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) -> BinaryAPIResponse</code>

## PromptCaching

### Messages

Types:

```python
from anthropic.types.beta.prompt_caching import (
PromptCachingBetaCacheControlEphemeral,
PromptCachingBetaImageBlockParam,
PromptCachingBetaMessage,
PromptCachingBetaMessageParam,
PromptCachingBetaTextBlockParam,
PromptCachingBetaTool,
PromptCachingBetaToolResultBlockParam,
PromptCachingBetaToolUseBlockParam,
PromptCachingBetaUsage,
RawPromptCachingBetaMessageStartEvent,
RawPromptCachingBetaMessageStreamEvent,
)
```

Methods:

- <code title="post /v1/messages?beta=prompt_caching">client.beta.prompt_caching.messages.<a href="./src/anthropic/resources/beta/prompt_caching/messages.py">create</a>(\*\*<a href="src/anthropic/types/beta/prompt_caching/message_create_params.py">params</a>) -> <a href="./src/anthropic/types/beta/prompt_caching/prompt_caching_beta_message.py">PromptCachingBetaMessage</a></code>
- <code title="post /v1/messages?beta=prompt_caching">client.beta.prompt_caching.messages.<a href="./src/anthropic/resources/beta/prompt_caching/messages.py">stream</a>(\*\*<a href="src/anthropic/types/beta/prompt_caching/message_create_params.py">params</a>) -> <a href="./src/anthropic/lib/streaming/_prompt_caching_beta_messages.py">PromptCachingBetaMessageStreamManager</a></code>
11 changes: 10 additions & 1 deletion src/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_async_library,
)
from ._version import __version__
from .resources import messages, completions
from .resources import models, completions
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError
from ._base_client import (
Expand All @@ -34,6 +34,7 @@
AsyncAPIClient,
)
from .resources.beta import beta
from .resources.messages import messages

__all__ = [
"Timeout",
Expand All @@ -50,6 +51,7 @@
class Anthropic(SyncAPIClient):
completions: completions.Completions
messages: messages.Messages
models: models.Models
beta: beta.Beta
with_raw_response: AnthropicWithRawResponse
with_streaming_response: AnthropicWithStreamedResponse
Expand Down Expand Up @@ -120,6 +122,7 @@ def __init__(

self.completions = completions.Completions(self)
self.messages = messages.Messages(self)
self.models = models.Models(self)
self.beta = beta.Beta(self)
self.with_raw_response = AnthropicWithRawResponse(self)
self.with_streaming_response = AnthropicWithStreamedResponse(self)
Expand Down Expand Up @@ -268,6 +271,7 @@ def _make_status_error(
class AsyncAnthropic(AsyncAPIClient):
completions: completions.AsyncCompletions
messages: messages.AsyncMessages
models: models.AsyncModels
beta: beta.AsyncBeta
with_raw_response: AsyncAnthropicWithRawResponse
with_streaming_response: AsyncAnthropicWithStreamedResponse
Expand Down Expand Up @@ -338,6 +342,7 @@ def __init__(

self.completions = completions.AsyncCompletions(self)
self.messages = messages.AsyncMessages(self)
self.models = models.AsyncModels(self)
self.beta = beta.AsyncBeta(self)
self.with_raw_response = AsyncAnthropicWithRawResponse(self)
self.with_streaming_response = AsyncAnthropicWithStreamedResponse(self)
Expand Down Expand Up @@ -487,27 +492,31 @@ class AnthropicWithRawResponse:
def __init__(self, client: Anthropic) -> None:
self.completions = completions.CompletionsWithRawResponse(client.completions)
self.messages = messages.MessagesWithRawResponse(client.messages)
self.models = models.ModelsWithRawResponse(client.models)
self.beta = beta.BetaWithRawResponse(client.beta)


class AsyncAnthropicWithRawResponse:
def __init__(self, client: AsyncAnthropic) -> None:
self.completions = completions.AsyncCompletionsWithRawResponse(client.completions)
self.messages = messages.AsyncMessagesWithRawResponse(client.messages)
self.models = models.AsyncModelsWithRawResponse(client.models)
self.beta = beta.AsyncBetaWithRawResponse(client.beta)


class AnthropicWithStreamedResponse:
def __init__(self, client: Anthropic) -> None:
self.completions = completions.CompletionsWithStreamingResponse(client.completions)
self.messages = messages.MessagesWithStreamingResponse(client.messages)
self.models = models.ModelsWithStreamingResponse(client.models)
self.beta = beta.BetaWithStreamingResponse(client.beta)


class AsyncAnthropicWithStreamedResponse:
def __init__(self, client: AsyncAnthropic) -> None:
self.completions = completions.AsyncCompletionsWithStreamingResponse(client.completions)
self.messages = messages.AsyncMessagesWithStreamingResponse(client.messages)
self.models = models.AsyncModelsWithStreamingResponse(client.models)
self.beta = beta.AsyncBetaWithStreamingResponse(client.beta)


Expand Down
6 changes: 0 additions & 6 deletions src/anthropic/lib/streaming/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@
MessageStreamManager as MessageStreamManager,
AsyncMessageStreamManager as AsyncMessageStreamManager,
)
from ._prompt_caching_beta_messages import (
PromptCachingBetaMessageStream as PromptCachingBetaMessageStream,
AsyncPromptCachingBetaMessageStream as AsyncPromptCachingBetaMessageStream,
PromptCachingBetaMessageStreamManager as PromptCachingBetaMessageStreamManager,
AsyncPromptCachingBetaMessageStreamManager as AsyncPromptCachingBetaMessageStreamManager,
)
Loading

0 comments on commit 5db8538

Please sign in to comment.