The path to the genspark2api dialog interface is/chat/completions, supports both streaming and non-streaming output modes.
Get Cookie:
A valid cookie needs to be obtained before use:
1. Access genspark.ai in your browser developer tools (F12).
2. Initiation of a dialogue
3. Locate the ask request in the Network tab.
4. Copy the cookie value in the request header
(must contain session_id=xxx)
Calling example:
Non-streaming requests:
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": "你好"}]}'
Streaming output is simply a matter of adding the request body to the"stream": trueparameter is sufficient.
Return to Example:
{
"choices": [{"message": {"role": "assistant ", "content": "Hello! How can I help you?"}}]
}
Be careful to useAuthorizationThe header carries the configured API_SECRET and the message body follows the standard dialog format.
This answer comes from the articleGenspark2api (failed)The































