Skip to content

OpenAPI Toolset

The OpenAPI toolset automatically generates tools from OpenAPI/Swagger specifications, allowing agents to interact with any API that provides an OpenAPI spec.

Basic Usage

agents:
  api_agent:
    toolsets:
      - type: openapi
        spec: https://api.example.com/openapi.json

Configuration

From URL

toolsets:
  - type: openapi
    spec: https://petstore.swagger.io/v2/swagger.json

From Local File

toolsets:
  - type: openapi
    spec: ./specs/my-api.yaml

With Authentication

toolsets:
  - type: openapi
    spec: https://api.example.com/openapi.json
    base_url: https://api.example.com/v1
    headers:
      Authorization: "Bearer ${API_TOKEN}"

Generated Tools

Each OpenAPI operation becomes a tool with:

  • Name: Derived from operationId or path
  • Description: From operation summary/description
  • Parameters: Mapped from path, query, and body parameters
  • Return type: Based on response schema

Configuration Reference

OpenAPI Toolset

Configuration for OpenAPI toolsets.

OpenAPI Toolset (YAML)
1
2
3
4
5
6
7
8
toolsets:
- type: openapi
  spec:  # URL or path to the OpenAPI specification document.
    path: https://api.example.com/openapi.json
    protocol: https
    storage_options: {}
  base_url: null  # Optional base URL for API requests, overrides the one in spec.
  namespace: null  # Optional namespace prefix for tool names

Tips

  • Use namespace to prefix tool names and avoid collisions
  • Provide base_url if different from spec's server URL
  • Headers support environment variable substitution