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

   ### Description
   
   This PR adds [Eden AI](https://www.edenai.co/docs) as a first-class `edenai` 
provider for `ai-proxy`, `ai-proxy-multi` and `ai-request-rewrite`.
   
   Eden AI is an AI gateway that fronts many LLM providers behind one 
OpenAI-compatible API at `https://api.edenai.run/v3`, with models addressed as 
`provider/model` (e.g. `openai/gpt-latest`). It can already be reached today 
with `provider: openai-compatible` plus a full `override.endpoint`, but that 
only serves one endpoint path per instance, gives `ai-proxy-multi` no default 
host for health checks, requires repeating the endpoint in 
`ai-request-rewrite`, and converts Anthropic-format clients instead of passing 
them through. A first-class provider removes all of that with a declarative 
module, following the same pattern as the `openrouter`, `gemini` and `aimlapi` 
providers.
   
   **What the provider declares** (`apisix/plugins/ai-providers/edenai.lua`)
   
   | Client protocol | Eden AI endpoint | `llm_options.max_tokens` maps to |
   |---|---|---|
   | `openai-chat` | `/v3/chat/completions` | `max_tokens` |
   | `openai-responses` | `/v3/responses` | `max_output_tokens` |
   | `openai-embeddings` | `/v3/embeddings` | — |
   | `anthropic-messages` | `/v3/v1/messages` (native pass-through) | 
`max_tokens` |
   
   Host `api.edenai.run`, port 443. Authentication is the existing 
`auth.header` with `Authorization: Bearer <key>`; no new auth scheme, no 
`provider_conf`, no changes to the shared pipeline. Request bodies are 
forwarded as sent except for the `max_tokens` mapping above and the 
`stream_options.include_usage` injection every OpenAI-chat provider already 
gets.
   
   **Verified against the live Eden AI API** (sandbox token, requests shaped 
exactly as the plugin builds them):
   
   - All four endpoints accept bearer-only auth and return the expected shapes; 
`/v1/chat/completions` on that host is a 404, which is why `openai-compatible` 
with a host-only override cannot be used.
   - Both `max_tokens` and `max_completion_tokens` are accepted on chat; the 
provider writes `max_tokens`.
   - Streamed chat returns a `usage` chunk before `data: [DONE]` when 
`stream_options.include_usage` is set, so streamed token counts are extracted.
   - Anthropic Messages streams carry proper `event:` names (`message_start` … 
`message_stop`) and parse fully.
   - Error responses are JSON (`401`/`403` `detail`, `422` `detail`+`errors`, 
`400` `error` object) and pass through unchanged.
   
   **Files**
   
   - `apisix/plugins/ai-providers/edenai.lua` (new), 
`apisix/plugins/ai-providers/schema.lua` (+1 provider name, which drives the 
enums of all three plugins)
   - `t/plugin/ai-proxy-edenai.t` (new, 33 cases): schema acceptance in all 
three plugins and rejection of unknown providers; default path, method, model, 
configured-auth-overrides-client-auth and body assertions per protocol via an 
in-file echo upstream that only serves `/v3/`; `max_tokens` mapping and absence 
of extra rewrites; verbatim `override.endpoint` path+query; non-streaming and 
streaming pass-through for chat, Responses, embeddings and Anthropic Messages 
with token-usage assertions through the access log; 422 error pass-through; 
`ai-proxy-multi` instance resolution and `http_429` fallback; 
`ai-request-rewrite` end to end.
   - `docs/en|zh/latest/plugins/ai-proxy.md`: description, `provider` row, 
`max_tokens` mapping row, new "Proxy to Eden AI" example with the 
protocol-to-endpoint table and limitations.
   - `docs/en|zh/latest/plugins/ai-proxy-multi.md`, `ai-request-rewrite.md`: 
`provider` rows; health-check note about Eden's unauthenticated `GET 
/v3/models`.
   
   Backward compatible: adds one enum value; no existing provider, schema 
default or test changes.


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