Skip to main content

AI Gateway

Overview

SmolAgents is a lightweight Python agent framework by Hugging Face. Using OpenAIServerModel with a custom api_base, you can route all LLM calls through Orq.ai’s AI Gateway for access to 300+ models, cost tracking, and reliability features.

Prerequisites

  • An Orq.ai account and API Key
  • Python 3.9 or higher
To setup your API key, see API keys & Endpoints.

Installation

pip install smolagents

Configuration

Python
import os
from smolagents import OpenAIServerModel

model = OpenAIServerModel(
    model_id="openai/gpt-4o",
    api_base="https://api.orq.ai/v3/router",
    api_key=os.environ["ORQ_API_KEY"],
)
api_base: https://api.orq.ai/v3/router

Basic Agent Example

Python
import os
from smolagents import CodeAgent, OpenAIServerModel

model = OpenAIServerModel(
    model_id="openai/gpt-4o-mini",
    api_base="https://api.orq.ai/v3/router",
    api_key=os.environ["ORQ_API_KEY"],
)

agent = CodeAgent(tools=[], model=model)
agent.run("What is the capital of France?")

Model Selection

With Orq.ai, you can use any supported model from 20+ providers:
Python
import os
from smolagents import OpenAIServerModel

# Use Claude
claude_model = OpenAIServerModel(
    model_id="anthropic/claude-sonnet-4-6",
    api_base="https://api.orq.ai/v3/router",
    api_key=os.environ["ORQ_API_KEY"],
)

# Use Gemini
gemini_model = OpenAIServerModel(
    model_id="google-ai/gemini-2.5-flash",
    api_base="https://api.orq.ai/v3/router",
    api_key=os.environ["ORQ_API_KEY"],
)

# Use Groq
groq_model = OpenAIServerModel(
    model_id="groq/llama-3.3-70b-versatile",
    api_base="https://api.orq.ai/v3/router",
    api_key=os.environ["ORQ_API_KEY"],
)