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

# OpenAI Agents SDK

> Sử dụng các mô hình TokenLab với OpenAI Agents SDK

## Tổng quan

OpenAI Agents SDK có thể sử dụng TokenLab thông qua một client tương thích với OpenAI và `OpenAIChatCompletionsModel`.

<Note>
  **Loại**: Python Agent SDK

  **Đường dẫn chính**: Chat completions tương thích với OpenAI

  **Độ tin cậy hỗ trợ**: Hỗ trợ đường dẫn chat-completions
</Note>

## Môi trường

```bash theme={null}
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
export TOKENLAB_BASE_URL="https://api.tokenlab.sh/v1"
export TOKENLAB_MODEL="gpt-5.4-mini"
```

## Ví dụ

```python theme={null}
import asyncio
import os

from openai import AsyncOpenAI

from agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled

client = AsyncOpenAI(
    base_url=os.getenv("TOKENLAB_BASE_URL", "https://api.tokenlab.sh/v1"),
    api_key=os.environ["TOKENLAB_API_KEY"],
)

set_tracing_disabled(disabled=True)


async def main():
    agent = Agent(
        name="Assistant",
        instructions="You are concise and practical.",
        model=OpenAIChatCompletionsModel(
            model=os.getenv("TOKENLAB_MODEL", "gpt-5.4-mini"),
            openai_client=client,
        ),
    )

    result = await Runner.run(agent, "Explain custom model providers in one paragraph.")
    print(result.final_output)


asyncio.run(main())
```

## Phạm vi

Đường dẫn này sử dụng khả năng tương thích Chat Completions. Endpoint Responses gốc của TokenLab khả dụng tại `https://api.tokenlab.sh/v1/responses`, tuy nhiên các tính năng của SDK phụ thuộc vào ngữ nghĩa Responses đặc thù của OpenAI cần được xác minh với mô hình và quy trình làm việc chính xác trước khi đưa vào môi trường production.
