Documentation

Quick start

# Two lines, no install. Point any OpenAI-compatible client at InferAll:
#   base URL  https://api.inferall.ai/v1
#   api key   your ifu_... key from inferall.ai/keys

# Python SDK
pip install inferall-ai

# TypeScript SDK
npm install @inferall/sdk

# There is also an install wizard that edits your project for you:
npx @inferall/cli init
#
# Heads up: the published wizard (0.2.0) is several releases behind and has a
# number of known problems, including a doctor command that can call a
# committed .env safe and an init that may leave your key written but not
# gitignored. All are fixed in the repo and unpublished. Until the next release
# lands, the two lines above are the reliable path.

Want a runnable example? examples/ in the repo has minimal Python and TypeScript scripts you can clone, edit, and run.

Base URL

https://api.inferall.ai

All requests require an API key via Authorization: Bearer ifu_... or x-api-key: ifu_... (legacy kr_proj_ keys are still accepted).

Endpoints

MethodPathDescription
POST/ai/v1/generateGenerate text, chat, images, or video
GET/ai/v1/modelsList all models with pricing
GET/ai/v1/healthHealth check
POST/v1/messagesAnthropic-compatible (Claude Code)
POST/ai/v1/keysCreate API key (requires JWT)
GET/ai/v1/keysList your keys (requires JWT)
GET/ai/v1/usageUsage summary (requires JWT)
GET/ai/v1/key/statusTrial counter, balance, savings — auth via API key
POST/ai/v1/billing/checkoutStripe checkout session
GET/ai/v1/billing/statusBilling status and spend

Common errors

The gateway returns structured error messages that name the likely cause. Read the response body — the message field tells you exactly what to fix.

401 — wrong key prefix

If you point ANTHROPIC_BASE_URL/OPENAI_BASE_URL at InferAll but leave your existing provider key in place, the 401 message names the provider it came from:

  • sk-... → “looks like an OpenAI API key”
  • sk-ant-... → “looks like an Anthropic API key”
  • sk-or-... → “looks like an OpenRouter API key”
  • AIzaSy... → “looks like a Google AI Studio key”
  • ifu_... but not in our DB → “key has an InferAll prefix but isn't in our database” (likely revoked or mistyped — mint a fresh one at /keys)

402 — billing required

Trial-eligible accounts (tier pending) get 25 free NIM-model calls before any payment. When those run out you will see a 402, and completing the $5 starter-pack checkout at /billing unlocks ongoing access to the 40+ open models priced at $0 in and out. The $5 becomes spendable balance, not a fee. Already activated and still seeing 402? Check that has_paid_successfully flipped after your charge cleared; if not, the webhook may have lagged, so retry once and file support if it persists.

429 / 529 — rate limited

Honor Retry-After when present, otherwise exponential backoff. See /docs/rate-limits for the per-tier daily caps and per-operation limits.

TypeScript SDK

The native TypeScript SDK is live on npm as @inferall/sdk 0.1.0 (npm install @inferall/sdk). Prefer the official OpenAI or Anthropic SDK? Point either at the InferAll base URL — both work unchanged, and npx @inferall/cli init makes that one-line change for you (and checks your setup any time with npx @inferall/cli doctor).

// Native TypeScript SDK — live on npm as @inferall/sdk 0.1.0
import { Inferall } from "@inferall/sdk";

const ai = new Inferall(); // reads INFERALL_API_KEY (ifu_...)

// Text (free OSS by default)
const text = await ai.text("Explain quantum computing in two sentences");

// Chat with a specific provider/model
const reply = await ai.chat(messages, {
  provider: "anthropic",
  model: "claude-sonnet-4-6",
});

// Vision
const analysis = await ai.vision(imageBase64, "What is this?");

// Image-to-video (Veo3) — pass a source frame for persona-consistency
const talkingHead = await ai.generate({
  provider: "gemini",
  model: "veo-3.1-generate-preview",
  operation: "video-generate",
  prompt: "Talking-head shot, looking at camera",
  source_image_url: "https://example.com/persona-portrait.jpg",
});

// Prefer the official OpenAI/Anthropic SDKs instead? Point them at InferAll:
//   OPENAI_BASE_URL=https://api.inferall.ai/v1   (key: ifu_...)
//   ANTHROPIC_BASE_URL=https://api.inferall.ai   (key: ifu_...)

Python SDK

from inferall import Inferall

ai = Inferall()  # reads INFERALL_API_KEY from the environment

# Text generation (free via NVIDIA Llama by default)
text = ai.text("Explain quantum computing")

# Chat with any provider
reply = ai.chat(messages, provider="anthropic", model="claude-sonnet-4-6")

# Vision
analysis = ai.vision(image_base64, "What is this?")

# Generate (image or video)
video = ai.generate(
    provider="gemini",
    model="veo-3.1-fast-generate-preview",
    operation="video-generate",
    prompt="Drone shot of a city",
)

# Image-to-video (Veo3) — pass a source frame to keep the subject consistent
talking_head = ai.generate(
    provider="gemini",
    model="veo-3.1-generate-preview",
    operation="video-generate",
    prompt="Talking-head shot, looking at camera",
    source_image_url="https://example.com/persona-portrait.jpg",
)

OpenAI SDK (drop-in)

Keep the code you already have. Point the OpenAI SDK at https://api.inferall.ai/v1 with your ifu_ key and the same call reaches any model we route. The models page marks the few we do not.

One habit worth keeping when you point existing code at a new base URL: read resp.model. It names the model that actually ran, which is not always the ID you sent. An ID we cannot route is answered by a free default instead, and because that is a routing decision rather than a failure there is no error and no warning header. The response body is the only place it shows.

# Already using the OpenAI SDK? Change two arguments.
from openai import OpenAI

client = OpenAI(
    base_url="https://api.inferall.ai/v1",
    api_key="ifu_your_inferall_key",
)

# Free NVIDIA NIM open models: $0 in, $0 out
resp = client.chat.completions.create(
    model="meta/llama-3.1-8b-instruct",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
)
print(resp.choices[0].message.content)

# Check what actually answered.
print(resp.model)   # meta/llama-3.1-8b-instruct, the id you sent

# Reach a premium provider with a model prefix, billed from your balance
resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Same call, different provider"}],
)
print(resp.model)   # claude-sonnet-4-6, the prefix is routing and is stripped

# If resp.model names a model you did not ask for, the ID could not be routed
# and a free default answered instead. A bare "gpt-4o" comes back this way as
# meta/llama-3.1-70b-instruct. There is no error and no warning header when it
# happens, so resp.model is the check that catches it.

Claude Code integration

Point Claude Code (or any Anthropic-SDK app) at InferAll and the two env vars below are enough.

Default routing sends requests to free NVIDIA NIM open models at $0 input / $0 output. New accounts get 25 free NIM calls before any payment; after those, the $5 starter pack unlocks ongoing NIM access and that same $5 becomes spendable balance for premium providers via the anthropic/claude-sonnet-4-6 style prefix.

One difference from the OpenAI SDK section above, and it matters if you were planning to check. On /v1/messages the reply carries the model ID you sent, not the one that answered. So if Claude Code displays claude-sonnet-4-6 while a free NVIDIA model actually served the request, nothing in the response says so. Naming the provider explicitly is what removes the doubt: a prefixed ID such as anthropic/claude-sonnet-4-6 reaches that provider, and on the rare occasion we have to fall back, the response carries an X-Inferall-Actual-Model header naming where it went.

# Use Claude Code with free inference
export ANTHROPIC_BASE_URL=https://api.inferall.ai
export ANTHROPIC_API_KEY=your_inferall_key

# Run Claude Code normally — uses free NVIDIA models by default
claude

# Force a specific provider with model prefix
# anthropic/claude-sonnet-4-6  → actual Claude
# gemini/gemini-2.5-flash            → Google Gemini

Key status (trial counter + savings)

GET /ai/v1/key/status — auth via your ifu_/kr_user_ API key (Bearer or x-api-key). Returns the trial counter, balance, and 7-day savings vs paid providers — enough for an SDK or CLI to render an upgrade nudge inline.

{
  "tier": "pending",
  "project": false,
  "trial":   { "used": 50, "remaining": 150, "cap": 200 },
  "balance_cents": 500,
  "balance_usd": 5,
  "has_card": true,
  "has_paid_successfully": true,
  "savings_7d": {
    "vs_gpt4o_mini_usd": 0.0318,
    "vs_claude_sonnet_usd": 0.6373
  },
  "checkout_url": "https://inferall.ai/billing"
}

For per-call awareness without an extra round-trip, every successful /v1/chat/completions from a trial key also includes X-InferAll-Trial-Usage: N/CAP and X-InferAll-Trial-Status: active|halfway|near_cap response headers, where CAP is the allowance the gateway is currently enforcing. Read it from the header rather than hardcoding a number, since it is a server-side setting and has changed.

Providers

OpenAIGPT-4.1, o3, o4-mini, GPT-4o, gpt-image-1
AnthropicClaude Opus/Sonnet/Haiku 4.x
Google Gemini2.5 Flash/Pro, Veo, Imagen
NVIDIA NIM40+ free models (Llama, Mixtral, Nemotron)
ReplicateFlux, Stable Diffusion
RunwayGen-4.5, video generation
ElevenLabseleven_multilingual_v2 TTS

Live model list

Browse every model and its price on the model catalog, which marks the free ones a no-card trial key can call. The raw JSON is at api.inferall.ai/ai/v1/models

More resources

Integrations — Claude Code, Cline, Cursor, LangChain, LlamaIndex, and more

Pricing — Free trial, Pro, Team, and Enterprise plans

Rate limits — Per-operation limits and spending caps