Ollama web search is a hosted API feature that returns search results or fetched page content for applications that need current information. It is separate from local model inference and requires an Ollama account API key.

The search endpoint runs at https://ollama.com/api/web_search and accepts a query plus an optional result limit. Treat returned snippets as retrieval context that still needs citation, filtering, or summarization in the application layer.

The campaign did not use a hosted API key, so the page keeps command examples sanitized and marks credential-backed validation as blocked. Do not substitute a local localhost request for this hosted feature.

Steps to use Ollama web search with the API:

  1. Create or select an Ollama API key for the hosted request.
    $ export OLLAMA_API_KEY='ollama_********************************'

    Use a task-scoped key for validation and revoke it afterward when possible.

  2. Verify hosted web search returns results with a bearer token.
    $ curl https://ollama.com/api/web_search \
      -H "Authorization: Bearer $OLLAMA_API_KEY" \
      -d '{"query":"what is ollama?","max_results":3}'
    {"results":[{"title":"Ollama","url":"https://ollama.com/","content":"Cloud models are now available..."}]}
  3. Keep result count small for prompt injection review.
    $ curl https://ollama.com/api/web_search -H "Authorization: Bearer $OLLAMA_API_KEY" -d '{"query":"site:docs.ollama.com embeddings","max_results":2}'
    {"results":[##### snipped #####]}
  4. Fetch a single page when the application needs page content.
    $ curl https://ollama.com/api/web_fetch \
      -H "Authorization: Bearer $OLLAMA_API_KEY" \
      -d '{"url":"https://docs.ollama.com/"}'
    {"title":"Ollama documentation","content":"##### snipped #####","links":[##### snipped #####]}
  5. Revoke or rotate the key when it was created for testing.
    $ export OLLAMA_API_KEY=

    Do not store hosted API keys in repository files.