> ## Documentation Index
> Fetch the complete documentation index at: https://docs.near.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Web Search

> Give models access to live web results through Chat Completions

NEAR AI Cloud provides a built-in **server-side web search tool** for Chat Completions. The model decides when to search, the platform executes the search, and the results are fed back to the model without tool-handling code on your side.

Web search is billed per request as a platform service in addition to model tokens. Current pricing is available from the public [`/v1/services`](https://cloud-api.near.ai/v1/services) endpoint.

<Warning>
  The stateless Responses API does not execute built-in `web_search` or `web_context_search` tools. Use Chat Completions as shown below, or expose search as a custom function and execute it in your application.
</Warning>

## Chat Completions API

`web_context_search` is also available on `/v1/chat/completions`. It requires `stream: true`:

```bash theme={"dark"}
curl https://cloud-api.near.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "z-ai/glm-5.2",
    "messages": [{"role": "user", "content": "What is the current population of Tokyo? One short sentence."}],
    "tools": [{"type": "web_context_search"}],
    "stream": true
  }'
```

The stream interleaves the search activity with the answer:

1. `delta.tool_calls` chunks show the model composing its search query (function name `web_context_search`)
2. a `delta.nearai_tool_result` chunk carries the search results that were injected back into the model's context
3. regular `delta.content` (and `delta.reasoning_content`) chunks stream the final answer

This makes it easy to display "searching the web…" states and surface sources in your UI.

<Note>
  Unlike client-side function calling, you never receive a `finish_reason: "tool_calls"` response that you have to answer — the search loop runs entirely server-side, on infrastructure operated by NEAR AI.
</Note>

## See Also

* [Stateless Responses](/cloud/guides/stateless-responses) — client-managed functions and unsupported built-in tools
* [OpenAI Compatibility](/cloud/guides/openai-compatibility) — SDK setup
* [Prompt Caching](/cloud/guides/prompt-caching) — search context benefits from cache-read pricing on repeated turns


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.