Skip to content

Commit e7fcd47

Browse files
authored
Merge pull request #372 from agentgateway/adb-multimodel
2 parents 423fbd3 + 38d05fa commit e7fcd47

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

content/docs/standalone/latest/llm/about.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,45 @@ llm:
167167

168168
Clients send `"model": "fast"` or `"model": "smart"`, and agentgateway translates these to the corresponding provider models.
169169

170+
### Route priority
171+
172+
When multiple models match a request, agentgateway selects the best match by using the following priority order:
173+
174+
1. **Match specificity**: Routes with more match criteria take priority. For example, a route with two header matchers ranks higher than a route with one.
175+
2. **Config order**: When two routes have equal specificity, the route listed first in the configuration file takes priority.
176+
177+
This means you can control tie-breaking behavior by ordering your models in the config. Place more specific routes before generic or wildcard routes to ensure they match first.
178+
179+
```yaml
180+
llm:
181+
models:
182+
# Specific route — listed first, wins ties against the wildcard
183+
- name: "accounts/fireworks/*"
184+
provider: openAI
185+
matches:
186+
- headers:
187+
- name: "x-org"
188+
value:
189+
exact: "eng"
190+
params:
191+
apiKey: "$FIREWORKS_API_KEY"
192+
hostOverride: api.fireworks.ai:443
193+
backendTLS: {}
194+
# Catch-all route — matches anything, but lower priority
195+
- name: "*"
196+
provider: openAI
197+
matches:
198+
- headers:
199+
- name: "x-org"
200+
value:
201+
exact: "engineering"
202+
params:
203+
apiKey: "$OPENAI_API_KEY"
204+
```
205+
206+
In this example, both routes have one header matcher, so they have equal specificity. Because the Fireworks route is listed first, it takes priority when both routes match.
207+
208+
{{< callout type="info" >}}
209+
For advanced routing based on request body fields like the `model` name, see [Content-based routing]({{< link-hextra path="/llm/content-routing/" >}}).
210+
{{< /callout >}}
211+

content/docs/standalone/main/llm/about.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,45 @@ llm:
168168

169169
Clients send `"model": "fast"` or `"model": "smart"`, and agentgateway translates these to the corresponding provider models.
170170

171+
### Route priority
172+
173+
When multiple models match a request, agentgateway selects the best match by using the following priority order:
174+
175+
1. **Match specificity**: Routes with more match criteria take priority. For example, a route with two header matchers ranks higher than a route with one.
176+
2. **Config order**: When two routes have equal specificity, the route listed first in the configuration file takes priority.
177+
178+
This means you can control tie-breaking behavior by ordering your models in the config. Place more specific routes before generic or wildcard routes to ensure they match first.
179+
180+
```yaml
181+
llm:
182+
models:
183+
# Specific route — listed first, wins ties against the wildcard
184+
- name: "accounts/fireworks/*"
185+
provider: openAI
186+
matches:
187+
- headers:
188+
- name: "x-org"
189+
value:
190+
exact: "eng"
191+
params:
192+
apiKey: "$FIREWORKS_API_KEY"
193+
hostOverride: api.fireworks.ai:443
194+
backendTLS: {}
195+
# Catch-all route — matches anything, but lower priority
196+
- name: "*"
197+
provider: openAI
198+
matches:
199+
- headers:
200+
- name: "x-org"
201+
value:
202+
exact: "engineering"
203+
params:
204+
apiKey: "$OPENAI_API_KEY"
205+
```
206+
207+
In this example, both routes have one header matcher, so they have equal specificity. Because the Fireworks route is listed first, it takes priority when both routes match.
208+
209+
{{< callout type="info" >}}
210+
For advanced routing based on request body fields like the `model` name, see [Content-based routing]({{< link-hextra path="/llm/content-routing/" >}}).
211+
{{< /callout >}}
212+

0 commit comments

Comments
 (0)