Skip to content
OpenAI SDK

Frameworks and SDKs

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/v1 Endpoint: /v1/chat/completions
Every snippet below follows your choice.

Set it up

  1. Install the SDK

    pip install openai
  2. Point it at Shannon

    Only the client changes. The SDKs also read OPENAI_BASE_URL and OPENAI_API_KEY from 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="")
  3. Call tools

    Tools work as with OpenAI: the reply ends with finish_reason: "tool_calls" and the calls in message.tool_calls.

    Python
    tools = [{"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 idContext windowMax outputImage 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/responses without storing replies, so send the whole conversation each time.
  • Reasoning arrives as reasoning_content on each chunk's delta, beside content.
  • There is no /v1/embeddings; use a separate embedding model for retrieval.

Tips

  1. Set OPENAI_BASE_URL and OPENAI_API_KEY in the environment and the client picks them up with no arguments, so existing code needs no changes.
  2. Pass stream=True for long answers; text and reasoning arrive as they are written.
  3. Set max_retries and timeout on the client: the SDK retries 429 and 5xx answers on its own.
  4. Read usage on every response to log how many tokens each call used, including the cached ones.

Troubleshooting

SymptomCauseFix
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.

Choose your language

All languages are equal. Pick the one you want to browse in.

Europe

Middle East & North Africa

South Asia

Southeast Asia

East Asia

Central Asia & Caucasus

Africa

Oceania

Constructed & Classical