Setup
- Install a current official Anthropic SDK.
- Set base_url to the TokenReply origin without adding /v1; the SDK appends /v1/messages.
- Use a TokenReply API key and an exact model ID that supports the Anthropic endpoint.
- Start with a small non-streaming Messages request and explicit max_tokens.
from anthropic import Anthropic
client = Anthropic(
api_key="sk-your-token-here",
base_url="https://api.tokenreply.com",
)
message = client.messages.create(
model="YOUR_MODEL_ID",
max_tokens=256,
messages=[{"role": "user", "content": "Say hello."}],
)
print(message.content[0].text)
How to verify
- The final request path is /v1/messages, not /v1/v1/messages.
- The response contains an Anthropic content block with text.
- Streaming, tools, prompt caching, and beta headers are tested separately when required.
Limitations
- Only use model routes that advertise Anthropic-compatible Messages support.
- Provider-specific beta features and headers are not guaranteed across every routed model.
- The Anthropic SDK base URL convention differs from OpenAI SDK base URLs that normally end in /v1.
Troubleshooting
| Symptom | What it usually means | What to do |
|---|
| The request path contains /v1/v1/messages | base_url already contains /v1 and the SDK appended /v1/messages. | Set the Anthropic client base_url to the gateway origin only. TokenReply currently tolerates the repeated prefix, but other services and proxies may not. |
|---|
| A catalog model works through chat but not Messages | The model route does not advertise the Anthropic endpoint type. | Choose a route that supports Anthropic Messages or use its advertised OpenAI endpoint. |
|---|