Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

如何获取和使用genspark2api的对话接口?

2025-09-05 1.3 K

genspark2api的对话接口路径为/chat/completions,支持流式和非流式两种输出模式。

获取Cookie:
使用前需要先获取有效的Cookie:
1. 在浏览器开发者工具(F12)中访问genspark.ai
2. 发起一次对话
3. 在网络(Network)选项卡中找到ask请求
4. 复制请求头中的cookie值
(必须包含session_id=xxx)

调用示例:
非流式请求:

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参数即可。

Return to Example:
{
“choices”: [{“message”: {“role”: “assistant”, “content”: “你好!有什么可以帮助你的吗?”}}]
}

注意要使用Authorization头部携带配置的API_SECRET,消息体遵循标准对话格式。

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish