Skip to content

LlamaIndex

LlamaIndex’s OpenAILike LLM is made for OpenAI-compatible endpoints with their own model names, so it works with OpenPike’s chat completions endpoint.

Parameter Value
api_base https://api.openpike.dev/v1
api_key a virtual key
model an OpenPike name, such as deepseek/deepseek-flash
is_chat_model True, so it calls chat completions (the default is False)
context_window the model’s context window; LlamaIndex assumes 3,900 tokens otherwise
default_headers {"x-openpike-tags": ...}

Use OpenAILike rather than LlamaIndex’s OpenAI class: OpenAILike accepts any model name.

Terminal window
pip install llama-index-llms-openai-like
chat.py
import os
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="deepseek/deepseek-flash",
api_base="https://api.openpike.dev/v1",
api_key=os.environ["OPENPIKE_API_KEY"],
is_chat_model=True,
context_window=128000,
default_headers={"x-openpike-tags": "agent=docs-example,env=dev"},
)
reply = llm.chat([ChatMessage(role="user", content="Name one river in Europe.")])
print(reply.message.content)
  • To cap one agent run with a run budget, create the LLM per task with x-openpike-run in default_headers.
  • Embeddings are not served by OpenPike, so keep your embedding model on its own provider.
  • Set context_window to the real window of the model you route to, so LlamaIndex fills prompts correctly.

A runnable copy of this setup, with a .env.example, is in the OpenPike examples repo.