You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ni...@apache.org on 2026/04/08 09:36:57 UTC

(apisix) branch feat/native-anthropic-messages-api created (now 6476ecd1f)

This is an automated email from the ASF dual-hosted git repository.

nic443 pushed a change to branch feat/native-anthropic-messages-api
in repository https://gitbox.apache.org/repos/asf/apisix.git


      at 6476ecd1f fix: use /anything/v1/messages in tests to avoid /v1/ control API conflict

This branch includes the following new commits:

     new 6476ecd1f fix: use /anything/v1/messages in tests to avoid /v1/ control API conflict

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(apisix) 01/01: fix: use /anything/v1/messages in tests to avoid /v1/ control API conflict

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nic443 pushed a commit to branch feat/native-anthropic-messages-api
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 6476ecd1fd6a3e04ada55531301099cf7d8d96dd
Author: Nic <qi...@api7.ai>
AuthorDate: Wed Apr 8 17:36:43 2026 +0800

    fix: use /anything/v1/messages in tests to avoid /v1/ control API conflict
    
    The APISIX test framework maps 'location /v1/' to http_control(),
    which intercepts all requests starting with /v1/ before they reach the
    APISIX router. This caused 404 for test requests to /v1/messages.
    
    Changed test URIs to /anything/v1/messages which avoids the conflict
    while still matching the Anthropic protocol detection (URI suffix check).
---
 t/plugin/ai-proxy-protocol-conversion.t | 46 ++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/t/plugin/ai-proxy-protocol-conversion.t b/t/plugin/ai-proxy-protocol-conversion.t
index a6ee0f2e2..99b95d08f 100644
--- a/t/plugin/ai-proxy-protocol-conversion.t
+++ b/t/plugin/ai-proxy-protocol-conversion.t
@@ -164,7 +164,7 @@ __DATA__
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -194,7 +194,7 @@ passed
 
 === TEST 2: Send Anthropic request to /v1/messages and verify protocol conversion
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 { "model": "claude-3-5-sonnet-20241022", "messages": [ { "role": "user","content": "hello" } ] }
 --- more_headers
 Authorization: Bearer token
@@ -206,7 +206,7 @@ qr/"text":"1 \+ 1 = 2\."/
 
 === TEST 3: Missing messages field returns 400
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 { "model": "claude-3-5-sonnet-20241022" }
 --- more_headers
 Authorization: Bearer token
@@ -218,7 +218,7 @@ Authorization: Bearer token
 
 === TEST 4: Malformed JSON body returns 400
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 this is not valid json
 --- more_headers
 Authorization: Bearer token
@@ -229,7 +229,7 @@ Content-Type: application/json
 
 === TEST 5: messages field is wrong type (non-array)
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 { "model": "claude-3-5-sonnet-20241022", "messages": "hello" }
 --- more_headers
 Authorization: Bearer token
@@ -241,7 +241,7 @@ Authorization: Bearer token
 
 === TEST 6: messages is an empty array
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 { "model": "claude-3-5-sonnet-20241022", "messages": [] }
 --- more_headers
 Authorization: Bearer token
@@ -259,7 +259,7 @@ Authorization: Bearer token
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -356,7 +356,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "claude-3-5-sonnet-20241022",
@@ -389,7 +389,7 @@ qr/event: message_start\ndata:.*?"type":"message_start".*?event: content_block_s
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -487,7 +487,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "claude-3-5-sonnet-20241022",
@@ -515,7 +515,7 @@ qr/"text":"system prompt ok"/
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -545,7 +545,7 @@ passed
 
 === TEST 12: Tool calling request/response conversion (Anthropic <-> OpenAI)
 --- request
-POST /v1/messages
+POST /anything/v1/messages
 {"model":"claude-3-5-sonnet-20241022","messages":[{"role":"user","content":"What is the weather in Paris?"}],"tools":[{"name":"get_weather","description":"Get weather","input_schema":{"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}}]}
 --- more_headers
 Authorization: Bearer token
@@ -564,7 +564,7 @@ qr/(?=.*"stop_reason":"tool_use")(?=.*"type":"tool_use")(?=.*"name":"get_weather
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -638,7 +638,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "gpt-4o",
@@ -691,7 +691,7 @@ OK: message_stop appeared exactly once
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -769,7 +769,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "gpt-4o",
@@ -836,7 +836,7 @@ OK: two finish_reason chunks handled correctly
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -914,7 +914,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "deepseek-chat",
@@ -968,7 +968,7 @@ OK: DeepSeek usage:null chunks handled correctly
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -1042,7 +1042,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "gpt-4o",
@@ -1156,7 +1156,7 @@ OK: sse.encode output ends with \n\n
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "gpt-4o",
@@ -1246,7 +1246,7 @@ OK: sse.encode edge cases passed
             local code, body = t('/apisix/admin/routes/1',
                  ngx.HTTP_PUT,
                  [[{
-                    "uri": "/v1/messages",
+                    "uri": "/anything/v1/messages",
                     "plugins": {
                         "ai-proxy": {
                             "provider": "openai",
@@ -1320,7 +1320,7 @@ passed
 
             local res, err = httpc:request({
                 method = "POST",
-                path = "/v1/messages",
+                path = "/anything/v1/messages",
                 headers = { ["Content-Type"] = "application/json", ["Connection"] = "close" },
                 body = [[{
                     "model": "gpt-4o",