Back to guides
API·July 1, 2026·7 min read

OpenAI-compatible API guide — from Ollama's local endpoint to hosted frontier models

'OpenAI-compatible' means any OpenAI SDK works by changing only base_url. Ollama exposes one for local models; Kunavo exposes one for hosted frontier models. Here's the pattern, and how to move between them without rewriting code.

"OpenAI-compatible" means an API speaks the same wire format as OpenAI's /v1/chat/completions — so any OpenAI SDK or tool works against it by changing only the base_url. Ollama exposes an OpenAI-compatible endpoint for models running locally on your machine. Kunavo exposes one for hosted frontier models — Claude, Gemini, GPT and 200+ more — behind one bearer token. This guide shows the pattern and how to move between them without rewriting code.

What "OpenAI-compatible" means

The OpenAI Chat Completions format became the de-facto standard: a messages array in, a choices[].message out, Server-Sent Events for streaming, tools for function calling. Any endpoint that honours that contract is "OpenAI-compatible," and the official openai SDKs (Python, Node, and every community port) point at it by setting base_url.

The Ollama pattern (local)

Ollama runs open models locally and serves them at http://localhost:11434/v1:

ollama.py
from openai import OpenAI

# Ollama exposes an OpenAI-compatible endpoint on localhost
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

resp = client.chat.completions.create(
    model="llama3.1",
    messages=[{"role": "user", "content": "Summarize this changelog."}],
)
print(resp.choices[0].message.content)

Same code, hosted frontier models (Kunavo)

Point the exact same SDK at Kunavo and pick a frontier model. Only base_url, api_key and model change — the call is byte-for-byte the same:

kunavo.py
import os
from openai import OpenAI

# Same SDK, same call shape — only base_url, api_key and model change
client = OpenAI(
    base_url="https://api.kunavo.com/v1",
    api_key=os.environ["KUNAVO_API_KEY"],
)

resp = client.chat.completions.create(
    model="claude-sonnet-4-6",  # or gemini-2-5-flash, gpt-5-5, gemini-2-5-pro...
    messages=[{"role": "user", "content": "Summarize this changelog."}],
)
print(resp.choices[0].message.content)

Get a key at /app/keys; the quickstart has Node and curl forms.

Local vs hosted — when to use which

Ollama (local)Kunavo (hosted)
Model qualityOpen models (Llama, Qwen, Mistral)Frontier: Claude, Gemini, GPT
HardwareYour GPU / RAMNone — fully hosted
CostFree (your electricity)Pay-as-you-go, ~30-70% under list
PrivacyFully offlineHosted; DPA + ZDR available
MultimodalLimitedImage, video, audio on one key

A common setup: Ollama on localhost for offline dev, Kunavo for hosted quality in production — one env var swaps them.

Discover models at runtime

Like Ollama's /api/tags, Kunavo exposes an OpenAI-shaped catalog. Resolve slugs at runtime instead of hardcoding:

models.sh
# Discover every enabled model (OpenAI-shaped, like Ollama's /api/tags)
curl https://api.kunavo.com/v1/models \
  -H "Authorization: Bearer $KUNAVO_API_KEY"

Beyond chat

The same key reaches image (/v1/images/generations), video (/v1/video/generations) and audio endpoints — all OpenAI-shaped. See the multimodal AI guide and the OpenRouter comparison for how Kunavo differs from other gateways.

FAQ

What is an OpenAI-compatible API?

One that speaks OpenAI's /v1/chat/completions format, so any OpenAI SDK works by changing only base_url.

Is there an OpenAI-compatible API for hosted models like Ollama?

Yes — Kunavo serves hosted Claude, Gemini, GPT and more behind https://api.kunavo.com/v1, with the same code shape as Ollama's local endpoint.

Can I use Ollama locally and Kunavo in production?

Yes — swap base_url and model per environment; the SDK and call stay the same.

Which models are available?

Claude, Gemini, GPT and 200+ more — GET /v1/models returns the live list. Browse the model catalog.