fix(openai): add missing stream parameter for Responses API
- The OpenAI Responses API actually requires the 'stream: true' parameter in the JSON body, contrary to some documentation summaries. - Omitting it caused the API to return a full application/json response instead of SSE text/event-stream, leading to stream failures and probe warnings in the proxy logs.
This commit is contained in:
@@ -664,7 +664,6 @@ impl super::Provider for OpenAIProvider {
|
||||
let mut body = serde_json::json!({
|
||||
"model": request.model,
|
||||
"input": input_parts,
|
||||
"stream": true,
|
||||
});
|
||||
|
||||
// Add standard parameters
|
||||
@@ -711,6 +710,7 @@ impl super::Provider for OpenAIProvider {
|
||||
}
|
||||
}
|
||||
|
||||
body["stream"] = serde_json::json!(true);
|
||||
let url = format!("{}/responses", self.config.base_url);
|
||||
let api_key = self.api_key.clone();
|
||||
let model = request.model.clone();
|
||||
@@ -889,16 +889,11 @@ impl super::Provider for OpenAIProvider {
|
||||
Ok(_) => continue,
|
||||
Err(e) => {
|
||||
// Attempt to probe for the actual error body
|
||||
let mut probe_body_no_stream = probe_body.clone();
|
||||
if let Some(obj) = probe_body_no_stream.as_object_mut() {
|
||||
obj.remove("stream");
|
||||
}
|
||||
|
||||
let probe_resp = probe_client
|
||||
.post(&url)
|
||||
.header("Authorization", format!("Bearer {}", api_key))
|
||||
.header("Accept", "application/json")
|
||||
.json(&probe_body_no_stream)
|
||||
.json(&probe_body)
|
||||
.send()
|
||||
.await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user