How to Call a Local LLM API from Your App

OpenAI-compatible endpoints on Ollama, llama.cpp, LM Studio, and vLLM. How to point your app at a local server with a base URL change.

A local model on your machine is a server with a URL. The fastest way to call it from application code is to use a client that already speaks the OpenAI HTTP schema and point it at a different base_url. Four local runtimes - Ollama, llama.cpp’s llama-server, LM Studio, and vLLM - all expose the same /v1/chat/completions endpoint the OpenAI Python and JavaScript SDKs already target. This page walks through each server’s actual endpoints, the documented fields, and the differences that surface only after you point an SDK at them.

Why one SDK, four servers

The OpenAI Python SDK accepts a base_url parameter that overrides the default OpenAI endpoint. Any local server that speaks the same wire format becomes drop-in. The Ollama OpenAI compatibility page shows the pattern (its example comments that the key is “required but ignored”):

client = OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama",
)

The same client.chat.completions.create(model=..., messages=..., stream=True) call works against Ollama, llama.cpp, LM Studio, and vLLM. The SDK is Apache-2.0 and the base_url parameter is the documented override (openai-python README). Every local server below has the same answer for /v1/chat/completions; the differences show up in default ports, auth, multimodal fields, tool-call support, and what other endpoints (audio, rerank, decisions) they ship alongside it.

Ollama: native API and OpenAI-compatible layer

Ollama’s own API lives on localhost:11434 (the Ollama FAQ confirms Ollama binds 127.0.0.1 port 11434 by default). The native endpoints are documented at the Ollama HTTP API reference: /api/generate (single-prompt), /api/chat (multi-turn, with messages, tools, think, format), /api/embed (which supersedes the older /api/embeddings), /api/tags (list local models), /api/ps (list running models with expires_at and size_vram), /api/show, /api/pull, /api/push, /api/create, /api/copy, DELETE /api/delete, /api/version, and /api/blobs/:digest for blob upload. The OpenAI-compatible endpoints live under /v1/ and are listed at the Ollama OpenAI compatibility page: /v1/chat/completions, /v1/completions, /v1/embeddings, /v1/models, /v1/models/{model}, the non-stateful /v1/responses (added v0.13.3), /v1/audio/speech (added v0.40.8), and /v1/audio/transcriptions with /v1/audio/translations (the translation route is marked as added in v0.40.12).

The OpenAI layer supports tools, response_format, JSON mode, seed, frequency_penalty, presence_penalty, stop, temperature, top_p, max_tokens, stream, stream_options.include_usage, reasoning_effort, and reasoning.effort. It does not support tool_choice, logit_bias, user, n, or logprobs, and image URLs are not accepted - only base64 in content arrays (Ollama OpenAI compatibility). For server-side tuning the FAQ documents OLLAMA_NUM_PARALLEL (default 1), OLLAMA_MAX_LOADED_MODELS (default 3 * GPUs, or 3 on CPU), OLLAMA_MAX_QUEUE (default 512), OLLAMA_KEEP_ALIVE (default 5m), OLLAMA_HOST (default 127.0.0.1:11434), OLLAMA_ORIGINS, OLLAMA_MODELS, OLLAMA_KV_CACHE_TYPE, OLLAMA_CONTEXT_LENGTH (default 4096), and OLLAMA_FLASH_ATTENTION. As of 2026-11-13, the latest stable release on the Ollama releases page is v0.40.16, published 2026-11-09 (preceded by v0.40.15 and v0.40.14, both on 2026-11-03, and v0.40.13 on 2026-10-28).

llama.cpp server

llama-server is the C++ HTTP server that ships with llama.cpp. Defaults: --host 127.0.0.1, --port 9931, --parallel -1 (auto), --cont-batching enabled, --metrics disabled. The server exposes both native endpoints (/completion, /tokenize, /detokenize, /apply-template, /embedding, /embeddings, /reranking, /infill, /tts, /props, /slots, /metrics, /lora-adapters) and OpenAI-compatible endpoints under /v1/ (/v1/models, /v1/completions, /v1/chat/completions, /v1/chat/completions/control, /v1/responses, /v1/embeddings, /v1/audio/speech, /v1/realtime), with /rerank, /v1/rerank and /v1/reranking listed as aliases of the native /reranking route. The same README also documents the Anthropic-compatible /v1/messages (plus /v1/messages/count_tokens), the token-counting routes /v1/responses/input_tokens and /v1/chat/completions/input_tokens, a TypeSafe-compatible /v1/systemone, and a /models family for multi-model servers (list, load, unload, download and delete). Two of those need care: /embeddings is a separate native route that the README explicitly flags as non-OpenAI-compatible, because its “response format of this endpoint is different from /v1/embeddings”; and /v1/realtime is a WebSocket route for realtime transcription, not a plain HTTP request-and-response endpoint. It also ships /health, which returns a 503 with a “Loading model” error body while the model loads and 200 {"status":"ok"} once it is ready.

/v1/chat/completions accepts multimodal content (image_url, input_audio, input_video), tools (function calling via OpenAI-style schema, which uses the Jinja template engine; the README lists --jinja as enabled by default), response_format with {"type":"json_object"}, {"type":"json_object","schema":{...}}, or {"type":"json_schema","schema":{...}}, parallel_tool_calls, max_tokens, chat_template_kwargs (for example {"enable_thinking": false}), reasoning_effort, and reasoning_format. The reasoning parser flags are documented as --reasoning-format (default auto; values none, deepseek, deepseek-legacy), --reasoning-budget (default -1 unrestricted; 0 ends immediately; N>0 is a token budget), and --reasoning-effort (default default; values minimal/low/medium/high/xhigh/max). Auth is --api-key KEY (or a file via --api-key-file); no key is required by default (llama-server README).

LM Studio

LM Studio’s OpenAI compatibility page documents the local server on http://localhost:1234/v1. It exposes /v1/models, /v1/responses, /v1/decisions, /v1/chat/completions, /v1/embeddings, and /v1/completions. The page’s example changes only the base URL: OpenAI(base_url="http://localhost:1234/v1"). The sidebar lists dedicated pages for Structured Output and Tool Use. Auth is documented on a separate Core/Authentication page that this URL does not cover.

vLLM

vLLM’s OpenAI-compatible server is started with vllm serve <model>; port 8000 is vLLM’s usual default, though the cited page does not state it. It exposes /v1/completions, /v1/chat/completions, /v1/chat/completions/batch, /v1/responses (plus /v1/responses/{response_id} and its /cancel route), /v1/decisions, /v1/embeddings, /v1/audio/transcriptions, /v1/audio/translations, /v1/models, and a Cohere-compatible rerank at /rerank//v1/rerank//v2/rerank (the page notes the rerank endpoint also implements Jina AI’s v1 rerank schema). That list is the OpenAI-compatible core rather than everything the server exposes: the same page also documents Anthropic-compatible /v1/messages and /v1/messages/count_tokens, a realtime /v1/realtime route for ASR models, a structured-decisions /v1/systemone route, a Cohere-compatible /v2/embed, and custom /classify, /score, /v1/score, /pooling and /generative_scoring APIs. The page says the chat endpoint is only applicable to text generation models with a chat template, and documents the --chat-template-content-format argument to override how message content is formatted. The page does not mention the --tool-call-parser or --reasoning-parser arguments; vLLM’s separate tool calling page says to start the server with both --enable-auto-tool-choice and --tool-call-parser.

What differs across the four

RuntimeDefault base URLAuth by defaultStreamingJSON modeToolsMultimodal chatRerankAudio
Ollamahttp://localhost:11434/v1Key “required but ignored” by the local server (OpenAI compatibility)YesYes (format on /api/chat and response_format on /v1/chat/completions)Yes (OpenAI-style)Yes (base64 images)NoYes (/v1/audio/speech, plus /v1/audio/transcriptions and /v1/audio/translations)
llama-serverhttp://127.0.0.1:9931None unless --api-key is setYesYes (json_object, json_object+schema, json_schema)Yes (Jinja templates, on by default)Yes (image_url, input_audio, input_video)Yes (/v1/rerank)Speech output via /v1/audio/speech (converted to a native /tts request); realtime transcription over the /v1/realtime WebSocket, no /v1/audio/transcriptions route
LM Studiohttp://localhost:1234/v1See LM Studio’s Authentication pageYesYes (Structured Output page)Yes (Tool Use page)Yes (vision-capable models)NoNo
vLLMhttp://localhost:8000/v1 (usual default)Not covered on the cited pageYesYesYes (parser required)Yes (per model)Yes (/v1/rerank, Jina and Cohere schemas)Yes (/v1/audio/transcriptions, /v1/audio/translations)

The biggest surprises for code that already targets OpenAI:

  • Auth on Ollama. The local server ignores the key, but the SDK needs one; the docs’ examples use "ollama".
  • Multimodal. OpenAI’s hosted API accepts image URLs. Ollama only accepts base64 inside content arrays; llama-server accepts image_url, input_audio, input_video directly.
  • Reasoning fields. llama-server exposes --reasoning-effort and --reasoning-budget server-side as well as a per-request reasoning_effort; Ollama accepts reasoning_effort and reasoning.effort per request.
  • Rerank. Only llama-server and vLLM ship a rerank endpoint at all. Ollama and LM Studio do not (Ollama OpenAI compatibility, LM Studio OpenAI compatibility).
  • Audio. Ollama and vLLM both expose /v1/audio/transcriptions and /v1/audio/translations, so both handle ASR. Ollama also exposes /v1/audio/speech for text-to-speech, marked as added in v0.40.8; its docs mark /v1/audio/translations as added in v0.40.12 and give no version note for /v1/audio/transcriptions. llama-server generates speech from text over /v1/audio/speech, which its README says is converted to a request on its native /tts route, and transcribes streamed audio over the /v1/realtime WebSocket rather than /v1/audio/transcriptions. LM Studio exposes neither.

Bottom line

For an application that already targets the OpenAI Chat Completions schema, the swap to a local model is one line: base_url. Pick the runtime by what you need beyond chat. Ollama is the path of least resistance when the workload is text-only, with simple multimodal in base64. llama-server is the right pick when you need a rerank endpoint or multimodal in OpenAI’s native image_url form. LM Studio is the same API surface for a desktop-friendly install. Ollama and vLLM are the two of the four that ship /v1/audio/transcriptions and /v1/audio/translations for ASR workloads. For deployment patterns - exposing the server to your household or your team, putting it behind Caddy or Authentik, logging and auth - the cluster’s serve-a-local-model-to-your-household and serve-a-local-model-to-your-team pages cover the network side; this page covers the client side.

Other GPUs and tasks: Local AI by VRAM · RSS