ChatGPTNextWeb / ChatGPTNextWeb/NextChat

[Feature Request] x.ai新api功能,Live search支持

Open
#6,502 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
88.8k
Forks
59.1k
PR merge metrics
No merged PRs in 30d

Description

### 🥰 需求描述

https://docs.x.ai/docs/guides/live-search
x.ai的api增加了live search的支持,通过参数可以选择

### 🧐 解决方案

import os
import requests

url = "https://api.x.ai/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('XAI_API_KEY')}"
}
payload = {
"messages": [
{
"role": "user",
"content": "Provide me a digest of world news in the last 24 hours."
}
],
"search_parameters": {
"mode": "auto"
},
"model": "grok-3-latest"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())

简单的例子,json形式的一个新参数和三个选项可以提供开关,文档如上
还有一个返回的参数,应该只需要增加这两个就可以

### 📝 补充信息

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.