Local API Guide contents
Overview
Runs the app's web search on its own and returns what it found, so you can build your own prompts or show sources. The loaded model plans the searches, so a model must be loaded and the request counts as one Local API prompt. Unlike web_search on chat completions, this endpoint always searches.
Request body
| Parameter | Description |
|---|---|
querystringrequired | What to search for: a question or keywords. |
depthstring | quick (a few seconds), balanced or deep (most thorough). Default: the app's setting (Balanced). |
| Authorization header | Authorization: Bearer <key>, only when Require API key is on in the app. |
Response
| Field | Description |
|---|---|
objectstring | web.search |
querystring | Your query. |
searchedboolean | Always true here. |
depthstring | The depth used. |
queriesstring[] | The searches the model ran. |
pages_readinteger | Pages read in full. |
secondsnumber | How long it took. |
notestring | null | A remark, e.g. when nothing usable was found. |
sourcesarray | index, type (web), title, url, site, snippet. |
contextstring | null | The numbered passages, ready to put in your own prompt; null when nothing usable was found. |
Example
curl http://localhost:1234/v1/web/search \ -H "Content-Type: application/json" \ -d '{"query": "NVIDIA GeForce RTX 5090 memory size", "depth": "quick"}'
import requests r = requests.post("http://localhost:1234/v1/web/search", json={"query": "NVIDIA GeForce RTX 5090 memory size", "depth": "quick"}).json() for s in r["sources"]: print(f"[{s['index']}] {s['title']} - {s['url']}") prompt = f"Using these sources:\n{r['context']}\n\nAnswer: how much memory does the RTX 5090 have?"
const r = await (await fetch("http://localhost:1234/v1/web/search", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ query: "NVIDIA GeForce RTX 5090 memory size", depth: "quick" }), })).json(); r.sources.forEach(s => console.log(`[${s.index}] ${s.title} - ${s.url}`));
{
"object": "web.search",
"query": "NVIDIA GeForce RTX 5090 memory size",
"searched": true,
"depth": "quick",
"queries": ["NVIDIA GeForce RTX 5090 memory size specs", "NVIDIA GeForce RTX 5090 memory size"],
"pages_read": 5,
"seconds": 6.8,
"note": null,
"sources": [
{ "index": 1, "type": "web", "title": "GeForce RTX 5090 Graphics Cards | NVIDIA",
"url": "https://www.nvidia.com/…", "site": "nvidia.com", "snippet": "32 GB GDDR7 …" }
],
"context": "[1] GeForce RTX 5090 Graphics Cards | NVIDIA / nvidia.com / https://www.nvidia.com/…\n…"
}Errors
| Status | Code | When |
|---|---|---|
| 401 | invalid_api_key | Require API key is on and the key is missing or wrong. |
| 400 | invalid_request | query is missing or empty, or depth is not quick, balanced or deep. |
| 402 | trial_exhausted | Today's Local API allowance is used up. |
| 503 | model_not_loaded | No model is loaded (the model plans the search). |
| 502 | web_search_failed | The search failed, for example without an internet connection. |
Web searches send your query to search engines (Bing, DuckDuckGo, Brave, Google, Wikipedia) and visit the pages found; everything else stays on your PC.