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

# DSPy

> Configure TokenLab as an OpenAI-compatible language model in DSPy

## Overview

DSPy can call TokenLab by using the `openai/` provider prefix with TokenLab's OpenAI-compatible `/v1` endpoint.

<Note>
  **Type**: Programming Framework

  **Primary Path**: OpenAI-compatible language model calls

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

## Environment

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

## Configure DSPy

```python theme={null}
import os

import dspy

lm = dspy.LM(
    "openai/claude-sonnet-5",
    api_key=os.environ["TOKENLAB_API_KEY"],
    api_base="https://api.tokenlab.sh/v1",
)

dspy.configure(lm=lm)
```

## Use a Module

```python theme={null}
qa = dspy.ChainOfThought("question -> answer")

response = qa(question="What should I monitor in an LLM gateway?")
print(response.answer)
```

## Model Suggestions

Use `gpt-5.4-mini` for quick experiments, `claude-sonnet-5` for stronger reasoning traces, and `deepseek-v4-flash` for fast iteration loops.
