genspark2api的对话接口路径为/chat/completions
,支持流式和非流式两种输出模式。
获取Cookie:
使用前需要先获取有效的Cookie:
1. 在浏览器开发者工具(F12)中访问genspark.ai
2. 发起一次对话
3. 在网络(Network)选项卡中找到ask请求
4. 复制请求头中的cookie值
(必须包含session_id=xxx)
Beispielaufruf:
非流式请求:
curl -X POST http://localhost:7055/chat/completions
-H "Authorization: Bearer 123456"
-H "Content-Type: application/json"
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "你好"}]}'
流式输出只需在请求体中添加"stream": true
参数即可。
Zurück zum Beispiel:
{
“choices”: [{“message”: {“role”: “assistant”, “content”: “你好!有什么可以帮助你的吗?”}}]
}
注意要使用Authorization
头部携带配置的API_SECRET,消息体遵循标准对话格式。
Diese Antwort stammt aus dem ArtikelGenspark2api (fehlgeschlagen)Die