Skip to content

feat: sync schemas v1.14.1 and accept standard OpenAI stream chunks - #182

Merged
edenreich merged 2 commits into
mainfrom
schemas-sync
Nov 17, 2026
Merged

edenreich merged 2 commits into
mainfrom
schemas-sync

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Deterministic type sync from inference-gateway/schemas at v1.14.1. The main effect is that CreateChatCompletionStreamResponse now accepts standard OpenAI stream chunks, which previously failed validation. The examples and README drop the raw-JSON workaround and go back to the typed model.

Closes #181

Generated changes (inference_gateway/models.py, openapi.yaml)

  • ChatCompletionStreamChoice.finish_reason is now optional and nullable (FinishReason | None = None). It is null on every chunk except the last one of a choice
  • ChatCompletionStreamChoice.logprobs now uses a new Logprobs1 class whose content and refusal are nullable
  • ChatCompletionStreamResponseDelta.content and .role are now optional, and content and refusal are nullable
  • MessagesResponse.stop_reason adds the model_context_window_exceeded value and its description now documents that it is only null in the streaming message_start event

Hand-written follow-up

  • tests/test_client.py - removed the strict xfail on test_stream_response_delta_allows_missing_content (it started passing, which failed the suite) and added parametrized tests for a chunk with "finish_reason": null and no role, a chunk with null content and refusal, and an empty final delta
  • examples/chat/main.py, examples/chat/README.md, README.md - validate chunks with CreateChatCompletionStreamResponse again and drop the notes saying the model rejects standard chunks

Type verification

  • openapi.yaml is byte-identical to the upstream spec at tag v1.14.1
  • Re-running task generate SCHEMAS_REF=refs/tags/v1.14.1 on this branch produces no diff, so models.py is exactly what the generator emits for this spec
  • Every change in models.py corresponds to a change in the spec diff. There are no stray edits
  • Neither Logprobs nor Logprobs1 is exported from inference_gateway/__init__.py, which matches the state on main, so no export changes are needed

API compatibility

  • delta.role, delta.content and choice.finish_reason can now be None. Code that read them without a None check can now see None on chunks that previously raised a validation error instead
  • The stream choice logprobs type was renamed from Logprobs to the generated Logprobs1. Same fields, but nullable now. Logprobs is still used by the non-streaming choice. Neither class is part of the public __init__ exports
  • MessagesResponse.stop_reason has a new literal value, model_context_window_exceeded

Tests run

  • task test - 57 passed
  • task lint - black, isort and mypy clean
  • Examples were not run against a live gateway

@edenreich

Copy link
Copy Markdown
Contributor

@claude can you fix the tests and prepare this PR for a review? #181

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 2m 9s —— View job


Fixed the tests - PR is ready for review

  • Read issue [FEATURE] Regenerate models for relaxed chat stream chunk schema #181 and the PR diff
  • Run tests - 53 passed and 1 failed. test_stream_response_delta_allows_missing_content had a strict xfail marker, and it started passing (which counts as a failure) because the regenerated models fixed the bug it was tracking
  • Removed that stale xfail marker and added tests for the cases the issue asks for (a chunk with "finish_reason": null and no role, a chunk with null content and refusal, and an empty final delta)
  • Reverted the raw-JSON workaround in examples/chat/main.py, examples/chat/README.md and README.md so they read chunks through CreateChatCompletionStreamResponse again
  • Lint and commit (92b7c48)
  • Updated the PR description: summary, Closes #181, compatibility notes and the tests I ran

Summary

All of #181 is now covered. task test passes (57 tests) and task lint passes (black, isort and mypy).

API compatibility (for the reviewer):

  • delta.role, delta.content and choice.finish_reason in stream chunks can now be None.
  • The logprobs type on stream choices was renamed from Logprobs to the generated Logprobs1, and its fields can now be null.
  • MessagesResponse.stop_reason has a new value, model_context_window_exceeded.

Not done: I didn't run the examples against a live gateway.

In the README snippet, a chunk that fails validation now raises an error instead of being skipped. Skipping those chunks is what made the old example print nothing without any error.

Drop the strict xfail marker now that the regenerated delta model
accepts missing content, add parse tests for standard OpenAI chunks,
and revert the raw-JSON streaming workaround in the examples.

Closes #181

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor

@claude [model:claude-fable-5-1] [effort:medium] can you make sure all types are correct now? can you also update the PR description and title to reflect on the change?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 3m 24s —— View job


Types verified, PR title and description updated

  • Compare inference_gateway/models.py against openapi.yaml for the changed schemas
  • Regenerate models from the pinned spec and confirm no drift
  • Run task test and task lint
  • Update PR title and description

What I checked

  • Spec is exact. openapi.yaml on this branch is byte-identical to inference-gateway/schemas at tag v1.14.1.
  • Generated code is exact. task generate SCHEMAS_REF=refs/tags/v1.14.1 on this branch produces no diff, so models.py is precisely what the generator emits. Every change in the model diff maps to a change in the spec diff: nullable finish_reason, optional/nullable delta.content and delta.role, nullable delta.refusal, the new Logprobs1 with nullable fields, and the new model_context_window_exceeded stop reason.
  • Exports are consistent. Neither Logprobs nor Logprobs1 was ever exported from inference_gateway/__init__.py, so no export change is needed.
  • Checks pass. task test - 57 passed. task lint - black, isort and mypy clean.

PR metadata

  • Title is now feat: sync schemas v1.14.1 and accept standard OpenAI stream chunks
  • Description now leads with the user-facing effect (typed stream model accepts standard chunks), lists the generated vs hand-written changes, documents the verification above, and keeps the compatibility notes

No code changes were needed, so nothing new was committed.

Not done: examples were not run against a live gateway.

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title feat: sync generated types with schemas v1.14.1 feat: sync schemas v1.14.1 and accept standard OpenAI stream chunks Nov 17, 2026
@edenreich
edenreich merged commit d4e2634 into main Nov 17, 2026
1 check passed
@edenreich
edenreich deleted the schemas-sync branch November 17, 2026 20:54
inference-gateway-releaser Bot added a commit that referenced this pull request Nov 17, 2026
## [0.26.0](v0.25.0...v0.26.0) (2026-11-17)

### ✨ Features

* sync schemas v1.14.1 and accept standard OpenAI stream chunks ([#182](#182)) ([d4e2634](d4e2634)), closes [#181](#181)

### 🐛 Bug Fixes

* allow null stop_reason in Messages stream message_start ([#179](#179)) ([cb9440e](cb9440e))
* read stream chunks as JSON in chat examples ([#178](#178)) ([fca4630](fca4630)), closes [#172](#172)

### 👷 CI

* align Dependabot schedule and grouping ([#169](#169)) ([3f5ad19](3f5ad19))
* set up orchestrators from repos.yaml ([#170](#170)) ([bffe983](bffe983))

### 📚 Documentation

* add audio example for speech, sfx and music ([#176](#176)) ([c1f04d0](c1f04d0))
* add Responses API example and README section ([#180](#180)) ([ec0e02a](ec0e02a))
* sync examples and README with gateway config ([#177](#177)) ([ee0999d](ee0999d))

### 🔧 Miscellaneous

* **deps:** bump flox dependencies to latest ([#167](#167)) ([55f32c5](55f32c5))
* **deps:** bump flox dependencies to latest ([#168](#168)) ([de020e9](de020e9))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.26.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 17, 2026
@edenreich edenreich moved this from QA to Done in 2026 Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot Opened by an org automation released Shipped in a release schema sync

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Regenerate models for relaxed chat stream chunk schema

1 participant