Skip to main content
This page walks through creating a virtual model in the TrueFoundry dashboard and using it from your application. For an overview of routing strategies, health detection, and advanced features like sticky routing, see the Virtual Models overview.

Create a virtual model

1

Open Virtual Models in AI Gateway

From the TrueFoundry dashboard, go to AI GatewayModelsVirtual Model.
Navigate to Virtual Models in AI Gateway

Navigate to Virtual Models in AI Gateway

Virtual models live inside Virtual Model Provider Groups. You can add models to an existing group or create a new group when you start.
2

Create or select a provider group and set access controls

Give the group a unique name (3–64 characters, alphanumeric and hyphens, cannot start with a number). Configure collaborators:
  • User — May call the virtual models in this group for inference.
  • Manager — May change virtual model configuration.
Create Virtual Model Provider Group and configure access controls

Create Virtual Model Provider Group and configure access controls

See Gateway access control for details.
3

Define the virtual model, strategy, and targets

For each virtual model in the group, set:
  • Name — Identifier used in the full path group-name/virtual-model-name (for example gpt-4-production).
  • Model types — Operation kinds this virtual model supports — chat, completion, embedding, rerank, moderation, and the audio types (text to speech, audio transcription, audio translation). All targets must support the operation you invoke.
  • Routing strategy — Choose one of three strategies: For how each strategy works, see the overview.
  • Target models — For each target, configure:
    prompt_version_fqn override does not apply when using agents with MCP/tools; it is supported for standard chat completion requests.
  • Slug (optional) — Short global alias for this virtual model. See Slugs.
Configure virtual model details, routing strategy, and target models

Configure virtual model details, routing strategy, and target models

Configure the slug in the Virtual Model Provider Group settings. Slugs must be unique across all virtual models in the tenant.

Common patterns

The following YAML sketches show the routing_config shape used inside a virtual model. In the dashboard, the same fields are set in the UI.
Route speech-to-text traffic to a primary provider and fall back to a second provider on failure. Set the virtual model’s Model types to audio_transcription so it can be called on POST /audio/transcriptions. The same shape works for text_to_speech and audio_translation — just swap the targets and model type.
Call the virtual model from your application the same way you’d call any STT model — pass the virtual model’s full path as model:
Route to region-specific model deployments based on which SaaS gateway handled the request. The gateway automatically adds tfy_gateway_region and tfy_gateway_zone to request metadata — no client changes needed.
US gateway traffic goes to the Azure US deployment, EU traffic to Azure EU, and everything else falls back to OpenAI. See Metadata Keys for all available region and zone values.
Inject or remove headers on specific targets — useful when one provider needs extra headers the others don’t.
Route enterprise-tier traffic to a dedicated deployment while standard traffic uses a shared pool.
Requests with x-tfy-metadata: {"tier":"enterprise"} go exclusively to the dedicated Azure deployment. All other requests are split 60/40 between OpenAI and the shared Azure deployment.
Full configuration using priority-based routing with SLA thresholds, custom retries, and controlled fallback eligibility.

Environment- or segment-specific routing

Use different virtual model names per environment or segment (for example booking-app/gpt-prod vs booking-app/gpt-dev) and have your client pass the appropriate model. You can still send metadata and headers for observability, rate limits, and other gateway features; routing for a given virtual model name is always defined on that virtual model.
SaaS gateway metadata keys (tfy_gateway_region, tfy_gateway_zone) are available in request metadata and can be used for metadata-driven virtual model routing rules. See Metadata Keys for all available values and metadata-based target filtering for worked examples.

Use a virtual model from your application

Once created, use the full path virtual-model-group-name/virtual-model-name as the model value in API requests — it works like any other model in the gateway.

Try in the Playground

  • Click Try in playground on the virtual model row after creation, or
  • Open the Playground and pick the virtual model from the model dropdown.
Try in playground button next to virtual model

Try in playground button next to virtual model

Select virtual model from model dropdown in playground

Select virtual model from playground dropdown

Virtual model slugs

Slugs are optional short names that refer to a single virtual model. They are unique across the tenant. You can use either the slug or the full group/model path in requests.
Configure slug in Virtual Model Provider Group settings

Configure slug in Virtual Model Provider Group settings

If the virtual model is my-first-virtual-account/model-1 with slug virtual-model-1, both bodies are valid: