ollama - ✅(Solved) Fix OpenAPI spec: ChatStreamEvent missing usage fields in final chunk [2 pull requests, 6 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14680Fetched 2026-04-08 00:33:01
View on GitHub
Comments
6
Participants
3
Timeline
20
Reactions
0
Timeline (top)
commented ×6cross-referenced ×4mentioned ×3subscribed ×3

The OpenAPI spec at docs/openapi.yaml defines ChatStreamEvent with only 4 fields: model, created_at, message, done.

However, the Ollama API sends additional usage/timing fields in the final streaming chunk (when done: true), just like it does for GenerateStreamEvent and ChatResponse. These fields are missing from the ChatStreamEvent schema:

  • done_reason
  • total_duration
  • load_duration
  • prompt_eval_count
  • prompt_eval_duration
  • eval_count
  • eval_duration

Root Cause

The OpenAPI spec at docs/openapi.yaml defines ChatStreamEvent with only 4 fields: model, created_at, message, done.

However, the Ollama API sends additional usage/timing fields in the final streaming chunk (when done: true), just like it does for GenerateStreamEvent and ChatResponse. These fields are missing from the ChatStreamEvent schema:

  • done_reason
  • total_duration
  • load_duration
  • prompt_eval_count
  • prompt_eval_duration
  • eval_count
  • eval_duration

Fix Action

Fixed

PR fix notes

PR #80: feat(ollama_dart): add missing fields to response models

Description (problem / solution / changelog)

Summary

  • ChatStreamEvent: Add usage/timing fields (doneReason, totalDuration, loadDuration, promptEvalCount, promptEvalDuration, evalCount, evalDuration) and logprobs — these are sent by Ollama in the final streaming chunk but were missing from our type, forcing users to parse raw NDJSON
  • ChatResponse, GenerateResponse, GenerateStreamEvent: Add remoteModel and remoteHost for Ollama's remote/proxy model routing
  • ModelSummary: Add model, remoteModel, and remoteHost

All fields verified against Ollama's Go source. The upstream OpenAPI spec is missing these fields on ChatStreamEvent — filed https://github.com/ollama/ollama/issues/14680.

Test plan

  • dart analyze passes with zero warnings
  • All unit tests pass
  • api-toolkit verify passes (no errors)
<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/davidmigloz/ai_clients_dart/pull/80" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->

Changed files

  • packages/ollama_dart/lib/src/models/chat/chat_response.dart (modified, +20/-0)
  • packages/ollama_dart/lib/src/models/chat/chat_stream_event.dart (modified, +75/-2)
  • packages/ollama_dart/lib/src/models/completions/generate_response.dart (modified, +20/-0)
  • packages/ollama_dart/lib/src/models/completions/generate_stream_event.dart (modified, +12/-0)
  • packages/ollama_dart/lib/src/models/models/model_summary.dart (modified, +29/-1)

PR #14717: Added : OpenAPI spec: ChatStreamEvent missing usage fields in final chunk #14680

Description (problem / solution / changelog)

The ChatStreamEvent schema in docs/openapi.yaml now includes all 8 missing fields (done_reason, total_duration, load_duration, prompt_eval_count, prompt_eval_duration, eval_count, eval_duration, logprobs) — matching what the API actually returns in the final streaming chunk. Resolves #14680

Changed files

  • docs/openapi.yaml (modified, +31/-0)
RAW_BUFFERClick to expand / collapse

Description

The OpenAPI spec at docs/openapi.yaml defines ChatStreamEvent with only 4 fields: model, created_at, message, done.

However, the Ollama API sends additional usage/timing fields in the final streaming chunk (when done: true), just like it does for GenerateStreamEvent and ChatResponse. These fields are missing from the ChatStreamEvent schema:

  • done_reason
  • total_duration
  • load_duration
  • prompt_eval_count
  • prompt_eval_duration
  • eval_count
  • eval_duration

Current state

SchemaHas usage fields?
GenerateResponse
GenerateStreamEvent
ChatResponse
ChatStreamEvent❌ (missing)

Expected

ChatStreamEvent should include the same usage fields as GenerateStreamEvent, since the API returns them in the final chunk.

Impact

SDK generators that rely on the OpenAPI spec produce types that can't capture usage metrics from chat streaming responses, forcing users to bypass the typed API and parse raw NDJSON.

extent analysis

Fix Plan

To fix the issue, we need to update the ChatStreamEvent schema in the OpenAPI spec to include the missing usage fields.

  • Update the docs/openapi.yaml file to add the following fields to the ChatStreamEvent schema:
    • done_reason
    • total_duration
    • load_duration
    • prompt_eval_count
    • prompt_eval_duration
    • eval_count
    • eval_duration

Example code snippet:

components:
  schemas:
    ChatStreamEvent:
      type: object
      properties:
        model:
          type: string
        created_at:
          type: string
        message:
          type: string
        done:
          type: boolean
        done_reason:
          type: string
        total_duration:
          type: number
        load_duration:
          type: number
        prompt_eval_count:
          type: integer
        prompt_eval_duration:
          type: number
        eval_count:
          type: integer
        eval_duration:
          type: number

Verification

To verify that the fix worked, regenerate the SDKs using the updated OpenAPI spec and check that the ChatStreamEvent type includes the added usage fields.

Extra Tips

  • Make sure to update any dependent code or documentation that relies on the ChatStreamEvent schema.
  • Consider adding tests to ensure that the updated schema is correctly parsed and used by the SDKs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING