Skip to main content

OpenAPI Tool

This tool loads an OpenAPI spec and allow the Agent to retrieve endpoints and details about endpoints. The RequestsToolSpec can also be laoded into the agent to allow the agent to hit the nessecary endpoints with a REST request.

Usage

This tool has more extensive example usage documented in a Jupyter notebook here

Here's an example usage of the OpenAPIToolSpec.

from llama_hub.tools.openapi import OpenAPIToolSpec
from llama_index.agent import OpenAIAgent

f = requests.get(
    "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
).text
open_api_spec = yaml.safe_load(f)
# OR
open_spec = OpenAPIToolSpec(
    url="https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml"
)


tool_spec = OpenAPIToolSpec(open_api_spec)

agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())

agent.chat("What is the base url for the API")
agent.chat("What parameters does the x endpoint need?")

load_openapi_spec: Returns the parsed OpenAPI spec that the class was initialized with

This loader is designed to be used as a way to load data as a Tool in a Agent. See here for examples.

Metadata

Release files for flying-delta-tools-openapi 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flying-delta-tools-openapi 0.1.0
File Size Uploaded
flying_delta_tools_openapi-0.1.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flying-delta-tools-openapi 0.1.0
File Interpreter ABI Platform
flying_delta_tools_openapi-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / flying_delta_tools_openapi-0.1.0.tar.gz

Download URL flying_delta_tools_openapi-0.1.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b9965183d54bc789ecbdabef47246734622e48fc5eca956aba00b2f6c1e00b24
BLAKE2b-256 checksum
How to use checksums
284c9465fb3eef1d1757b9ee1ec451168c25a6c08854f67d751fae97a5aa06bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.13 Darwin/23.0.0

Release files / flying_delta_tools_openapi-0.1.0-py3-none-any.whl

Download URL flying_delta_tools_openapi-0.1.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
839b1633a40c397e6b9ca819a6fc91ec7ed1d54403c0e15b691ee4617be57f2a
BLAKE2b-256 checksum
How to use checksums
293ef057ecac50542e1416500d868291cce974a2e2a4d2939c0fa51444468fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.13 Darwin/23.0.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page