Docs

LlamaIndex

Use Odin v1 as the LLM in LlamaIndex through the OpenAI-like integration.

LlamaIndex connects through its OpenAI-like LLM class, which accepts any model name and base URL. See Not supported for what the OpenAI-compatible API doesn't accept.

Install

pip install llama-index-core llama-index-llms-openai-like

Configure

import os

from llama_index.core import Settings
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="odin-v1",
    api_base="https://api.interodin.com/v1",
    api_key=os.environ["INTERODIN_API_KEY"],
    is_chat_model=True,
    is_function_calling_model=True,
    context_window=1000000,
)

# Make it the default LLM for indexes, query engines and agents.
Settings.llm = llm

print(llm.complete("Name three Norse gods."))

reply = llm.chat([
    ChatMessage(role="system", content="You are a concise assistant."),
    ChatMessage(role="user", content="Write a haiku about Odin."),
])
print(reply.message.content)

for chunk in llm.stream_complete("Count to five."):
    print(chunk.delta, end="", flush=True)
  • is_chat_model=True makes LlamaIndex use Chat Completions.
  • is_function_calling_model=True lets agents use tool calling.
  • context_window must match the model page. LlamaIndex uses it to decide how much context it can pack into a prompt.

Embeddings

InterOdin serves chat models only and has no embeddings route. Set Settings.embed_model explicitly to the provider you already use. If you leave it unset and a global OPENAI_BASE_URL points at InterOdin, LlamaIndex sends embedding requests here and gets a 404. Retrieval works as before, and Odin v1 writes the answers.

On this page