Skip to content

fix(gateway): handle deepinfra in streaming transform - #2663

Merged
steebchen merged 1 commit into
mainfrom
fix-deepinfra-streaming-fallback
Jun 13, 2026
Merged

steebchen merged 1 commit into
mainfrom
fix-deepinfra-streaming-fallback

Conversation

@steebchen

@steebchen steebchen commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

Problem

Streaming requests routed to DeepInfra logged a warning on every chunk:

WARN (llmgateway): [streaming] Unknown provider using OpenAI fallback
    provider: "deepinfra"
    model: "glm-5.1"

DeepInfra uses the OpenAI-compatible /chat/completions endpoint, but deepinfra was missing from the provider switch in transform-streaming-to-openai.ts. Every streamed chunk fell through to the default case, which still works (it applies the same OpenAI transform) but emits a noisy warning per chunk.

Fix

Add deepinfra to the OpenAI-compatible case list alongside the other OpenAI-compatible providers (together-ai, inference.net, etc.), so chunks are handled explicitly and the warning is no longer logged.

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Improved streaming response handling for the DeepInfra provider by normalizing finish reason values to align with OpenAI's standard format, ensuring consistent behavior across all supported providers.

DeepInfra uses the OpenAI-compatible /chat/completions endpoint but was
missing from the provider switch in transform-streaming-to-openai, so every
streamed chunk fell through to the default case and logged
'Unknown provider using OpenAI fallback'. Add it to the OpenAI-compatible
case list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d61c51c4-773e-4ba6-a3a0-a72705036f24

📥 Commits

Reviewing files that changed from the base of the PR and between 0b4f031 and 1588c1a.

📒 Files selected for processing (1)
  • apps/gateway/src/chat/tools/transform-streaming-to-openai.ts

Walkthrough

The PR adds the "deepinfra" provider to the OpenAI-compatible streaming transformation in the switch case, allowing it to use transformOpenaiStreaming and normalize non-standard finish_reason values the same way as other compatible providers.

Changes

DeepInfra streaming provider integration

Layer / File(s) Summary
DeepInfra OpenAI streaming integration
apps/gateway/src/chat/tools/transform-streaming-to-openai.ts
DeepInfra provider is added to the OpenAI streaming transformation, applying finish-reason normalization (end_turn→stop, abort→canceled, tool_use→tool_calls).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • theopenco/llmgateway#2244: Both PRs adjust finish_reason handling for upstream "abort" during OpenAI-compatible streaming in apps/gateway/src/chat/tools/transform-streaming-to-openai.ts (one adds deepinfra to the same transform/mapping flow; the other adds warning logging when "abort" becomes "canceled").
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding DeepInfra provider handling to the streaming transform function.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-deepinfra-streaming-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@steebchen
steebchen added this pull request to the merge queue Jun 13, 2026
Merged via the queue into main with commit ac3d317 Jun 13, 2026
17 of 18 checks passed
@steebchen
steebchen deleted the fix-deepinfra-streaming-fallback branch June 13, 2026 13:23
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