Skip to content

API Compatibility

github-actions[bot] edited this page Aug 14, 2026 · 7 revisions

🔌 API compatibility

/v1/* and /api/v1/* are forwarded directly to LM Studio. Every other Ollama endpoint is translated to its native equivalent.

Endpoint support

Endpoint Behaviour
GET / Returns "Ollama is running"
GET /api/tags Translates to /api/v1/models; includes proxy-managed aliases
GET /api/ps Translates to /api/v1/models; shows loaded models plus aliases; size_vram mirrors the loaded model size (LM Studio reports no GPU/CPU split); details.parent_model is ""; expires_at is a best-effort placeholder
POST /api/show Fetches real LM Studio metadata; capabilities (vision/tools/thinking) come from the backend capabilities object, with an id-keyword fallback only when the backend reports none; description/display_name surfaced; verbose model_info adds loaded tuning (flash_attention/eval_batch_size/parallel/offload_kv_cache_to_gpu) while the model is loaded and multi-quant variants/selected_variant when the backend reports them; merges alias info when present. Native models omit modelfile/template/parameters/license since LM Studio exposes no Modelfile
POST /api/chat Translates to /api/v0/chat/completions (or native /api/v1/chat with --use-native-chat / --native-chat-streaming). Non-streaming replies carry LM Studio's real eval_count / eval_duration / prompt_eval_* from the v0 stats block. The v0 SSE stream ends without a stats chunk, so streaming counts are length-proportional estimates; the native path reports real ones from its chat.end event. A messageless request warms the model (done_reason:"load" no-op); keep_alive: 0 without messages unloads it
POST /api/generate Translates to /api/v0/completions; vision requests use the v0 chat endpoint. A promptless request warms the model; keep_alive: 0 without a prompt unloads it
POST /api/embed Translates to /v1/embeddings; also handles /api/embeddings. Auto-loads (JIT) an unloaded embedding model on demand instead of returning "no models loaded"; honors num_ctx; truncate defaults to true
GET /api/version Returns configurable version string (--ollama-version, default 0.30.0) in Ollama format
GET /health Validates LM Studio reachability
POST /api/create Creates proxy-managed virtual aliases (no custom blobs)
POST /api/pull Translates to /api/v1/models/download; NDJSON progress, polled from LM Studio's job status every 500ms; insecure is accepted and ignored (no TLS-skip surface to emulate); failed downloads surface LM Studio's error_message
POST /api/push Returns 501 (LM Studio has no model registry)
POST /api/web_search Generic JSON passthrough to a configurable provider (--search-url); returns 501 when unconfigured. Request: {query, max_results?}; provider response returned verbatim
POST /api/web_fetch Fetches URL, renders HTML to markdown. Request: {url}; response: {title, content, links}. SSRF guard on by default (disable with --allow-private-fetch). No LM Studio dependency
DELETE /api/delete Removes proxy-managed aliases only
POST /api/copy Duplicates aliases or references LM Studio models; returns an empty 200 body and upserts (overwrites an existing destination)
HEAD/POST /api/blobs/:digest Stores and validates blobs for alias manifests

Error codes

Upstream LM Studio 429 (rate limited) and 502 (bad gateway) pass through unchanged; other upstream-unreachable failures map to 503. Proxy-side validation errors return 400, and a model missing from LM Studio returns 404.

Verbatim passthrough

ANY /v1/* and ANY /api/v1/* are forwarded directly to LM Studio without modification. This includes POST /v1/messages (Anthropic-compat) and POST /v1/responses (OpenAI Responses), which LM Studio serves natively. The proxy remaps the model field (and the GET /v1/models/{id} path segment) from the Ollama-style name or a /api/copy alias to the resolved LM Studio id before forwarding. A few compatibility shims apply on top:

  • response_format: {"type": "json_object"} is rewritten to the permissive json_schema envelope LM Studio accepts.
  • encoding_format: "base64" on /v1/embeddings is honored by the proxy (LM Studio always returns floats; the proxy re-encodes them).
  • Proxy-generated errors on /v1/messages use Anthropic's {"type":"error","error":{...}} envelope, including auth rejections.
  • Mid-stream proxy errors (timeout, cancel, upstream failure) are framed per protocol: event: error for Anthropic, event: response.failed for /v1/responses, a typed error object for OpenAI-style streams.

Anthropic clients such as Claude Code work against /v1/messages with no extra setup: point ANTHROPIC_BASE_URL at the proxy.

Virtual model aliases

  • /api/create and /api/copy manage aliases stored under $XDG_CACHE_HOME/ollama-lmstudio-proxy/virtual_models.json (fallback: $HOME/.cache/ollama-lmstudio-proxy/, then system temp). Alias metadata (system, template, parameters, license, adapters, messages, renderer, parser) is recorded on the alias. system and parameters reach inference; the rest are stored but stay inert on the LM Studio backend.
  • /api/delete removes only proxy-managed aliases. /api/show returns LM Studio metadata plus alias info when present.
  • A virtual_models.json that fails to parse is renamed aside to virtual_models.json.corrupt (counting up .1, .2 on repeat) before the proxy continues with an empty alias set. The original bytes stay recoverable by hand.
  • /api/pull streams LM Studio catalog downloads (or blocks when "stream": false); optional quantization and source fields are forwarded.

Clone this wiki locally