Zack Saadioui
8/26/2024

1
claude-3-5-sonnet-202406201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18import httpx url = "https://api.anthropic.com/v1/messages" headers = { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" } data = { "model": "claude-3-5-sonnet-20240620", "messages": [{ "role": "user", "content": "What are some effective API call techniques with Claude 3.5 Sonnet?" }] } response = httpx.post(url, headers=headers, json=data) print(response.json())
1
4001
4291
5001 2 3 4 5 6try: response.raise_for_status() # Process your data normally except httpx.HTTPStatusError as e: print(f"Error: {e}") # Implement your error handling logic here
Copyright © Arsturn 2025