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

> Use TokenLab models with the OpenAI Agents SDK

## Overview

The OpenAI Agents SDK can use TokenLab through an OpenAI-compatible client and `OpenAIChatCompletionsModel`.

<Note>
  **Type**: Python Agent SDK

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

  **Support Confidence**: Supported chat-completions path
</Note>

## Environment

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

## Example

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

## Scope

This path uses Chat Completions compatibility. TokenLab's native Responses endpoint is available at `https://api.tokenlab.sh/v1/responses`, but SDK features that depend on OpenAI-specific Responses semantics should be verified with the exact model and workflow before production use.
