Use NeverMetered with Anthropic SDK
The official Python and TypeScript clients for the Messages API.
Anthropic Messages
Model
qwen3.8-27b8,192 max output tokens on the free planReplace
YOUR_API_KEY with your key.- 1
Create an API key
Create a key in API keys and name it after the tool, for example “Anthropic SDK”. A dedicated key per tool lets you see its usage separately and give it its own parallel-stream cap. The key is shown once; the snippets below use
YOUR_API_KEYwhere it goes. - 2
Install the SDK
pip install anthropic - 3
Export your key
export NEVERMETERED_API_KEY="YOUR_API_KEY" - 4
Stream a message
Use the base URL without
/v1; the SDK adds it. The key is sent as thex-api-keyheader, which the gateway accepts.import os import anthropic client = anthropic.Anthropic(base_url="https://api.nevermetered.com", api_key=os.environ["NEVERMETERED_API_KEY"]) with client.messages.stream( model="qwen3.8-27b", max_tokens=1024, messages=[{"role": "user", "content": "Reply with the word ready"}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True) - 5
Verify it works
Run the script; it prints the model's reply. The request shows up in Requests within a few seconds, with its input, cached and output tokens.
Tips
max_tokensis required by the Messages API. Your plan allows up to 8,192 output tokens per request.- Token counting (
client.messages.count_tokens) is supported and doesn't use your daily free requests.
Troubleshooting
404on every request- The base URL probably ends in
/v1, so the SDK calls/v1/v1/messages. Usehttps://api.nevermetered.com. 404 model_not_found- Use a model id exactly as
GET /v1/modelslists it, for exampleqwen3.8-27b. Plans can restrict which models a key may call. 429 concurrency_limit_exceeded- All your parallel streams are busy and your queue allowance is full. Lower the tool's parallelism (subagents, batch size), or get more streams on your plan.
- Answers stop mid-sentence
- The response hit your plan's output cap of 8,192 tokens (finish reason
lengthormax_tokens). Ask for shorter steps, or upgrade for a higher cap. 403 email_verification_required- Free requests need a verified email. Click the link in your verification email (you can resend it from the dashboard), or upgrade.
429 daily_quota_exceeded- You've used today's free requests; agents send one request per step, so they go quickly. The allowance resets at 00:00 UTC, and paid plans have no daily limit.
503/504 request_queue_timeout- The service stayed busy longer than the queue timeout and nothing was generated. Retry with backoff, and give the tool a generous request timeout.