feat: support client-driven model selection in ai-proxy-multi via `models` request body field
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
- #13084 de @kjprice — cerrado sin fusionar
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- lua
- Área
- api, backend-api-design
Línea de trabajo
Comienza leyendo ai-proxy-multi.lua y su flujo de selección de instancias en la access-phase. Traza cómo se gestionan los cuerpos de las solicitudes y las instancias configuradas antes del reenvío al upstream, y luego define pruebas para el orden opt-in, la coincidencia de cadenas y objetos, las entradas sin coincidencia, la eliminación de modelos y el comportamiento de fallback; se considera terminado cuando el comportamiento predeterminado sigue estando controlado por el servidor, mientras que las rutas habilitadas respetan las preferencias del cliente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Currently, ai-proxy-multi selects AI instances entirely server-side via configured priority, weight, and fallback_strategy. The client has no way to influence which model or provider handles their request, or in what order fallbacks should be attempted.
This proposal adds support for a models field in the request body, allowing clients to specify their preferred model ordering while the gateway retains full control over authentication, rate limiting, and provider configuration.
Proposed API
Clients include a models array in the chat completions request body. Each element can be:
Object form (full control):
{
"messages": [{"role": "user", "content": "Hello"}],
"models": [
{"provider": "anthropic", "model": "claude-sonnet-4-20250514"},
{"provider": "openai", "model": "gpt-4o"}
]
}
String shorthand (just model names, matched against configured instances):
{
"messages": [{"role": "user", "content": "Hello"}],
"models": ["claude-sonnet-4-20250514", "gpt-4o"]
}
Mixed:
{
"messages": [{"role": "user", "content": "Hello"}],
"models": [
{"provider": "anthropic", "model": "claude-sonnet-4-20250514"},
"gpt-4o"
]
}
Behavior
- The
modelsarray defines the client's preferred instance ordering (first element = highest priority). - Each entry is matched against the route's configured
ai-proxy-multiinstances bymodelname and optionallyprovider. - String entries match by model name only. Object entries can match by
provider+modelfor disambiguation (e.g., two providers serving the same model). - Unmatched entries are ignored (the client cannot introduce providers/models not configured on the route).
- Configured instances not referenced in
modelsare appended after the client's preferred list, in their original priority order. - The existing
fallback_strategystill applies — if the top-priority instance fails, the plugin falls back through the client-specified order, then server-configured instances. - Auth, rate limiting, and all other instance config remain server-controlled.
Configuration
A new optional boolean on the plugin config to opt-in:
plugins:
ai-proxy-multi:
allow_client_model_preference: true # default: false
instances:
- name: anthropic-primary
provider: anthropic
options:
model: claude-sonnet-4-20250514
# ...
- name: openai-fallback
provider: openai
options:
model: gpt-4o
# ...
When allow_client_model_preference is false (default), the models field is stripped from the request body and instance ordering is purely server-driven. This ensures backward compatibility.
Use Case
We're building an LLM proxy gateway where multiple teams consume AI services through a shared gateway. Different clients have different model preferences:
- Team A prefers Claude with GPT-4o fallback
- Team B prefers GPT-4o with Claude fallback
- The gateway team manages auth keys, rate limits, and provider configs centrally
Today this requires separate routes per team/preference. With client-driven model selection, a single route handles all teams while respecting their preferences.
Implementation Notes
- The matching logic would live in
ai-proxy-multi.lua, executed before instance selection in theaccessphase. - The
modelsfield should be stripped from the request body before forwarding to the upstream provider (providers don't recognize it). - String matching should be case-sensitive to match provider model naming conventions.
- When using
chashbalancer, client preference should take precedence over hash-based selection.
I'm happy to submit a PR for this feature if the approach looks good.
- Lenguaje dominante
- Lua
- Estrellas
- 17.3k
- Forks
- 3k
- Merge medio
- 4 d 14 h
- PR fusionados (30 d)
- 73
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/apisix
-
bug: an admin key injected with ${{VAR}} that contains only digits becomes a number, so the correct key gets 401Posiblemente ocupada @Ymmcc la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
bug(body-transformer): runtime crash when request or response body is a JSON primitivePosiblemente ocupada @bhuvan-somisetty la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
bug: openapi-to-mcp appends a second ? to a query-suffixed path templatePosiblemente ocupada @lordcheng10 la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 2 días
-
ai-proxy forwards client `Transfer-Encoding: chunked` but sends an unchunked body (upstream 400)Posiblemente ocupada @locker95 la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
As a user, I want the opa plugin to propagate trace context (traceparent) to OPA, so that OPA spans are linked to the APISIX request tracePosiblemente ocupada @GitNimay la tomó hace 21 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/apisix#14051 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de apache/apisix
Issues similares
-
severity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
luainkernel/lunatik#2460 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
nvim-neo-tree/neo-tree.nvim#2121 ·
Los mantenedores suelen responder en 5 días
-
Dustwallow soothing spices stepAbiertobug discord guide:04-dustwallow-marsh locale:enUS lua-error triage v0.3.6
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NaixGames/Polycosmos#79 ·