Skip to main content
Use Ollama’s API to build applications with cloud or local models.

Get started

Call cloud models with an API key. No Ollama installation required. Start with the API quickstart. To run models on your computer, install Ollama and run a local model.

Base URLs

The Anthropic client appends /v1/messages to its base URL. Cloud requests need an API key. Local requests do not. To use cloud models through your local server, sign in to Ollama. Creating or deleting models requires a local Ollama server. For supported API features, see OpenAI compatibility and Anthropic compatibility.

Ollama API example

Set OLLAMA_API_KEY to your API key, then call a cloud model:
Read the answer from message.content. For local inference, use http://localhost:11434/api/chat with a downloaded model and omit the authorization header.

Libraries

Use Ollama’s official libraries with either a local server or the hosted API: For direct cloud access, set the host to https://ollama.com and supply your API key in the Authorization: Bearer header. Browse community libraries.

Versioning

Ollama’s API isn’t strictly versioned, but the API is expected to be stable and backwards compatible. Deprecations are rare and will be announced in the release notes.