OpenAPIConnector
Invoke REST endpoints defined in an OpenAPI specification. Use this component to call any REST API that follows the OpenAPI standard directly from a Haystack pipeline.
Key Features
- Dynamically interprets an OpenAPI specification and exposes its operations.
- Invokes endpoints by
operation_idwith query, path, or body parameters. - Supports optional API credentials for authenticated services.
- Accepts additional client configuration through
service_kwargs.
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
OpenAPIConnectorcomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set
openapi_specto a URL, file path, or raw OpenAPI specification string. - Set
credentialsif the API requires authentication.
- Set
- Go to the Advanced tab to configure
service_kwargsfor additional OpenAPI client options.
Connections
OpenAPIConnector receives an operation_id and optional arguments as inputs. It outputs a response dictionary with the service response. Connect it to components that supply operation parameters or process API results.
Source Code
To check this component's source code, open openapi.py in the Haystack Core Integrations repository.
Usage Examples
Basic Configuration
OpenAPIConnector:
type: haystack_integrations.components.connectors.openapi.openapi.OpenAPIConnector
init_parameters:
openapi_spec: https://bit.ly/serperdev_openapi
credentials:
type: env_var
env_vars:
- SERPERDEV_API_KEY
strict: false
Pass the operation_id and arguments at query time:
# haystack-pipeline
components:
api_connector:
type: haystack_integrations.components.connectors.openapi.openapi.OpenAPIConnector
init_parameters:
openapi_spec: https://bit.ly/serperdev_openapi
credentials:
type: env_var
env_vars:
- SERPERDEV_API_KEY
strict: false
inputs:
operation_id:
- api_connector.operation_id
arguments:
- api_connector.arguments
outputs:
response: api_connector.response
Parameters
Inputs
| Parameter | Type | Description |
|---|---|---|
operation_id | str | The operationId from the OpenAPI spec to invoke. |
arguments | Dict[str, Any] | None | Parameters for the endpoint (query, path, or body parameters). |
Outputs
| Parameter | Type | Description |
|---|---|---|
response | Dict[str, Any] | The service response. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
openapi_spec | str | URL, file path, or raw string of the OpenAPI specification. | |
credentials | Secret | None | None | API key or credentials for the service. |
service_kwargs | Dict[str, Any] | None | None | Additional keyword arguments passed to the OpenAPI client. |
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 |
|---|---|---|---|
operation_id | str | The operationId from the OpenAPI spec to invoke. | |
arguments | Dict[str, Any] | None | None | Parameters for the endpoint. |
Related Information
Was this page helpful?