Zack Saadioui
8/26/2024
1
claude-3-5-sonnet-20240620
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import 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
400
1
429
1
500
1 2 3 4 5 6
try: 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 2024