Back to Guides

Anthropic Python

Official Anthropic SDK for Python applications

Pythoneasy

The Anthropic Python SDK provides access to Claude models. Decyra captures all Anthropic API calls, giving you complete visibility into your Claude interactions.

Prerequisites

  • Decyra account with API key
  • Python 3.8+ installed
  • anthropic package installed

Installation

pip install anthropic decyra-sdk httpx

Integration

Configure custom HTTP transport with Decyra:

from anthropic import Anthropic
import httpx
import os

def create_decyra_transport():
    return httpx.Client(
        base_url="https://proxy.decyra.com",
        headers={
            "X-Decyra-API-Key": os.getenv("DECYRA_API_KEY"),
            "anthropic-version": "2023-06-01",
        }
    )

client = Anthropic(
    api_key=os.getenv("DECYRA_API_KEY"),
    http_client=create_decyra_transport(),
)

Use the client for messages:

message = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "What is quantum computing?"}
    ],
)

print(message.content[0].text)

What Gets Captured

FieldDescription
ModelClaude model identifier
Max TokensMaximum response tokens
MessagesConversation messages array
Prompt HashHash of input prompt
Response TimeAPI call duration
Token UsageInput/output tokens
CostEstimated cost
Stop SequencesStop sequence settings

Verify

Visit your Decyra dashboard and check the traces page. All Anthropic API calls will be visible with complete context.

Next Steps