Skip to main content
Web Search enables Zark to search the web in real-time, browse web pages, and extract relevant information to answer queries with up-to-date content.

Basic Usage

Web Search is triggered automatically when your question requires current or external information. You can also specify it explicitly via the API.
import requests

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={
        "x-api-key": "your_api_key",
        "Content-Type": "application/json",
    },
    json={
        "messages": [
            {"role": "user", "content": "What are the latest developments in AI regulation?"}
        ],
        "workspace_id": "wks-xxxxx",
        "tools": ["web_search"],
        "tool_choice": "auto",
        "temperature": 0,
        "max_tokens": 4000,
    },
)

data = response.json()
print(data["response"])
When tool_choice is set to "auto", Zark decides whether Web Search is needed based on your query. Setting tools: ["web_search"] makes it available — not mandatory. To ensure Web Search is always used, set tool_choice to target it:
{
  "messages": [
    {"role": "user", "content": "Current price of gold"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["web_search"],
  "tool_choice": "web_search",
  "temperature": 0,
  "max_tokens": 4000
}

Streaming

Web Search supports streaming via Server-Sent Events (SSE):
Python
import requests
import json

response = requests.post(
    "https://api.zarkai.xyz/v1/chat",
    headers={
        "x-api-key": "your_api_key",
        "Content-Type": "application/json",
    },
    json={
        "messages": [
            {"role": "user", "content": "Latest funding rounds in climate tech"}
        ],
        "workspace_id": "wks-xxxxx",
        "tools": ["web_search"],
        "tool_choice": "auto",
        "stream": True,
    },
    stream=True,
)

for line in response.iter_lines():
    if line:
        event = json.loads(line.decode("utf-8").removeprefix("data: "))
        event_type = event.get("type")

        if event_type == "ai_chunk":
            print(event["content"], end="", flush=True)
        elif event_type == "ai_complete":
            print("\n\nDone.")

Streaming Events

EventDescription
ai_chunkIncremental text content of the response
ai_completeFinal complete response

How It Works

When Web Search is triggered, Zark:
  1. Formulates targeted search queries based on your question
  2. Searches the web and identifies relevant sources
  3. Reads and extracts information from the most relevant pages
  4. Synthesizes findings into a coherent answer with source attribution

Combining with Files

Web Search becomes powerful when combined with your uploaded data:
{
  "messages": [
    {"role": "user", "content": "How does our Q3 revenue compare to industry benchmarks?"}
  ],
  "workspace_id": "wks-xxxxx",
  "tools": ["web_search"],
  "file_ids": ["file-abc123"],
  "tool_choice": "auto"
}
Zark uses your uploaded spreadsheet for internal data and Web Search for external benchmarks, then synthesizes both into a single response.

Privacy

When Web Search is used, queries are anonymized and do not include your internal data. External sources receive generic search requests — not information from your files or Space. Your uploaded content stays private.

Examples

What are the latest developments in AI regulation?
Current exchange rate USD to EUR
Find recent funding rounds in the climate tech space
What's the weather in Tokyo this weekend?