19 lines
536 B
Python
19 lines
536 B
Python
import anthropic
|
|
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
client = anthropic.Anthropic(api_key=os.getenv("CLAUDE_API_KEY"))
|
|
print("API Key loaded:", os.getenv("CLAUDE_API_KEY")[:20] + "..." if os.getenv("CLAUDE_API_KEY") else "NOT FOUND")
|
|
|
|
# Test the API
|
|
try:
|
|
response = client.messages.create(
|
|
model="claude-3-5-sonnet-20241022",
|
|
max_tokens=100,
|
|
messages=[{"role": "user", "content": "Hello"}]
|
|
)
|
|
print("API test successful!")
|
|
except Exception as e:
|
|
print(f"API test failed: {e}") |