Skip to main content

llama-index tools openapi integration

Project description

OpenAPI Tool

pip install llama-index-tools-openapi

This tool loads an OpenAPI spec and allow the Agent to retrieve endpoints and details about endpoints. The RequestsToolSpec can also be loaded into the agent to allow the agent to hit the necessary 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_index.tools.openapi import OpenAPIToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

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 = FunctionAgent(
    tools=tool_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

print(await agent.run("What is the base url for the API"))
print(await agent.run("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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_openapi-0.6.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_openapi-0.6.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_openapi-0.6.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_openapi-0.6.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_openapi-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ca0582a2fd94bd0df5612f8d4b20cec172a5e9638fd5878216f5d758afa82faa
MD5 bb1e2b76457c50d2ae41b565023d8ac7
BLAKE2b-256 629114dbcd9395a85c8d9e55e1dc45ce15007b8e6599ed4d9d1cf86e4db6661c

See more details on using hashes here.

File details

Details for the file llama_index_tools_openapi-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_tools_openapi-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_openapi-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df9b440897144723b6175e245af7981599fe609fc616b9002bcd8815ab413cf5
MD5 f45bb276b24007611ad1221548ea65d7
BLAKE2b-256 198eeb946a9f19fad05f6045590a3c588eb21b86b8a68730c64b8cc7fab14019

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page