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

# LlamaIndex

> Use Mesh as the LLM behind LlamaIndex agents and query engines with OpenAILike — including tool calling and the auto-router.

LlamaIndex reaches Mesh through `OpenAILike`, the connector built for OpenAI-compatible endpoints. It takes an `api_base`, so no Mesh-specific package is needed.

## Install

```bash theme={null}
pip install llama-index-core llama-index-llms-openai-like
```

## Connect

```python theme={null}
import os

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="auto",                              # or any Mesh catalog id
    api_base="https://api.meshapi.ai/v1",
    api_key=os.environ["MESH_API_KEY"],        # rsk_...
    is_chat_model=True,
    is_function_calling_model=True,
)
```

> [!WARNING]
>
> `is_chat_model` and `is_function_calling_model` both default to **false** on `OpenAILike`. Leave them unset and LlamaIndex treats Mesh as a legacy completion endpoint with no tool support, so agents and `chat_with_tools` silently stop working. Always set both to `True`.

## Tool calling

```python theme={null}
from llama_index.core.llms import ChatMessage
from llama_index.core.tools import FunctionTool


def get_shipment_status(order_id: str) -> dict:
    """Look up the shipment status of an order."""
    book = {"A-1042": {"state": "in transit", "eta_days": 2}}
    if order_id in book:
        return {"status": "success", "order_id": order_id, **book[order_id]}
    return {"status": "error", "error_message": f"No order {order_id}."}


tool = FunctionTool.from_defaults(fn=get_shipment_status)

messages = [ChatMessage(role="user", content="What's the shipment status of order A-1042?")]
response = llm.chat_with_tools([tool], chat_history=messages)

messages.append(response.message)
for call in llm.get_tool_calls_from_response(response, error_on_no_tool_call=False):
    output = get_shipment_status(**call.tool_kwargs)
    messages.append(
        ChatMessage(
            role="tool",
            content=str(output),
            additional_kwargs={"tool_call_id": call.tool_id, "name": call.tool_name},
        )
    )

final = llm.chat(messages)
print(final.message.content)
```

The same `llm` drives `FunctionAgent`, `AgentWorkflow`, query engines, and anywhere else LlamaIndex takes an LLM.

## Caveats

Everything in [Caveats that apply to every framework](https://developers.meshapi.ai/agent/frameworks.md#caveats-that-apply-to-every-framework) applies here.

## Related

* [Agent frameworks](https://developers.meshapi.ai/agent/frameworks.md) — the shared pattern and compatibility matrix
* [Auto-routing](https://developers.meshapi.ai/docs/capabilities/auto-routing.md) — how `auto` picks a model
* [Embeddings](https://developers.meshapi.ai/docs/capabilities/embeddings.md) — Mesh embeddings for LlamaIndex indexes


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.