Skip to main content
For AI agents: a documentation index is available at https://docs.parallel.ai/llms.txt. The full text of all docs is at https://docs.parallel.ai/llms-full.txt. You may also fetch any page as Markdown by appending .md to its URL or sending Accept: text/markdown.
Give locally-hosted models running under Ollama real-time web search by registering Parallel Search as a tool. This guide uses Ollama’s native Python SDK, which derives the tool schema directly from your function signature and docstring.

Overview

Modern Ollama models (Qwen 3.5, Gemma 4, Llama 3.1+) support native tool calling: you pass tools=[...] on a chat call, the model emits structured tool_calls, your code executes them, and you feed results back in a follow-up turn. By registering Parallel Search as a tool, your local model can:
  • Search the web for current information
  • Access real-time news, research, and facts
  • Cite sources with URLs in responses
This guide uses the native ollama Python SDK. If your application already speaks the OpenAI Chat Completions API — including TypeScript apps using openai — point your existing client at http://localhost:11434/v1 and follow the OpenAI Tool Calling guide unchanged.

Prerequisites

  1. Install Ollama and start the daemon (ollama serve)
  2. Pull a tool-capable model (Qwen 3.5 has the most reliable tool calls)
  3. Get your Parallel API key from Platform
  4. Install the Python SDKs

Define the Search Tool

The Ollama Python SDK accepts plain Python functions as tools. It reads the parameter type hints and docstring (Google-style) to build the JSON schema automatically — no separate schema object required. See Search Tool Definition for the recommended objective + queries shape.
This example uses the default advanced mode, which prioritizes result quality for tool use. For lower-latency responses, consider "turbo" (p50 ~200ms) or "basic". To switch, add mode="turbo" to the search call inside your search_web handler. The tool schema the model sees stays unchanged. See Search Modes.

Process Tool Calls

Pass the function directly in tools, then dispatch any returned calls and append the results as role: "tool" messages:

Complete Example

End-to-end: a chat loop that lets the model decide when to search.

Tool Parameters

Choosing a Model

Tool calling reliability varies sharply by model. From most to least dependable for this workflow: Smaller models (under ~7B) occasionally hallucinate parameters or skip required fields. If you see flaky calls, jump up a size before tuning prompts.

Differences from the OpenAI Client

If you’re porting code from the OpenAI Tool Calling guide, three things change: The OpenAI-compatible endpoint at http://localhost:11434/v1 follows the OpenAI conventions instead — useful if you want to keep one code path across providers. Note that tool_choice is not supported on that endpoint.