Claude Enterprise API access
Quick answer
To access the Claude Enterprise API, use the
anthropic Python SDK with your Enterprise API key. Instantiate Anthropic client, specify the claude-3-5-sonnet-20241022 model, and call client.messages.create() with system= and messages= parameters for chat completions.PREREQUISITES
Python 3.8+Anthropic Enterprise API keypip install anthropic>=0.20
Setup
Install the official anthropic Python SDK and set your Enterprise API key as an environment variable for secure authentication.
pip install anthropic>=0.20 output
Collecting anthropic Downloading anthropic-0.20.0-py3-none-any.whl (20 kB) Installing collected packages: anthropic Successfully installed anthropic-0.20.0
Step by step
Use the Anthropic client to call the Claude Enterprise API. Provide your Enterprise API key via ANTHROPIC_API_KEY environment variable. Use the claude-3-5-sonnet-20241022 model for best Enterprise features.
import os
from anthropic import Anthropic
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=512,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": "Hello, Claude Enterprise!"}]
)
print(response.content[0].text) output
Hello! How can I assist you with Claude Enterprise API today?
Common variations
You can use async calls with the anthropic SDK, adjust max_tokens for longer responses, or switch models if your Enterprise plan includes newer Claude versions.
import asyncio
import os
from anthropic import Anthropic
async def main():
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
response = await client.messages.acreate(
model="claude-3-5-sonnet-20241022",
max_tokens=256,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": "Async call test."}]
)
print(response.content[0].text)
asyncio.run(main()) output
Hello! This is an async response from Claude Enterprise API.
Troubleshooting
- If you receive authentication errors, verify your
ANTHROPIC_API_KEYenvironment variable is set correctly. - Ensure you use the exact model name
claude-3-5-sonnet-20241022as Enterprise API requires. - For rate limit errors, check your Enterprise plan quotas and retry after backoff.
Key Takeaways
- Use the official
anthropicSDK with your Enterprise API key for Claude Enterprise access. - Specify
claude-3-5-sonnet-20241022as the model for Enterprise-grade features. - Set
ANTHROPIC_API_KEYenvironment variable to authenticate securely. - Async calls and token limits can be adjusted per your application needs.
- Check API key and model name carefully to avoid authentication and usage errors.