Skip to main content

Routing rules and fallbacks

Learn how to save memtrunk routing rules in the console. See the rule fields, project scope, precedence, fallbacks, where rules apply and their limits.

Last updated

A routing rule sends a request for one model to a different model. Each user saves rules for their own requests. The gateway reads the rules of the user who owns the memtrunk key.

Open the Routing page#

Select Routing in the console navigation. The page has four tabs: Tier preferences, Model overrides, Effort overrides and Profiles. This guide covers Model overrides, Tier preferences and Profiles.

Routing rules apply to /v1/messages and /v1/responses. The Codex route also applies them. The /v1/chat/completions path does not apply routing rules. Project scope applies on /v1/messages only.

Add a model override#

  1. Open the Model overrides tab.
  2. Select Add override.
  3. Enter the Source model. This is the model name that the client asks for.
  4. Choose the Target provider and the Target model.
  5. Optional: choose a Fallback model and a Fallback provider.
  6. Choose the Scope. The choices are All projects or one or more projects.
  7. Keep Enabled on.
  8. Select Save overrides.

The Source model of a saved override is read-only. To change it, remove the override and add a new one.

The gateway lowercases a model name and removes a date stamp or a suffix. It does this for the saved rule and for the request before it compares them.

Fields#

FieldMeaning
Source modelThe model that the client asks for.
Target providerClaude accounts, ChatGPT accounts or Antigravity. The list also shows other providers. A provider stays disabled unless your account has it enabled.
Target modelThe model to use instead. You choose it from the models of the target provider. The field is required.
Fallback modelOptional. The console says the gateway uses it when the target cannot serve the request, such as for a 429 rate limit.
Fallback providerSame as target, or another of the three providers. The field stays off until you choose a fallback model.
ScopeAll projects, or the projects that you pick.
EnabledA disabled rule stays saved. The gateway skips it.

The Scope menu lists the projects that appear in your requests. If the list is empty, the console asks you to send an attributed request and reload the page.

Tier preferences#

The Tier preferences tab sets a personal default for each Claude-family tier. The tiers are flagship, standard, fast and reasoning. Choose Instance default as the Target provider to remove a saved preference. Select Save tiers to save your changes.

Example#

This example uses made-up model names. The table shows two override rows.

Source modelTarget providerTarget modelFallback modelFallback providerScope
claude-example-largeChatGPT accountsgpt-example-5gpt-example-miniSame as targetAll projects
claude-example-largeChatGPT accountsgpt-example-miniNoneSame as targetOne project

A /v1/messages request for claude-example-large from the one project goes to gpt-example-mini. The same request from any other project goes to gpt-example-5. The first row has gpt-example-mini as its fallback.

Project scope and precedence#

On /v1/messages, the gateway reads the project from the declared project header, or from the project that it detects. The console lists the order of the destinations, highest first:

  1. A model override for the project.
  2. A rule of a profile that you assigned to the project.
  3. A model override for All projects.
  4. Your tier preference for the Claude-family tier.
  5. The instance mapping.

The gateway picks the first match. An unavailable selected rule does not retry a lower saved rule.

A profile is a reusable set of rules. On the Profiles tab, you select New profile, add its rules, and assign the projects that use it. Only the assigned projects activate the profile.

Fallback rules#

The gateway resolves the fallback of a rule with these rules:

  • An empty fallback model means no fallback.
  • The gateway ignores a fallback to the same provider when the fallback model equals the target model.
  • The gateway drops a fallback to a different provider when the caller may not use the pool of that provider.

What you cannot route to#

  • A rule can target only a provider that your account may use. The list also shows other providers. A provider stays disabled unless your account has it enabled. If the server refuses the save, the console starts the error with: Changes were not saved. Your account may not be entitled to this provider, or this session is read-only.
  • A Claude-family source model cannot target Claude accounts. The console shows the server message for the refused save.
  • A rule has no effect when the caller key may not use the pool of the target provider. Read Credentials for the Allowed sources field.

A read-only auditor sees the Routing page in read-only form.

Next steps#