AELDER

Connect Haystack

Set a custom base URL on OpenAIChatGenerator for the text generation part of your pipeline.

AELDER · SERVICE BASE URL
https://aelder.dev/v1

LOCAL CONFIGURATION

Let my agent set this up

Copy this task to an agent already running on your computer. Enter your API key locally when asked.

SETUP PROMPT
Help me connect Haystack to AELDER using this guide: https://aelder.dev/docs/haystack/
Service Base URL: https://aelder.dev/v1
First inspect my installed version, active profile and configuration. Explain any mismatch with the guide before changing anything.
Use the documented local configuration or CLI method. Do not automate the GUI, install software or change permissions without asking.
Preserve existing accounts, providers, models, defaults, permissions and unrelated settings. Propose the smallest change, show a redacted diff, and back up any files before editing.
Have me enter my API key locally using the tool's secret storage or an environment variable. Never ask me to paste a key into chat, print it, or include it in a command, diff, log or commit.
Use the exact model ID I choose from my account's model list. Do not invent model IDs or assume every model supports every API format or tool feature.
Validate syntax and configuration loading before making any generation request. If there is no dry-run, say so.
Explain any proposed paid test, the model and what it sends, and ask for approval before running it. Do not send project files or private conversation history as a test.
Finish with the settings changed, checks performed and steps to restore the backup.

Haystack’s OpenAIChatGenerator accepts a custom Chat Completions endpoint. Use it for the generation step in an existing Python pipeline.

1. Prepare your environment

Install Haystack in your project virtual environment:

python -m pip install haystack-ai

Set SERVICE_BASE_URL to the Base URL above with /v1, and SERVICE_MODEL_ID to an exact model ID. Supply SERVICE_API_KEY privately in the Python process environment. Haystack’s Secret wrapper below resolves that variable instead of embedding a key in code.

2. Create the generator

import os
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret

generator = OpenAIChatGenerator(
    model=os.environ["SERVICE_MODEL_ID"],
    api_base_url=os.environ["SERVICE_BASE_URL"],
    api_key=Secret.from_env_var("SERVICE_API_KEY"),
    max_retries=0,
)
result = generator.run(messages=[
    ChatMessage.from_user("Reply with OK."),
])
for reply in result["replies"]:
    print(reply.text)

Keep /v1 in api_base_url; the component appends the Chat Completions path. Change model to another exact ID to use a different model. In a pipeline, replace only the intended generator component, preserving its existing connections and other settings.

3. Validate the generation step

Construct the generator first to check imports and required environment values. generator.run sends a billable request. Confirm the selected model in your dashboard before running a full pipeline, which may make multiple calls.

This recipe does not change retrieval, embedding or document-store components. Keep those separately configured. Tool invocation, structured replies and streaming callbacks depend on both the selected model and your Haystack component configuration; test them individually after the text check.

Sources: Haystack’s OpenAIChatGenerator guide and component implementation.

Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.