Ollama can answer requests shaped like the Anthropic Messages API, which lets tools that expect Anthropic endpoints talk to a local Ollama server. The compatibility layer is useful when an application exposes only Anthropic-style base URL and token settings.
The local server still ignores the placeholder token, but many clients require one syntactically. Point the client at http://localhost:11434 and keep the model name set to an Ollama model that supports the requested behavior.
Compatibility does not make every Anthropic feature identical. Start with a minimal messages request, then add streaming, tools, or longer context after the basic route returns final text.
$ export ANTHROPIC_AUTH_TOKEN=ollama $ export ANTHROPIC_BASE_URL=http://localhost:11434
The token value is required by some clients but ignored by the local Ollama server.
$ curl -s http://localhost:11434/v1/messages \ -H 'Content-Type: application/json' \ -H 'x-api-key: ollama' \ -H 'anthropic-version: 2023-06-01' \ -d '{ "model": "gpt-oss:20b", "max_tokens": 80, "messages": [{"role":"user","content":"Return only OK."}] }' {"type":"message","content":[{"type":"thinking"},{"type":"text","text":"OK"}],"stop_reason":"end_turn"}
$ python3 - <<'PY'
content = [{"type":"thinking"}, {"type":"text", "text":"OK"}]
print(''.join(part.get('text','') for part in content if part.get('type') == 'text'))
PY
OK
$ curl -s http://localhost:11434/v1/messages -d '{"model":"gpt-oss:20b","max_tokens":20,"messages":[{"role":"user","content":"Return OK."}]}' {"content":[{"type":"thinking"}],"stop_reason":"max_tokens"}
For gpt-oss models, too small a token cap can spend the budget on reasoning.
$ export ANTHROPIC_MODEL=gpt-oss:20b
Use the model name from ollama list or api/tags.