nic-6443 opened a new pull request, #13186:
URL: https://github.com/apache/apisix/pull/13186

   ## Description
   
   Add protocol adapter for OpenAI Responses API, enabling ai-proxy and related 
AI plugins to handle `/v1/responses` endpoints with both streaming (SSE named 
events) and non-streaming modes.
   
   ### Production changes
   
   - **New protocol**: `ai-protocols/openai-responses.lua` (315 lines)
     - `matches()` detects Response API by URI + `body.input`
     - `parse_sse_event()` handles named SSE events 
(`response.output_text.delta`, `response.completed`, `response.failed`)
     - `extract_usage()` maps `input_tokens`/`output_tokens`
     - `build_deny_response()` generates Response API format errors
     - `get_messages()` returns instructions + input for content checking
   - **Protocol registry**: Register `openai-responses` in 
`ai-protocols/init.lua` detection order (before `openai-chat`, since both check 
body but responses also checks URI)
   - **Provider capabilities**: Add `openai-responses` capability with 
`/v1/responses` path to `openai` and `openai-compatible` providers
   - **Prompt guard fix**: Skip `get_content_to_check` for Response API in 
`ai-prompt-guard.lua` (instructions + input are parallel fields, not 
conversation history)
   
   ### Test coverage (5 test files updated)
   
   | Test file | Coverage |
   |-----------|----------|
   | `ai-proxy.t` | Basic routing, non-streaming passthrough with usage 
extraction, streaming SSE passthrough |
   | `ai-prompt-guard.t` | Deny/allow patterns for string input, instructions, 
array input; `match_all_roles` true/false behavior |
   | `ai-prompt-decorator.t` | Prepend sets instructions, append modifies input 
(string and array), combined prepend+append |
   | `ai-rag.t` | RAG result injection appended to Response API input |
   | `ai-aliyun-content-moderation.t` | Content moderation for violent input, 
Response API format deny response, streaming SSE deny format, `input_tokens` 
usage format, nil-schema fix for non-openai providers |
   
   ### Technical notes
   
   - Response API is implemented as passthrough (no protocol conversion 
needed), just SSE event model adaptation
   - Protocol detection order matters: `openai-responses` must come before 
`openai-chat` (both check body, but responses also checks URI)
   - SSE transport layer already supports named events, no modification needed
   - All test files include `BEGIN { $ENV{TEST_ENABLE_CONTROL_API_V1} = "0"; }` 
to prevent `/v1/responses` route conflict with control API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to