Mintlify Index
构建实现上下文
在 token 预算内为应用或代理组装带有来源引用的技术上下文。
POST
/
v1
/
context
构建实现上下文
curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "我应该如何在 Next.js 16 中配置缓存?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/context"
payload = {
"query": "我应该如何在 Next.js 16 中配置缓存?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
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({
query: '我应该如何在 Next.js 16 中配置缓存?',
product: 'Next.js',
format: 'txt',
tokenBudget: 3000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/context', 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://leaves.mintlify.com/api/universal-search/v1/context",
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([
'query' => '我应该如何在 Next.js 16 中配置缓存?',
'product' => 'Next.js',
'format' => 'txt',
'tokenBudget' => 3000
]),
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://leaves.mintlify.com/api/universal-search/v1/context"
payload := strings.NewReader("{\n \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\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://leaves.mintlify.com/api/universal-search/v1/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/context")
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 \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}"
response = http.request(request)
puts response.read_body{
"requestId": "7f2ab8d1-3bea-4a29-bc51-c05a8d3a3e3c",
"query": "我应该如何在 Next.js 16 中配置缓存?",
"response": "### 缓存与重新验证\n\n来源:https://nextjs.org/docs/app/getting-started/caching-and-revalidating\n\n使用本指南中介绍的当前缓存 API。\n\n--------------------------------",
"resultsCount": 3,
"outputTokens": 1842
}{
"error": "请求正文无效"
}{
"error": "未授权"
}{
"error": "该 API key 不允许此 IP 地址"
}{
"error": "超出速率限制。请稍后重试"
}{
"error": "<string>"
}授权
带有 mint_us_ 前缀的 Mintlify Index API 密钥。
请求体
application/json
要研究的实现问题。
Minimum string length:
1response 字符串的格式。txt 返回 Markdown 部分,json 返回包含结果项目的序列化 JSON 对象。
可用选项:
txt, json 用作额外检索提示的产品或公司名称。
Minimum string length:
1要纳入检索的域名。
Minimum array length:
1Minimum string length:
1要从检索中排除的域名。
Minimum array length:
1Minimum string length:
1输出 token 的最大数量。
必填范围:
1 <= x <= 6000⌘I
构建实现上下文
curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/context \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "我应该如何在 Next.js 16 中配置缓存?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/context"
payload = {
"query": "我应该如何在 Next.js 16 中配置缓存?",
"product": "Next.js",
"format": "txt",
"tokenBudget": 3000
}
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({
query: '我应该如何在 Next.js 16 中配置缓存?',
product: 'Next.js',
format: 'txt',
tokenBudget: 3000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/context', 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://leaves.mintlify.com/api/universal-search/v1/context",
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([
'query' => '我应该如何在 Next.js 16 中配置缓存?',
'product' => 'Next.js',
'format' => 'txt',
'tokenBudget' => 3000
]),
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://leaves.mintlify.com/api/universal-search/v1/context"
payload := strings.NewReader("{\n \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\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://leaves.mintlify.com/api/universal-search/v1/context")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/context")
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 \"query\": \"我应该如何在 Next.js 16 中配置缓存?\",\n \"product\": \"Next.js\",\n \"format\": \"txt\",\n \"tokenBudget\": 3000\n}"
response = http.request(request)
puts response.read_body{
"requestId": "7f2ab8d1-3bea-4a29-bc51-c05a8d3a3e3c",
"query": "我应该如何在 Next.js 16 中配置缓存?",
"response": "### 缓存与重新验证\n\n来源:https://nextjs.org/docs/app/getting-started/caching-and-revalidating\n\n使用本指南中介绍的当前缓存 API。\n\n--------------------------------",
"resultsCount": 3,
"outputTokens": 1842
}{
"error": "请求正文无效"
}{
"error": "未授权"
}{
"error": "该 API key 不允许此 IP 地址"
}{
"error": "超出速率限制。请稍后重试"
}{
"error": "<string>"
}