LlamaIndex
Use AICredits with LlamaIndex through OpenAI-compatible chat and embedding clients for RAG and document agents.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
LlamaIndex is a framework for document agents, retrieval, ingestion, and RAG. Use AICredits with its OpenAI-compatible LLM and embedding integrations.
OpenAI-Compatible LLM
Install the OpenAI-like LLM integration:
pip install llama-index-llms-openai-likeConfigure the client:
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="openai/gpt-4o-mini",
api_base="https://api.aicredits.in/v1",
api_key="sk-your-aicredits-key",
context_window=128000,
is_chat_model=True,
is_function_calling_model=True,
)
response = llm.complete('Reply with "AICredits via LlamaIndex" and nothing else.')
print(str(response))Embeddings
For RAG ingestion, configure OpenAI-compatible embeddings with the same base URL if your LlamaIndex embedding package supports custom API bases:
OPENAI_API_KEY=sk-your-aicredits-key
OPENAI_BASE_URL=https://api.aicredits.in/v1Use text-embedding-3-small for most retrieval workloads.
Separate ingestion experiments from production query traffic with different AICredits API keys. It makes embedding and chat costs easier to inspect.
Verify
Run the chat snippet and then open Dashboard -> Usage to confirm the request.
Troubleshooting
Import error - Install llama-index-llms-openai-like.
Request uses the wrong host - Confirm api_base is set on the LLM instance.
Tool/function calls fail - Set is_function_calling_model=True only for models you use with tools.