diff options
| author | Adam Malczewski <[email protected]> | 2026-06-21 22:07:37 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-21 22:07:37 +0900 |
| commit | 4a71e0672f7433f2e29df16fa2865f2702a64db2 (patch) | |
| tree | 92073e809cd18801eb77639829cbf3b5dabc2dbd /packages | |
| parent | ba9149a6474d0b4cb01c325acea1c83e04f22379 (diff) | |
| download | dispatch-4a71e0672f7433f2e29df16fa2865f2702a64db2.tar.gz dispatch-4a71e0672f7433f2e29df16fa2865f2702a64db2.zip | |
fix(openai-stream): add stream_options.include_usage to all requests
Without stream_options.include_usage, OpenAI-compatible providers omit
the usage field from the SSE stream entirely. Umans returned 0 tokens
for everything; OpenCode's proxy happened to include usage without it.
Now both providers return proper prompt_tokens + completion_tokens.
Note: Umans does not report cache_read_tokens or
prompt_tokens_details.cached_tokens — cache hit rate will be 0% for
Umans regardless. This is a provider limitation, not a parsing issue.
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/openai-stream/src/provider.test.ts | 1 | ||||
| -rw-r--r-- | packages/openai-stream/src/stream.ts | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/packages/openai-stream/src/provider.test.ts b/packages/openai-stream/src/provider.test.ts index 7b2d938..434c405 100644 --- a/packages/openai-stream/src/provider.test.ts +++ b/packages/openai-stream/src/provider.test.ts @@ -145,6 +145,7 @@ describe("transformBody", () => { model: "test-model", messages: [{ role: "user", content: "Hello" }], stream: true, + stream_options: { include_usage: true }, temperature: 0.5, max_tokens: 42, }); diff --git a/packages/openai-stream/src/stream.ts b/packages/openai-stream/src/stream.ts index 2916432..e801cc5 100644 --- a/packages/openai-stream/src/stream.ts +++ b/packages/openai-stream/src/stream.ts @@ -69,6 +69,7 @@ export async function* streamChat( model: opts?.model ?? config.model, messages: finalMessages, stream: true, + stream_options: { include_usage: true }, }; if (openaiTools.length > 0) { |
