Use OpenAI SDK with Shannon
Keep the OpenAI SDK you already use: change the base URL and the key, and pick a Shannon model id.
- Tested Nov 7, 2026
- OpenAI Chat Completions
- About 1 min
About OpenAI SDK
The official OpenAI libraries for Python and Node.js are the most common way to call a chat API from code. They accept a base URL, so the same code works against Shannon: chat completions, streaming, tool calls and the Responses API.
What you need
- A Shannon API key
- Keys & usage
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Every snippet below follows your choice.
Set it up
-
Install the SDK
pip install openainpm install openai -
Point it at Shannon
Only the client changes. The SDKs also read
OPENAI_BASE_URLandOPENAI_API_KEYfrom the environment.from openai import OpenAI client = OpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY") stream = client.chat.completions.create( model="Kimi-K3-uncensored-NVFP4", messages=[{"role": "user", "content": "Name three colours a cat can be."}], stream=True, ) for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.shannon-ai.com/v1", apiKey: "YOUR_API_KEY" }); const stream = await client.chat.completions.create({ model: "Kimi-K3-uncensored-NVFP4", messages: [{ role: "user", content: "Name three colours a cat can be." }], stream: true, }); for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); -
Call tools
Tools work as with OpenAI: the reply ends with
finish_reason: "tool_calls"and the calls inmessage.tool_calls.Pythontools = [{"type": "function", "function": { "name": "get_weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, }}] r = client.chat.completions.create( model="Kimi-K3-uncensored-NVFP4", messages=[{"role": "user", "content": "What is the weather in Oslo?"}], tools=tools, ) print(r.choices[0].message.tool_calls[0].function.arguments) # {"city": "Oslo"}
Check that it works
Send: Run the streaming sample.
You should see: The colours printed as they stream in, e.g. "Cats can be black, white, and orange."
Models that fit OpenAI SDK
Every id below meets what OpenAI 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
client.responses.create(...)works too; Shannon serves/v1/responseswithout storing replies, so send the whole conversation each time.- Reasoning arrives as
reasoning_contenton each chunk'sdelta, besidecontent. - There is no
/v1/embeddings; use a separate embedding model for retrieval.
Tips
- Set
OPENAI_BASE_URLandOPENAI_API_KEYin the environment and the client picks them up with no arguments, so existing code needs no changes. - Pass
stream=Truefor long answers; text and reasoning arrive as they are written. - Set
max_retriesandtimeouton the client: the SDK retries429and5xxanswers on its own. - Read
usageon every response to log how many tokens each call used, including the cached ones.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
404 Not Found | base_url lacks /v1. | Use https://api.shannon-ai.com/v1. |
400 unknown model | An OpenAI model name such as gpt-4o. | 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
Is Shannon a drop-in replacement for the OpenAI API?
For chat completions, the Responses API, streaming, tools and structured outputs, yes: change base_url, the key and the model id.
Does the Anthropic SDK work too?
Yes: Anthropic(base_url="https://api.shannon-ai.com", api_key=...) talks to /v1/messages.