Skip to content

feat(ai-proxy): add passthrough protocol for unrecognized API formats#13320

Open
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
shreemaan-abhishek:feat/ai-proxy-passthrough-protocol
Open

feat(ai-proxy): add passthrough protocol for unrecognized API formats#13320
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
shreemaan-abhishek:feat/ai-proxy-passthrough-protocol

Conversation

@shreemaan-abhishek
Copy link
Copy Markdown
Contributor

Description

The ai-proxy plugin currently rejects any request whose body does not match a known protocol (openai-chat, openai-responses, openai-embeddings, anthropic-messages, bedrock-converse), making it impossible to proxy OpenAI-compatible APIs whose body shape isn't recognized — for example /v1/images/generations, whose {prompt, model, n, size} body matches no existing matcher. This PR adds a passthrough protocol adapter that is registered last in the detection order and matches any non-empty JSON body, acting as a catch-all. When selected, the plugin forwards the request body unchanged to the upstream using ctx.var.uri (or override.endpoint when configured) as the target path; only model rewrite (options.model), auth header injection (auth.header), and endpoint override (override.endpoint) are applied. All other protocol hooks (SSE parsing, usage extraction, message manipulation, response text extraction) return safe no-op values, so passthrough imposes zero parsing cost and stays out of the way of arbitrary upstream payloads.

Which issue(s) this PR fixes:

Fixes #

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants