Web Search

Give your models and agents current information from the web without building your own search dependencies. staik runs the search for the model and feeds the results back automatically — or call search directly when you just want raw results.

Overview

There are two ways to use web search in staik:

  • Server-side tool — add "web_search": true to a chat call; the model calls the tool and staik runs the search and loops the results back. You get a finished answer.
  • Direct callPOST /v1/tools/web-search returns raw search results without a model.

Server-side (for agents)

Send "web_search": true (or add {"type": "web_search"} to tools) in a regular /v1/chat/completions call. The model decides when it needs to search, staik runs the search and continues until the model has an answer. Works both with and without stream.

curlServer-side web_search
curl https://api.staik.se/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-st-your-key" \
  -d '{
    "model": "qwen3.5:9b",
    "messages": [
      {"role": "user", "content": "What happened recently in EU AI regulation?"}
    ],
    "web_search": true
  }'

If you send your own tools in the same call they are not executed server-side — if the model calls one of your tools, tool_calls are returned to you as usual. Only web_search is run by staik.

Via header (clients without body fields)

Some OpenAI clients and agent tools don't let you add custom fields to the request body. Set the header X-Staik-Web-Search: 1 instead — it enables web_search for the call (equivalent to "web_search": true). Many clients let you set headers per provider or model in their config.

curlHeader instead of body field
curl https://api.staik.se/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-st-your-key" \
  -H "X-Staik-Web-Search: 1" \
  -d '{
    "model": "qwen3.5:9b",
    "messages": [{"role": "user", "content": "..."}]
  }'

How the loop works

  1. The model is given access to the web_search(query, max_results) tool.
  2. If it needs current information, it calls the tool.
  3. staik runs the search and feeds the results back to the model.
  4. The model answers — or searches again (up to an internal limit).

Tokens for all rounds (search calls + final answer) are summed in usage, just like a regular call.

Direct call

If you just want raw search results (no model) — e.g. for your own RAG pipeline — use POST /v1/tools/web-search:

curlDirect call
curl https://api.staik.se/v1/tools/web-search \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-st-your-key" \
  -d '{"query": "swedish LLM API", "max_results": 5}'

# => {"results": [{"title": "...", "url": "...", "content": "..."}, ...]}

Privacy

Search runs via a self-hosted search engine on staik's own hardware — no third-party search API key. The query is never logged, the same way we never log prompt text.

Tips

  • Set max_results (1–10) on the direct call to control the number of results.
  • Need several tools in the same agent? Combine web_search with your own in tools — see Tool Calling.

Explore more