Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
reorganizing the docs folder, adding error handling to the sample project, changing wording
Anna Rahn8ca05a6027bf
diff --git a/docs/README.md b/docs/README.mdindex f11addb3f..c2caa9e51 100644--- a/docs/README.md+++ b/docs/README.md@@ -2,29 +2,29 @@### Getting started-* [Quickstart](https://docs.ollama.com/quickstart)+* [Quickstart](https://docs.ollama.com/guide/quickstart)* [Ollama Cloud](https://docs.ollama.com/cloud)* [Run Ollama locally](https://docs.ollama.com/local)* [Examples](./examples.md)### Local-* [macOS](https://docs.ollama.com/macos)-* [Linux](https://docs.ollama.com/linux)-* [Windows](https://docs.ollama.com/windows)-* [Docker](https://docs.ollama.com/docker)-* [Importing models](https://docs.ollama.com/import)+* [macOS](https://docs.ollama.com/local/macos)+* [Linux](https://docs.ollama.com/local/linux)+* [Windows](https://docs.ollama.com/local/windows)+* [Docker](https://docs.ollama.com/local/docker)+* [Importing models](https://docs.ollama.com/local/import)### Reference* [API Reference](https://docs.ollama.com/api)-* [Modelfile Reference](https://docs.ollama.com/modelfile)+* [Modelfile Reference](https://docs.ollama.com/local/modelfile)* [OpenAI Compatibility](https://docs.ollama.com/api/openai-compatibility)* [Anthropic Compatibility](./api/anthropic-compatibility.mdx)### Resources-* [Troubleshooting Guide](https://docs.ollama.com/troubleshooting)-* [Local FAQ](https://docs.ollama.com/faq)+* [Troubleshooting Guide](https://docs.ollama.com/local/troubleshooting)+* [Local FAQ](https://docs.ollama.com/local/faq)* [Cloud FAQ](https://docs.ollama.com/cloud/faq)* [Development guide](./development.md)diff --git a/docs/api.md b/docs/api.mdindex 95cac42ca..26d9247e3 100644--- a/docs/api.md+++ b/docs/api.md@@ -50,7 +50,7 @@ Generate a response for a given prompt with a provided model. This is a streaminAdvanced parameters (optional):- `format`: the format to return a response in. Format can be `json` or a JSON schema-- `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature`+- `options`: additional model parameters listed in the documentation for the [Modelfile](./local/modelfile.mdx#valid-parameters-and-values) such as `temperature`- `system`: system message to (overrides what is defined in the `Modelfile`)- `template`: the prompt template to use (overrides what is defined in the `Modelfile`)- `stream`: if `false` the response will be returned as a single response object, rather than a stream of objects@@ -508,7 +508,7 @@ The `message` object has the following fields:Advanced parameters (optional):- `format`: the format to return a response in. Format can be `json` or a JSON schema.-- `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature`+- `options`: additional model parameters listed in the documentation for the [Modelfile](./local/modelfile.mdx#valid-parameters-and-values) such as `temperature`- `stream`: if `false` the response will be returned as a single response object, rather than a stream of objects- `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`)@@ -1192,7 +1192,7 @@ If you are creating a model from a safetensors directory or from a GGUF file, yo- `parser`: (optional) the name of the parser for the model- `license`: (optional) a string or list of strings containing the license or licenses for the model- `system`: (optional) a string containing the system prompt for the model-- `parameters`: (optional) a dictionary of parameters for the model (see [Modelfile](./modelfile.mdx#valid-parameters-and-values) for a list of parameters)+- `parameters`: (optional) a dictionary of parameters for the model (see [Modelfile](./local/modelfile.mdx#valid-parameters-and-values) for a list of parameters)- `messages`: (optional) a list of message objects used to create a conversation- `stream`: (optional) if `false` the response will be returned as a single response object, rather than a stream of objects- `quantize` (optional): quantize a non-quantized (e.g. float16) model@@ -1701,7 +1701,7 @@ Generate embeddings from a modelAdvanced parameters:- `truncate`: truncates the end of each input to fit within context length. Returns error if `false` and context length is exceeded. Defaults to `true`-- `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature`+- `options`: additional model parameters listed in the documentation for the [Modelfile](./local/modelfile.mdx#valid-parameters-and-values) such as `temperature`- `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`)- `dimensions`: number of dimensions for the embedding@@ -1820,7 +1820,7 @@ Generate embeddings from a modelAdvanced parameters:-- `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature`+- `options`: additional model parameters listed in the documentation for the [Modelfile](./local/modelfile.mdx#valid-parameters-and-values) such as `temperature`- `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`)### Examplesdiff --git a/docs/cloud/faq.mdx b/docs/cloud/faq.mdxindex e5b2a1a61..41025e415 100644--- a/docs/cloud/faq.mdx+++ b/docs/cloud/faq.mdx@@ -4,7 +4,7 @@ sidebarTitle: FAQdescription: Frequently asked questions about Ollama Cloud accounts, authentication, privacy, and requests.----For questions about installation, hardware, and the local Ollama server, see the [Local FAQ](/faq).+For questions about installation, hardware, and the local Ollama server, see the [Local FAQ](/local/faq).## Does Ollama send my prompts and answers back to ollama.com?@@ -12,7 +12,7 @@ Ollama runs locally. We don't see your prompts or data when you run local modelsWhen you use Cloud models, Ollama processes your prompts and responses to provide the service but does not store or log that content and never trains on it. Ollama collects basic account information and limited usage metadata that does not include prompt or response content. Ollama does not sell your data, and you can delete your account at any time.-To prevent a local Ollama installation from using Cloud models and web search, enable [local-only mode](/faq#how-do-i-disable-ollama-cloud-features).+To prevent a local Ollama installation from using Cloud models and web search, enable [local-only mode](/local/faq#how-do-i-disable-ollama-cloud-features).## How do I manage the maximum number of requests the Ollama server can queue?@@ -24,7 +24,7 @@ Set `OLLAMA_MAX_QUEUE` before starting the local server to change the maximum nuOLLAMA_MAX_QUEUE=1024 ollama serve```-See [How do I configure Ollama server?](/faq#how-do-i-configure-ollama-server) for operating-system-specific instructions for setting environment variables.+See [How do I configure Ollama server?](/local/faq#how-do-i-configure-ollama-server) for operating-system-specific instructions for setting environment variables.## What is the difference between an API key and my Ollama Public Key?diff --git a/docs/cloud.mdx b/docs/cloud/index.mdxsimilarity index 88%rename from docs/cloud.mdxrename to docs/cloud/index.mdxindex 6f34bd658..d82f785d3 100644--- a/docs/cloud.mdx+++ b/docs/cloud/index.mdx@@ -30,7 +30,7 @@ Follow the [Cloud API guide](/cloud/api) to call `https://ollama.com/api` direct## Local only-Use [Local](/local) when you want inference to run on hardware you control. Ollama can also run in [local-only mode](/faq#how-do-i-disable-ollama-cloud-features) with Cloud features disabled.+Use [Local](/local) when you want inference to run on your own hardware. Ollama can also run in [local-only mode](/local/faq#how-do-i-disable-ollama-cloud-features) with Cloud features disabled.## Retirementsdiff --git a/docs/docs.json b/docs/docs.jsonindex 8c848dee6..50cd98b49 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -70,7 +70,7 @@},{"source": "/gpu.mdx",- "destination": "/gpu"+ "destination": "/local/gpu"},{"source": "/integrations/vscode.mdx",@@ -78,7 +78,7 @@},{"source": "/troubleshooting.mdx",- "destination": "/troubleshooting"+ "destination": "/local/troubleshooting"},{"source": "/openai",@@ -99,6 +99,94 @@{"source": "/integrations/poolside","destination": "/integrations/pool"+ },+ {+ "source": "/quickstart",+ "destination": "/guide/quickstart"+ },+ {+ "source": "/capabilities/streaming",+ "destination": "/guide/capabilities/streaming"+ },+ {+ "source": "/capabilities/thinking",+ "destination": "/guide/capabilities/thinking"+ },+ {+ "source": "/capabilities/structured-outputs",+ "destination": "/guide/capabilities/structured-outputs"+ },+ {+ "source": "/capabilities/vision",+ "destination": "/guide/capabilities/vision"+ },+ {+ "source": "/capabilities/embeddings",+ "destination": "/guide/capabilities/embeddings"+ },+ {+ "source": "/capabilities/tool-calling",+ "destination": "/guide/capabilities/tool-calling"+ },+ {+ "source": "/capabilities/web-search",+ "destination": "/guide/capabilities/web-search"+ },+ {+ "source": "/sample-projects/research-brief-agent",+ "destination": "/guide/sample-projects/research-report-agent"+ },+ {+ "source": "/guide/sample-projects/research-brief-agent",+ "destination": "/guide/sample-projects/research-report-agent"+ },+ {+ "source": "/cli",+ "destination": "/local/cli"+ },+ {+ "source": "/context-length",+ "destination": "/local/context-length"+ },+ {+ "source": "/macos",+ "destination": "/local/macos"+ },+ {+ "source": "/linux",+ "destination": "/local/linux"+ },+ {+ "source": "/windows",+ "destination": "/local/windows"+ },+ {+ "source": "/docker",+ "destination": "/local/docker"+ },+ {+ "source": "/import",+ "destination": "/local/import"+ },+ {+ "source": "/modelfile",+ "destination": "/local/modelfile"+ },+ {+ "source": "/gpu",+ "destination": "/local/gpu"+ },+ {+ "source": "/troubleshooting",+ "destination": "/local/troubleshooting"+ },+ {+ "source": "/faq",+ "destination": "/local/faq"+ },+ {+ "source": "/template",+ "destination": "/local/template"}],"navigation": {@@ -110,82 +198,82 @@"group": "Get started","pages": ["index",- "quickstart"+ "/guide/quickstart"]},{"group": "Capabilities","pages": [- "/capabilities/streaming",- "/capabilities/thinking",- "/capabilities/structured-outputs",- "/capabilities/vision",- "/capabilities/embeddings",- "/capabilities/tool-calling",- "/capabilities/web-search"+ "/guide/capabilities/streaming",+ "/guide/capabilities/thinking",+ "/guide/capabilities/structured-outputs",+ "/guide/capabilities/vision",+ "/guide/capabilities/embeddings",+ "/guide/capabilities/tool-calling",+ "/guide/capabilities/web-search"]},{"group": "Sample projects","pages": [- "/sample-projects/research-brief-agent"+ "/guide/sample-projects/research-report-agent"]}]},{- "tab": "Cloud",+ "tab": "Local","groups": [{"group": "Get started","pages": [- "/cloud",- "/cloud/models",- "/cloud/api"+ "/local/index",+ "/local/macos",+ "/local/linux",+ "/local/windows",+ "/local/docker"]},{- "group": "Operations",+ "group": "Run and configure","pages": [- "/cloud/model-lifecycle",- "/cloud/faq"+ "/local/cli",+ "/local/context-length"]- }- ]- },- {- "tab": "Local",- "groups": [+ },{- "group": "Get started",+ "group": "Customize models","pages": [- "/local",- "/macos",- "/linux",- "/windows",- "/docker"+ "/local/import",+ "/local/modelfile"]},{- "group": "Run and configure",+ "group": "Hardware and support","pages": [- "/cli",- "/context-length"+ "/local/gpu",+ "/local/troubleshooting",+ "/local/faq"]- },+ }+ ]+ },+ {+ "tab": "Cloud",+ "groups": [{- "group": "Customize models",+ "group": "Get started","pages": [- "/import",- "/modelfile"+ "/cloud/index",+ "/cloud/models",+ "/cloud/api"]},{- "group": "Hardware and support",+ "group": "Operations","pages": [- "/gpu",- "/troubleshooting",- "/faq"+ "/cloud/model-lifecycle",+ "/cloud/faq"]}]diff --git a/docs/capabilities/embeddings.mdx b/docs/guide/capabilities/embeddings.mdxsimilarity index 100%rename from docs/capabilities/embeddings.mdxrename to docs/guide/capabilities/embeddings.mdxdiff --git a/docs/capabilities/streaming.mdx b/docs/guide/capabilities/streaming.mdxsimilarity index 100%rename from docs/capabilities/streaming.mdxrename to docs/guide/capabilities/streaming.mdxdiff --git a/docs/capabilities/structured-outputs.mdx b/docs/guide/capabilities/structured-outputs.mdxsimilarity index 100%rename from docs/capabilities/structured-outputs.mdxrename to docs/guide/capabilities/structured-outputs.mdxdiff --git a/docs/capabilities/thinking.mdx b/docs/guide/capabilities/thinking.mdxsimilarity index 100%rename from docs/capabilities/thinking.mdxrename to docs/guide/capabilities/thinking.mdxdiff --git a/docs/capabilities/tool-calling.mdx b/docs/guide/capabilities/tool-calling.mdxsimilarity index 100%rename from docs/capabilities/tool-calling.mdxrename to docs/guide/capabilities/tool-calling.mdxdiff --git a/docs/capabilities/vision.mdx b/docs/guide/capabilities/vision.mdxsimilarity index 100%rename from docs/capabilities/vision.mdxrename to docs/guide/capabilities/vision.mdxdiff --git a/docs/capabilities/web-search.mdx b/docs/guide/capabilities/web-search.mdxsimilarity index 100%rename from docs/capabilities/web-search.mdxrename to docs/guide/capabilities/web-search.mdxdiff --git a/docs/quickstart.mdx b/docs/guide/quickstart.mdxsimilarity index 100%rename from docs/quickstart.mdxrename to docs/guide/quickstart.mdxdiff --git a/docs/guide/sample-projects/research-report-agent.mdx b/docs/guide/sample-projects/research-report-agent.mdxnew file mode 100644index 000000000..7a796f0a8--- /dev/null+++ b/docs/guide/sample-projects/research-report-agent.mdx@@ -0,0 +1,398 @@+---+title: Build a research report agent+sidebarTitle: Research report agent+description: Build an Ollama Cloud agent that searches the web, reads primary sources, and produces a cited research report.+---++Build an agent that researches a question and turns its findings into a cited decision report. This is useful for market research, policy summaries, product comparisons, event planning, and other tasks where current sources matter.++The project uses an Ollama Cloud model for reasoning and the Ollama web search and web fetch APIs for research. Inference runs in Ollama Cloud, so you do not need to download the 120B model weights or provide a local GPU. Your local Ollama installation sends requests to the Cloud model.++## What you will build++Given a question such as:++> What have four-day workweek pilots since 2022 reported about employee wellbeing and business performance?++the agent will:++1. Turn the question into several focused searches.+2. Search the web and choose promising results.+3. Fetch source pages for more context.+4. Compare claims across sources.+5. Write a report with links, caveats, and suggested follow-up questions.++The tutorial uses `gpt-oss:120b-cloud` throughout.++## Before you begin++You need:++- [Ollama installed](https://ollama.com/download)+- Python 3.10 or later+- An [Ollama account](https://ollama.com)+- An [Ollama API key](https://ollama.com/settings/keys)++Signing in to Ollama gives your local installation access to the Cloud model. The API key gives the script access to the [web search tools](/guide/capabilities/web-search). Treat the API key like a password and do not add it to source control.++## 1. Set up the project++Create a project directory and a Python virtual environment:++<Tabs>+ <Tab title="macOS and Linux">++```shell+mkdir research-report-agent+cd research-report-agent+python3 -m venv .venv+source .venv/bin/activate+```++ </Tab>+ <Tab title="Windows PowerShell">++```powershell+mkdir research-report-agent+cd research-report-agent+py -m venv .venv+.venv\Scripts\Activate.ps1+```++ </Tab>+</Tabs>++Install the Ollama Python library:++```shell+pip install --upgrade ollama+```++Set your API key for the current terminal session:++<Tabs>+ <Tab title="macOS and Linux">++```shell+export OLLAMA_API_KEY=your_api_key+```++ </Tab>+ <Tab title="Windows PowerShell">++```powershell+$env:OLLAMA_API_KEY="your_api_key"+```++ </Tab>+</Tabs>++<Note>+ Environment variables set this way last only for the current terminal session. Use your operating system's secret manager for a persistent setup.+</Note>++## 2. Pull and test the Cloud model++Sign in to your Ollama account:++```shell+ollama signin+```++Pull `gpt-oss:120b-cloud`:++```shell+ollama pull gpt-oss:120b-cloud+```++This downloads the Cloud model configuration, not the 120B model weights. The model runs on Ollama's infrastructure when you use it.++Send a test prompt to confirm that the model is ready:++```shell+ollama run gpt-oss:120b-cloud "Reply with exactly: Cloud model ready"+```++You should receive:++```text+Cloud model ready+```++The research agent will use this same model through the Ollama Python library.++## 3. Create the agent++Save the following as `research_agent.py`:++```python+import os+import sys+from datetime import datetime+from pathlib import Path++from ollama import Client, RequestError, ResponseError, web_fetch, web_search+++# The ":cloud" suffix tells Ollama to run this model in Ollama Cloud+# The "120b" tells Ollama what quantization level to use+MODEL = "gpt-oss:120b-cloud"+MAX_TOOL_ROUNDS = 8+MAX_SOURCE_CHARS = 12000++DEFAULT_QUESTION = (+ "What have four-day workweek pilots since 2022 reported about "+ "employee wellbeing and business performance?"+)++# These are the only tools the model is allowed to call+TOOLS = {+ "web_search": web_search,+ "web_fetch": web_fetch,+}++SYSTEM_PROMPT = """You are a careful research agent.++Research the user's question before answering. Search broadly, then fetch the+most useful pages. Prefer primary sources, original studies, official reports,+and sources that clearly explain their methods.+Only call web_fetch with an exact URL returned by web_search. Never guess or+construct a source URL.++Your final answer must contain:+1. An executive summary+2. Key findings, including disagreements between sources+3. Limitations and missing evidence+4. Practical next steps+5. A Sources section with Markdown links++Attach a source link to every important factual claim. Never invent a citation.+If the available evidence does not support a conclusion, say so explicitly.+"""++FINAL_REPORT_PROMPT = """Using the research above, write the complete cited+report now. Return only the Markdown report and do not call more tools."""+++def run_tool(name: str, arguments: dict) -> str:+ """Run a tool requested by the model and return its result as text."""+ tool = TOOLS.get(name)+ if tool is None:+ return f"Unknown tool: {name}"++ print(f"Tool: {name}({arguments})", flush=True)++ try:+ result = tool(**arguments)+ except ResponseError as error:+ # A page may have moved or may reject automated access. Returning the+ # error lets the model search for another source instead of crashing+ message = (+ f"{name} failed with HTTP {error.status_code}: {error.error}. "+ "Do not cite this result. Try another search result or URL."+ )+ print(f"Tool error: {message}", flush=True)+ return message+ except RequestError as error:+ message = (+ f"{name} could not reach the service: {error}. "+ "Try the request again or use another source."+ )+ print(f"Tool error: {message}", flush=True)+ return message++ # Limit long pages so one source does not fill the model's context window+ return str(result)[:MAX_SOURCE_CHARS]+++def create_final_report(client: Client, messages: list) -> str:+ """Ask the model for the final report, retrying once if it is empty."""+ final_messages = messages + [+ {"role": "user", "content": FINAL_REPORT_PROMPT}+ ]++ for _ in range(2):+ # Omitting tools prevents the model from doing more research here+ response = client.chat(+ model=MODEL,+ messages=final_messages,+ think=False,+ )+ report = response.message.content or ""+ if report.strip():+ return report++ # Keep the empty response in the conversation, then ask once more+ final_messages += [+ response.message,+ {+ "role": "user",+ "content": "Your response was empty. Write the Markdown report now.",+ },+ ]++ raise RuntimeError("The Cloud model returned an empty report twice.")+++def research(question: str) -> str:+ """Research a question and return a non-empty Markdown report."""+ # The web search and fetch APIs use this key automatically+ if not os.environ.get("OLLAMA_API_KEY"):+ raise RuntimeError("Set OLLAMA_API_KEY before running the agent.")++ # Client() connects to the local Ollama app. Ollama routes the :cloud model+ # to Ollama Cloud because you signed in during setup+ client = Client()++ # messages stores the complete conversation, including tool results+ messages = [+ {"role": "system", "content": SYSTEM_PROMPT},+ {"role": "user", "content": question},+ ]++ for _ in range(MAX_TOOL_ROUNDS):+ response = client.chat(+ model=MODEL,+ messages=messages,+ tools=list(TOOLS.values()),+ think=True,+ )+ messages.append(response.message)++ tool_calls = response.message.tool_calls or []+ if not tool_calls:+ # The model may return the finished report during the tool loop+ report = response.message.content or ""+ if report.strip():+ return report+ break++ # Run every requested tool and send each result back to the model+ for call in tool_calls:+ name = call.function.name+ result = run_tool(name, call.function.arguments)+ messages.append(+ {+ "role": "tool",+ "tool_name": name,+ "content": result,+ }+ )++ # This also runs when the agent reaches MAX_TOOL_ROUNDS+ return create_final_report(client, messages)+++def save_report(report: str) -> None:+ """Save the report in a reusable output directory beside this script."""+ output_dir = Path(__file__).resolve().parent / "output"+ output_dir.mkdir(exist_ok=True)++ timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")+ output_path = output_dir / f"Research report {timestamp}.md"+ output_path.write_text(report, encoding="utf-8")+++if __name__ == "__main__":+ # Text after the script name (research_agent.py) becomes the research question. If no+ # text is provided, the tutorial's default question is used+ question = " ".join(sys.argv[1:]) or DEFAULT_QUESTION+ report = research(question)++ # Never print or save a blank report+ if not report.strip():+ raise RuntimeError("The research agent returned an empty report.")++ print(report, flush=True)+ save_report(report)+```++The model receives the functions in `TOOLS`, decides when to call them, and uses their results in later turns. When research ends, the script accepts a non-empty report or runs `create_final_report` without tools.++Search results sometimes point to pages that have moved, reject automated access, or no longer exist. The error handlers return those failures to the model as tool results so it can search for another source instead of stopping the program.++`MAX_TOOL_ROUNDS` prevents an open-ended research loop. `create_final_report` disables thinking output and retries once if the model returns empty content. The script raises an error instead of creating an empty file if both attempts are empty.++## 4. Run the project++Run the agent with the example research question:++```shell+python research_agent.py+```++Or provide your own question:++```shell+python research_agent.py "What evidence supports later high school start times?"+```++During the run, the script prints each tool call. A typical trace looks like this:++```text+Tool: web_search({'query': 'four-day workweek pilot 2022 study results'})+Tool: web_search({'query': 'four-day week trial company revenue retention report'})+Tool: web_fetch({'url': 'https://example.org/report'})+Tool error: web_fetch failed with HTTP 404: not found. Do not cite this result. Try another search result or URL.+```++Search queries, sources, and occasional fetch errors will vary between runs. That is expected: the model chooses its next action from the evidence it has already gathered. A failed fetch should be followed by another search or source selection rather than a Python traceback.++## 5. Review the result++The first run creates an `output` directory next to `research_agent.py`. Later runs reuse the same directory. Each report is saved as a timestamped Markdown file, for example:++```text+output/Research report 2026-10-06_15-45-12.md+```++The complete Markdown report is printed to the terminal before it is saved. Empty output is treated as an error, so the script will not create a blank report file.++Expect a Markdown report with this general shape in the `./output/` folder:++```text+# Research report++## Executive summary+A concise answer to the research question.++## Key findings+Findings grouped by theme, with links attached to factual claims.++## Limitations+Gaps in the available evidence, methodology concerns, and conflicting results.++## Practical next steps+Actions or questions that follow from the evidence.++## Sources+A list of the pages used in the report.+```++The first run should produce a useful draft, not an unquestionable final answer. Check that links open, quoted numbers match their sources, and the report distinguishes published evidence from the model's interpretation.++<Warning>+ Web results can be incomplete, outdated, or wrong. Review the original sources before using the report for medical, legal, financial, employment, or other high-impact decisions.+</Warning>++## What happens at each stage++| Stage | What the Cloud model does | What you should expect |+| --- | --- | --- |+| Plan | Breaks the question into searchable claims | Several queries covering different aspects of the topic |+| Search | Calls `web_search` and evaluates result snippets | A visible tool trace; some searches may be discarded |+| Read | Calls `web_fetch` for promising pages | More detailed evidence from a smaller set of sources |+| Compare | Looks for agreement, conflicts, and missing context | Findings that separate strong evidence from uncertainty |+| Synthesize | Writes the requested report | A readable report with citations, caveats, and next steps |++## Improve the agent++Try these changes after the basic project works:++- Change `SYSTEM_PROMPT` to require a particular audience, length, or report format.+- Ask the agent to prefer sources from specific domains or a date range.+- Increase `MAX_TOOL_ROUNDS` for broader research, or decrease it for faster, more focused runs.+- Save the final string to a Markdown file for sharing.+- Add a human approval step before the agent fetches unfamiliar domains.++See [Tool calling](/guide/capabilities/tool-calling) for more agent-loop patterns and [Web search](/guide/capabilities/web-search) for the complete search and fetch interfaces.diff --git a/docs/index.mdx b/docs/index.mdxindex f9c9e2641..afb4e075e 100644--- a/docs/index.mdx+++ b/docs/index.mdx@@ -6,7 +6,7 @@ description: Learn what Ollama can do, choose cloud or local models, and find thBuild with open models in Ollama Cloud or on your own hardware.-Follow the [quickstart](/quickstart), then choose the environment that matches your needs.+Follow the [quickstart](/guide/quickstart), then choose the environment that matches your needs.## Choose where models run@@ -24,7 +24,7 @@ Cloud and local models use the same Ollama tools and API shapes. The main differ## What you can build-Ollama supports [streaming](/capabilities/streaming), [tool calling](/capabilities/tool-calling), [structured outputs](/capabilities/structured-outputs), [vision](/capabilities/vision), [embeddings](/capabilities/embeddings), [thinking](/capabilities/thinking), and [web search](/capabilities/web-search).+Ollama supports [streaming](/guide/capabilities/streaming), [tool calling](/guide/capabilities/tool-calling), [structured outputs](/guide/capabilities/structured-outputs), [vision](/guide/capabilities/vision), [embeddings](/guide/capabilities/embeddings), [thinking](/guide/capabilities/thinking), and [web search](/guide/capabilities/web-search).## Next steps@@ -63,11 +63,11 @@ Connect Ollama to an app, or build with the API.Join the Ollama subreddit.</Card>- <Card title="X (Twitter)" icon="discord" href="https://twitter.com/ollama">- Join the Ollama X (Twitter).+ <Card title="X" icon="x-twitter" href="https://x.com/ollama">+ Follow Ollama on X.</Card>- <Card title="Github" icon="discord" href="https://github.com/ollama/ollama">- Join the Ollama GitHub.+ <Card title="GitHub" icon="github" href="https://github.com/ollama/ollama">+ Explore Ollama on GitHub.</Card></CardGroup>diff --git a/docs/integrations/claude-code.mdx b/docs/integrations/claude-code.mdxindex 499b8c833..4da08b3c1 100644--- a/docs/integrations/claude-code.mdx+++ b/docs/integrations/claude-code.mdx@@ -107,7 +107,7 @@ Choose a model with enough context for your repository.</Card></CardGroup>-<Note>For larger repositories, set the [context length](/context-length) to 64k or higher.</Note>+<Note>For larger repositories, set the [context length](/local/context-length) to 64k or higher.</Note>## More features@@ -125,7 +125,7 @@ The `--yes` flag skips selectors, pulls the model when needed, and requires `--mUse Ollama's web search API from Claude Code.-See [Web search](/capabilities/web-search) for setup and usage.+See [Web search](/guide/capabilities/web-search) for setup and usage.### Scheduled tasks with `/loop`diff --git a/docs/integrations/cline.mdx b/docs/integrations/cline.mdxindex 371fc6288..a3a93f912 100644--- a/docs/integrations/cline.mdx+++ b/docs/integrations/cline.mdx@@ -13,7 +13,7 @@ Install [Cline](https://docs.cline.bot/getting-started/installing-cline) in your2. Select a model under `Model` or type one (e.g. `qwen3`)3. Update the context window to at least 32K tokens under `Context Window`-<Note>Coding tools require a larger context window. It is recommended to use a context window of at least 32K tokens. See [Context length](/context-length) for more information.</Note>+<Note>Coding tools require a larger context window. It is recommended to use a context window of at least 32K tokens. See [Context length](/local/context-length) for more information.</Note><div style={{ display: 'flex', justifyContent: 'center' }}><imgdiff --git a/docs/integrations/copilot-cli.mdx b/docs/integrations/copilot-cli.mdxindex 5262234ed..bd7a3c956 100644--- a/docs/integrations/copilot-cli.mdx+++ b/docs/integrations/copilot-cli.mdx@@ -90,4 +90,4 @@ Or run with environment variables inline:COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1 COPILOT_PROVIDER_API_KEY= COPILOT_PROVIDER_WIRE_API=responses COPILOT_MODEL=glm-5:cloud copilot```-**Note:** Copilot requires a large context window. We recommend at least 64k tokens. See the [context length documentation](/context-length) for how to adjust context length in Ollama.+**Note:** Copilot requires a large context window. We recommend at least 64k tokens. See the [context length documentation](/local/context-length) for how to adjust context length in Ollama.diff --git a/docs/integrations/droid.mdx b/docs/integrations/droid.mdxindex 249554510..0a94c9a16 100644--- a/docs/integrations/droid.mdx+++ b/docs/integrations/droid.mdx@@ -11,7 +11,7 @@ Install the [Droid CLI](https://factory.ai/):curl -fsSL https://app.factory.ai/cli | sh```-<Note>Droid requires a larger context window. It is recommended to use a context window of at least 64k tokens. See [Context length](/context-length) for more information.</Note>+<Note>Droid requires a larger context window. It is recommended to use a context window of at least 64k tokens. See [Context length](/local/context-length) for more information.</Note>## Usage with Ollamadiff --git a/docs/integrations/openclaw.mdx b/docs/integrations/openclaw.mdxindex ff5f91e26..bb891ea37 100644--- a/docs/integrations/openclaw.mdx+++ b/docs/integrations/openclaw.mdx@@ -18,7 +18,7 @@ Ollama handles everything automatically:4. **Onboarding** — Ollama configures the provider, installs the gateway daemon, sets your model as the primary, and enables OpenClaw's bundled Ollama web search5. **Gateway** — Starts in the background and opens the OpenClaw TUI-<Note>OpenClaw requires a larger context window. It is recommended to use a context window of at least 64k tokens if using local models. See [Context length](/context-length) for more information.</Note>+<Note>OpenClaw requires a larger context window. It is recommended to use a context window of at least 64k tokens if using local models. See [Context length](/local/context-length) for more information.</Note><Note>Previously known as Clawdbot. `ollama launch clawdbot` still works as an alias.</Note>diff --git a/docs/integrations/opencode.mdx b/docs/integrations/opencode.mdxindex 12a9cb32e..71dca27eb 100644--- a/docs/integrations/opencode.mdx+++ b/docs/integrations/opencode.mdx@@ -82,7 +82,7 @@ Choose a model with enough context for your repository.</Card></CardGroup>-<Note>OpenCode requires a context length of 64k or higher. See [Context length](/context-length) for more information.</Note>+<Note>OpenCode requires a context length of 64k or higher. See [Context length](/local/context-length) for more information.</Note>## Manual setupdiff --git a/docs/integrations/roo-code.mdx b/docs/integrations/roo-code.mdxindex 61c91a717..c4184d3fc 100644--- a/docs/integrations/roo-code.mdx+++ b/docs/integrations/roo-code.mdx@@ -15,7 +15,7 @@ Install [Roo Code](https://marketplace.visualstudio.com/items?itemName=RooVeteri4. Enter a valid `Model ID` (for example `qwen3` or `qwen3-coder:480b-cloud`)5. Adjust the `Context Window` to at least 32K tokens for coding tasks-<Note>Coding tools require a larger context window. It is recommended to use a context window of at least 32K tokens. See [Context length](/context-length) for more information.</Note>+<Note>Coding tools require a larger context window. It is recommended to use a context window of at least 32K tokens. See [Context length](/local/context-length) for more information.</Note>## Connecting to ollama.comdiff --git a/docs/integrations/vscode.mdx b/docs/integrations/vscode.mdxindex 7d4ef52cf..488d20d66 100644--- a/docs/integrations/vscode.mdx+++ b/docs/integrations/vscode.mdx@@ -44,7 +44,7 @@ Local models do not require sign-in.VS Code may show a model's maximum supported context length even when Ollama allocates a smaller context at runtime.-For local models, open Ollama **Settings**, set the context length to at least 64k, reload the VS Code window, and resend your prompt. See [Context length](/context-length) for more information.+For local models, open Ollama **Settings**, set the context length to at least 64k, reload the VS Code window, and resend your prompt. See [Context length](/local/context-length) for more information.## Troubleshootingdiff --git a/docs/cli.mdx b/docs/local/cli.mdxsimilarity index 100%rename from docs/cli.mdxrename to docs/local/cli.mdxdiff --git a/docs/context-length.mdx b/docs/local/context-length.mdxsimilarity index 95%rename from docs/context-length.mdxrename to docs/local/context-length.mdxindex abc2133b8..2d03c94f8 100644--- a/docs/context-length.mdx+++ b/docs/local/context-length.mdx@@ -22,7 +22,7 @@ Cloud models are set to their maximum context length by default.### AppChange the slider in the Ollama app under settings to your desired context length.-+### CLIIf editing the context length for Ollama is not possible, the context length can also be updated when serving Ollama.diff --git a/docs/docker.mdx b/docs/local/docker.mdxsimilarity index 100%rename from docs/docker.mdxrename to docs/local/docker.mdxdiff --git a/docs/faq.mdx b/docs/local/faq.mdxsimilarity index 99%rename from docs/faq.mdxrename to docs/local/faq.mdxindex 92a7404da..452c21cc0 100644--- a/docs/faq.mdx+++ b/docs/local/faq.mdx@@ -248,7 +248,7 @@ Refer to the section [above](#how-do-i-configure-ollama-server) for how to set e## How can I use Ollama in Visual Studio Code?-Install the [Ollama extension](https://marketplace.visualstudio.com/items?itemName=Ollama.ollama) to use Ollama models in VS Code Chat. See the [VS Code integration guide](./integrations/vscode.mdx) for setup and troubleshooting.+Install the [Ollama extension](https://marketplace.visualstudio.com/items?itemName=Ollama.ollama) to use Ollama models in VS Code Chat. See the [VS Code integration guide](/integrations/vscode) for setup and troubleshooting.## How do I use Ollama with GPU acceleration in Docker?diff --git a/docs/gpu.mdx b/docs/local/gpu.mdxsimilarity index 99%rename from docs/gpu.mdxrename to docs/local/gpu.mdxindex e0e141442..97ecf3f66 100644--- a/docs/gpu.mdx+++ b/docs/local/gpu.mdx@@ -35,7 +35,7 @@ Check your compute compatibility to see if your card is supported:| 5.0 | GeForce GTX | `GTX 750 Ti` `GTX 750` `NVS 810` || | Quadro | `K2200` `K1200` `K620` `M1200` `M520` `M5000M` `M4000M` `M3000M` `M2000M` `M1000M` `K620M` `M600M` `M500M` |-For building locally to support older GPUs, see [development](./development.md).+For building locally to support older GPUs, see [development](/development).### GPU Selectiondiff --git a/docs/import.mdx b/docs/local/import.mdxsimilarity index 100%rename from docs/import.mdxrename to docs/local/import.mdxdiff --git a/docs/local.mdx b/docs/local/index.mdxsimilarity index 58%rename from docs/local.mdxrename to docs/local/index.mdxindex dafc22b59..7cb107482 100644--- a/docs/local.mdx+++ b/docs/local/index.mdx@@ -11,19 +11,19 @@ Run models on your own hardware with Ollama. Local inference keeps model executiChoose the installation guide for your environment.<CardGroup cols={2}>- <Card title="macOS" icon="apple" href="/macos">+ <Card title="macOS" icon="apple" href="/local/macos">Install the Ollama app on Apple silicon or Intel hardware.</Card>- <Card title="Windows" icon="windows" href="/windows">+ <Card title="Windows" icon="windows" href="/local/windows">Install the native Windows application.</Card>- <Card title="Linux" icon="linux" href="/linux">+ <Card title="Linux" icon="linux" href="/local/linux">Install Ollama with the install script or a manual package.</Card>- <Card title="Docker" icon="docker" href="/docker">+ <Card title="Docker" icon="docker" href="/local/docker">Run Ollama in a container with CPU or GPU acceleration.</Card></CardGroup>@@ -48,10 +48,10 @@ curl http://localhost:11434/api/chat -d '{## Configure your environment-- Use the [CLI reference](/cli) to run, download, copy, and remove models.-- Adjust the [context length](/context-length) for agents and other long-context workloads.-- Review [hardware support](/gpu) for GPU compatibility and acceleration.-- [Import a model](/import) or create a customized model with a [Modelfile](/modelfile).-- Use [local-only mode](/faq#how-do-i-disable-ollama-cloud-features) to disable Ollama Cloud features.+- Use the [CLI reference](/local/cli) to run, download, copy, and remove models.+- Adjust the [context length](/local/context-length) for agents and other long-context workloads.+- Review [hardware support](/local/gpu) for GPU compatibility and acceleration.+- [Import a model](/local/import) or create a customized model with a [Modelfile](/local/modelfile).+- Use [local-only mode](/local/faq#how-do-i-disable-ollama-cloud-features) to disable Ollama Cloud features.-For failures, start with [Troubleshooting](/troubleshooting).+For failures, start with [Troubleshooting](/local/troubleshooting).diff --git a/docs/linux.mdx b/docs/local/linux.mdxsimilarity index 100%rename from docs/linux.mdxrename to docs/local/linux.mdxdiff --git a/docs/macos.mdx b/docs/local/macos.mdxsimilarity index 100%rename from docs/macos.mdxrename to docs/local/macos.mdxdiff --git a/docs/modelfile.mdx b/docs/local/modelfile.mdxsimilarity index 100%rename from docs/modelfile.mdxrename to docs/local/modelfile.mdxdiff --git a/docs/template.mdx b/docs/local/template.mdxsimilarity index 100%rename from docs/template.mdxrename to docs/local/template.mdxdiff --git a/docs/troubleshooting.mdx b/docs/local/troubleshooting.mdxsimilarity index 100%rename from docs/troubleshooting.mdxrename to docs/local/troubleshooting.mdxdiff --git a/docs/windows.mdx b/docs/local/windows.mdxsimilarity index 100%rename from docs/windows.mdxrename to docs/local/windows.mdxdiff --git a/docs/sample-projects/research-brief-agent.mdx b/docs/sample-projects/research-brief-agent.mdxdeleted file mode 100644index e10839bf1..000000000--- a/docs/sample-projects/research-brief-agent.mdx+++ /dev/null@@ -1,306 +0,0 @@-----title: Build a research brief agent-sidebarTitle: Research brief agent-description: Build an Ollama Cloud agent that searches the web, reads primary sources, and produces a cited research brief.------Build an agent that researches a question and turns its findings into a cited decision brief. This is useful for market research, policy summaries, product comparisons, event planning, and other tasks where current sources matter.--The project uses an Ollama Cloud model for reasoning and the Ollama web search and web fetch APIs for research. It runs entirely through Ollama Cloud, so you do not need a local model or GPU.--## What you will build--Given a question such as:--> What have four-day workweek pilots since 2022 reported about employee wellbeing and business performance?--the agent will:--1. Turn the question into several focused searches.-2. Search the web and choose promising results.-3. Fetch source pages for more context.-4. Compare claims across sources.-5. Write a brief with links, caveats, and suggested follow-up questions.--The example uses `gpt-oss:120b`, but you can choose another tool-capable model returned by the Cloud API.--## Before you begin--You need:--- Python 3.10 or later-- An [Ollama account](https://ollama.com)-- An [Ollama API key](https://ollama.com/settings/keys)--The API key gives the script access to both the Cloud model and the [web search tools](/capabilities/web-search). Treat it like a password and do not add it to source control.--## 1. Set up the project--Create a project directory and a Python virtual environment:--<Tabs>- <Tab title="macOS and Linux">--```shell-mkdir research-brief-agent-cd research-brief-agent-python3 -m venv .venv-source .venv/bin/activate-```-- </Tab>- <Tab title="Windows PowerShell">--```powershell-mkdir research-brief-agent-cd research-brief-agent-py -m venv .venv-.venv\Scripts\Activate.ps1-```-- </Tab>-</Tabs>--Install the Ollama Python library:--```shell-pip install --upgrade ollama-```--Set your API key for the current terminal session:--<Tabs>- <Tab title="macOS and Linux">--```shell-export OLLAMA_API_KEY=your_api_key-```-- </Tab>- <Tab title="Windows PowerShell">--```powershell-$env:OLLAMA_API_KEY="your_api_key"-```-- </Tab>-</Tabs>--<Note>- Environment variables set this way last only for the current terminal session. Use your operating system's secret manager for a persistent setup.-</Note>--## 2. Check Cloud access--List the models available to your account:--```shell-curl https://ollama.com/api/tags \- -H "Authorization: Bearer $OLLAMA_API_KEY"-```--Look for `gpt-oss:120b` in the response. If it is not available, choose another Cloud model that supports tool calling and set its name with `OLLAMA_MODEL`:--<Tabs>- <Tab title="macOS and Linux">--```shell-export OLLAMA_MODEL=your_model_name-```-- </Tab>- <Tab title="Windows PowerShell">--```powershell-$env:OLLAMA_MODEL="your_model_name"-```-- </Tab>-</Tabs>--## 3. Create the agent--Save the following as `research_agent.py`:--```python-import os-import sys--from ollama import Client, web_fetch, web_search---MODEL = os.getenv("OLLAMA_MODEL", "gpt-oss:120b")-MAX_TOOL_ROUNDS = 8--SYSTEM_PROMPT = """You are a careful research agent.--Research the user's question before answering. Search broadly, then fetch the-most useful pages. Prefer primary sources, original studies, official reports,-and sources that clearly explain their methods.--Your final answer must contain:-1. An executive summary-2. Key findings, including disagreements between sources-3. Limitations and missing evidence-4. Practical next steps-5. A Sources section with Markdown links--Attach a source link to every important factual claim. Never invent a citation.-If the available evidence does not support a conclusion, say so explicitly.-"""---def run_tool(name: str, arguments: dict) -> str:- """Run one tool selected by the model and return text for the next turn."""- tools = {- "web_search": web_search,- "web_fetch": web_fetch,- }-- tool = tools.get(name)- if tool is None:- return f"Unknown tool: {name}"-- print(f"Tool: {name}({arguments})")- result = tool(**arguments)-- # Large pages can crowd useful evidence out of the model's context.- return str(result)[:12000]---def research(question: str) -> str:- api_key = os.environ.get("OLLAMA_API_KEY")- if not api_key:- raise RuntimeError("Set OLLAMA_API_KEY before running the agent.")-- client = Client(- host="https://ollama.com",- headers={"Authorization": f"Bearer {api_key}"},- )-- messages = [- {"role": "system", "content": SYSTEM_PROMPT},- {"role": "user", "content": question},- ]-- for _ in range(MAX_TOOL_ROUNDS):- response = client.chat(- model=MODEL,- messages=messages,- tools=[web_search, web_fetch],- think=True,- )- messages.append(response.message)-- if not response.message.tool_calls:- return response.message.content-- for call in response.message.tool_calls:- name = call.function.name- result = run_tool(name, call.function.arguments)- messages.append(- {- "role": "tool",- "tool_name": name,- "content": result,- }- )-- # Force a final report if the model uses the full research budget.- messages.append(- {- "role": "user",- "content": "Stop researching and write the final cited brief now.",- }- )- response = client.chat(model=MODEL, messages=messages, think=True)- return response.message.content---if __name__ == "__main__":- default_question = (- "What have four-day workweek pilots since 2022 reported about "- "employee wellbeing and business performance?"- )- question = " ".join(sys.argv[1:]) or default_question- print(research(question))-```--The model receives two tools as Python functions. Ollama converts those functions into tool definitions, the Cloud model decides when and how to call them, and the script returns each tool result to the model. The loop ends when the model produces a response without another tool call.--`MAX_TOOL_ROUNDS` prevents an open-ended research loop. The final request removes the tools and asks for a report if the agent uses its entire tool budget.--## 4. Run the project--Run the agent with the example research question:--```shell-python research_agent.py-```--Or provide your own question:--```shell-python research_agent.py "What evidence supports later high school start times?"-```--During the run, the script prints each tool call. A typical trace looks like this:--```text-Tool: web_search({'query': 'four-day workweek pilot 2022 study results'})-Tool: web_search({'query': 'four-day week trial company revenue retention report'})-Tool: web_fetch({'url': 'https://example.org/report'})-```--Search queries and sources will vary between runs. That is expected: the model chooses its next action from the evidence it has already gathered.--## 5. Review the result--Expect a Markdown report with this general shape:--```text-# Research brief--## Executive summary-A concise answer to the research question.--## Key findings-Findings grouped by theme, with links attached to factual claims.--## Limitations-Gaps in the available evidence, methodology concerns, and conflicting results.--## Practical next steps-Actions or questions that follow from the evidence.--## Sources-A list of the pages used in the report.-```--The first run should produce a useful draft, not an unquestionable final answer. Check that links open, quoted numbers match their sources, and the report distinguishes published evidence from the model's interpretation.--<Warning>- Web results can be incomplete, outdated, or wrong. Review the original sources before using the brief for medical, legal, financial, employment, or other high-impact decisions.-</Warning>--## What happens at each stage--| Stage | What the Cloud model does | What you should expect |-| --- | --- | --- |-| Plan | Breaks the question into searchable claims | Several queries covering different aspects of the topic |-| Search | Calls `web_search` and evaluates result snippets | A visible tool trace; some searches may be discarded |-| Read | Calls `web_fetch` for promising pages | More detailed evidence from a smaller set of sources |-| Compare | Looks for agreement, conflicts, and missing context | Findings that separate strong evidence from uncertainty |-| Synthesize | Writes the requested report | A readable brief with citations, caveats, and next steps |--## Improve the agent--Try these changes after the basic project works:--- Change `SYSTEM_PROMPT` to require a particular audience, length, or report format.-- Ask the agent to prefer sources from specific domains or a date range.-- Increase `MAX_TOOL_ROUNDS` for broader research, or decrease it for faster, more focused runs.-- Save the final string to a Markdown file for sharing.-- Add a human approval step before the agent fetches unfamiliar domains.--See [Tool calling](/capabilities/tool-calling) for more agent-loop patterns and [Web search](/capabilities/web-search) for the complete search and fetch interfaces.