diff --git a/docs.json b/docs.json index a962c3ce6..926ab152b 100644 --- a/docs.json +++ b/docs.json @@ -2037,6 +2037,18 @@ } ] }, + { + "group": "TokenLab", + "pages": [ + "models/providers/gateways/tokenlab/overview", + { + "group": "Usage", + "pages": [ + "models/providers/gateways/tokenlab/usage/basic" + ] + } + ] + }, { "group": "Sambanova", "pages": [ @@ -3947,6 +3959,18 @@ } ] }, + { + "group": "TokenLab", + "pages": [ + "models/providers/gateways/tokenlab/overview", + { + "group": "Usage", + "pages": [ + "models/providers/gateways/tokenlab/usage/basic" + ] + } + ] + }, { "group": "Sambanova", "pages": [ diff --git a/models/providers/gateways/tokenlab/overview.mdx b/models/providers/gateways/tokenlab/overview.mdx new file mode 100644 index 000000000..5484ce4df --- /dev/null +++ b/models/providers/gateways/tokenlab/overview.mdx @@ -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). + + + +```bash Mac +export TOKENLAB_API_KEY=*** +``` + +```bash Windows +setx TOKENLAB_API_KEY *** +``` + + + +## Example + +Use `TokenLab` with your `Agent`: + + + +```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") +``` + + + +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") +``` + + View more examples [here](/models/providers/gateways/tokenlab/usage/basic). + +## 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). diff --git a/models/providers/gateways/tokenlab/usage/basic.mdx b/models/providers/gateways/tokenlab/usage/basic.mdx new file mode 100644 index 000000000..72c30275e --- /dev/null +++ b/models/providers/gateways/tokenlab/usage/basic.mdx @@ -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 + + + + + + ```bash + export TOKENLAB_API_KEY=xxx + ``` + + + + ```bash + uv pip install -U agno openai + ``` + + + + ```bash + python cookbook/90_models/tokenlab/basic.py + ``` + + diff --git a/models/providers/model-index.mdx b/models/providers/model-index.mdx index ddab95ead..eed508c69 100644 --- a/models/providers/model-index.mdx +++ b/models/providers/model-index.mdx @@ -393,6 +393,14 @@ Browse the provider guides available in this documentation. Capabilities vary by > Route model requests through Requesty. + + TokenLab multi-model gateway. +