Drex guides

Drex Router

Pick the best model for a conversation before you call it. How to send candidates, choose quality or price, read the probabilities, and what a call costs.

Drex Router chooses which language model should answer a conversation. You send the conversation and the models you are willing to use (the candidates). Drex returns the one it selects and a probability for every candidate. It never calls the chosen model: you call it yourself, with your own provider keys, so Drex Router fits in front of any LLM gateway you already use.

Each successful call costs $0.02 per million encoded input tokens, measured by the router across the conversation and candidate profiles. Before dispatch, Drex reserves the maximum possible cost for the encoded-input limit. It settles only the tokens used and releases the remainder. An account that cannot fund the maximum gets 402 before the router runs, even if the eventual charge would have fit. Failed requests are free. See Pricing.

Route a conversation

curl https://console.nace.ai/v1/route \
  -H "Authorization: Bearer $NACE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "system", "content": "You are a support agent for an invoicing app." },
      { "role": "user", "content": "Why was I charged twice this month?" }
    ],
    "candidates": ["openai/gpt-6-luna", "google/gemini-3.8-flash", "anthropic/claude-haiku-5.5"],
    "selection_priority": "balanced"
  }'

The answer names the selected candidate and gives each candidate's probability:

{
  "selected": "openai/gpt-6-luna",
  "probabilities": {
    "openai/gpt-6-luna": 0.44,
    "google/gemini-3.8-flash": 0.28,
    "anthropic/claude-haiku-5.5": 0.28
  },
  "request_id": "req_6d5ad37046ca001d64d0587461385bcc"
}
FieldRequiredWhat it is
messagesyesThe conversation so far, in order: {role, content} with role system, user or assistant and text content. Only text turns are accepted.
candidatesyesThe models to choose from, each a known candidate ID (below) or a full profile. IDs must be unique.
selection_prioritynoquality prefers the strongest candidate, cheapest the lowest price, and balanced weighs both. Default balanced.
cost_weightnoDeprecated: use selection_priority. A number from 0 to 1, where 0 favors quality and 1 favors price. A request that sends both fields is refused with 422.

The API reference lists every limit and error.

The same call from the clients:

from nace_sdk import NaceClient

client = NaceClient()
result = client.route(
    [{"role": "user", "content": "Why was I charged twice this month?"}],
    ["openai/gpt-6-luna", "google/gemini-3.8-flash", "anthropic/claude-haiku-5.5"],
    selection_priority="balanced",
)
print(result.selected, result.probabilities)

Routing needs nace-sdk 0.11.0 or later (Python and TypeScript), nace-cli 0.8.0 or later, or nace-mcp 0.7.0 or later. Depending on the installed build, each package takes either the selection_priority argument and --priority flag shown above or the deprecated scale — cost_weight in the SDKs, --cost-weight in the CLI, 0 favoring quality and 1 favoring price. The endpoint accepts either field. The local and hosted MCP servers have a route tool; the hosted one needs a Console API key. The playground has Drex Router in its model picker.

Candidates

A known candidate can be sent as its bare ID:

Candidate IDProvider
openai/gpt-6-lunaopenai
openai/gpt-6-solopenai
openai/gpt-oss-120bopenai
openai/gpt-4o-miniopenai
openai/gpt-4-1106-previewopenai
anthropic/claude-opus-5.5anthropic
anthropic/claude-sonnet-5.5anthropic
anthropic/claude-haiku-5.5anthropic
google/gemini-3.8-flashgoogle
google/gemma-4-31b-itgoogle
deepseek/deepseek-v4.1-flashdeepseek
z-ai/glm-5.3-flashz-ai
mistralai/mistral-smallmistralai
mistralai/mistral-small-3.2-24b-instructmistralai
mistralai/mixtral-8x7b-instructmistralai
mistralai/ministral-3bmistralai
meta-llama/llama-3.1-8b-instructmeta-llama

Any other model needs a full profile, so Drex knows what it costs and what it can hold. A bare ID that is not in the table is refused with 422.

{
  "id": "my-org/fine-tuned-support-model",
  "provider": "my-org",
  "price_in": 0.4,
  "price_out": 1.6,
  "context": 128000,
  "tags": ["support", "chat"]
}
Profile fieldWhat it is
idYour name for the model. It keys probabilities and is returned as selected.
providerWho serves it.
price_in, price_outUSD per million input and output tokens.
contextContext window in tokens.
tagsFree-form labels that describe the model, such as code or reasoning.

Known IDs and profiles can be mixed in one request.

Read the answer

  • selected is the candidate with the highest probability. Ties go to the earlier candidate, so put your preferred model first.
  • probabilities has one entry per candidate and sums to 1. Use it for your own rule if you need one, such as "use the selected model only when its probability is at least 0.5, else my default".
  • The router only picks. Send the conversation to the selected model through your own provider.

When routing fails

On a timeout, 429, 503, 504 or 529, no selection is returned and nothing is charged. Fall back to a default model of your choice rather than waiting: routing should never hold up the answer. A 402 means the account cannot fund the call; it is refused before the router runs. See Errors and retries.

Each call appears as Route in Usage › Logs.

On this page