Web Asset House Guides
Local AI

Use OpenAI Client Code with Ollama: The /v1 Endpoints, What's Supported and What Isn't

By Web Asset House Studio ·

Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.

How we wrote this: A plain-English summary of Ollama's official OpenAI compatibility documentation, checked October 29, 2026. Ollama supports a subset of the OpenAI API, so check the docs before relying on a specific field.

The two-line change

Point any official OpenAI client library at your local Ollama server:

from openai import OpenAI
client = OpenAI(base_url='http://localhost:11434/v1/', api_key='ollama')
r = client.chat.completions.create(model='qwen3:8b',
    messages=[{'role': 'user', 'content': 'Say this is a test'}])
print(r.choices[0].message.content)

Pull the model first (ollama pull qwen3:8b). Local models must be downloaded before use.

Endpoints Ollama provides

Endpoint Notes from the docs
/v1/chat/completions Chat, streaming, JSON mode, seeds, vision (base64 images only, not image URLs), tools, thinking control
/v1/completions prompt must be a string
/v1/responses Responses API, stateless only: no previous_response_id or conversation
/v1/models, /v1/models/{model} owned_by defaults to library
/v1/embeddings String or array-of-strings input, dimensions supported
/v1/audio/speech, /transcriptions, /translations For speech-capable models (newer Ollama versions)

Fields that don't work (yet)

On chat completions the docs list tool_choice, logit_bias, user and n as unsupported, and logprobs isn't available. Plan around these if you're porting an app.

Tools that expect "gpt-3.5-turbo"

Some tools hard-code OpenAI model names. The docs suggest copying a local model to that name:

ollama cp llama3.2 gpt-3.5-turbo

Requests for gpt-3.5-turbo then go to your local Llama model.

Setting the context size

The OpenAI API has no field for context length, so the docs say to create a model with a Modelfile:

FROM qwen3:8b
PARAMETER num_ctx 16384

Then run ollama create mymodel and call mymodel. See context length explained and Modelfiles.

Privacy note

The docs also describe a cloud base URL (https://ollama.com/v1) that needs an Ollama account key. Using localhost keeps requests on your machine. To turn cloud features off entirely, see local-only mode.

Related: Ollama local API basics, streaming, tool calling.

Sources

← All Local AI guides · All guides