Skip to content

API Reference parrot.tools.openapitoolkit

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.openapitoolkit

View source

OpenAPIToolkit - Dynamic toolkit that exposes OpenAPI services as tools.

IMPROVEMENTS IN THIS VERSION:

  • Uses prance for robust OpenAPI parsing and reference resolution
  • Inline schema refs via prance (no manual recursion)
  • Support for application/x-www-form-urlencoded
  • Optimized schemas for single-operation specs (cleaner LLM experience)

This toolkit automatically converts OpenAPI specifications into callable tools, allowing LLMs to interact with REST APIs without manual tool definition.

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Alias HTTPService

Re-exported from parrot.interfaces.http.HTTPService.

Attribute LoginHook

Class OpenAPIToolkit

Toolkit that dynamically generates tools from OpenAPI specifications.

This toolkit:

  • Uses prance for robust OpenAPI 3.x parsing (JSON/YAML, local or remote)
  • Automatically resolves ALL $ref references (internal and external)
  • Creates one tool per operation with naming: {service}{method}{path}
  • Handles path parameters, query parameters, and request bodies
  • Supports multiple content types: application/json, application/x-www-form-urlencoded
  • Optimizes schemas for single-operation specs (cleaner for LLMs)
  • Supports multiple authentication methods (API keys, Bearer tokens, Basic auth)

The tools are generated dynamically and integrated with HTTPService for robust HTTP handling with retry logic, proxy support, etc.

Parameter Type Default Description
spec Union[str, Dict[str, Any]] OpenAPI spec as JSON string, YAML string, URL, dict, or file path
service str Service name used as prefix for tool names (e.g., "petstore")
base_url Optional[str] None Override base URL from spec
api_key Optional[str] None API key for authentication
auth_type str 'bearer' Authentication type ("bearer", "apikey", "basic")
auth_header str 'Authorization' Header name for authentication (default: "Authorization")
api_key_location str 'header' Where to put API key ("header" or "query")
api_key_name str 'api_key' Name of API key parameter (for query params)
credentials Optional[Dict[str, str]] None Alternative credentials dict (username/password for basic auth)
use_proxy bool False Enable proxy usage
timeout int 30 Request timeout in seconds
debug bool False Enable debug logging
path_defaults Optional[Dict[str, Any]] None Toolkit-supplied path parameter values hidden from tool schemas
include_tags Optional[Sequence[str]] None Operation tags to include, based on each operation's first tag
exclude_paths Optional[Sequence[str]] None Regular expression patterns for paths to exclude
exclude_methods Optional[Sequence[str]] None HTTP methods to exclude
operation_filter Optional[Callable[[str, str], bool]] None Callable deciding whether a method and raw path are kept
max_tools Optional[int] None Maximum number of generated operations
login_hook Optional[LoginHook] None Async callback that logs in and returns session cookies for cookie authentication
extra_headers Optional[Dict[str, str]] None Headers included on every request, including cookie-session requests
**kwargs {} Additional toolkit configuration

Attributes:

Attribute Type Description
exclude_tools tuple[str, ...]

Method OpenAPIToolkit.set_cookies

Replace the jar with externally obtained cookies (e.g. exported from a browser).

set_cookies(cookies: Dict[str, str]) -> None

Parameter Type Default Description
cookies Dict[str, str] Session cookies to retain for future cookie-mode requests.

Method OpenAPIToolkit.get_cookies

Return a copy of the cookie jar. Callers must never log the values.

get_cookies() -> Dict[str, str]

Returns: Dict[str, str] — A detached copy of the current cookie jar.

Attribute PRANCE_AVAILABLE

Alias ToolResult

Re-exported from parrot.tools.abstract.ToolResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally