> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SmolAgents integration

> Connect HuggingFace SmolAgents to Orq.ai's AI Gateway. Access 300+ LLMs with built-in fallbacks, load balancing, and cost tracking.

## 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](/docs/ai-gateway/configuration/api-keys)
* Python 3.9 or higher

<Info>
  To setup your API key, see [API keys & Endpoints](/docs/ai-gateway/configuration/api-keys).
</Info>

### Installation

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
pip install smolagents
```

### Configuration

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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 Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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 Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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"],
)
```
