LlamaIndex
RAG and agents, European inference.
Point `OpenAILike` and `OpenAILikeEmbedding` at our base URL. Indexes, query engines, and agents: every LlamaIndex pattern, on European infrastructure.
from llama_index.core import Settings
from llama_index.llms.openai_like import OpenAILike
from llama_index.embeddings.openai_like import OpenAILikeEmbedding
Settings.llm = OpenAILike(
model=class="s">"glm-5.1",
api_base=class="s">"https://api.melious.ai/v1",
api_key=class="s">"sk-mel-<YOUR_API_KEY>",
is_chat_model=True,
is_function_calling_model=True,
)
Settings.embed_model = OpenAILikeEmbedding(
model_name=class="s">"bge-m3",
api_base=class="s">"https://api.melious.ai/v1",
api_key=class="s">"sk-mel-<YOUR_API_KEY>",
)What is LlamaIndex?
LlamaIndex is a Python and TypeScript framework focused on retrieval and structured data for LLM apps. Indexes, query engines, and agents, connected by a global Settings object. The OpenAILike client and OpenAILikeEmbedding companion are the first-party way to point the whole pipeline at a Chat Completions endpoint with a custom base URL.
How to use LlamaIndex with Melious?
-
Install LlamaIndex
Install the core package plus the
openai-likeLLM and embedding adapters. They speak Chat Completions, which is what Melious serves.Shellpip install llama-index llama-index-llms-openai-like llama-index-embeddings-openai-like export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY> -
Configure the global Settings
Set
Settings.llmandSettings.embed_modelonce. Every index, query engine, and agent reads from these by default.is_chat_model=Trueandis_function_calling_model=Trueare required for agent workflows.Pythonimport os from llama_index.core import Settings from llama_index.llms.openai_like import OpenAILike from llama_index.embeddings.openai_like import OpenAILikeEmbedding Settings.llm = OpenAILike( model=class="s">"glm-5.1", api_base=class="s">"https://api.melious.ai/v1", api_key=os.environ[class="s">"MELIOUS_API_KEY"], is_chat_model=True, is_function_calling_model=True, ) Settings.embed_model = OpenAILikeEmbedding( model_name=class="s">"bge-m3", api_base=class="s">"https://api.melious.ai/v1", api_key=os.environ[class="s">"MELIOUS_API_KEY"], ) -
Index and query
Load documents, build a vector index, query it. Both the embedding pass and the completion call route through Melious. For agents, use
FunctionAgentfromllama_index.core.agent.workflow, the current LlamaIndex API.Pythonfrom llama_index.core import SimpleDirectoryReader, VectorStoreIndex documents = SimpleDirectoryReader(class="s">"./docs").load_data() index = VectorStoreIndex.from_documents(documents) query_engine = index.as_query_engine() response = query_engine.query(class="s">"What does the onboarding flow do?") print(response)
Three steps from here.
Grab a Melious key. Pick your tool. Follow the guide. Same client, now answering from Europe.