Running Claude Code with Ollama: what the Anthropic-compatible endpoint does
A team that wants Claude Code or an Anthropic SDK tool to use models on infrastructure it controls can point those clients at Ollama, because Ollama exposes an Anthropic-compatible /v1/messages endpoint on its REST API at port 11434. The client sends Anthropic-style Messages requests, and Ollama answers them with a model running on your own hardware. The endpoint is the same API surface that serves Ollama's native and OpenAI-compatible routes, so one server can support several kinds of tools at once.
Teams usually need this for two reasons. The first is keeping source code and prompts on their own network, since a local Ollama server processes requests without sending them to a hosted model provider. The second is governing model access: a platform team can decide which models are installed, which clients reach them and where usage is logged. Be aware that the local API at localhost:11434 has no authentication by default, so any process or machine that can reach the port can send requests. Before a shared server exists, decide who may connect, and plan a gateway or reverse proxy in front of the port, which the Ollama security and access control section covers in detail.
Confirm three things before you rely on the endpoint: the Ollama version installed on the server, the exact list of Messages fields that version supports, and whether the models your team chose are served locally or through Ollama's cloud. Test each client with a short prompt and a tool call, because compatibility is per feature rather than per protocol. The Ollama FAQ is the next place to check bind address and environment settings.
Configuration options and when each fits
This table compares the client-side and server-side settings that shape a Claude Code or Anthropic SDK setup against Ollama, and shows where each one fits a shared server or a single workstation. Read each row as a decision: the server settings control who can reach the API and how requests queue, while the client settings control which endpoint and model a developer's tool uses. Confirm the exact client variable names against Ollama's Anthropic compatibility documentation before you write them into a team setup guide.
| Setting | Role in the setup | Shared server | Single workstation |
|---|---|---|---|
| Client base URL | Points Claude Code or the Anthropic SDK at the Ollama host on port 11434 | Set to the server's internal address so all developers use one endpoint | Keep at localhost when Ollama runs on the same machine |
| OLLAMA_HOST | Changes the bind address from the default 127.0.0.1 | Bind to a private interface behind a reverse proxy that adds authentication | Leave at default so only the local machine reaches the API |
| OLLAMA_NO_CLOUD=1 | Turns off cloud features on the server | Set it so coding traffic stays on approved hardware | Optional, useful when a machine must never pull cloud models |
| OLLAMA_NUM_PARALLEL | Sets parallel requests per model, default 1 | Raise only after testing GPU memory with concurrent coding sessions | Default is usually enough for one developer |
| OLLAMA_MAX_QUEUE | Sets how many requests can wait, default 512 | Confirm how queued sessions time out under peak team use | Rarely changed when one person sends requests |
| Local model choice | Runs models on your own hardware | Keeps source code on your network, but context length needs enough VRAM | Fits a single developer whose hardware matches the model |
| Cloud model choice | Sends inference to ollama.com using an API key | Needs per-user key management and a written policy on what code leaves the network | Suits trials, but the same data review applies to the workstation |
Setting up Claude Code against a self-hosted Ollama server
This sequence takes a host you control from a fresh Ollama install to a Claude Code session that sends its requests to a model running on your own server. Each step ends with a check so you know the previous step is sound before moving on.
Install Ollama on a host you control
A platform engineer installs Ollama on a Linux, macOS, Windows or Docker host inside your network, using the method your infrastructure team has approved. Ollama is an MIT-licensed runtime, so the installation itself carries no license fee, but the host needs enough memory and GPU capacity for the models you plan to use. Record the version you install, because the Anthropic-compatible behavior described on this page depends on it. Check that the
ollamacommand is on the path and that it reports a version number before you continue.Confirm the server answers on port 11434
Start the Ollama service and query its REST API on port 11434 from the host itself. By default Ollama binds to 127.0.0.1, so a successful response from the host proves the service is running but says nothing about access from other machines. Keep the server on loopback for this setup, and do not change the bind address with OLLAMA_HOST until you have a reverse proxy and authentication planned. The check passes when the API returns a model list, even if that list is empty.
Pull an approved model
Pull one model tag that your security or model governance team has approved, and confirm the exact tag name in the current Ollama model library before you run the command. Model weights are stored under ~/.ollama/models on macOS, under /usr/share/ollama/.ollama/models on Linux and in the .ollama\models folder on Windows, unless OLLAMA_MODELS points elsewhere. Confirm the model's license terms separately, because the Ollama runtime license does not cover model weights. The check passes when the model appears in the local model list and a short local prompt returns text.
Set the base URL and placeholder auth variables
On the machine where Claude Code runs, set the Anthropic base URL to your Ollama server and set the auth token variables to placeholder values, since the local Ollama API does not require authentication. Confirm the exact variable names and any required values in the current Ollama documentation for Anthropic-compatible clients, because these names can change between releases. Point the base URL at localhost only for a single-user workstation. For a shared server, use the internal address your proxy exposes. The check passes when the variables are visible in the shell session that will launch the client.
Send a test message to the messages endpoint
Send a minimal request to the Anthropic-compatible /v1/messages endpoint using curl or an Anthropic SDK, with the model tag you pulled earlier and a short user message. This step separates server problems from client problems: if the request fails here, fix the server or the model name before touching Claude Code. Confirm the request shape and required headers against the current Ollama documentation. The check passes when the response contains a message with generated text and the server log records the request.
Launch Claude Code against the local server
Start Claude Code from the same shell where the environment variables are set, and select the model tag you tested in the previous step. Ask it to read a small, non-sensitive file in a test repository and make one trivial edit, so you can see tool calls and file operations work end to end. Expect that some Claude Code features depend on the model's capabilities and on the Anthropic features Ollama supports, so validate the workflows your teams need rather than assuming parity. The check passes when the session completes the test task and the server logs show the expected requests.
Which Anthropic features work and which ones fail
Ollama's Anthropic-compatible endpoint covers the core Messages format, but not every feature a Claude client may send. The cards below separate what to test with your own workloads from the gaps that need a workaround or a different model path before you rely on them.
Core text messages and system prompts
Plain text turns, multi-turn conversations and system prompts are the baseline that Claude Code and most Anthropic SDK clients depend on. Run a short scripted conversation against your chosen local model and confirm the replies, role ordering and system instructions match what your client expects. Do not assume a model that answers well in the Ollama CLI behaves identically through the Messages endpoint.
Ollama FAQTool calls need explicit testing
Tool use is where coding agents do real work, from reading files to running commands, so a gap here breaks the workflow silently. Test each tool your agent uses, including multi-step calls where the model must read a tool result and continue. Confirm with Ollama which tool-calling fields are honored on the Anthropic endpoint, since support can differ from the OpenAI-compatible path.
Streaming responses
Coding clients often stream tokens so developers see progress and can interrupt a long answer. Verify that server-sent events arrive in the order your client parses them, and that a cancelled request frees the model for the next user. Streaming problems often appear only under concurrent use, so repeat the test with more than one session open.
Image inputs and the PDF and URL gap
Ollama's Anthropic-compatible endpoint does not support PDF documents or image references by URL, so requests containing them will fail or drop content. Base64 image blocks should be tested separately against the model you plan to use, because vision support depends on the model. Ask Ollama to confirm the current image coverage before you build a workflow that depends on it.
Vendor confirmation before production
Feature coverage changes between Ollama releases, and the endpoint is not a full clone of the Anthropic API. Record the Ollama version you tested, pin it in your deployment, and re-run your test suite before each upgrade. Ask the vendor in writing which Messages features are supported, partial or unsupported, and check the release notes for changes.
Ollama release notesHow a Claude Code request reaches Ollama
The request starts on a developer workstation running Claude Code or an Anthropic SDK client. It passes through an optional reverse proxy with authentication, then reaches the Ollama server on port 11434, which by default binds only to 127.0.0.1. From there the server either serves a model stored locally or forwards a cloud model call to ollama.com with an API key sent as a Bearer token. Check where the trust boundary sits, since only the cloud path leaves your network.
Request path from a workstation through Ollama to local or cloud models, with the trust boundary marked.
Local versus cloud models: where the data goes
The first decision is whether a Claude Code or Anthropic SDK request stays on your server or leaves it. When the model runs on your own Ollama server, Ollama states that it does not see your prompts or data, so the source code you send to the /v1/messages endpoint is handled inside your infrastructure. A cloud model is different. Requests go to ollama.com and authenticate with an API key sent as a Bearer token, so prompts and code leave your network and fall under Ollama's terms for the plan you hold. Model names do not always make this obvious, so check which models your developers select before any source code is sent.
Cost follows the same split. Ollama's pricing page states that running models on your own hardware is always unlimited, so the spend is for the hardware, power, administration and any support you buy. Cloud models are billed through paid plans: Pro at $20 per month ($200 per year), Max at $100 per month, Team at $500 per month and Enterprise at custom pricing, as listed on the pricing page. Ask which plan covers your developer count, whether usage limits apply and how Enterprise budgets per user or API key would be set up before you commit.
Approval for source code should be a written decision, not a default. Security and legal teams should confirm three things: which models are approved for proprietary code, whether OLLAMA_NO_CLOUD=1 or the server configuration file is set to block cloud features on shared servers, and what data terms apply to the plan you choose. Confirm those terms directly with Ollama for your plan, and record the answers in your vendor file. Until that review is complete, route Claude Code only to local models on servers you control.
Security and operational risks to control
Pointing Claude Code at Ollama moves a developer tool that reads source code onto a model server that may be shared, reachable and linked to cloud accounts. The risks below connect because each one changes who can reach the model, what leaves the network and which versions must match.
Unauthenticated API exposed by OLLAMA_HOST
Ollama binds to 127.0.0.1 port 11434 by default, and the local API does not require authentication. Setting OLLAMA_HOST to a wider address so that Claude Code on other machines can connect makes the model server reachable by anyone on that network. Confirm the bind address on the server, check host firewall rules, and test from a machine that should not have access.
Reverse proxy with authentication
Where several developers share one server, place a reverse proxy such as Nginx in front of Ollama and require authentication there, since Ollama itself has no login for the local API. Keep Ollama bound to localhost and let only the proxy reach it. Decide how client credentials are issued, rotated and revoked, and confirm the proxy forwards streaming responses that Claude Code depends on.
Ollama FAQCloud API keys on developer machines
Direct cloud inference at ollama.com/api and ollama.com/v1 requires an API key sent as a Bearer token. Developers who export that key into shell profiles or Claude Code settings leave a billable, account-wide credential on laptops. Use a managed secret store where possible, scope keys per person, and remove keys when people change roles or leave.
Ollama API authenticationCloud features and data handling
Ollama states that local runs do not expose your prompts or data to it, but cloud models send requests to Ollama's service. Where data rules forbid that, set OLLAMA_NO_CLOUD=1 or the equivalent server configuration entry, and verify that Claude Code sessions resolve only to local models. Ask whether any approved workflow still needs a cloud model and document that exception.
Browser origins and web access
Any web page open in a browser on the same machine could try to call a local model API if its origin is allowed. Limit allowed origins to the tools you have approved, and do not add broad wildcard origins when exposing the server through a proxy. Review the origin settings after every change to the bind address, since a relaxed setting often survives a later network change.
Model provenance and source code logging
Claude Code sends source code, file contents and command output as context, so the model choice and the logs decide what sensitive material is retained. Record which model and tag each user runs, pull models only from sources your security team has approved, and confirm where any proxy or gateway stores request bodies. Ask the team to state the retention period for those logs.
Ollama GitHub repositoryVersion drift between Claude Code and Ollama
Ollama ships frequent releases, and the Anthropic-compatible endpoint can change behavior between versions, so a developer upgrade can break or alter Claude Code sessions. Pin the Ollama version on the server and the Claude Code version on developer machines, test each upgrade on a staging server, and track pre-release tags separately. Recent examples include v0.40.5 released on 14 October 2026.
Ollama GitHub releasesLimits to confirm in your environment
Can Claude Code send PDF or URL images through Ollama's Anthropic endpoint?
The Anthropic-compatible /v1/messages endpoint does not accept PDF or URL image inputs, so confirm this against the current Ollama API reference before you design a workflow that depends on them. Any document or image your staff send will need to be converted first, for example by rendering PDF pages to PNG or JPEG and sending the image data directly. Test each input type you expect, including scanned PDFs, screenshots and files a coding agent reads from a repository. Record the error returned for each unsupported shape and whether the client fails or falls back silently. Ask the Ollama maintainers through the project's GitHub issue tracker whether support is planned. Decide early whether the conversion step lives in the client, a proxy or a service you own.
What are the default concurrency limits for Ollama?
By default Ollama handles one parallel request per model, and it holds up to 512 queued requests before it refuses more. These defaults come from the variables OLLAMA_NUM_PARALLEL and OLLAMA_MAX_QUEUE. The number of models kept in memory is set by OLLAMA_MAX_LOADED_MODELS, which defaults to 3 times the number of GPUs, or 3 on CPU. Coding agents often send several requests in one session, so a single developer can occupy the only parallel slot for a model. Load test with the number of simultaneous sessions you expect, measure queue wait time and decide whether to raise the parallel setting, which also raises memory use. Confirm the current defaults in the Ollama FAQ for the version you run.
Will a local model call tools correctly when Claude Code runs it?
Tool-calling quality depends on the model, its chat template and the prompt, so the endpoint alone cannot guarantee it. Build a test set that covers the tools your developers use: reading and writing files, running shell commands, multi-step edits and stopping to report when a step fails. Score each run for malformed tool calls, wrong arguments, skipped steps and repeated loops. Run the same tasks against a cloud model so you have a baseline. Check each model's documentation for stated tool support, and ask the model publisher or the Ollama community when the documentation is unclear. Repeat the test after every model change, because a new model tag can behave differently from the one you approved.
How much context length does Claude Code need from a local model?
Context needs depend on the session, and you should measure them rather than assume a figure. Agent sessions accumulate system prompts, tool definitions, file contents and conversation history, so long tasks fill the window faster than chat. A larger context window uses more memory on the GPU or CPU, which affects how many models and parallel requests a server can hold. Confirm the context length the model loads with on your Ollama version, because the default may differ from what the model supports. Run your longest realistic task, record peak memory at the context size you choose, and ask your hardware provider or platform team to size the server from those numbers.
Which Ollama version should we pin for Anthropic clients?
Ollama releases often, so pin a version you have tested and upgrade on a schedule. The project published v0.40.5 on 14 October 2026 and v0.40.6 as a pre-release on 16 October 2026. Treat a pre-release as a test candidate, not a production build. Before each upgrade, read the release notes for changes to the Anthropic-compatible endpoint, run your test suite against the new version and keep the previous version available for rollback. Store the version number in your configuration so every developer machine and shared server runs the same build. Release history is listed on the Ollama GitHub releases page.
Do prompts sent through the local Anthropic endpoint leave our network?
When Ollama runs locally, the project states that it does not see your prompts or data, but you should verify this in your own network. Cloud models are different: direct cloud inference at ollama.com requires an API key sent as a Bearer token, so any request to a cloud model leaves your infrastructure. Set OLLAMA_NO_CLOUD=1 or the equivalent server configuration entry to disable cloud features, then confirm the setting took effect. Use egress logs or a test firewall rule to check that no outbound calls occur during a full session. Document which models are allowed in each environment, and have your security team review the configuration before developers use it.
Does a shared Anthropic-compatible Ollama server need authentication?
The local Ollama API does not require authentication, and by default it binds to 127.0.0.1 on port 11434, so only the same machine can reach it. Changing the bind address with OLLAMA_HOST exposes the API to other hosts, and the Ollama FAQ describes placing a proxy such as Nginx in front of it. Anyone who can reach an unprotected server can run models and consume its capacity. Put an authenticating proxy, network policy or identity-aware gateway in front of the server, restrict access to approved subnets and log requests at the proxy. Test the setup from outside the allowed network to confirm that unauthenticated calls fail.
Who should confirm these limits before a rollout?
Split the questions by owner. Ask the Ollama maintainers through the GitHub repository about API features, defaults and planned changes, and read the current documentation for the version you run. Ask your platform team to confirm network exposure, proxy and logging setup, and where models are stored. Ask your security team to review cloud settings, egress controls and access policy. Ask the model publisher about licenses and intended use for each model. If you want an independent check, DeployOpen can plan and run a test plan against your environment under a written scope, covering endpoint behavior, concurrency, tool use and exposure, with findings and retesting included in the agreed deliverables.
How DeployOpen scopes and delivers Anthropic client setups on Ollama
DeployOpen delivers an Anthropic client setup on Ollama against a written scope agreed before work starts. For this topic, that scope names each component the work touches: the Ollama host and its operating system, the address and port the server listens on, the network path between Claude Code or other Anthropic SDK clients and that host, the authentication layer placed in front of an API that has none by default, the cloud policy for the server, the client configuration on each developer workstation or application, and the test plan that proves the setup works. Because the local API at port 11434 accepts unauthenticated requests, the scope has to say exactly where access control lives and who owns it after handover.
DeployOpen implements, hardens and documents these platforms inside the client's own infrastructure, whether that is a cloud account, a data center or a restricted network. Hardening covers the decisions that matter most for this topic: keeping OLLAMA_HOST off public interfaces, deciding whether OLLAMA_NO_CLOUD=1 is set, limiting which models clients can request, and recording the environment variables that each client uses. The deliverables are the configuration, a runbook for the platform team, and a short client guide for users. Ask any provider to name these deliverables in writing, and to state whether they include the reverse proxy or identity integration in front of Ollama.
Ongoing support is available as a retainer, which typically covers Ollama version updates, configuration drift checks and retesting after client tool or model changes. A quote follows from the written scope, so the inputs that move cost are the number of Ollama hosts, the number of client environments, whether cloud models are in use and the depth of testing required. DeployOpen does not hold certifications or partner status for Ollama or Anthropic tooling, so treat the delivery as engineering work that your own assessors will review, not as an attestation of compliance.

