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

> Utilice TokenLab con Haystack OpenAIChatGenerator

## Descripción general

El `OpenAIChatGenerator` de Haystack admite implementaciones personalizadas compatibles con OpenAI a través de `api_base_url`. Apúntelo a TokenLab y proporcione una clave de API de TokenLab.

<Note>
  **Tipo**: Framework de RAG y pipeline

  **Ruta principal**: Chat Completions compatibles con OpenAI

  **Nivel de soporte**: Ruta compatible con OpenAI soportada
</Note>

## Entorno

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

## Generador

```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.")]
)
```

## Notas sobre el endpoint

Utilice esta ruta para los pipelines del generador de chat de Haystack. Para embeddings, configure el componente de embedding de Haystack correspondiente con la URL base `/v1` de TokenLab si su pipeline utiliza embeddings de TokenLab.
