[PR #14875] [CLOSED] docs(openapi): add missing usage fields to ChatStreamEvent #77181

Closed
opened 2026-05-05 09:52:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14875
Author: @BillionClaw
Created: 3/16/2026
Status: Closed

Base: mainHead: clawoss/docs/chat-stream-event-usage-fields


📝 Commits (1)

  • 223633d docs(openapi): add missing usage fields to ChatStreamEvent

📊 Changes

1 file changed (+21 additions, -0 deletions)

View changed files

📝 docs/openapi.yaml (+21 -0)

📄 Description

Summary

The OpenAPI specification for ChatStreamEvent was missing the usage/timing fields that the API actually sends in the final streaming chunk (when done: true).

What was incorrect in the spec

The ChatStreamEvent schema only defined 4 fields: model, created_at, message, and done.

However, the Ollama API sends additional usage/timing fields in the final streaming chunk, similar to GenerateStreamEvent and ChatResponse.

What's now correct

Added the following 7 fields to ChatStreamEvent:

Field Type Description
done_reason string Reason the response finished
total_duration integer Total time spent generating in nanoseconds
load_duration integer Time spent loading the model in nanoseconds
prompt_eval_count integer Number of tokens in the prompt
prompt_eval_duration integer Time spent evaluating the prompt in nanoseconds
eval_count integer Number of tokens generated in the response
eval_duration integer Time spent generating tokens in nanoseconds

Verification

Verified by examining the Go source code (api/types.go):

  • ChatResponse struct embeds Metrics which contains all these fields
  • GenerateStreamEvent already has these fields in the spec
  • The API behavior is consistent across streaming and non-streaming responses

YAML syntax validated with Python yaml.safe_load().

Fixes #14680


CLA Confirmation:

I have read, understood, and agree to the Ollama Contributor License Agreement (CLA). I understand that this contribution may be used under the terms of the MIT license.


🔄 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/14875 **Author:** [@BillionClaw](https://github.com/BillionClaw) **Created:** 3/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `clawoss/docs/chat-stream-event-usage-fields` --- ### 📝 Commits (1) - [`223633d`](https://github.com/ollama/ollama/commit/223633d3a0d4ec43d90e50624d56d1ead0755b95) docs(openapi): add missing usage fields to ChatStreamEvent ### 📊 Changes **1 file changed** (+21 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/openapi.yaml` (+21 -0) </details> ### 📄 Description ## Summary The OpenAPI specification for `ChatStreamEvent` was missing the usage/timing fields that the API actually sends in the final streaming chunk (when `done: true`). ## What was incorrect in the spec The `ChatStreamEvent` schema only defined 4 fields: `model`, `created_at`, `message`, and `done`. However, the Ollama API sends additional usage/timing fields in the final streaming chunk, similar to `GenerateStreamEvent` and `ChatResponse`. ## What's now correct Added the following 7 fields to `ChatStreamEvent`: | Field | Type | Description | |-------|------|-------------| | `done_reason` | string | Reason the response finished | | `total_duration` | integer | Total time spent generating in nanoseconds | | `load_duration` | integer | Time spent loading the model in nanoseconds | | `prompt_eval_count` | integer | Number of tokens in the prompt | | `prompt_eval_duration` | integer | Time spent evaluating the prompt in nanoseconds | | `eval_count` | integer | Number of tokens generated in the response | | `eval_duration` | integer | Time spent generating tokens in nanoseconds | ## Verification Verified by examining the Go source code (`api/types.go`): - `ChatResponse` struct embeds `Metrics` which contains all these fields - `GenerateStreamEvent` already has these fields in the spec - The API behavior is consistent across streaming and non-streaming responses YAML syntax validated with Python yaml.safe_load(). Fixes #14680 --- **CLA Confirmation:** I have read, understood, and agree to the Ollama Contributor License Agreement (CLA). I understand that this contribution may be used under the terms of the MIT license. --- <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-05-05 09:52:09 -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#77181