Nexus
1.x
Docs/Nexus/Model Aliases
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/core/aliases.mdx

Model aliases let clients use logical names like "fast" or "smart" instead of provider-specific model identifiers. This decouples your API surface from provider details.

Creating Aliases01

import "github.com/xraph/nexus/model"

gw := nexus.New(
    nexus.WithAlias("fast", model.AliasTarget{
        Provider: "anthropic",
        Model:    "claude-3.5-haiku",
    }),
    nexus.WithAlias("smart", model.AliasTarget{
        Provider: "openai",
        Model:    "gpt-4o",
    }),
)

Clients request model: "fast" and Nexus resolves it to anthropic/claude-3.5-haiku.

Weighted Routing02

Distribute traffic across multiple targets:

nexus.WithAlias("balanced",
    model.AliasTarget{Provider: "openai", Model: "gpt-4o-mini", Weight: 0.7},
    model.AliasTarget{Provider: "anthropic", Model: "claude-3.5-haiku", Weight: 0.3},
)

Per-Tenant Overrides03

Different tenants can resolve the same alias to different models:

nexus.WithTenantAlias("premium-tenant", "fast",
    model.AliasTarget{Provider: "openai", Model: "gpt-4o"},
)

When premium-tenant requests model: "fast", they get gpt-4o instead of the default claude-3.5-haiku.

Alias Resolution04

Alias resolution happens in the pipeline middleware chain (priority 250). The original model name is replaced with the resolved provider and model before routing.