stream=true 时,接口返回 text/event-stream。{
"model": "gpt-4.1",
"messages": [
{
"role": "system",
"content": "你是一个简洁的中文助手。"
},
{
"role": "user",
"content": "用三句话解释 SSE 为什么适合大模型流式输出。"
}
]
}curl --location --request POST 'https://api.ccapi.ai//v1/chat/completions' \
--header 'Authorization: Bearer sk-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4.1",
"messages": [
{
"role": "system",
"content": "你是一个简洁的中文助手。"
},
{
"role": "user",
"content": "用三句话解释 SSE 为什么适合大模型流式输出。"
}
]
}'{
"id": "chatcmpl_example",
"object": "chat.completion",
"created": 1741852800,
"model": "gpt-4.1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "SSE 允许服务端逐段推送内容、降低首字节等待时间,并且非常适合长文本生成场景。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 25,
"total_tokens": 67
}
}