G
YouTube TikTok Games
Skip to content

无法使用非流式输出 #610

Open

Description

@Lockjava

把 "Accept": "text/event-stream"去掉,也无法禁用流式输出,我应该怎么操作呢?我的代码如下“”
import requests
import json

url = "{baseurl}/api/v1/chat/completions"
api_key = "xxxxxxxxx"

headers = {
"Authorization": api_key,
"content-type": "application/json",
# "Accept": "text/event-stream"
}

data = {
"prompt": [
{
"type": "text",
"content": "周杰伦的主要作品有哪些?"
}
],
"session_id": 19,
"thinking_enabled": True,
"user_no": "123456",
}

response = requests.post(url, headers=headers, json=data)
print(response.text)
“”

Activity

  1. thundax-lyp commented on Dec 9, 2025

    @thundax-lyp

    把 "Accept": "text/event-stream"去掉,也无法禁用流式输出,我应该怎么操作呢?我的代码如下“” import requests import json

    url = "{baseurl}/api/v1/chat/completions" api_key = "xxxxxxxxx"

    headers = { "Authorization": api_key, "content-type": "application/json", # "Accept": "text/event-stream" }

    data = { "prompt": [ { "type": "text", "content": "周杰伦的主要作品有哪些?" } ], "session_id": 19, "thinking_enabled": True, "user_no": "123456", }

    response = requests.post(url, headers=headers, json=data) print(response.text) “”

    无法在客户端禁止。不建议禁止,这是一个长时间的应答,不用流式输出容易导致请求超时。

  2. Lockjava commented on Dec 9, 2025

    @Lockjava
    Author

    把 "Accept": "text/event-stream"去掉,也无法禁用流式输出,我应该怎么操作呢?我的代码如下“” import requests import json
    url = "{baseurl}/api/v1/chat/completions" api_key = "xxxxxxxxx"
    headers = { "Authorization": api_key, "content-type": "application/json", # "Accept": "text/event-stream" }
    data = { "prompt": [ { "type": "text", "content": "周杰伦的主要作品有哪些?" } ], "session_id": 19, "thinking_enabled": True, "user_no": "123456", }
    response = requests.post(url, headers=headers, json=data) print(response.text) “”

    无法在客户端禁止。不建议禁止,这是一个长时间的应答,不用流式输出容易导致请求超时。

    我们确实需要非流式输出的场景,能在服务端禁止吗?或者说如何禁止呢?

  3. thinkhejie commented on Jan 29, 2026

    @thinkhejie

    服务端是不是默认启用了SSE ? 哪里可以关掉吗 ? 我也有诉求,服务端不要返回中间过程。举个例子,现在的API返回的是:
    你
    你好
    你好! 世界。
    其实,我只需要【你好! 世界。】前面两句不需要的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions