/v1/services endpoint.
Responses API
Addweb_search to the tools array. Set count to control the maximum number of results returned by each search in this request:
count is optional and accepts integers from 0 through 20. When set, it overrides the result count chosen by the model for every web_search call in the request. Omit it to let the model choose. With count: 0, search calls return empty results without calling the search provider; the model can still make a search tool call. Fewer results than requested may be returned.
count applies to web_search in the Responses API. You can also use web_context_search in Responses, but it does not accept this request-level count setting. The response includes search activity as web_search_call output items alongside the model’s answer.
Chat Completions API
web_context_search is also available on /v1/chat/completions. It requires stream: true:
delta.tool_callschunks show the model composing its search query (function nameweb_context_search)- a
delta.nearai_tool_resultchunk carries the search results that were injected back into the model’s context - regular
delta.content(anddelta.reasoning_content) chunks stream the final answer
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.See Also
- Stateless Responses — native stateless requests and client-managed functions
- OpenAI Compatibility — SDK setup
- Prompt Caching — search context benefits from cache-read pricing on repeated turns