OpenAPI Agent
⚠️ DEPRECATION WARNING
This component is deprecated and will be removed in a future version of Nappai. Please migrate to the recommended alternative components.
The OpenAPI Agent component lets you connect your language model to any API that follows the OpenAPI specification. By providing the API definition file and a prompt, the agent can automatically decide which calls to make and combine the results into a single answer.
How it Works
- Load the API definition – The component reads a JSON or YAML file that describes the API’s endpoints, parameters, and responses.
- Create a toolkit – Using LangChain’s OpenAPI toolkit, it turns the specification into a set of tools the agent can call.
- Build the agent – The language model (LLM) is paired with the toolkit to form an agent that can reason about the task, choose the right API calls, and assemble the final response.
- Execute – When you run the component, the agent processes the user’s input, makes the necessary API requests, and returns the combined answer.
Inputs
- Model – The language model that the agent will use to generate responses and decide which API calls to make.
- File Path – The location of the OpenAPI specification file (JSON or YAML) that defines the API endpoints the agent can call.
- Allow Dangerous Requests – A safety switch that lets the agent make potentially risky API calls (like deleting data). Set to false by default.
- Handle Parse Errors – If the agent receives a response that can’t be parsed, this flag tells it how to handle the error.
- Input – The initial user prompt or task that the agent should perform.
- Max Iterations – The maximum number of steps the agent can take before stopping. Helps prevent endless loops.
- Verbose – If true, the agent will provide detailed logs of its reasoning and API calls.
Outputs
- Agent – The fully configured
AgentExecutor
that can be reused or inspected. - Response – The final message produced by the agent after executing the task.
Usage Example
- Choose a model – Select a language model such as “gpt-4o” from the Model dropdown.
- Upload the spec – Drag and drop the
weather_api.yaml
file that describes the weather API. - Set safety – Leave “Allow Dangerous Requests” unchecked to keep the agent safe.
- Enter a prompt – Type “What’s the weather forecast for tomorrow in New York?” in the Input field.
- Run – Click the run button. The agent will read the spec, call the appropriate endpoint, and return the forecast in the Response output.
Related Components
- OpenAPI Agent (New) – The recommended replacement for this legacy component. It offers the same functionality with improved safety and performance.
- OpenAPI Agent (Legacy) – The current component, marked as deprecated.
Tips and Best Practices
- Keep the OpenAPI spec up‑to‑date; changes in the API should be reflected in the file you upload.
- Use a small “Max Iterations” value (e.g., 5) when testing to avoid long execution times.
- Enable “Verbose” only when debugging; it can produce large logs.
- If you need to call an API that performs destructive actions, set “Allow Dangerous Requests” to true only after reviewing the safety implications.
Security Considerations
- Dangerous Requests – Enabling this option allows the agent to perform actions like deleting data or modifying resources. Use it only when you trust the API and the data.
- Input Validation – The component does not sanitize user input; ensure that the prompt does not contain malicious content that could be passed to the API.
- API Keys – Store any required authentication tokens securely in Nappai’s credential manager; do not hard‑code them in the spec file.