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

OpenAPIServiceConnector

Invoke OpenAPI services from tool calls in chat messages. Use this component in agent pipelines where an LLM selects tools and this component executes them against a REST API.

Key Features

  • Processes ChatMessage objects with tool calls and invokes the matching OpenAPI operations.
  • Authenticates with http and apiKey security schemes defined in the OpenAPI spec.
  • Returns service responses as ChatMessage objects for downstream LLM components.
  • Works with function definitions produced by OpenAPIServiceToFunctions.

Configuration

Add Workspace-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Workspace>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in the current workspace.

Add Organization-Level Integration

  1. Click your profile icon and choose Settings.
  2. Go to Organization>Integrations.
  3. Find the provider you want to connect and click Connect next to them.
  4. Enter the API key and any other required details.
  5. Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
  1. Drag the OpenAPIServiceConnector component onto the canvas from the Component Library.
  2. Connect an upstream component that provides OpenAPI function definitions (typically OpenAPIServiceToFunctions).
  3. Connect chat messages with tool calls to the messages input.
  4. Pass the resolved OpenAPI spec and credentials at runtime through service_openapi_spec and service_credentials.

Connections

OpenAPIServiceConnector receives a list of ChatMessage objects (the last message must be from the assistant and contain tool calls), an OpenAPI specification, and optional credentials. It outputs service_response as a list of ChatMessage objects with JSON responses from the service.

Connect it downstream from a chat generator that produces tool calls and upstream from components that consume tool results.

Source Code

To check this component's source code, open openapi_service.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  OpenAPIServiceConnector:
type: haystack_integrations.components.connectors.openapi.openapi_service.OpenAPIServiceConnector
init_parameters: {}

In an agent pipeline, convert OpenAPI specs first, then pass a single resolved spec into the connector with OutputAdapter. The converter outputs a list of specs; the connector expects one dict:

# haystack-pipeline
components:
spec_converter:
type: haystack_integrations.components.converters.openapi.openapi_functions.OpenAPIServiceToFunctions
init_parameters: {}

openapi_spec_adapter:
type: haystack.components.converters.output_adapter.OutputAdapter
init_parameters:
template: "{{ specs[0] }}"
output_type: Dict[str, Any]
unsafe: true

service_connector:
type: haystack_integrations.components.connectors.openapi.openapi_service.OpenAPIServiceConnector
init_parameters: {}

connections:
- sender: spec_converter.openapi_specs
receiver: openapi_spec_adapter.specs
- sender: openapi_spec_adapter.output
receiver: service_connector.service_openapi_spec

inputs:
sources:
- spec_converter.sources
messages:
- service_connector.messages

outputs:
service_response: service_connector.service_response

Parameters

Inputs

ParameterTypeDescription
messagesList[ChatMessage]Chat messages to process. The last message must be from the assistant and contain tool calls.
service_openapi_specDict[str, Any]The OpenAPI JSON specification with resolved references.
service_credentialsDict | str | NoneCredentials for authentication. A string for single-scheme APIs, or a dictionary keyed by security scheme name.

Outputs

ParameterTypeDescription
service_responseList[ChatMessage]Responses from the service as user-role chat messages with JSON content.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
ssl_verifybool | str | NoneNoneWhether to verify SSL for requests. Pass a string to use it as the CA certificate.

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
messagesList[ChatMessage]Chat messages with tool calls to execute.
service_openapi_specDict[str, Any]The OpenAPI specification of the service.
service_credentialsDict | str | NoneNoneCredentials for service authentication.