Skip to content

feat: multi-protocol request translation across Anthropic/OpenAI/Gemini#40

Closed
ChasLui wants to merge 1 commit into
LiteLLM-Labs:mainfrom
ChasLui:feat-multi-protocol-translation
Closed

feat: multi-protocol request translation across Anthropic/OpenAI/Gemini#40
ChasLui wants to merge 1 commit into
LiteLLM-Labs:mainfrom
ChasLui:feat-multi-protocol-translation

Conversation

@ChasLui

@ChasLui ChasLui commented Jun 9, 2026

Copy link
Copy Markdown

@codex review

This is PR 1 of the split proposed in #39, carving the multi-protocol translation foundation out of the (now-closed) #38 so it can be reviewed on its own. Response caching follows as a separate stacked PR.

What this adds

A protocol-agnostic intermediate representation (IR) plus per-protocol codecs, so the gateway can accept a request in one wire format and route it to an upstream that speaks another:

  • Codecs: Anthropic Messages, OpenAI Chat Completions, OpenAI Responses, Gemini generateContent — each covering requests, responses, and streaming (SSE) in both directions.
  • Router: parses with the inbound codec, renders with the outbound codec. When both sides share a wire format the body is passed through untouched (fast path) to preserve the low-overhead goal.
  • Coverage: tool calls, reasoning/thinking, images, and usage normalization across providers.
  • Error fidelity: provider failures (non-2xx, HTTP-200 error bodies, Responses status:"failed", streamed error events) are surfaced in the inbound protocols native error shape rather than leaking as a clean success.
  • Endpoints: native OpenAI Chat Completions and Gemini routes, a multi-provider wildcard router, and an expanded provider catalog.
  • Docs: docs/protocols.md describes the translation model and its limits.

Scope / what is intentionally NOT here

  • Response caching (exact-match, redb/redis backends, semantic cache, litellm cache-config compat) — that is PR 2 per Break up #38 (multi-protocol translation + response caching) into smaller PRs #39.
  • Prompt-cache passthrough is kept here (it is part of protocol translation): Anthropic cache_control breakpoints ride through the IR and re-emit on Anthropic render; cache token usage is normalized and echoed in each protocols native shape. The opt-in auto-injection of breakpoints moves to PR 2 with the rest of the caching feature.

Verification

Each gate passes on this branch in isolation:

  • cargo fmt --check
  • cargo clippy --all-targets (no warnings)
  • cargo test (all suites green)
  • python3 scripts/check_code_size.py (<=300 lines/file, <=50 LOC/function)

Closes part of #39.

Add a protocol-agnostic intermediate representation (IR) plus per-protocol
codecs so the gateway can accept a request in one wire format and route it to
an upstream that speaks another. The router parses with the inbound codec and
renders with the outbound codec; when both sides share a wire format the body
is passed through untouched (fast path) to preserve low overhead.

Codecs implemented: Anthropic Messages, OpenAI Chat Completions, OpenAI
Responses, and Gemini generateContent — covering requests, responses, and
streaming (SSE) in each direction, including tool calls, reasoning/thinking,
images, and usage normalization. Provider failures (non-2xx, HTTP-200 error
bodies, Responses `status:"failed"`, streamed error events) are surfaced in
the inbound protocol's native error shape rather than leaking as a clean
success.

Also adds native endpoints for OpenAI Chat Completions and Gemini, a
multi-provider wildcard router, an expanded provider catalog, and
docs/protocols.md describing the translation model and its limits.

Response caching is intentionally excluded and will follow as a separate PR
(see LiteLLM-Labs#39).
@ChasLui ChasLui force-pushed the feat-multi-protocol-translation branch from 7ccbe1e to 5e2b5bf Compare June 9, 2026 16:21
@ChasLui

ChasLui commented Jun 9, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ccbe1ebb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .claude/skills/gitnexus Outdated
@@ -0,0 +1 @@
/Users/chao.liu/my-clone/github.com/ChasLui/litellm-rust/.claude/skills/gitnexus No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove absolute local tool symlinks

This committed symlink points to an author-specific /Users/chao.liu/... path, and the same pattern is used for the new .serena links. On any checkout outside that machine these entries are dangling, so tools or setup scripts that traverse .claude/skills or .serena will see broken repository contents; this also conflicts with the repo-wide CODING_STANDARDS.md guidance to keep local/tooling artifacts out of the root tree. Please remove these symlinks or generate/ignore them outside the committed tree.

Useful? React with 👍 / 👎.

@ChasLui ChasLui closed this Jun 10, 2026
@ChasLui ChasLui deleted the feat-multi-protocol-translation branch June 10, 2026 02:48
@ChasLui

ChasLui commented Jun 10, 2026

Copy link
Copy Markdown
Author

For the record: we've decided to maintain this as an independent fork rather than upstream the work, so this PR stays closed. Thanks for the reviews on #38.

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