Skip to content
INFRO

Documentation

SDKs & frameworks

Connect the OpenAI SDKs, LangChain, Vercel AI SDK, LlamaIndex, and LiteLLM to INFRO. Every OpenAI-compatible tool works with one base URL and key.


INFRO is a drop-in replacement for the OpenAI API, so there is no INFRO SDK to install. Any client that lets you override the OpenAI base URL works: point it at https://api.infro.io/v1, authenticate with an sk_infro_... key, and use INFRO model IDs like anthropic/claude-sonnet-5 wherever the tool expects a model name.

The snippets below cover the most common SDKs and frameworks. If yours is not here, the integration is always the same two settings.

base_urlstringrequired
Always https://api.infro.io/v1. The setting name varies by client: base_url in the OpenAI Python SDK and LangChain, baseURL in the Node SDK and Vercel AI SDK, api_base in LlamaIndex and LiteLLM.
api_keystringrequired
An INFRO key (sk_infro_...), created in the console — most clients read it from an environment variable. See Authentication for key labels and spend limits.

OpenAI SDKs

The official OpenAI SDKs (openai on PyPI and npm) are the fastest migration path for existing OpenAI code — change the constructor arguments and the model name, keep everything else.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.infro.io/v1",
    api_key=os.environ["INFRO_API_KEY"],
)

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

INFRO extensions

INFRO-specific request fields — routing, fallbacks, and logging — are top-level body fields the OpenAI SDK types don't know about. In Python, pass them with extra_body; in Node, add them to the request params and silence the type error with // @ts-expect-error — the SDK forwards unknown fields as-is.

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.infro.io/v1",
    api_key=os.environ["INFRO_API_KEY"],
)

response = client.chat.completions.create(
    model="openai/gpt-5.1",
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={
        "routing": {"policy": "cheapest"},
        "fallbacks": ["deepseek/deepseek-v3.2"],
    },
)
print(response.model)  # the model that actually served — matters with fallbacks

LangChain

LangChain fits when you're composing chains, agents, or retrieval pipelines and want models swappable behind one interface. Use ChatOpenAI from the langchain-openai package with a custom base_url.

Python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="openai/gpt-5-mini",
    base_url="https://api.infro.io/v1",
    api_key=os.environ["INFRO_API_KEY"],
)

print(llm.invoke("Hello").content)

Vercel AI SDK

The Vercel AI SDK fits streaming chat UIs in Next.js and React — streamText and the useChat hook handle the SSE plumbing and UI state. Create a provider with createOpenAI from @ai-sdk/openai and reference models through .chat() — the provider's bare callable targets OpenAI's Responses API, which INFRO does not serve.

TypeScript
import { createOpenAI } from "@ai-sdk/openai";
import { streamText } from "ai";

const infro = createOpenAI({
  baseURL: "https://api.infro.io/v1",
  apiKey: process.env.INFRO_API_KEY,
});

const result = streamText({
  model: infro.chat("google/gemini-3-pro"),
  prompt: "Explain SSE in one paragraph.",
});

for await (const text of result.textStream) process.stdout.write(text);

LlamaIndex

LlamaIndex fits RAG applications where the framework manages ingestion, indexing, and retrieval over your own data. Install llama-index-llms-openai-like and set api_base.

Python
import os
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="deepseek/deepseek-v3.2",
    api_base="https://api.infro.io/v1",
    api_key=os.environ["INFRO_API_KEY"],
    is_chat_model=True,
)

print(llm.complete("Hello"))

Keep is_chat_model=True. INFRO only serves /v1/chat/completions — the legacy text-completions endpoint is not supported, and OpenAILike falls back to it when the flag is off.

LiteLLM

LiteLLM fits when it is already your abstraction layer across providers, or when you run its proxy in front of application code. The openai/ prefix tells LiteLLM to speak the OpenAI protocol to a custom api_base; everything after the prefix is the INFRO model ID.

Python
import os
import litellm

response = litellm.completion(
    model="openai/moonshot/kimi-k2",
    api_base="https://api.infro.io/v1",
    api_key=os.environ["INFRO_API_KEY"],
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.choices[0].message.content)

Other OpenAI-compatible tools

Any tool with a configurable OpenAI base URL — desktop chat clients, coding agents, evaluation harnesses, no-code builders — works the same way: base URL https://api.infro.io/v1, key in the Authorization: Bearer header. Streaming is standard OpenAI SSE (see Streaming) and failures follow the OpenAI error shape (see Errors), so existing retry and parsing logic carries over.

The quickstart covers creating a key and making a first request with plain curl; the chat completions reference documents every request and response field, including INFRO extensions.