File size: 1,498 Bytes
a765e3e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #!/usr/bin/env python3
import os
import httpx
import json
from dotenv import load_dotenv
load_dotenv()
def test_rest():
api_key = os.getenv("ANTHROPIC_API_KEY")
url = "https://api.anthropic.com/v1/messages"
headers = {
"x-api-key": api_key,
"anthropic-version": "2023-06-01",
"anthropic-beta": "output-128k-2025-02-19", # test if needed
"content-type": "application/json"
}
payload = {
"model": "claude-opus-4-6",
"max_tokens": 4000,
"messages": [{"role": "user", "content": "Write a short poem about justice in 4 lines."}],
"temperature": 1.0,
"thinking": {"type": "adaptive"}
}
# Also test effort
payload_effort = {
"model": "claude-opus-4-6",
"max_tokens": 4000,
"messages": [{"role": "user", "content": "Write a short poem about justice in 4 lines."}],
"temperature": 1.0,
"thinking": {"type": "adaptive", "effort": "low"}
}
client = httpx.Client(timeout=30.0)
print("Testing adaptive without effort...")
r = client.post(url, headers=headers, json=payload)
print("Status:", r.status_code)
if r.status_code != 200:
print(r.json())
print("\nTesting adaptive with effort parameter...")
r = client.post(url, headers=headers, json=payload_effort)
print("Status:", r.status_code)
if r.status_code != 200:
print(r.json())
if __name__ == "__main__":
test_rest()
|