Skip to main content
Models & Routing

Model Selection & Routing

Relay never auto-switches your model mid-session — you pick it once, for the whole run.

The one rule: you choose the model, once

Relay is a router, not an auto-picker. It does not choose a cheaper or faster model on your behalf mid-request, mid-session, or based on measured latency or cost. You (or your VG Code configuration) select the model once, up front, for the whole session, and Relay uses exactly that model for every request in it.

There is no cost-based, latency-based, or usage-based model auto-selection anywhere in the Relay request path.

This is deliberate: a code-editing agent needs a stable, predictable model identity across a task — swapping models mid-session would change tone, formatting conventions, and even correctness assumptions partway through a change.

How the model is resolved

vg code "..." --model anthropic/claude-sonnet-5   # explicit — always wins
vg code "..."                                       # falls back to the catalog default
  • POST /relay/v1/chat/completions uses the caller's explicit model field when given.
  • When the field is omitted entirely, Relay falls back to the one model flagged default in the current catalog (see Supported models) — never a guess, never the cheapest available, always the same published default.

What Relay does do automatically

Relay's automation is about serving path, never about which model answers:

  • It transparently prefers Cloudflare Workers AI over an upstream provider proxy when a mapping exists for your chosen model — invisible to you, and priced identically either way.
  • On a provider-side failure with no usable fallback path, it fails the request outright (502/503) rather than silently substituting a different model you didn't ask for.

Choosing between Relay and other providers

VG Code's --provider flag accepts vibgrate-relay, ollama, lmstudio, foundry-local, openrouter, litellm, openai, together, and llama-cpp. When VIBGRATE_RELAY_TOKEN is set, Relay is preferred automatically over other hosted providers, with local models as fallback if Relay itself is unreachable. See VG Code integration for the full precedence order.

Related Documentation