> ## 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 o TokenLab com o OpenAIChatGenerator do Haystack

## Visão Geral

O `OpenAIChatGenerator` do Haystack suporta implantações personalizadas compatíveis com OpenAI através do `api_base_url`. Aponte-o para o TokenLab e forneça uma chave de API do TokenLab.

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

  **Caminho Principal**: Chat Completions compatíveis com OpenAI

  **Nível de Suporte**: Caminho compatível com OpenAI suportado
</Note>

## Ambiente

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

## Gerador

```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 o Endpoint

Use este caminho para pipelines de gerador de chat do Haystack. Para embeddings, configure o componente de embedding correspondente do Haystack com a URL base `/v1` do TokenLab, caso seu pipeline utilize embeddings do TokenLab.
