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

# Haystack

> Use TokenLab with Haystack OpenAIChatGenerator

## Overview

Haystack's `OpenAIChatGenerator` supports custom OpenAI-compatible deployments through `api_base_url`. Point it at TokenLab and provide a TokenLab API key.

<Note>
  **Type**: RAG and pipeline framework

  **Primary Path**: OpenAI-compatible Chat Completions

  **Support Confidence**: Supported OpenAI-compatible path
</Note>

## Environment

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

## Generator

```python theme={null}
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret

generator = OpenAIChatGenerator(
    api_key=Secret.from_env_var("TOKENLAB_API_KEY"),
    api_base_url="https://api.tokenlab.sh/v1",
    model="claude-sonnet-5",
)

response = generator.run(
    messages=[ChatMessage.from_user("Summarize this document in one sentence.")]
)
```

## Endpoint Notes

Use this path for Haystack chat generator pipelines. For embeddings, configure the matching Haystack embedding component with TokenLab's `/v1` base URL if your pipeline uses TokenLab embeddings.
