> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/integration-examples/tooling/llamaindex.md).

# LlamaIndex

LlamaIndex provides an OpenAI-compatible adapter for custom inference services. The adapter uses Chat Completions, so treat this integration as a fallback when your workflow cannot use the Cortecs Responses API.

## 1. Install the adapter

```bash
pip install llama-index-llms-openai-like
```

## 2. Connect to Cortecs

```python
import os

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model=os.environ["CORTECS_MODEL"],
    api_base="https://api.cortecs.ai/v1",
    api_key=os.environ["CORTECS_API_KEY"],
    is_chat_model=True,
    is_function_calling_model=True,
)

response = llm.complete("Explain semantic search in two sentences.")
print(response)
```

Set `is_function_calling_model=True` only when the selected model lists `tools` in `supported_features` in the [Models API](/api-overview/models.md). For Responses-native agents, use the [OpenAI SDK](/integration-examples/tooling/openai-sdk.md), [Vercel AI SDK](/integration-examples/tooling/vercel-ai-sdk.md) or [Pydantic AI](/integration-examples/agents-and-automations/pydantic-ai.md) instead.

See the LlamaIndex [OpenAI-like adapter source and usage guide](https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/llms/llama-index-llms-openai-like) for current adapter options.
