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
ChatMessageobjects with tool calls and invokes the matching OpenAPI operations. - Authenticates with
httpandapiKeysecurity schemes defined in the OpenAPI spec. - Returns service responses as
ChatMessageobjects for downstream LLM components. - Works with function definitions produced by
OpenAPIServiceToFunctions.
Configuration
Add Workspace-Level Integration
- Click your profile icon and choose Settings.
- Go to Workspace>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in the current workspace.
Add Organization-Level Integration
- Click your profile icon and choose Settings.
- Go to Organization>Integrations.
- Find the provider you want to connect and click Connect next to them.
- Enter the API key and any other required details.
- Click Connect. You can use this integration in pipelines and indexes in all workspaces in the current organization.
- Drag the
OpenAPIServiceConnectorcomponent onto the canvas from the Component Library. - Connect an upstream component that provides OpenAPI function definitions (typically
OpenAPIServiceToFunctions). - Connect chat messages with tool calls to the
messagesinput. - Pass the resolved OpenAPI spec and credentials at runtime through
service_openapi_specandservice_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
| Parameter | Type | Description |
|---|---|---|
messages | List[ChatMessage] | Chat messages to process. The last message must be from the assistant and contain tool calls. |
service_openapi_spec | Dict[str, Any] | The OpenAPI JSON specification with resolved references. |
service_credentials | Dict | str | None | Credentials for authentication. A string for single-scheme APIs, or a dictionary keyed by security scheme name. |
Outputs
| Parameter | Type | Description |
|---|---|---|
service_response | List[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:
| Parameter | Type | Default | Description |
|---|---|---|---|
ssl_verify | bool | str | None | None | Whether 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
messages | List[ChatMessage] | Chat messages with tool calls to execute. | |
service_openapi_spec | Dict[str, Any] | The OpenAPI specification of the service. | |
service_credentials | Dict | str | None | None | Credentials for service authentication. |
Related Information
Was this page helpful?