Web Search Pro
Run a web search via the /v1/tools/search_pro endpoint with site and time-range constraints, plus structured content chunks.
curl --request POST \
--url https://api.moonshot.ai/v1/tools/search_pro \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text_query": "<string>"
}
'import requests
url = "https://api.moonshot.ai/v1/tools/search_pro"
payload = { "text_query": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({text_query: '<string>'})
};
fetch('https://api.moonshot.ai/v1/tools/search_pro', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/tools/search_pro",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text_query' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/tools/search_pro"
payload := strings.NewReader("{\n \"text_query\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/tools/search_pro")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text_query\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/tools/search_pro")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text_query\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"search_results": [
{
"authority": "<string>",
"date": "<string>",
"icon": "<string>",
"mime": "<string>",
"site_name": "<string>",
"snippet": "<string>",
"title": "<string>",
"url": "<string>",
"chunks": [
{
"text": "<string>",
"score": 123
}
]
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}sites (multiple sites are OR’d, up to 5), constrain the time range with time_window, and return structured content chunks (chunks) for each result. Ideal for retrieval scenarios that require control over sources and freshness.
start and end of time_window accept YYYY, YYYY-MM, and YYYY-MM-DD formats. Both are normalized to the first day of their period before comparison, and start must not be later than end.
Usage Example
Usage Example
import os
import requests
api_key = os.environ.get("MOONSHOT_API_KEY")
url = "https://api.moonshot.ai/v1/tools/search_pro"
response = requests.post(
url,
headers={"Authorization": f"Bearer {api_key}"},
json={
"text_query": "Kimi K2 model release",
"limit": 5,
"sites": ["moonshot.ai", "kimi.com"],
"time_window": {"start": "2026-01", "end": "2026-09"},
},
)
print(response.json())
curl https://api.moonshot.ai/v1/tools/search_pro \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-d '{"text_query": "Kimi K2 model release", "limit": 5, "sites": ["moonshot.ai", "kimi.com"], "time_window": {"start": "2026-01", "end": "2026-09"}}'
const apiKey = process.env.MOONSHOT_API_KEY;
async function main() {
const response = await fetch("https://api.moonshot.ai/v1/tools/search_pro", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify({
text_query: "Kimi K2 model release",
limit: 5,
sites: ["moonshot.ai", "kimi.com"],
time_window: { start: "2026-01", end: "2026-09" },
}),
});
const data = await response.json();
console.log(data);
}
main();
Response Fields
Response Fields
| Field | Type | Description |
|---|---|---|
search_results | array[object] | List of search results; an empty array when nothing matches |
search_results[].authority | string | Authority level of the source |
search_results[].date | string | Date of the search result |
search_results[].icon | string | Site icon URL |
search_results[].mime | string | MIME type of the content |
search_results[].site_name | string | Site name |
search_results[].snippet | string | Snippet of the search result |
search_results[].title | string | Title of the search result |
search_results[].url | string | URL of the search result |
search_results[].chunks | array[object] | Structured content chunks collected for each page; an empty array when no content is available |
search_results[].chunks[].text | string | Content of the chunk |
search_results[].chunks[].score | number | Relevance score of the chunk to the query |
chunks, the string fields above are returned as empty strings when no data is available.Response Example{
"search_results": [
{
"authority": "S",
"date": "2026-06-01",
"icon": "https://platform.kimi.ai/favicon.ico",
"mime": "text/html",
"site_name": "Kimi API Open Platform",
"snippet": "Documentation entry of the Kimi API open platform.",
"title": "API Overview - Kimi API Open Platform",
"url": "https://platform.kimi.ai/docs/api/overview",
"chunks": [
{
"text": "The Kimi API provides chat completions, files, and batch endpoints, compatible with OpenAI and Anthropic protocols.",
"score": 1.23
}
]
}
]
}
| Header | Description |
|---|---|
X-Msh-Track-Id | Request ID. If the client sends this header, its value is reused; otherwise the server generates one. Provide this ID when troubleshooting |
X-Msh-Chat-Id | Session ID, always toolgw-{X-Msh-Track-Id}; provide both IDs when troubleshooting |
Error Codes
Error Codes
| HTTP Status | error.type | Typical message | Description |
|---|---|---|---|
| 400 | invalid_request | invalid request body | The request body is not valid JSON |
| 400 | invalid_request | text_query is required | Missing search query text |
| 400 | invalid_request | timeout_seconds must be less than or equal to 60 | timeout_seconds must be between 1 and 60 |
| 400 | invalid_request | limit must be between 1 and 20 | limit must be between 1 and 20 |
| 400 | invalid_request | sites must contain at most 5 entries | sites accepts at most 5 entries |
| 400 | invalid_request | site must not contain whitespace or parentheses | A sites entry must not contain whitespace or parentheses |
| 400 | invalid_request | time_window.start is invalid, expect YYYY / YYYY-MM / YYYY-MM-DD | Invalid time_window date format (same for end) |
| 400 | invalid_request | time_window.start must not be after time_window.end | After normalization to the first day of each period, start must not be later than end |
| 401 | - | No error body | Missing or invalid API key |
| 403 | - | No error body | Account inactive or suspended |
| 408 | client_canceled | client canceled the request | The client disconnected before the server responded |
| 429 | rate_limited | project qps limit exceeded | Rate or concurrency limit exceeded; the response carries X-RateLimit-Limit and X-RateLimit-Remaining headers, plus X-RateLimit-Reset when a per-second limit is hit |
| 429 | rate_limit_unavailable | rate limit store unavailable | Rate-limit service temporarily unavailable; retry later |
| 500 | internal_error | Raw internal error text | Internal server error; retry later, and contact support with the X-Msh-Track-Id if it persists |
| 502 | upstream_failed | upstream service failed | Service temporarily unavailable; retry later |
| 504 | timeout | request timeout | The search timed out; increase timeout_seconds or simplify the query and retry |
search_results array; failed or empty-result calls are free. For pricing details, see WebSearch Pricing.Authorizations
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
Body
Search query text. Must not be empty.
Search timeout in seconds, from 1 to 60. If omitted, no per-request timeout is applied.
1 <= x <= 60Maximum number of results to return, from 1 to 20. Defaults to 5.
1 <= x <= 20Restrict results to the given sites. Multiple sites are OR'd, up to 5 entries; each entry must be non-empty and must not contain whitespace or parentheses.
5Time-window constraint on result dates. start and end are each normalized to the first day of their period before comparison; start must not be later than end.
Show child attributes
Show child attributes
Response
Search results with content snippets
List of search results; an empty array when nothing matches.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.moonshot.ai/v1/tools/search_pro \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text_query": "<string>"
}
'import requests
url = "https://api.moonshot.ai/v1/tools/search_pro"
payload = { "text_query": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({text_query: '<string>'})
};
fetch('https://api.moonshot.ai/v1/tools/search_pro', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/tools/search_pro",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text_query' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/tools/search_pro"
payload := strings.NewReader("{\n \"text_query\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/tools/search_pro")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text_query\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/tools/search_pro")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text_query\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"search_results": [
{
"authority": "<string>",
"date": "<string>",
"icon": "<string>",
"mime": "<string>",
"site_name": "<string>",
"snippet": "<string>",
"title": "<string>",
"url": "<string>",
"chunks": [
{
"text": "<string>",
"score": 123
}
]
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}