[PR #15208] Add token usage for cloud model streaming (inject stream_options.include_usage) #25616

Open
opened 2026-04-19 18:18:49 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15208
Author: @mahendrarathore1742
Created: 4/2/2026
Status: 🔄 Open

Base: mainHead: fix/cloud-stream-usage


📝 Commits (1)

  • f35c1e2 Add usage stats to cloud streaming

📊 Changes

2 files changed (+92 additions, -0 deletions)

View changed files

📝 server/cloud_proxy.go (+50 -0)
📝 server/routes_cloud_test.go (+42 -0)

📄 Description

Inject include_usage stream_options for proxied OpenAI streaming requests when missing. Add a cloud passthrough test to ensure usage options are forwarded for stream=true chat completions.

Summary:

  • Ensure cloud OpenAI-compatible streaming requests include token usage by injecting stream_options.include_usage=true when stream:true and no stream options are provided.
  • Files changed: cloud_proxy.go, routes_cloud_test.go
  • Tests: added a proxy test that verifies stream_options.include_usage is forwarded for stream:true chat completions.
  • Note: Local full test run can fail in minimal environments due to native linker requirements; server tests pass. CI should run the full suite.

Closes: #15169


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15208 **Author:** [@mahendrarathore1742](https://github.com/mahendrarathore1742) **Created:** 4/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cloud-stream-usage` --- ### 📝 Commits (1) - [`f35c1e2`](https://github.com/ollama/ollama/commit/f35c1e2ebf43ebbd20ee7466390c83ba2057dd1d) Add usage stats to cloud streaming ### 📊 Changes **2 files changed** (+92 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/cloud_proxy.go` (+50 -0) 📝 `server/routes_cloud_test.go` (+42 -0) </details> ### 📄 Description Inject include_usage stream_options for proxied OpenAI streaming requests when missing. Add a cloud passthrough test to ensure usage options are forwarded for stream=true chat completions. Summary: - Ensure cloud OpenAI-compatible streaming requests include token usage by injecting stream_options.include_usage=true when [stream:true](vscode-file://vscode-app/home/msr/Desktop/VSCode-linux-x64/resources/app/out/vs/code/electron-browser/workbench/workbench.html) and no stream options are provided. - Files changed: [cloud_proxy.go](vscode-file://vscode-app/home/msr/Desktop/VSCode-linux-x64/resources/app/out/vs/code/electron-browser/workbench/workbench.html), [routes_cloud_test.go](vscode-file://vscode-app/home/msr/Desktop/VSCode-linux-x64/resources/app/out/vs/code/electron-browser/workbench/workbench.html) - Tests: added a proxy test that verifies stream_options.include_usage is forwarded for [stream:true](vscode-file://vscode-app/home/msr/Desktop/VSCode-linux-x64/resources/app/out/vs/code/electron-browser/workbench/workbench.html) chat completions. - Note: Local full test run can fail in minimal environments due to native linker requirements; server tests pass. CI should run the full suite. Closes: #15169 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:18:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25616