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

> Cấu hình TokenLab như một mô hình ngôn ngữ tương thích với OpenAI trong DSPy

## Tổng quan

DSPy có thể gọi TokenLab bằng cách sử dụng tiền tố nhà cung cấp `openai/` với endpoint `/v1` tương thích với OpenAI của TokenLab.

<Note>
  **Loại**: Khung lập trình (Programming Framework)

  **Đường dẫn chính**: Các lệnh gọi mô hình ngôn ngữ tương thích với OpenAI

  **Độ tin cậy hỗ trợ**: Hỗ trợ đường dẫn endpoint tùy chỉnh
</Note>

## Môi trường

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

## Cấu hình 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)
```

## Sử dụng Module

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

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

## Gợi ý mô hình

Sử dụng `gpt-5.4-mini` cho các thử nghiệm nhanh, `claude-sonnet-5` cho các chuỗi suy luận mạnh mẽ hơn và `deepseek-v4-flash` cho các vòng lặp lặp lại nhanh.
