iakuf opened a new pull request, #13050:
URL: https://github.com/apache/apisix/pull/13050

   ## Summary
   
   Add a new `anthropic-native` driver that speaks the native Anthropic 
Messages API protocol (`/v1/messages`) directly.
   
   The existing `anthropic` provider uses the OpenAI-compatible driver, which 
works for basic use cases but cannot handle Anthropic-specific protocol 
details. The new `anthropic-native` provider addresses this.
   
   ## Key differences from `openai-base` driver
   
   - **SSE event types**: handles `message_start`, `content_block_delta`, 
`message_delta`, `message_stop` (no `[DONE]` sentinel)
   - **Token usage fields**: reads `input_tokens`/`output_tokens` instead of 
`prompt_tokens`/`completion_tokens`
   - **Request format**: removes `stream_options` (not supported by Anthropic), 
injects `anthropic-version` header automatically
   - **Response format**: extracts text from `content[].text` array instead of 
`choices[].message.content`
   - **System prompt**: accepts top-level `system` field and flexible `content` 
types (string or array of content blocks)
   
   ## Changes
   
   - `apisix/plugins/ai-drivers/anthropic-native.lua`: new driver implementation
   - `apisix/plugins/ai-drivers/schema.lua`: register `anthropic-native` 
provider with its own request schema
   - `t/assets/anthropic-native-response.json`: mock response fixture for tests
   - `t/plugin/ai-proxy-multi.anthropic-native.t`: 26 test cases covering 
non-streaming, streaming, token usage, TTFT, error handling, and schema 
validation
   - `docs/en/latest/plugins/ai-proxy-multi.md`: document the new provider with 
a usage example
   
   ## Testing
   
   All 26 tests pass:
   


-- 
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