Skip to content

Frameworks

Most frameworks wrap one of the OpenAI, Anthropic, or Gemini SDKs. Point that underlying client at DirectInference — base URL plus an llm_live_… key — and the framework works unchanged. Model ids stay as they are; every id is accepted and echoed back.

This page has the drop-in for the common Python frameworks, then a map of how each framework’s higher-level abstractions land on the wire — so you can predict what is served before you run it.

Set base_url and api_key on the chat model — the OpenAI or Anthropic class, whichever your code already uses. The model string is unchanged.

from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5.5-mini",
base_url="https://api.directinference.com/di/v1",
api_key="llm_live_...",
)

In JavaScript: new ChatOpenAI({ apiKey, configuration: { baseURL: "https://api.directinference.com/di/v1" } }), or new ChatAnthropic({ apiKey, anthropicApiUrl: "https://api.directinference.com/di" }).

Use OpenAILike for the OpenAI-compatible surface — unlike the stock OpenAI class it does not validate the model name against a fixed list, so any id (including di-fusion) is accepted.

from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="di-fusion",
api_base="https://api.directinference.com/di/v1",
api_key="llm_live_...",
is_chat_model=True,
)

How framework abstractions map to the wire

Section titled “How framework abstractions map to the wire”

A framework’s high-level feature compiles down to a request shape. DirectInference serves the shapes that are part of the OpenAI / Anthropic / Gemini APIs — including the OpenAI Responses API (statelessly, at /v1/responses). The one line it does not serve is provider server-side tools (web search, code execution, URL context, and the Responses hosted tools). The mapping below lets you tell, per feature, which side of that line you are on — without reading framework source.

FrameworkAbstractionCompiles toServed?
PydanticAIoutput_type= structured outputForced tool call (final_result tool + forced tool_choice)✓ Served
PydanticAIbuiltin_tools=[WebSearchTool()]Provider server-side tool (e.g. Gemini googleSearch)✗ Keep on the original provider
PydanticAIprovider:model stringThe matching DI surface (openai: / anthropic: / google-gla:)✓ Served
LangChainChatOpenAI / ChatAnthropicChat Completions / Messages✓ Served
LangChaingrounding / web-search toolsProvider server-side tool✗ Keep on the original provider
LlamaIndexOpenAILike, AnthropicChat Completions / Messages✓ Served
Vercel AI SDK (≥5)provider("id") (default)OpenAI Responses API✓ Served (stateless) — or provider.chat("id") for Chat Completions
LiteLLMopenai/…, anthropic/…Chat Completions / Messages✓ Served
Instructorresponse_model=Forced tool call / JSON mode✓ Served

Every framework above reaches structured output the same way underneath — a forced tool call or a response schema — and DirectInference guarantees the result is usable: a tool-bearing request never returns a 200 with unparseable arguments. That is what makes the output_type / response_model patterns reliable on DI inside an agent loop; the guarantee is spelled out in Request types.