Log Anthropic requests

Monitor your Anthropic Claude API calls by logging requests and responses asynchronously. Track metrics like cost, duration, and performance for all Claude models including Claude 3.5 Sonnet, Claude 3 Opus, and more.
import requests

url = "https://api.keywordsai.co/api/request-logs/create/"
payload = {
    "model": "claude-3-5-sonnet-20240620",
    "prompt_messages": [
        {
            "role": "user",
            "content": "What's the weather like today?"
        }
    ],
    "completion_message": {
        "role": "assistant",
        "content": "I don't have access to real-time weather data, but I can help you find weather information."
    },
    "cost": 0.00042,
    "generation_time": 1.8,
    "customer_params": {
        "customer_identifier": "user_456"
    }
}
headers = {
    "Authorization": "Bearer YOUR_KEYWORDS_AI_API_KEY",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json=payload)

Get Started with Logging

Learn how to set up comprehensive logging for all your LLM requests