Use Anthropic SDK with Shannon
Keep the Anthropic SDK: set base_url to Shannon, pass your key, and call Shannon models through the Messages API.
- Tested Nov 7, 2026
- Anthropic Messages
- About 1 min
About Anthropic SDK
The Anthropic SDK is the official client for the Messages API, used by apps and agents built for Claude. Shannon serves the same API at /v1/messages, so code written for the SDK runs on Shannon models after two changes: the base URL and the key. Streaming, tool use and system prompts work the same way.
What you need
- A Shannon API key
- Keys & usage
- Base URL
-
https://api.shannon-ai.comEndpoint:/v1/messages - Every snippet below follows your choice.
Set it up
-
Install the SDK
pip install anthropicnpm install @anthropic-ai/sdk -
Point it at Shannon and stream
The base URL has no
/v1: the SDK adds/v1/messagesitself.max_tokensis required, as with Claude.Pythonfrom anthropic import Anthropic client = Anthropic(base_url="https://api.shannon-ai.com", api_key="YOUR_API_KEY") with client.messages.stream( model="Kimi-K3-uncensored-NVFP4", max_tokens=1024, messages=[{"role": "user", "content": "Name three colours a cat can be."}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True) -
Call tools
Tool calls come back as
tool_useblocks withstop_reason: "tool_use".Pythonr = client.messages.create( model="Kimi-K3-uncensored-NVFP4", max_tokens=1024, tools=[{ "name": "get_weather", "description": "Weather for a city", "input_schema": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, }], messages=[{"role": "user", "content": "What is the weather in Oslo?"}], ) print(r.stop_reason) # tool_use print([b.input for b in r.content if b.type == "tool_use"]) # [{'city': 'Oslo'}]
Check that it works
Send: Run the streaming sample.
You should see: The colours printed as they stream in.
Models that fit Anthropic SDK
Every id below meets what Anthropic SDK needs. The first one is the default in the snippets.
| Model id | Context window | Max output | Image input |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Yes |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Yes |
shannon-3 | 196,608 | 65,536 | Yes |
shannon-coder-1 | 131,072 | 65,536 | No |
Good to know
base_urlishttps://api.shannon-ai.comwithout/v1; with/v1the SDK calls/v1/v1/messagesand gets404.- The SDK sends the key as
x-api-key; Shannon also acceptsAuthorization: Bearer. - Use Shannon model ids from
GET /v1/models; Claude ids are not served.
Tips
- The SDK also reads
ANTHROPIC_BASE_URLandANTHROPIC_API_KEY, so existing code can switch with two environment variables. - Tools built for Claude, such as Claude Code and agents on the Claude Agent SDK, use the same endpoint.
- In TypeScript the options are
baseURLandapiKey.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
404 Not Found | base_url ends in /v1. | Use https://api.shannon-ai.com. |
400 unknown model | A Claude model id. | Use a Shannon id from GET /v1/models. |
401 Unauthorized | The key is missing, mistyped or rotated. | Copy the key again from Keys & usage; it starts with sk-. |
context_length_exceeded / "prompt is too long" | The conversation is longer than the model's window. | Start a new chat, let the tool compact it, or pick a model with a larger window. |
insufficient_quota | Your balance cannot pay for the request. | Top up or change plan; the request is not retried by itself. |
Questions
Does the Anthropic SDK work with Shannon?
Yes. Shannon serves the Messages API at https://api.shannon-ai.com/v1/messages; set base_url to https://api.shannon-ai.com.
Do streaming and tool use work?
Yes, both; we ran a stream and a tool call through the Python SDK.