Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,18 @@
}
]
},
{
"group": "TokenLab",
"pages": [
"models/providers/gateways/tokenlab/overview",
{
"group": "Usage",
"pages": [
"models/providers/gateways/tokenlab/usage/basic"
]
}
]
},
{
"group": "Sambanova",
"pages": [
Expand Down Expand Up @@ -3947,6 +3959,18 @@
}
]
},
{
"group": "TokenLab",
"pages": [
"models/providers/gateways/tokenlab/overview",
{
"group": "Usage",
"pages": [
"models/providers/gateways/tokenlab/usage/basic"
]
}
]
},
{
"group": "Sambanova",
"pages": [
Expand Down
67 changes: 67 additions & 0 deletions models/providers/gateways/tokenlab/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: TokenLab
sidebarTitle: Overview
description: Use TokenLab models with Agno agents.
---

TokenLab provides an OpenAI-compatible API for routing Agno agents across GPT, Claude, Gemini, DeepSeek, Qwen, Kimi, MiniMax, GLM, Grok, and other leading models through one endpoint.

Explore available models from the [TokenLab model API](https://api.tokenlab.sh/v1/models).

## Authentication

Set your `TOKENLAB_API_KEY` environment variable. Get your API key from the [TokenLab dashboard](https://tokenlab.sh/dashboard).

<CodeGroup>

```bash Mac
export TOKENLAB_API_KEY=***
```

```bash Windows
setx TOKENLAB_API_KEY ***
```

</CodeGroup>

## Example

Use `TokenLab` with your `Agent`:

<CodeGroup>

```python agent.py
from agno.agent import Agent
from agno.models.tokenlab import TokenLab

agent = Agent(model=TokenLab(id="gpt-5.4-mini"), markdown=True)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")
```

</CodeGroup>

You can also use the model string shortcut:

```python
from agno.agent import Agent

agent = Agent(model="tokenlab:gpt-5.4-mini", markdown=True)
agent.print_response("Share a 2 sentence horror story")
```

<Note> View more examples [here](/models/providers/gateways/tokenlab/usage/basic). </Note>

## Params

| Parameter | Type | Default | Description |
| ------------ | --------------- | ------------------------------- | ------------------------------------------------------------------ |
| `id` | `str` | `"gpt-5.4-mini"` | The id of the model to use through TokenLab |
| `name` | `str` | `"TokenLab"` | The name of the model |
| `provider` | `str` | `"TokenLab"` | The provider of the model |
| `api_key` | `Optional[str]` | `None` | The API key for TokenLab (defaults to TOKENLAB_API_KEY env var) |
| `base_url` | `str` | `"https://api.tokenlab.sh/v1"` | The base URL for the TokenLab OpenAI-compatible API |
| `max_tokens` | `int` | `1024` | The maximum number of tokens to generate |

`TokenLab` also supports the params of [OpenAI](/reference/models/openai).
46 changes: 46 additions & 0 deletions models/providers/gateways/tokenlab/usage/basic.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Basic Agent
---

## Code

```python cookbook/90_models/tokenlab/basic.py
from agno.agent import Agent, RunOutput # noqa
from agno.models.tokenlab import TokenLab

agent = Agent(
model=TokenLab(id="gpt-5.4-mini"),
markdown=True,
)

# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")
```

## Usage

<Steps>
<Snippet file="create-venv-step.mdx" />

<Step title="Set your API key">
```bash
export TOKENLAB_API_KEY=xxx
```
</Step>

<Step title="Install dependencies">
```bash
uv pip install -U agno openai
```
</Step>

<Step title="Run Agent">
```bash
python cookbook/90_models/tokenlab/basic.py
```
</Step>
</Steps>
8 changes: 8 additions & 0 deletions models/providers/model-index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ Browse the provider guides available in this documentation. Capabilities vary by
>
Route model requests through Requesty.
</Card>
<Card
title="TokenLab"
icon="route"
iconType="duotone"
href="/models/providers/gateways/tokenlab/overview"
>
TokenLab multi-model gateway.
</Card>
<Card
title="SambaNova"
icon="server"
Expand Down