LlamaIndex
LlamaIndex gets a governed OpenAILike LLM pointed at the Agent Fabric LLM
proxy, with the chat-model flag a chat-only gateway requires already set.
What you get
- A native
llama_index.llms.openai_like.OpenAILike. is_chat_model=Trueandis_function_calling_model=Trueset for you.- Supported at
connection_kwargs(). The client receives a staticdefault_headerssnapshot, so per-run correlation anddonkey.last_callare not available (see Notes).
Install
pip install "donkey-kit[llamaindex]"Quickstart
Python
from donkey_kit.integrations.llamaindex import llm
model = llm("gpt-4o")model is a real llama_index.llms.openai_like.OpenAILike instance, ready to
hand to any LlamaIndex query engine, chat engine, or agent.
Three ways to construct
1. Off a shared Donkey instance:
from donkey_kit import Donkey
async with Donkey.from_env() as donkey:
model = donkey.llamaindex.llm("gpt-4o")2. Module-level factory (shortest):
from donkey_kit.integrations.llamaindex import llm
model = llm("gpt-4o")3. Governed kwargs, native constructor:
from donkey_kit import Donkey
from llama_index.llms.openai_like import OpenAILike
async with Donkey.from_env() as donkey:
model = OpenAILike(model="gpt-4o", **donkey.llamaindex.connection_kwargs())Manual equivalent
from llama_index.llms.openai_like import OpenAILike
model = OpenAILike(
model="gpt-4o",
api_base=..., # from DONKEY_LLM_PROXY_URL, no /v1 suffix
api_key=...,
default_headers=..., # client_id / client_secret header pair
is_chat_model=True, # required — see below
is_function_calling_model=True,
)LlamaIndex uses api_base rather than base_url; connection_kwargs()
already translates for you.
Notes
- Always set
is_chat_model=True.OpenAILikedefaults tois_chat_model=False, which routes requests to the completions endpoint instead of chat — and that fails against a chat-only proxy like the Omni Gateway LLM proxy.connection_kwargs()always sets it (andis_function_calling_model=True); set it yourself if you constructOpenAILikeoutside the adapter. - No per-run correlation or
donkey.last_call. The client receives a staticdefault_headerssnapshot, which excludes the correlation ID bound later bydonkey.run(id=...), and the SDK’s httpx client is not used. No response reaches the SDK, so gateway identity, routing, and usage fields can’t be observed. When every adapter resolved on aDonkeyis like this one,donkey.last_callreportsstatus == LastCallStatus.UNAVAILABLEandavailable == False, and names the resolved adapters insurface. The conformance suite asserts both as documented exemptions.
See the error taxonomy for how proxy rejections surface as typed exceptions, and the verification ledger for the current status of every constructor signature this adapter depends on.
Last updated on