> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nimbleway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LlamaIndex

> Add real-time web search to LlamaIndex agents and workflows with the Nimble tool spec.

### Overview

The [`llama-index-tools-nimble`](https://pypi.org/project/llama-index-tools-nimble/) package brings Nimble web search to [LlamaIndex](https://www.llamaindex.ai/). It provides a single tool spec, `NimbleToolSpec`, that lets LlamaIndex agents and workflows retrieve current information from the web.

Search results return as LlamaIndex `Document` objects. Each document carries the page title and source URL, so answers stay citable and ready for RAG pipelines.

#### Key Features

* **Real-time web search** — one method, `search()`, returns fresh results from across the web
* **Citable output** — every `Document` includes the title and source URL in its metadata
* **Agent-ready** — `to_tool_list()` plugs directly into any LlamaIndex agent or workflow
* **RAG-friendly** — `Document` output drops straight into LlamaIndex indexes and query engines

### Quick Start

#### Installation

```bash theme={"system"}
pip install llama-index-tools-nimble
```

#### Setup

Get your API key from [Nimble's dashboard](https://online.nimbleway.com/account-settings/api-keys) (free trial available). Set it as an environment variable:

```bash theme={"system"}
export NIMBLE_API_KEY="your-api-key"
```

Or pass it directly when constructing the tool spec:

```python theme={"system"}
from llama_index.tools.nimble import NimbleToolSpec

tool_spec = NimbleToolSpec(api_key="your-api-key")
```

#### Direct Search

Call `search()` on the tool spec to get results back as `Document` objects. Use `max_results` to cap how many results come back (default is 6):

```python theme={"system"}
from llama_index.tools.nimble import NimbleToolSpec

tool_spec = NimbleToolSpec()
documents = tool_spec.search(
    "latest developments in web data infrastructure",
    max_results=5,
)

for doc in documents:
    print(doc.metadata["title"], "-", doc.metadata["url"])
```

The loop above prints the title and source URL for each result:

```text theme={"system"}
Web Data Infrastructure for AI - https://nimbleway.com/...
The State of Web Data in 2026 - https://example.com/...
```

### Build an AI Agent

Pass the tool spec to a LlamaIndex `FunctionAgent` with `to_tool_list()`. The agent can then search the web to answer questions with current facts:

```python theme={"system"}
import asyncio
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.nimble import NimbleToolSpec

agent = FunctionAgent(
    tools=NimbleToolSpec().to_tool_list(),
    llm=OpenAI(model="gpt-4o-mini"),
    system_prompt="You are a research assistant. Use web search to answer with current facts.",
)

async def main():
    response = await agent.run("What has Nimble announced recently?")
    print(response)

asyncio.run(main())
```

### Citable Document Output

Every result is a LlamaIndex `Document`. The title and source URL are embedded in the document text, so the agent can read and cite the source even though it never sees metadata. Each document's text has this shape:

```text theme={"system"}
<title>
URL: <source url>

<page content or snippet>
```

The title and URL are also available as metadata fields for programmatic use:

| Field               | Description    |
| ------------------- | -------------- |
| `metadata["title"]` | The page title |
| `metadata["url"]`   | The source URL |

Use these fields to build citations or deduplicate sources:

```python theme={"system"}
from llama_index.tools.nimble import NimbleToolSpec

documents = NimbleToolSpec().search("state of retrieval-augmented generation")

for doc in documents:
    print(f"Source: {doc.metadata['title']} ({doc.metadata['url']})")
```

### Use Results in a LlamaIndex Index

Because `search()` returns `Document` objects, results drop straight into a LlamaIndex index for retrieval-augmented generation:

```python theme={"system"}
from llama_index.core import VectorStoreIndex
from llama_index.tools.nimble import NimbleToolSpec

# Fetch live web results as Documents
documents = NimbleToolSpec().search(
    "web data infrastructure trends",
    max_results=10,
)

# Index them, then query with citable sources
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("Summarize the key trends.")
print(response)
```

### Additional Resources

* [PyPI Package](https://pypi.org/project/llama-index-tools-nimble/)
* [GitHub Repository](https://github.com/Nimbleway/llama-index-tools-nimble)
* [v0.1.0 Release](https://github.com/Nimbleway/llama-index-tools-nimble/releases/tag/v0.1.0)
* [Nimble Python SDK](https://docs.nimbleway.com/nimble-sdk/sdks/python)
* [LangChain Integration](/integrations/connectors/langchain)
