Use OpenAI Agents SDK with Shannon
Wrap an AsyncOpenAI client pointed at Shannon in OpenAIChatCompletionsModel and run Agents SDK agents on Shannon models.
- Tested Nov 7, 2026
- OpenAI Chat Completions
- About 2 min
About OpenAI Agents SDK
The OpenAI Agents SDK is a small Python framework for agents with tools, handoffs between agents and guardrails. It works with any model behind the Chat Completions format through OpenAIChatCompletionsModel, so agents built with it can run on Shannon models.
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
Shellpip install openai-agents -
Create the model and an agent with a tool
set_tracing_disabled(True)stops the SDK sending traces to OpenAI, which would fail without an OpenAI key.Pythonimport asyncio from openai import AsyncOpenAI from agents import Agent, OpenAIChatCompletionsModel, Runner, function_tool, set_tracing_disabled set_tracing_disabled(True) client = AsyncOpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY") model = OpenAIChatCompletionsModel(model="Kimi-K3-uncensored-NVFP4", openai_client=client) @function_tool def get_weather(city: str) -> str: """Weather for a city.""" return f"Sunny, 18 C in {city}" agent = Agent(name="Weather", instructions="Use the tool for weather.", model=model, tools=[get_weather]) async def main(): result = await Runner.run(agent, "What is the weather in Oslo?") print(result.final_output) asyncio.run(main()) -
Stream a run
Pythonfrom openai.types.responses import ResponseTextDeltaEvent async def stream(): result = Runner.run_streamed(agent, "Name three colours a cat can be.") async for event in result.stream_events(): if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): print(event.data.delta, end="", flush=True) asyncio.run(stream())
Check that it works
Send: Run the agent sample.
You should see: The agent calls get_weather and answers with the weather in Oslo.
Models that fit OpenAI Agents SDK
Every id below meets what OpenAI Agents 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
- Pass the model to each agent as an
OpenAIChatCompletionsModel. A plain model name sends the request to OpenAI's Responses API with your OpenAI settings. - Without
set_tracing_disabled(True)the SDK tries to upload traces to OpenAI and logs errors. - A tool call takes two requests: the call, then the answer written from its result.
Tips
set_default_openai_client(client)andset_default_openai_api("chat_completions")make Shannon the default for every agent.OpenAIResponsesModelalso works, since Shannon serves/v1/responses; send the whole conversation each turn, as replies are not stored.- Handoffs between agents work the same way; give each agent the Shannon model.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
401 mentioning OpenAI | An agent without model= used the default OpenAI client. | Give every agent the Shannon model, or set the default client. |
| Trace upload errors in the log | Tracing is on. | Call set_tracing_disabled(True). |
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 OpenAI Agents SDK work with Shannon?
Yes, through OpenAIChatCompletionsModel over an AsyncOpenAI client with base_url="https://api.shannon-ai.com/v1".
Do tools and streaming work?
Yes; we ran a tool call and a streamed run.