Personal and autonomous agents
Use smolagents with Shannon
Point smolagents' OpenAIServerModel at Shannon and run ToolCallingAgent or CodeAgent on Shannon models.
- Tested Nov 7, 2026
- OpenAI Chat Completions
- About 2 min
About smolagents
smolagents is Hugging Face's minimal agent library. A CodeAgent writes Python to act, and a ToolCallingAgent uses native tool calls. Models come in through small wrappers, and the OpenAI-compatible one takes a base URL, so both agent types 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 smolagents with the OpenAI extra
Shellpip install 'smolagents[openai]' -
Create the model and an agent
Pythonfrom smolagents import OpenAIServerModel, ToolCallingAgent, tool model = OpenAIServerModel( model_id="Kimi-K3-uncensored-NVFP4", api_base="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY", ) @tool def get_weather(city: str) -> str: """Weather for a city. Args: city: The city name. """ return f"Sunny, 18 C in {city}" agent = ToolCallingAgent(tools=[get_weather], model=model, max_steps=4) print(agent.run("What is the weather in Oslo?"))
Check that it works
Send: Run the sample.
You should see: The agent calls get_weather, then final_answer, and prints the weather in Oslo.
Models that fit smolagents
Every id below meets what smolagents 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.1-Pro-uncensored-NVFP4 | 1,022,976 | 262,144 | Yes |
MiMo-V2.6-Pro-uncensored-NVFP4 | 1,022,976 | 131,072 | Yes |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Yes |
shannon-3 | 196,608 | 65,536 | Yes |
Good to know
- smolagents reads each tool's docstring: the
Args:section with a line per argument is required, or@toolraises an error. - Each step is one request.
max_stepscaps how many an agent may take. CodeAgentruns model-written Python on your machine; use its sandbox options for untrusted tasks.- Recent versions call the class
OpenAIModel;OpenAIServerModelstill works and is what we used.
Tips
ToolCallingAgentuses native tool calls;CodeAgentuses plain text and works with any model.agent.run(..., stream=True)yields each step as it happens.- Calling the model directly with
model.generate([...])is a quick connection test. - Each step prints its input and output tokens; our two-step weather task used about 20,000 input tokens on
shannon-coder-1.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
404 Not Found | api_base lacks /v1. | Use https://api.shannon-ai.com/v1. |
| "Reached max steps" | The task needs more steps than max_steps. | Raise max_steps or simplify the task. |
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 smolagents work with Shannon?
Yes, through OpenAIServerModel(api_base="https://api.shannon-ai.com/v1").
Which agent type should I use?
ToolCallingAgent with a model from the picker, since they all make native tool calls; we tested it.