Ollama: "search API error (status 402)"
Last checked
The error
Error: search error: search API error (status 402): unknown errorA fetch can fail the same way: "crawl API error (status 402)".
"search API error (status 402)" means Ollama's hosted web search refused the request as payment required. Web search needs an Ollama account: sign in (ollama signin), or set an API key from ollama.com/settings/keys as OLLAMA_API_KEY. If you're signed in, your account's web search allowance is used up, so check usage on ollama.com and wait for the reset or upgrade.
Why it happens
Ollama's web search and web fetch run on ollama.com, not on your machine, and they need an Ollama account. HTTP 402 means "payment required": the account behind the request has no web search allowance left, or the request isn't tied to a signed-in account or API key.
- No account or key attached. Ollama's docs say web search needs a free Ollama account, and API calls need an API key (OLLAMA_API_KEY or an Authorization header).
- The allowance is used up. When this error first appeared in August 2025 (Ollama issue #11674), an Ollama maintainer explained that web search draws on account credits and that the app wasn't showing the out-of-credits message. Limits were raised the same day.
The fix
- 1 Sign in to Ollama in the desktop app, or run ollama signin.
- 2 For API or tool use, create a key at ollama.com/settings/keys and set it as OLLAMA_API_KEY.
- 3 Check usage and plan for your account on ollama.com, then wait for the limit to reset or upgrade.
- 4 Retry with a short query to confirm search works before rerunning a long agent task.
curl https://ollama.com/api/web_search --header "Authorization: Bearer $OLLAMA_API_KEY" -d '{"query": "test"}'Still failing?
- The error is "web fetch is only allowed for URLs provided by the user" instead. That's the desktop app's URL policy, not billing.
- A 401 instead of a 402 means the key is missing or wrong, not out of allowance. Create a new key and set it again.
Related errors
Hit a different error?
Paste any agent error and get the cause and fix in seconds.
Frequently asked questions
Is Ollama web search free?
Ollama's docs say a free Ollama account is required for web search, and API access needs an API key. Usage is limited per account, and a 402 means that limit has been reached or no account is attached.
Why does a local model show a 402 at all?
The model runs locally, but the web search tool calls ollama.com. The 402 comes from that hosted service, not from your model or your machine.
Does a 402 mean my API key is invalid?
No. An invalid or missing key usually returns 401. A 402 means the request was understood but the account has no allowance left for it.
Stop firefighting agent errors
Decoding errors one at a time is the manual version of what BetterClaw automates. Run your agents on a no-code AI agent platform with managed models, retries and config validation built in.
Free plan available · Pro $49/mo · BYOK · 7-day free trial
