Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

feat: auto-inject stream_options.include_usage for OpenAI format streams (fixes #1423)

diegosouzapw96d0f57558a5
diff --git a/open-sse/executors/default.ts b/open-sse/executors/default.ts
index 76367a5008..25327f7518 100644
--- a/open-sse/executors/default.ts
+++ b/open-sse/executors/default.ts
@@ -218,9 +218,18 @@ export class DefaultExecutor extends BaseExecutor {
*/
transformRequest(model, body, stream, credentials) {
void model;
- void stream;
void credentials;
const withDefaults = applyProviderRequestDefaults(body, this.config.requestDefaults);
+
+ if (stream && this.config.format === "openai") {
+ if (typeof withDefaults === "object" && withDefaults !== null) {
+ withDefaults.stream_options = {
+ ...(withDefaults.stream_options || {}),
+ include_usage: true,
+ };
+ }
+ }
+
if (this.provider === "qwen" && typeof body === "object" && body !== null) {
return sanitizeQwenThinkingToolChoice(withDefaults, "QwenExecutor");
}