Skip to content

docs(mistral): reuse the OpenAI adapter for Responses streams - #104

Merged
Kinfe123 merged 2 commits into
mainfrom
docs/mistral-responses-integration
Oct 30, 2026
Merged

Kinfe123 merged 2 commits into
mainfrom
docs/mistral-responses-integration

Conversation

@Kinfe123

Copy link
Copy Markdown
Collaborator

Problem

Mistral's Responses API uses OpenAI-style tool events, but passing an @mistralai/mistralai@3.4.0 stream directly to streamfold/openai produces no updates. Unwrapping frame.data alone still drops argument deltas and ends with EMPTY_INPUT, because the SDK converts the wire's item_id to itemId.

Root cause

The existing adapter consumes decoded OpenAI events with snake-case argument identifiers. Mistral's SDK exposes a frame envelope and camel-case identifiers.

Change

Add a small copyable example that unwraps the frame, normalizes the two argument-event identifiers, and delegates to the existing OpenAI adapter through readStructured. It preserves immutable previews and managed iterator cleanup without introducing another stateful adapter.

Add the Mistral SDK as a development dependency for real decoder and consumer-type coverage. The published package gains no dependencies or exports. Document use, item IDs, cancellation, and the application-owned validation and response-status responsibilities.

Verification

  • node --test examples/mistral.test.mjs: both cases pass. The real SDK decodes wire SSE into interleaved calls; assertions cover IDs, final values, retained immutable partial values, and cancelling the response body on early exit.
  • Removing only the itemId conversion makes the interleaved replay fail with EMPTY_INPUT for call a; restoring it passes.
  • pnpm typecheck: passes, including a consumer of the actual client.responses.create() return type.
  • pnpm release:check: passes, including 199 JavaScript tests, 11 Rust tests, syntax/type checks, Rust formatting/lints, and package dry run.

No credentials or live model requests were used. This PR makes no end-to-end performance claim.

Public surface

Documentation and an example only. No published source, declarations, exports, or runtime dependencies change.

@Kinfe123 Kinfe123 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, mistral sdk frames reuse the adapter with tested cleanup.

@Kinfe123
Kinfe123 merged commit 013b3fa into main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant