The Route: Order help
At most 4 requests at once go to GPU server; the rest go straight to OpenAI.
A worked example: one endpoint that sends at most 4 requests at a time to a model on your own GPU server and every request past those straight to gpt-6.1-sol, without waiting in a queue, called from the OpenAI SDK.
At most 4 requests at once go to GPU server; the rest go straight to OpenAI.
The model you guard here is one that can only take so many requests at once: a server of your own with a fixed number of GPUs, or a provider plan that caps requests in flight. Past that number it slows everyone down or refuses, so the limit sends the extra requests to a provider that has room. You need a Model Waygate account and a key of your own with each provider; Model Waygate stores the provider keys encrypted and uses them only to forward your requests.
GPU server with your server's base URL and its key, then an OpenAI provider named OpenAI with your OpenAI key. Each row's Test button asks the provider for its models, which proves the address and the key work before any request depends on them.Order help. The slug fills in as order-help and becomes part of the endpoint's URL, never to change.Concurrency limit with backup. Lets at most 4 requests at a time through to the first model and sends the rest straight to the backup, without waiting; the limit's side panel in the editor changes how many.GPU server, Model qwen3-32b; Backup provider OpenAI, Backup model gpt-6.1-sol.mw_ and is shown once) and copy the endpoint's URL beside it.pool node and set how many requests it lets through at once, from 1 to 1000: as many as your server answers well side by side. Publish the change and deploy it.The diagram above is the endpoint's whole route: the request goes into a fallback, whose first child is the concurrency limit in front of GPU server and whose second is OpenAI. It opens in the route editor like any route you draw yourself; each change you publish becomes a new version, deployed when you choose.
pool: 3 of 4 in use. The count is shared by every server the gateway runs on.Point the SDK at the endpoint's URL, https://modelwaygate.com/USER_ID/order-help/api/v1, with the gateway key in place of an OpenAI key. USER_ID is your account's public id, which the endpoint's URL on the dashboard already carries. The code is the same whether the limit has room or not: the route decides, request by request.
mw_your_gateway_key stands for the key you minted. Keep it in an environment variable or a secret store, never in source control.curl https://modelwaygate.com/USER_ID/order-help/api/v1/chat/completions \
-H "Authorization: Bearer mw_your_gateway_key" \
-H "Content-Type: application/json" \
-d '{
"model": "order-help",
"messages": [
{"role": "system", "content": "You answer questions about orders in one short paragraph."},
{"role": "user", "content": "Where is order 1042?"}
]
}'
from openai import OpenAI
client = OpenAI(base_url="https://modelwaygate.com/USER_ID/order-help/api/v1", api_key="mw_your_gateway_key")
response = client.chat.completions.create(
model="order-help",
messages=[
{"role": "system", "content": "You answer questions about orders in one short paragraph."},
{"role": "user", "content": "Where is order 1042?"},
],
)
print(response.model, response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://modelwaygate.com/USER_ID/order-help/api/v1", apiKey: "mw_your_gateway_key" });
const response = await client.chat.completions.create({
model: "order-help",
messages: [
{ role: "system", content: "You answer questions about orders in one short paragraph." },
{ role: "user", content: "Where is order 1042?" },
],
});
console.log(response.model, response.choices[0].message.content);
OkHttpClient client = new OkHttpClient();
String json = "{\"model\": \"order-help\", \"messages\": ["
+ "{\"role\": \"system\", \"content\": \"You answer questions about orders in one short paragraph.\"}, "
+ "{\"role\": \"user\", \"content\": \"Where is order 1042?\"}]}";
Request request = new Request.Builder()
.url("https://modelwaygate.com/USER_ID/order-help/api/v1/chat/completions")
.header("Authorization", "Bearer mw_your_gateway_key")
.post(RequestBody.create(json, MediaType.get("application/json")))
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
import Data.Aeson (encode, object, (.=))
import Network.HTTP.Client
import Network.HTTP.Client.TLS (tlsManagerSettings)
main :: IO ()
main = do
manager <- newManager tlsManagerSettings
initial <- parseRequest "POST https://modelwaygate.com/USER_ID/order-help/api/v1/chat/completions"
let turn role content = object ["role" .= (role :: String), "content" .= (content :: String)]
body = object ["model" .= ("order-help" :: String), "messages" .= [turn "system" "You answer questions about orders in one short paragraph.", turn "user" "Where is order 1042?"]]
request = initial{requestHeaders = [("Authorization", "Bearer mw_your_gateway_key"), ("Content-Type", "application/json")], requestBody = RequestBodyLBS (encode body)}
response <- httpLbs request manager
print (responseBody response)
Nothing different. While 4 requests hold the limit's places, the next request is answered by gpt-6.1-sol, with the same status and shape as any other answer.
model field names the model that actually answered, so your code can tell an overflow answer from one your own server gave without asking the dashboard.Every request records the way it went, on the dashboard's Usage page, on the request's own page and through the control API.
fallback#1 → limit pool 1/4 → GPU server (qwen3-32b) is the first request into an empty limit; the number before the slash counts the places in use with this request's, so the fourth at once shows fallback#1 → limit pool 4/4 → GPU server (qwen3-32b).fallback#2 → OpenAI (gpt-6.1-sol) is a request the full limit sent on. The route taken names only the child that answered; the refusal is listed under the request's route events as Limit full: node pool (qwen3-32b): 4 of 4 in use, so it was not called, and in the control API as a concurrency_limited event naming the node, with the places in use and how many it allows.A rate limit counts how many requests start in a minute. A concurrency limit counts how many are under way right now. A hundred short requests a minute may never fill 4 places, while 4 long streams fill them for as long as they run.
concurrency_limit_reached with Retry-After: 1, saying Concurrency limit pool allows 4 requests at once and all are in use, so its output was not called. That is the shape for a limit that should protect a model without spending on another.The limit is the gateway's own count, kept in its database, of requests through this one node of this one endpoint.
limit_refused, which a new selective fallback starts with ticked; untick it and a full limit answers the 429 above instead of reaching the backup.The wizard offers more starting routes with a backup, each drawn the same way and editable afterwards; a route drawn by hand can also put a limit in front of the backup, or in front of a circuit breaker.