docs: clarify AI request protocol handling - #13731
Open
kayx23 wants to merge 7 commits into
Open
Conversation
kayx23
requested review from
Baoyuantop,
Yilialinn,
juzhiyuan,
moonming and
shreemaan-abhishek
and removed request for
Baoyuantop and
shreemaan-abhishek
July 24, 2026 09:11
juzhiyuan
previously approved these changes
Jul 24, 2026
Yilialinn
previously approved these changes
Aug 4, 2026
There was a problem hiding this comment.
Pull request overview
This PR updates the English and Chinese documentation for APISIX AI plugins to more consistently explain how overlapping AI request formats are detected (URI-suffix-first vs body-only), how providers map detected protocols to upstream endpoints (notably OpenAI Responses vs Embeddings), and how related AI plugins behave for each protocol (rewrite/template/guard/decorator/RAG/cache/moderation).
Changes:
- Document request protocol detection order (Bedrock Converse / Anthropic Messages / OpenAI Responses / Chat Completions / Embeddings / passthrough) and required URI suffix behavior.
- Clarify provider endpoint selection (OpenAI auto-selects Responses vs Embeddings endpoints; remove redundant Embeddings endpoint overrides) and add Responses API examples for
ai-proxy/ai-proxy-multi. - Clarify protocol-specific behavior across plugins (RAG, prompt guard/decorator, cache, Lakera Guard, AWS/Aliyun moderation) and that
ai-prompt-templatereplaces the entire request body with an arbitrary rendered JSON template.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/en/latest/plugins/ai-request-rewrite.md | Clarifies rewrite call independence from client protocol; documents non-streaming constraints. |
| docs/zh/latest/plugins/ai-request-rewrite.md | Same as English, localized. |
| docs/en/latest/plugins/ai-rag.md | Documents protocol-aware enrichment behavior and URI-first detection order. |
| docs/zh/latest/plugins/ai-rag.md | Same as English, localized. |
| docs/en/latest/plugins/ai-proxy.md | Adds protocol detection order + Responses API routing/examples; updates provider endpoint explanations. |
| docs/zh/latest/plugins/ai-proxy.md | Same as English, localized. |
| docs/en/latest/plugins/ai-proxy-multi.md | Adds protocol detection order + Responses API load-balancing example; updates provider endpoint explanations. |
| docs/zh/latest/plugins/ai-proxy-multi.md | Same as English, localized. |
| docs/en/latest/plugins/ai-prompt-template.md | Clarifies full-body replacement semantics; adds Responses web-search template example. |
| docs/zh/latest/plugins/ai-prompt-template.md | Same as English, localized. |
| docs/en/latest/plugins/ai-prompt-guard.md | Documents protocol-specific inspection behavior + detection order. |
| docs/zh/latest/plugins/ai-prompt-guard.md | Same as English, localized. |
| docs/en/latest/plugins/ai-prompt-decorator.md | Documents protocol-specific decoration behavior + detection order. |
| docs/zh/latest/plugins/ai-prompt-decorator.md | Same as English, localized. |
| docs/en/latest/plugins/ai-lakera-guard.md | Clarifies protocol coverage and request/response scanning behavior. |
| docs/zh/latest/plugins/ai-lakera-guard.md | Same as English, localized. |
| docs/en/latest/plugins/ai-cache.md | Clarifies exact-vs-semantic cache applicability across protocols. |
| docs/zh/latest/plugins/ai-cache.md | Same as English, localized. |
| docs/en/latest/plugins/ai-aws-content-moderation.md | Documents supported protocols and protocol-native extraction/deny formatting. |
| docs/zh/latest/plugins/ai-aws-content-moderation.md | Same as English, localized. |
| docs/en/latest/plugins/ai-aliyun-content-moderation.md | Documents supported protocols + URI-first detection order and format-specific behavior. |
| docs/zh/latest/plugins/ai-aliyun-content-moderation.md | Same as English, localized. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Several AI request formats share the same body fields: Bedrock Converse, Anthropic Messages, and OpenAI Chat Completions can contain
messages, while OpenAI Responses and Embeddings both useinput. APISIX resolves these overlaps by checking URI-specific formats before body-only formats, but the plugin documentation did not explain the detection order, required URI suffixes, or downstream endpoint selection consistently.The related AI plugins also handle the detected formats differently. Some inspect or modify each protocol's native content structure, while
ai-prompt-templatereplaces the complete request body andai-request-rewritecreates a separate provider request. The previous prompt-template description incorrectly limited templates to Chat Completions even though the plugin accepts any JSON template supported by the downstream plugin.This PR updates the English and Chinese plugin references to:
ai-proxyandai-proxy-multiai-prompt-templatereplaces the incoming body with an arbitrary rendered JSON templateapisix.apache.organd shows the resolved request and cited responseai-request-rewritecreates a separate non-streaming provider request instead of classifying and proxying the client's request as an AI protocolWhich issue(s) this PR fixes:
N/A
Validation
markdownlinton all changed pagesutils/fix-zh-doc-segment.pyandutils/check-category.pygit diff --checkChecklist