Skip to content

Ollama Docs, Revised

Quickstart

Task page. 7 changes, 3 questions for the owner. Audit: mixed. Original source at commit 318ee28.

Revised

Use Ollama in desktop apps and coding agents, or build an application with an API key.?1

Get started

Download Ollama for macOS, Windows, or Linux. Open the app, or get started from your terminal:

ollama

Follow the setup prompts. Sign in to use cloud models, or choose a local model.

Connect a desktop app

On macOS, open Ollama and select Apps. Connect Claude or ChatGPT (Desktop). Follow the prompts to install or restart the app.

Choose your Ollama models in Settings → Apps.

  • Claude Desktop: Use Ollama models in Claude.1
  • ChatGPT Desktop: Use Ollama models in Codex mode.2 Regular Chat and voice use your usual ChatGPT connection.

Use a coding agent

From your project directory, launch your agent:

Claude Code

ollama launch claude

Ollama offers to install Claude Code if needed. See Claude Code for details.

Codex CLI

Install Codex CLI first, then launch it:

ollama launch codex

See Codex CLI for setup.

OpenCode

ollama launch opencode

Ollama offers to install OpenCode if needed. See OpenCode for details.

Choose a model when prompted, then try:

Explain how this repository is organized.

For more tools, see Integrations. To connect an agent directly with an API key, see Claude Code.X9

Build an application

Use cloud models with an API key, or run models locally without one. Cloud requests don't3 require an Ollama installation.

1. Create an API key

For local models, skip this step and select Local under Send a request.

For cloud models, sign in or create an account, then create an API key.X43

Set your key in the terminal:

export OLLAMA_API_KEY="your_api_key"
$env:OLLAMA_API_KEY = "your_api_key"

Keep your key on your application's server, outside browser code and source control.

2. Send a request

Make your first request to Ollama.4

Cloud

These examples use the gemma4:31b cloud model.

Ollama API

curl https://ollama.com/api/chat \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
],
"stream": false
}'

Read the answer from message.content. See Ollama's API and libraries.

OpenAI Chat Completions

curl https://ollama.com/v1/chat/completions \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read the answer from choices[0].message.content. See OpenAI compatibility for client setup and supported features.

OpenAI Responses

curl https://ollama.com/v1/responses \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"input": "Say hello in one sentence."
}'

Read the output_text content blocks inside output. The OpenAI Python client exposes the text as response.output_text.

Responses requests are stateless: include conversation history in each request. previous_response_id and conversation aren't supported. See Responses compatibility.

Anthropic Messages

curl https://ollama.com/v1/messages \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemma4:31b",
"max_tokens": 1024,
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read text blocks from content. Direct cloud requests use bearer authentication. See Anthropic compatibility for client setup and supported features.

OpenAI and Anthropic compatibility each cover a subset of the original API. See Cloud for models and usage limits.

Local

Run Gemma 4 E2B on your computer. No API key required.

Note: The model download is about 7.2 GB. We recommend 8 GB of available video memory (VRAM)5, or unified memory on a Mac. Larger context windows need more memory. With less VRAM, Ollama can use system RAM, but responses may be slower.

Download Ollama and open the app. On Linux, start the server with ollama serve if it isn't6 already running.

Download the model:

ollama pull gemma4:e2b

Send a request to your local server:

Ollama API

curl http://localhost:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
],
"stream": false
}'

OpenAI Chat Completions

curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read the answer from choices[0].message.content. See OpenAI compatibility for client setup and supported features.

OpenAI Responses

curl http://localhost:11434/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"input": "Say hello in one sentence."
}'

Read the output_text content blocks inside output. The OpenAI Python client exposes the text as response.output_text.

Responses requests are stateless: include conversation history in each request. previous_response_id and conversation aren't supported. See Responses compatibility.

Anthropic Messages

curl http://localhost:11434/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemma4:e2b",
"max_tokens": 1024,
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read text blocks from content. See Anthropic compatibility for client setup and supported features.

Run a model locally

71. Download Ollama. 2. Run this command:

ollama run gemma4:e2b

Ollama downloads the model and starts a chat on your computer. To leave the chat, type /bye.

Next steps

Add tool calling, stream responses, or browse more models.

Notes on this page

  1. 1 Wording Audit: improved An em dash is replaced with a colon and a capital, matching the other link lists.

    Was: — use Ollama models in Claude.

    punct-em-dash EmDash

  2. 2 Wording Audit: improved An em dash is replaced with a colon and a capital, matching the other link lists.

    Was: — use Ollama models in Codex mode.

    punct-em-dash EmDash

  3. 3 Wording Audit: improved The contraction matches the page's other contractions.

    Was: do not

    voice-contractions Contractions

  4. 4 Wording Audit: improved The sentence gets its closing period.

    Was: Make your first request to Ollama

  5. 5 Wording Audit: regression The acronym is spelled out at first use. The later VRAM stays short.

    Was: VRAM

    SpellOutFirst

    Auditor: “Video memory” does not correctly spell out VRAM, which stands for “video random-access memory.”

  6. 6 Wording Audit: improved The contraction matches the page's other contractions.

    Was: is not

    voice-contractions Contractions

  7. 7 Structure Audit: improved The two actions are now numbered steps, one action each, and the result and the way to leave the chat follow the command.

    Was: Download Ollama, then run: shell ollama run gemma4:e2b Ollama downloads the model and starts a chat on your computer. Type /bye to leave.

    list-numbered-for-sequence proc-one-action-per-step proc-verify-end

Questions for the owner

  • ?1 This page covers four goals (connect a desktop app, use a coding agent, build an application, run a model locally); should each be its own task page, with this page as the overview?

    About: “Use Ollama in desktop apps and coding agents, or build an application with an API key.”

  • X9 Anchor to Claude Code direct-cloud section does not match the heading. Two pages link to #connect-directly-to-ollama-cloud, but the Claude Code heading is "Connect directly to Ollama's cloud", whose generated slug includes "ollamas". Should the heading get an explicit anchor id, or should both links be updated to the generated slug?

    Pages: Quickstart, Anthropic compatibility, Claude Code

  • X43 API key setup repeated on five pages. Creating the key and exporting OLLAMA_API_KEY is repeated in Quickstart, Creating an API key, Authentication and both compatibility pages; only Quickstart gives the PowerShell form. Which page should own API key setup, with the others linking to it?

    Pages: Quickstart, Create an API key, Authentication, OpenAI compatibility, Anthropic compatibility

Original

Use Ollama in desktop apps and coding agents, or build an application with an API key.

Get started

Download Ollama for macOS, Windows, or Linux. Open the app, or get started from your terminal:

ollama

Follow the setup prompts. Sign in to use cloud models, or choose a local model.

Connect a desktop app

On macOS, open Ollama and select Apps. Connect Claude or ChatGPT (Desktop). Follow the prompts to install or restart the app.

Choose your Ollama models in Settings → Apps.

  • Claude Desktop — use Ollama models in Claude.
  • ChatGPT Desktop — use Ollama models in Codex mode. Regular Chat and voice use your usual ChatGPT connection.

Use a coding agent

From your project directory, launch your agent:

Claude Code

ollama launch claude

Ollama offers to install Claude Code if needed. See Claude Code for details.

Codex CLI

Install Codex CLI first, then launch it:

ollama launch codex

See Codex CLI for setup.

OpenCode

ollama launch opencode

Ollama offers to install OpenCode if needed. See OpenCode for details.

Choose a model when prompted, then try:

Explain how this repository is organized.

For more tools, see Integrations. To connect an agent directly with an API key, see Claude Code.

Build an application

Use cloud models with an API key, or run models locally without one. Cloud requests do not require an Ollama installation.

1. Create an API key

For local models, skip this step and select Local under Send a request.

For cloud models, sign in or create an account, then create an API key.

Set your key in the terminal:

export OLLAMA_API_KEY="your_api_key"
$env:OLLAMA_API_KEY = "your_api_key"

Keep your key on your application's server, outside browser code and source control.

2. Send a request

Make your first request to Ollama

Cloud

These examples use the gemma4:31b cloud model.

Ollama API

curl https://ollama.com/api/chat \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
],
"stream": false
}'

Read the answer from message.content. See Ollama's API and libraries.

OpenAI Chat Completions

curl https://ollama.com/v1/chat/completions \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read the answer from choices[0].message.content. See OpenAI compatibility for client setup and supported features.

OpenAI Responses

curl https://ollama.com/v1/responses \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:31b",
"input": "Say hello in one sentence."
}'

Read the output_text content blocks inside output. The OpenAI Python client exposes the text as response.output_text.

Responses requests are stateless: include conversation history in each request. previous_response_id and conversation aren't supported. See Responses compatibility.

Anthropic Messages

curl https://ollama.com/v1/messages \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemma4:31b",
"max_tokens": 1024,
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read text blocks from content. Direct cloud requests use bearer authentication. See Anthropic compatibility for client setup and supported features.

OpenAI and Anthropic compatibility each cover a subset of the original API. See Cloud for models and usage limits.

Local

Run Gemma 4 E2B on your computer. No API key required.

Note: The model download is about 7.2 GB. We recommend 8 GB of available VRAM, or unified memory on a Mac. Larger context windows need more memory. With less VRAM, Ollama can use system RAM, but responses may be slower.

Download Ollama and open the app. On Linux, start the server with ollama serve if it is not already running.

Download the model:

ollama pull gemma4:e2b

Send a request to your local server:

Ollama API

curl http://localhost:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
],
"stream": false
}'

OpenAI Chat Completions

curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read the answer from choices[0].message.content. See OpenAI compatibility for client setup and supported features.

OpenAI Responses

curl http://localhost:11434/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"input": "Say hello in one sentence."
}'

Read the output_text content blocks inside output. The OpenAI Python client exposes the text as response.output_text.

Responses requests are stateless: include conversation history in each request. previous_response_id and conversation aren't supported. See Responses compatibility.

Anthropic Messages

curl http://localhost:11434/v1/messages \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemma4:e2b",
"max_tokens": 1024,
"messages": [
  {
    "role": "user",
    "content": "Say hello in one sentence."
  }
]
}'

Read text blocks from content. See Anthropic compatibility for client setup and supported features.

Run a model locally

Download Ollama, then run:

ollama run gemma4:e2b

Ollama downloads the model and starts a chat on your computer. Type /bye to leave.

Next steps

Add tool calling, stream responses, or browse more models.

What Changed

The edits are small: two em dashes became colons, two contractions were applied, VRAM was spelled out, one sentence got its period, and the local-model section became two numbered steps followed by what the reader sees. Every command, request body, model name, and link is unchanged, and the page keeps its sections. The anchor conflict and the repeated API key setup are flagged for the owner.

Content type: task. The page walks a reader through getting a result, but it holds several separate goals, so it is checked as a task and the mix is raised as a question.

Automated check, original: 0 errors, 5 warnings, 2 suggestions. Revised: 0 errors, 2 warnings, 0 suggestions.

Independent audit (GPT-6): mixed. The revision makes the local run instructions easier to follow and improves several small wording points. One acronym expansion is inaccurate, and the page still has structural issues the standard calls out.

Regressions:

  • The new expansion “video memory (VRAM)” gives an incorrect expansion of the acronym.

What the revision missed:

  • The heading “Get started” does not say what the section contains, contrary to the standard’s guidance to use descriptive headings.
  • The page repeats the local download and run instructions in separate sections, despite the standard’s guidance to say each thing once and link to it.
  • The revision leaves the intro’s broad audience and multiple goals unresolved; it flags this with a question, but the standard calls for knowing who the page is for and what they should do next.

Structure (1)

  • 7 The two actions are now numbered steps, one action each, and the result and the way to leave the chat follow the command. improved

Wording (6)

  • 1 An em dash is replaced with a colon and a capital, matching the other link lists. improved
  • 2 An em dash is replaced with a colon and a capital, matching the other link lists. improved
  • 3 The contraction matches the page's other contractions. improved
  • 4 The sentence gets its closing period. improved
  • 5 The acronym is spelled out at first use. The later VRAM stays short. regression
  • 6 The contraction matches the page's other contractions. improved