Virtual models
Configure model combos, fallback chains, and round-robin routers for high availability and load distribution.
Virtual models are logical groupings of real LLM models that enable high availability and load distribution without client-side logic.
Two types:
- Combo (Fallback Chain) — Models tried sequentially. If one fails, the next in order is used.
- Round-Robin — Models selected in rotating order across requests. No fallback.
Frontend route:
/admin/virtual-models
Backend routes:
/api/agents/virtual-models
Management UI
Manage virtual models from Admin → Virtual Models.
List
Table view of all virtual models with type badges (Combo / Round-Robin) and resolved underlying model names.
Create
Click New Virtual Model. Fields:
| Field | Type | Description |
|---|---|---|
| Name | string | Unique name among virtual models |
| Type | "combo" / "round_robin" | Select behavior |
| Underlying models | [model] | Searchable picker of real active models. Reorder with arrow buttons for combo types |
| Active | toggle | Create as active or inactive |
Edit
Click the … menu on any row. Update name, type, underlying models, or active status.
Delete
Click … → Delete. Soft-delete; reversible via API only.
CRUD API
All endpoints require admin authentication.
List virtual models
GET /api/agents/virtual-models?active_only=false
Returns all non-deleted virtual models. Resolves underlying model IDs to names.
Response:
{
"items": [
{
"id": "uuid",
"name": "my-fallback-group",
"type": "combo",
"underlying_model_ids": ["uuid-1", "uuid-2"],
"underlying_models": [
{"id": "uuid-1", "name": "gpt-4o"},
{"id": "uuid-2", "name": "claude-sonnet-4"}
],
"is_active": true,
"created_at": "2026-07-22T18:46:19"
}
]
}
Create virtual model
POST /api/agents/virtual-models
Request body:
{
"name": "my-fallback-group",
"type": "combo",
"underlying_model_ids": ["uuid-1", "uuid-2"],
"is_active": true
}
| Field | Type | Description |
|---|---|---|
name | string | Unique name among virtual models |
type | "combo" / "round_robin" | Virtual model type |
underlying_model_ids | [uuid] | UUIDs of real, active, non-virtual models (min 1) |
is_active | bool | Default true |
Validation:
typemust be"combo"or"round_robin"- All
underlying_model_idsmust reference existing real models (non-deleted, non-virtual) - Name must be unique among virtual models
Response: 201 Created with full virtual model object.
Update virtual model
PUT /api/agents/virtual-models/{virtual_model_id}
Request body (all fields optional):
{
"name": "renamed-group",
"type": "round_robin",
"underlying_model_ids": ["uuid-3", "uuid-4"],
"is_active": false
}
Delete virtual model
DELETE /api/agents/virtual-models/{virtual_model_id}
Soft-delete: sets is_deleted = TRUE.
Response:
{"status": "deleted"}
Exclusion from real model APIs
Virtual models are excluded from regular model endpoints and cannot be modified through them.
| Endpoint | Behavior |
|---|---|
GET /api/agents/models | Filters out is_combo=TRUE and is_round_robin=TRUE |
PUT /api/agents/models/{id} | Returns 400 — “Use /api/agents/virtual-models for virtual models” |
DELETE /api/agents/models/{id} | Returns 400 — “Use /api/agents/virtual-models for virtual models” |
Runtime behavior via OpenAI proxy
Virtual models are invoked through the OpenAI-compatible proxy at /api/agents/openai/v1.
Model resolution
When a request’s model field matches a virtual model name:
- The virtual model is loaded from the DB
underlying_model_idsare resolved to real model rows (active, non-deleted, non-virtual)- Order is preserved from the stored array
Combo (fallback chain)
Request → try model[0] → succeed? return
→ fail? try model[1] → succeed? return
→ fail? try model[2] → ...
→ all fail → 502
- Each model in order is attempted
- On failure, log the error and proceed to next
- If all models fail, returns
502witherrorsarray andlast_error - Same behavior for both streaming and non-streaming requests
Round-robin
Request 1 → pick model[idx % N], increment idx → use that model
Request 2 → pick model[(idx+1) % N], increment idx → use that model
- In-memory rotating index per virtual model ID (not persisted across restarts)
- Protected by
asyncio.Lockfor thread safety - No fallback — if the selected model fails, the request fails
- Round-robin virtual models with a single underlying model are functionally equivalent to a direct model reference
OpenAI format
Virtual models appear in the model list:
GET /api/agents/openai/v1/models
Each virtual model is returned as an OpenAI model object:
{
"id": "my-fallback-group",
"object": "model",
"created": 1234567890,
"owned_by": "pinter"
}
Streaming responses include X-Pinter-Routed-Model header indicating which real model handled the request.
Constraints and limitations
- No nesting: Virtual models cannot reference other virtual models. Validation rejects
underlying_model_idspointing to combo or round-robin models. - No pricing fields: Virtual models inherit no pricing from underlying models. Cost is tracked per real model at runtime.
- Round-robin index is in-memory: Resets on server restart. Stateless and ephemeral.
- All requests must be authenticated: Virtual models are not available via unauthenticated endpoints.
- Streaming fallback sequential: Each candidate’s stream is tried in order; the first to produce a stream wins. No model-parallel fan-out.
Use cases
| Scenario | Recommended type |
|---|---|
| High availability across providers (e.g., GPT-4o → Claude Sonnet → Gemini) | Combo |
| Load balancing across same-model deployments (e.g., multiple DeepSeek instances) | Round-Robin |
| Gradual migration — new model as primary, old model as fallback during validation | Combo |
| Isolating quota per model pool without client changes | Either |