> ## 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

> OpenAI互換クライアントを通じてMicrosoft AutoGenでTokenLabモデルを使用する

## 概要

AutoGenは、他のカスタムChat Completionsエンドポイントで使用するのと同じ `OpenAIChatCompletionClient` を通じて、TokenLabを利用できます。

<Note>
  **タイプ**: エージェントフレームワーク

  **主要パス**: OpenAI互換チャットコンプリーション

  **サポート信頼度**: サポートされているカスタムエンドポイントパス
</Note>

## インストール

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

## 環境設定

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

## YAMLモデル設定

TokenLabの `/v1` エンドポイントを `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クライアント

```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)
```

## エンドポイントに関する注意点

AutoGenのOpenAI拡張機能は、OpenAI互換のリクエスト形式を想定しています。Anthropic MessagesやGeminiの `generateContent` といったプロバイダー固有の機能については、それらのプロトコルを直接サポートするクライアントからTokenLabのネイティブエンドポイントを使用してください。
