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

# AutoGen

> Use TokenLab models with Microsoft AutoGen through OpenAI-compatible clients

## Overview

AutoGen can use TokenLab through `OpenAIChatCompletionClient`, the same OpenAI-compatible client path it uses for other custom Chat Completions endpoints.

<Note>
  **Type**: Agent Framework

  **Primary Path**: OpenAI-compatible chat completions

  **Support Confidence**: Supported custom endpoint path
</Note>

## Installation

```bash theme={null}
pip install -U autogen-agentchat "autogen-ext[openai]" pyyaml
```

## Environment

```bash theme={null}
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
```

## YAML Model Config

Use TokenLab's `/v1` endpoint as `base_url`:

```yaml theme={null}
provider: autogen_ext.models.openai.OpenAIChatCompletionClient
config:
  model: claude-sonnet-5
  base_url: https://api.tokenlab.sh/v1
  api_key: ${TOKENLAB_API_KEY}
  model_info:
    function_calling: true
    json_output: true
    vision: false
    family: claude
```

## Python Client

```python theme={null}
import os

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient

model_client = OpenAIChatCompletionClient(
    model="claude-sonnet-5",
    base_url="https://api.tokenlab.sh/v1",
    api_key=os.environ["TOKENLAB_API_KEY"],
    model_info={
        "function_calling": True,
        "json_output": True,
        "vision": False,
        "family": "claude",
    },
)

agent = AssistantAgent("assistant", model_client=model_client)
```

## Endpoint Notes

AutoGen's OpenAI extension expects the OpenAI-compatible request shape. For provider-native features such as Anthropic Messages or Gemini `generateContent`, use TokenLab's native endpoints from a client that supports those protocols directly.
