# anthropics/anthropic-sdk-python

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/anthropics-anthropic-sdk-python).**

2,795 stars · 459 forks · Python · mit

## Links

- GitHub: https://github.com/anthropics/anthropic-sdk-python
- awesome-repositories: https://awesome-repositories.com/repository/anthropics-anthropic-sdk-python.md

## Description

This is a Python SDK for interacting with large language models via API. It serves as a client library to generate text, process messages, and manage conversational states, while providing a specialized interface for connecting to models hosted across different cloud infrastructure providers.

The SDK includes a tool-calling framework that maps Python functions to JSON schemas, allowing models to execute external tools. It also features a built-in token counting utility to estimate input size before transmission and a server-sent events client for receiving model tokens in real time.

The library covers a broad range of capabilities, including asynchronous batch processing for large-scale prompt handling, automated pagination of API results, and file upload management. It also implements traffic management through automatic request retries with exponential backoff to handle transient network errors and rate limits.

## Tags

### Artificial Intelligence & ML

- [LLM Application Development](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/generative-ai/llm-application-development.md) — Provides standardized interfaces for interacting with Claude models to build generative AI applications in Python.
- [Text Generation APIs](https://awesome-repositories.com/f/artificial-intelligence-ml/text-generation-apis.md) — Provides the primary interface for interacting with language models to generate text, chat, and code completions. ([source](https://cdn.jsdelivr.net/gh/anthropics/anthropic-sdk-python@main/README.md))
- [AI Agent Tool Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-agent-integrations/ai-agent-tool-integrations.md) — Interfaces that connect language models to external Python functions for functional task execution.
- [Cloud Model Connectivity](https://awesome-repositories.com/f/artificial-intelligence-ml/cloud-model-connectivity.md) — Provides specialized authentication and endpoint handling for connecting to machine learning models across different cloud providers.
- [Cloud Model Connectors](https://awesome-repositories.com/f/artificial-intelligence-ml/cloud-model-connectors.md) — Acts as an interface for connecting to machine learning models hosted across different cloud infrastructure providers.
- [Custom Provider Implementations](https://awesome-repositories.com/f/artificial-intelligence-ml/custom-provider-implementations.md) — Provides specialized client implementations to support different cloud hosting environments and authentication methods.
- [API Client SDKs](https://awesome-repositories.com/f/artificial-intelligence-ml/llm-python-bindings/api-client-sdks.md) — Serves as a comprehensive Python client library for interacting with large language models via API.
- [Provider-Specific Configurations](https://awesome-repositories.com/f/artificial-intelligence-ml/model-provider-management/provider-specific-configurations.md) — Specializes base URLs and authentication logic to support various cloud hosting environments for the same model.
- [Tool-Calling Frameworks](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-calling-frameworks.md) — Provides a framework for mapping Python functions to JSON schemas, enabling models to execute external tools.
- [Tool Calling Integration Frameworks](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-calling-integration-frameworks.md) — Provides a framework to map Python functions to JSON schemas, enabling models to execute external tools through structured output.
- [Asynchronous Batch Processing](https://awesome-repositories.com/f/artificial-intelligence-ml/asynchronous-batch-processing.md) — Submits arrays of requests for asynchronous background processing and retrieves aggregated results. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [Batch Processors](https://awesome-repositories.com/f/artificial-intelligence-ml/batch-processors.md) — Provides a pipeline for submitting large arrays of requests for asynchronous background processing against model APIs.
- [Enterprise AI Infrastructure](https://awesome-repositories.com/f/artificial-intelligence-ml/enterprise-ai-infrastructure.md) — Implements production-grade infrastructure for managing model connections with built-in resilience and error handling.
- [Pre-Request Token Analysis](https://awesome-repositories.com/f/artificial-intelligence-ml/heuristic-token-estimators/pre-request-token-analysis.md) — Analyzes text input using a local tokenizer to estimate tokens before sending data to the server.
- [High Volume AI Processing](https://awesome-repositories.com/f/artificial-intelligence-ml/high-volume-ai-processing.md) — Handles high volumes of model requests through asynchronous batch processing and automated pagination.
- [LLM Token Counters](https://awesome-repositories.com/f/artificial-intelligence-ml/llm-token-counters.md) — Provides utilities for counting tokens in message payloads to estimate input usage and budget prompt size.
- [Token Context Limiting](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/model-integration-pipelines/model-inference/inference-context-customization/token-context-limiting.md) — Manages input token counts and file uploads to ensure prompts stay within model context window limits.
- [Text Tokenization Utilities](https://awesome-repositories.com/f/artificial-intelligence-ml/text-tokenization-utilities.md) — Analyzes raw text input to estimate the number of tokens used within a model's context window.

### Part of an Awesome List

- [Tool-Use Integrations](https://awesome-repositories.com/f/awesome-lists/ai/ai-model-and-api-integration/tool-use-integrations.md) — Connects AI models to external Python functions, enabling the model to perform actions and process data. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [LLM Providers and Models](https://awesome-repositories.com/f/awesome-lists/ai/llm-providers-and-models.md) — Official client library for Anthropic API services.

### DevOps & Infrastructure

- [Model Provider Implementations](https://awesome-repositories.com/f/devops-infrastructure/cloud-hosting-integrations/model-provider-implementations.md) — Offers specialized interfaces for connecting to language models hosted across different cloud infrastructure providers. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [Request Retries](https://awesome-repositories.com/f/devops-infrastructure/api-service-management/api-resilience/request-retries.md) — Automatically retries failed network requests using exponential backoff to handle transient errors and rate limits. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [File Uploaders](https://awesome-repositories.com/f/devops-infrastructure/file-uploaders.md) — Provides components for transmitting files to remote servers using file paths or binary data. ([source](https://platform.claude.com/docs/en/api/sdks/python))

### Networking & Communication

- [Chat Message Sending APIs](https://awesome-repositories.com/f/networking-communication/messaging-api-integrations/chat-message-sending-apis.md) — Provides a programmatic API for sending messages within conversational sessions to a language model. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [Token Streaming](https://awesome-repositories.com/f/networking-communication/real-time-event-streams/token-streaming.md) — Implements real-time delivery of AI model generated tokens using server-sent events.
- [Incremental Response Clients](https://awesome-repositories.com/f/networking-communication/real-time-telemetry-streams/agent-telemetry-streams/incremental-response-clients.md) — Implements a client that streams incremental model responses in real time using server-sent events. ([source](https://platform.claude.com/docs/en/api/sdks/python))

### Software Engineering & Architecture

- [Tool Schema Mappings](https://awesome-repositories.com/f/software-engineering-architecture/schema-mapping-tools/tool-schema-mappings.md) — Translates Python function signatures into JSON schemas to define tool capabilities for the language model.
- [API Error Handling Patterns](https://awesome-repositories.com/f/software-engineering-architecture/api-error-handling-patterns.md) — Implements client-side error handling patterns to catch connection issues, rate limits, and HTTP errors. ([source](https://platform.claude.com/docs/en/api/sdks/python))

### User Interface & Experience

- [Decorator-Based Tool Registrations](https://awesome-repositories.com/f/user-interface-experience/custom-component-extensions/custom-python-components/decorator-based-tool-registrations.md) — Allows Python functions to be registered as tools via decorators, enabling the model to execute external capabilities.

### Development Tools & Productivity

- [Batch Processing Clients](https://awesome-repositories.com/f/development-tools-productivity/api-client-libraries/llm-clients/asynchronous-clients/batch-processing-clients.md) — Provides a client for submitting and monitoring large groups of asynchronous requests for background execution.
- [CLI Token Counters](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/workflow-productivity-enhancers/developer-analytics/codebase-metrics/codebase-size-and-token-count-reporters/codebase-size-and-token-count-reporters/cli-token-counters.md) — Calculates the number of tokens in a text string to estimate input size and verify model limits. ([source](https://platform.claude.com/docs/en/api/sdks/python))
- [Input Token Estimators](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/workflow-productivity-enhancers/developer-analytics/codebase-metrics/codebase-size-and-token-count-reporters/codebase-size-and-token-count-reporters/cli-token-counters/input-token-estimators.md) — Analyzes input text using a local tokenizer to estimate token counts before transmitting data.

### Programming Languages & Runtimes

- [Exponential Backoff Retries](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/background-task-management/background-task-retry-policies/asynchronous-task-retries/exponential-backoff-retries.md) — Implements an exponential backoff strategy to automatically retry failed network requests and handle rate limits.
