All guides · API quickstart · Last checked: Settings from the packages' own code (llama-index-llms-openai-like 0.9.0, llama-index-embeddings-openai-like 0.5.0), November 2026; the requests they send (chat, tool calls, batched embeddings) tested against our live API
- 1. Create an accountSign up in a minute and get $5 of free credit. Already a customer? Sign in.
- 2. Make an API keyIn your account, open AI API and press Create key. Keys start with
dgk_. Keep yours secret. - 3. Follow the steps belowCopy each block, paste your key where it says
dgk_your_key_here.
Install
pip install -U llama-index-core llama-index-llms-openai-like llama-index-embeddings-openai-like
The model
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="gemma4:26b-nvfp4",
api_base="https://api.datagram.net/v1",
api_key="dgk_your_key_here",
is_chat_model=True,
is_function_calling_model=True,
context_window=8192,
)
print(llm.complete("Say hello in five words."))
is_chat_model=True: our models are chat models. Without it LlamaIndex uses the older completions endpoint.context_window=8192: the size of our models' window (use65536withqwen3-coder:30b-64k). LlamaIndex uses it to decide how much of your documents fits in one request; the default (3,900) wastes half the window.is_function_calling_model=Truelets agents and structured outputs use tool calls. Gemma 4 and the Qwen models support them.
Embeddings
from llama_index.embeddings.openai_like import OpenAILikeEmbedding
embed_model = OpenAILikeEmbedding(
model_name="qwen3-embedding:8b",
api_base="https://api.datagram.net/v1",
api_key="dgk_your_key_here",
embed_batch_size=32,
)
qwen3-embedding:8b is the most accurate; bge-m3 is the cheapest and handles many languages. Pick one and keep it: an index built with one model can't be searched with the other.
Ask questions about your documents
from llama_index.core import Settings, SimpleDirectoryReader, VectorStoreIndex
Settings.llm = llm
Settings.embed_model = embed_model
docs = SimpleDirectoryReader("./my_docs").load_data()
index = VectorStoreIndex.from_documents(docs)
print(index.as_query_engine().query("What does the contract say about renewals?"))
Your documents are read on your machine; only the pieces needed for each step (embedding and answering) are sent to us, and we never store them.
If something goes wrong
401 "Missing API key" or "Invalid or revoked API key"
Check the key is pasted in full (it starts with dgk_) and hasn't been revoked in your account under AI API.
Rambling or oddly formatted answers
Set is_chat_model=True. Without it LlamaIndex sends plain text completions instead of a chat, and the model doesn't see its usual chat format.
Answers cut off or "context length" errors
Set context_window to the model's window (8192, or 65536 for qwen3-coder:30b-64k) so LlamaIndex sends less at once.
402 "credit has run out"
Add credit in your account under AI API. Credit never expires.
Questions
Which models should I use?
gemma4:26b-nvfp4 to answer (quick, supports tool calls), and qwen3-embedding:8b or bge-m3 for embeddings. For very long inputs, qwen3-coder:30b-64k with context_window=65536.
Are my documents stored?
No. Only the text needed for each request is sent, to our own Macs, and it is never written to a log or database or used for training. Your index stays on your machine.
What does it cost?
Normal token prices from your credit. Embedding a 100-page document with bge-m3 costs well under a cent.