llama-index-tools-openapi


Namellama-index-tools-openapi JSON
Version 0.5.1 PyPI version JSON
download
home_pageNone
Summaryllama-index tools openapi integration
upload_time2025-09-08 20:49:06
maintainerajhofmann
docs_urlNone
authorNone
requires_python<4.0,>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenAPI Tool

```bash
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](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-openapi/examples/openapi_and_requests.ipynb)

Here's an example usage of the OpenAPIToolSpec.

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-tools-openapi",
    "maintainer": "ajhofmann",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Your Name <you@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/a1/04/0c784dd57cdc3c1b1aac98cf58b306401ec7681cf080ec2c8075c8811db3/llama_index_tools_openapi-0.5.1.tar.gz",
    "platform": null,
    "description": "# OpenAPI Tool\n\n```bash\npip install llama-index-tools-openapi\n```\n\nThis 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.\n\n## Usage\n\nThis tool has more extensive example usage documented in a Jupyter notebook [here](https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-openapi/examples/openapi_and_requests.ipynb)\n\nHere's an example usage of the OpenAPIToolSpec.\n\n```python\nfrom llama_index.tools.openapi import OpenAPIToolSpec\nfrom llama_index.core.agent.workflow import FunctionAgent\nfrom llama_index.llms.openai import OpenAI\n\nf = requests.get(\n    \"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml\"\n).text\nopen_api_spec = yaml.safe_load(f)\n# OR\nopen_spec = OpenAPIToolSpec(\n    url=\"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/openai.com/1.2.0/openapi.yaml\"\n)\n\n\ntool_spec = OpenAPIToolSpec(open_api_spec)\n\nagent = FunctionAgent(\n    tools=tool_spec.to_tool_list(),\n    llm=OpenAI(model=\"gpt-4.1\"),\n)\n\nprint(await agent.run(\"What is the base url for the API\"))\nprint(await agent.run(\"What parameters does the x endpoint need?\"))\n```\n\n`load_openapi_spec`: Returns the parsed OpenAPI spec that the class was initialized with\n\nThis loader is designed to be used as a way to load data as a Tool in a Agent.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "llama-index tools openapi integration",
    "version": "0.5.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dc7673135c5e2638cc42c59b4243db58cbc8a7d9ee4ba7fac90aa4638e7d44ea",
                "md5": "6ab413790b93043d58a55c7595dd4513",
                "sha256": "3236f03e0431ac1d7235a3f2c37c486b0e6b0ed26fde6bb771eddfb6496078f7"
            },
            "downloads": -1,
            "filename": "llama_index_tools_openapi-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6ab413790b93043d58a55c7595dd4513",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 4752,
            "upload_time": "2025-09-08T20:49:05",
            "upload_time_iso_8601": "2025-09-08T20:49:05.582015Z",
            "url": "https://files.pythonhosted.org/packages/dc/76/73135c5e2638cc42c59b4243db58cbc8a7d9ee4ba7fac90aa4638e7d44ea/llama_index_tools_openapi-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a1040c784dd57cdc3c1b1aac98cf58b306401ec7681cf080ec2c8075c8811db3",
                "md5": "cd1c66754538c44cfc847b06b8dfb322",
                "sha256": "28184b3829a40cef3a8335bea56a1edad2dc0dffcc359c317845a0c7cd3d65ad"
            },
            "downloads": -1,
            "filename": "llama_index_tools_openapi-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cd1c66754538c44cfc847b06b8dfb322",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 5065,
            "upload_time": "2025-09-08T20:49:06",
            "upload_time_iso_8601": "2025-09-08T20:49:06.265074Z",
            "url": "https://files.pythonhosted.org/packages/a1/04/0c784dd57cdc3c1b1aac98cf58b306401ec7681cf080ec2c8075c8811db3/llama_index_tools_openapi-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 20:49:06",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-tools-openapi"
}
        
Elapsed time: 3.51241s