Anthropic Python API library
The Anthropic Python library provides convenient access to the Anthropic REST API from any Python 3.8+
application. It includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by httpx.
Documentation
The REST API documentation can be found on docs.anthropic.com. The full API of this library can be found in api.md.
Installation
pip install anthropic
Usage
The full API of this library can be found in api.md.
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ.get("ANTHROPIC_API_KEY"),
)
message = client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Hello, Claude",
}
],
model="claude-3-opus-20240229",
)
print(message.content)
While you can provide an api_key keyword argument,
we recommend using python-d
|