Skip to content
smolagents

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

Set it up

  1. Install smolagents with the OpenAI extra

    Shell
    pip install 'smolagents[openai]'
  2. Create the model and an agent

    Python
    from 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 idContext windowMax outputImage 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 @tool raises an error.
  • Each step is one request. max_steps caps how many an agent may take.
  • CodeAgent runs model-written Python on your machine; use its sandbox options for untrusted tasks.
  • Recent versions call the class OpenAIModel; OpenAIServerModel still works and is what we used.

Tips

  1. ToolCallingAgent uses native tool calls; CodeAgent uses plain text and works with any model.
  2. agent.run(..., stream=True) yields each step as it happens.
  3. Calling the model directly with model.generate([...]) is a quick connection test.
  4. Each step prints its input and output tokens; our two-step weather task used about 20,000 input tokens on shannon-coder-1.

Troubleshooting

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

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