Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

ExternalGenerator

Call an external service with a prompt and return its response.

ExternalGenerator sends a prompt to an external service and returns the results from the service. It expects the service to respond with answer: str, meta: Dict. It acts just like any other Generator except that instead of calling an LLM, it calls an external service.

ExternalGenerator is flexible regarding what constitutes a prompt and what the external service does with it. For example, this component can send a SQL query as a prompt to be run on a database in an external service.

Key Features​

  • Sends a text prompt to any external HTTP service and returns the response.
  • Compatible with PromptBuilder for receiving prompts and with DeepsetAnswerBuilder for building answers with references.
  • Configurable timeout for requests.
  • Flexible: works with any service that accepts a string prompt and returns a string answer.

Configuration​

  1. Drag the ExternalGenerator component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Enter the URL of the external service to post the prompt to.
  4. Go to the Advanced tab to configure the timeout for requests (default: 50 seconds).

Connections​

ExternalGenerator receives the prompt from PromptBuilder through its prompt input. It outputs the responses from the service as a list of strings through its replies output, which you connect to DeepsetAnswerBuilder.

Usage Examples​

Basic Configuration​

ExternalGenerator:
type: deepset_cloud_custom_nodes.generators.external.ExternalGenerator
init_parameters:
url: https://your-service.example.com/generate

Using the Component in a Pipeline​

This query pipeline sends a prompt to an external HTTP service and builds an answer from the response:

# haystack-pipeline
components:
prompt_builder:
type: haystack.components.builders.prompt_builder.PromptBuilder
init_parameters:
template: "Answer the question: {{ query }}"
required_variables:
- query

external_generator:
type: deepset_cloud_custom_nodes.generators.external.ExternalGenerator
init_parameters:
url: https://your-service.example.com/generate
timeout: 50

answer_builder:
type: haystack.components.builders.answer_builder.AnswerBuilder
init_parameters: {}

connections:
- sender: prompt_builder.prompt
receiver: external_generator.prompt
- sender: external_generator.replies
receiver: answer_builder.replies

inputs:
query:
- prompt_builder.query
- answer_builder.query

outputs:
answers: answer_builder.answers

max_runs_per_component: 100

metadata: {}

Parameters​

Inputs​

ParameterTypeDescription
promptstrThe prompt to pass to the service.
metaOptional[Dict]Additional metadata related to the prompt.

Outputs​

ParameterTypeDescription
repliesList[str]The answers from the service.
metaList[Dict[str, Any]]Metadata related to the answers.

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
urlstrThe URL of the external service to post the prompt to.
timeoutint50The timeout for requests sent to the URL.

Run Method Parameters​

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
promptstrThe prompt to pass to the service.
metaOptional[Dict]NoneAdditional metadata related to the prompt.