Anthropic API

Anthropic API — User Guide

Claude API; long context.

Visit website VPN may be required Freemium Sign-up required
Strengths
  • Constitutional AI technology, industry-leading security and alignment
  • Claude series models perform outstandingly in long text understanding and coding capabilities
  • Provide enterprise-level API access, stable and reliable
  • Focus on transparency and regularly publish security research reports
Best for
  • Enterprises access Claude API to build AI applications
  • Researchers learn about advances on the AI ​​safety front
  • Developers use Claude for code assistance and documentation generation

Claude API access

Integrate Claude into your own applications via the Anthropic API.

Scenario

Call Claude API using Python SDK

Prompt example
import anthropic
client = anthropic.Anthropic(api_key="your_key")
message = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}]
)
print(message.content)
Output / what to expect
Claude returns a friendly greeting reply and the API call is successful. The response contains the content array, where the text field is the model output.
Tips

It is recommended to use the latest claude-3-5-sonnet model, which is the most cost-effective.

Sources & references: