|
| 1 | +--- |
| 2 | +title: Model Aliases - Cross-Backend Model Name Mapping |
| 3 | +description: Define virtual model names that map to platform-specific model names across Ollama, LM Studio, llamacpp and other backends. |
| 4 | +keywords: model aliases, model mapping, model name rewriting, cross-platform models, virtual model names |
| 5 | +--- |
| 6 | + |
| 7 | +# Model Aliases |
| 8 | + |
| 9 | +> :memo: **Configuration** |
| 10 | +> ```yaml |
| 11 | +> model_aliases: |
| 12 | +> gpt-oss-120b: |
| 13 | +> - gpt-oss:120b # Ollama format |
| 14 | +> - gpt-oss-120b-MLX # LM Studio MLX format |
| 15 | +> - gguf_gpt_oss_120b.gguf # llamacpp GGUF filename |
| 16 | +> ``` |
| 17 | +> **Key Points**: |
| 18 | +> |
| 19 | +> - Aliases are defined at the top level of `config.yaml` |
| 20 | +> - Each alias maps a single virtual name to one or more actual model names |
| 21 | +> - The request body's `"model"` field is automatically rewritten for the selected backend |
| 22 | +> - Aliases take priority over standard model routing when both match |
| 23 | +
|
| 24 | +## Overview |
| 25 | +
|
| 26 | +When running multiple LLM backends (Ollama, LM Studio, llamacpp, vLLM, etc.), the same underlying model often has different names on each platform. For example, `Llama 3.1 8B` might be known as: |
| 27 | +
|
| 28 | +- `llama3.1:8b` on Ollama |
| 29 | +- `llama-3.1-8b-instruct` on LM Studio |
| 30 | +- `Meta-Llama-3.1-8B-Instruct.gguf` on llamacpp |
| 31 | +
|
| 32 | +Without aliases, a client request for `llama3.1:8b` would only match the Ollama endpoint — even though the other backends have the same model. |
| 33 | +
|
| 34 | +**Model aliases** let you define a single virtual model name that maps to all of these variants, so any backend that has the model can serve the request. |
| 35 | +
|
| 36 | +## How It Works |
| 37 | +
|
| 38 | +When a request arrives with a model name that matches a configured alias: |
| 39 | +
|
| 40 | +```text |
| 41 | +Client request: "model": "my-llama" |
| 42 | + │ |
| 43 | + ▼ |
| 44 | +┌─────────────────────┐ |
| 45 | +│ Alias Resolution │ my-llama → [llama3.1:8b, llama-3.1-8b-instruct] |
| 46 | +└─────────┬───────────┘ |
| 47 | + │ |
| 48 | + ▼ |
| 49 | +┌─────────────────────┐ |
| 50 | +│ Endpoint Discovery │ Find endpoints serving any of those model names |
| 51 | +└─────────┬───────────┘ |
| 52 | + │ |
| 53 | + ▼ |
| 54 | +┌─────────────────────┐ |
| 55 | +│ Load Balancing │ Select best endpoint (priority, health, etc.) |
| 56 | +└─────────┬───────────┘ |
| 57 | + │ |
| 58 | + ▼ |
| 59 | +┌─────────────────────┐ |
| 60 | +│ Model Rewrite │ Rewrite "model" field → "llama3.1:8b" (for Ollama) |
| 61 | +└─────────┬───────────┘ |
| 62 | + │ |
| 63 | + ▼ |
| 64 | + Backend |
| 65 | +``` |
| 66 | +
|
| 67 | +1. **Alias resolution** — Olla checks whether the requested model name is a configured alias and looks up the list of actual model names. |
| 68 | +2. **Endpoint discovery** — For each actual model name, Olla queries the model registry to find endpoints that serve it. This builds an endpoint → actual model name mapping. |
| 69 | +3. **Load balancing** — The matched endpoints are filtered through the normal load balancing pipeline (priority, health checks, etc.). |
| 70 | +4. **Model rewrite** — Before the request is sent to the selected backend, Olla rewrites the `"model"` field in the JSON request body to the actual model name that backend expects. |
| 71 | +
|
| 72 | +## Configuration |
| 73 | +
|
| 74 | +Aliases are defined under the `model_aliases` key in `config.yaml`: |
| 75 | +
|
| 76 | +```yaml |
| 77 | +model_aliases: |
| 78 | + # Alias name → list of actual model names across backends |
| 79 | + my-llama: |
| 80 | + - "llama3.1:8b" # Ollama |
| 81 | + - llama-3.1-8b-instruct # LM Studio |
| 82 | + - Meta-Llama-3.1-8B-Instruct.gguf # llamacpp |
| 83 | +
|
| 84 | + my-codegen: |
| 85 | + - "qwen2.5-coder:7b" # Ollama |
| 86 | + - qwen2.5-coder-7b-instruct # LM Studio |
| 87 | +``` |
| 88 | +
|
| 89 | +Clients can then use the alias name in their requests: |
| 90 | +
|
| 91 | +```bash |
| 92 | +curl http://localhost:40114/v1/chat/completions \ |
| 93 | + -H "Content-Type: application/json" \ |
| 94 | + -d '{ |
| 95 | + "model": "my-llama", |
| 96 | + "messages": [{"role": "user", "content": "Hello!"}] |
| 97 | + }' |
| 98 | +``` |
| 99 | +
|
| 100 | +Olla will route to whichever backend has one of the listed models and rewrite `"my-llama"` to the correct name for that backend. |
| 101 | +
|
| 102 | +## Self-Referencing Aliases |
| 103 | +
|
| 104 | +An alias name can also appear in its own list of actual model names. This is useful when the alias name is itself a real model name on one of the backends: |
| 105 | +
|
| 106 | +```yaml |
| 107 | +model_aliases: |
| 108 | + gpt-oss-120b: |
| 109 | + - "gpt-oss:120b" # Ollama knows it as gpt-oss:120b |
| 110 | + - gpt-oss-120b # LM Studio knows it as gpt-oss-120b (same as alias) |
| 111 | +``` |
| 112 | +
|
| 113 | +In this case: |
| 114 | +
|
| 115 | +- An Ollama endpoint serving `gpt-oss:120b` will be included, and the request body will be rewritten to `"gpt-oss:120b"`. |
| 116 | +- An LM Studio endpoint serving `gpt-oss-120b` will also be included, and the request body keeps `"gpt-oss-120b"` (no unnecessary rewrite since it already matches). |
| 117 | +
|
| 118 | +## Alias Priority |
| 119 | +
|
| 120 | +When a model name matches both a configured alias **and** a real model known to the registry, the alias takes priority. This ensures consistent cross-backend routing. |
| 121 | +
|
| 122 | +If the alias resolves to zero endpoints (none of the actual model names are available), Olla falls back to standard model routing using the alias name as a regular model name. |
| 123 | +
|
| 124 | +## Interaction with Other Features |
| 125 | +
|
| 126 | +### Model Routing |
| 127 | +
|
| 128 | +Alias resolution runs **before** the standard model routing pipeline (strict, optimistic, or discovery modes). Once alias endpoints are resolved, they go through the same load balancing and health filtering as any other request. |
| 129 | +
|
| 130 | +### Model Unification |
| 131 | +
|
| 132 | +Aliases are separate from model unification. Unification merges model catalogues within a single provider type (e.g. multiple Ollama instances). Aliases map across provider types (e.g. Ollama ↔ LM Studio ↔ llamacpp). |
| 133 | +
|
| 134 | +### Proxy Engines |
| 135 | +
|
| 136 | +Both the Olla and Sherpa proxy engines support model alias rewriting. The rewrite happens transparently before the request is forwarded to the backend. |
| 137 | +
|
| 138 | +## Example Scenario |
| 139 | +
|
| 140 | +Consider a home lab with three backends: |
| 141 | +
|
| 142 | +```yaml |
| 143 | +discovery: |
| 144 | + static: |
| 145 | + endpoints: |
| 146 | + - url: "http://workstation:11434" |
| 147 | + name: "ollama-rtx4090" |
| 148 | + type: "ollama" |
| 149 | + priority: 100 |
| 150 | + - url: "http://macbook:1234" |
| 151 | + name: "lmstudio-m2" |
| 152 | + type: "lm-studio" |
| 153 | + priority: 75 |
| 154 | + - url: "http://server:8080" |
| 155 | + name: "llamacpp-a100" |
| 156 | + type: "llamacpp" |
| 157 | + priority: 50 |
| 158 | +
|
| 159 | +model_aliases: |
| 160 | + llama3: |
| 161 | + - "llama3.1:8b" |
| 162 | + - llama-3.1-8b-instruct |
| 163 | + - Meta-Llama-3.1-8B-Instruct.gguf |
| 164 | +``` |
| 165 | +
|
| 166 | +A request for `"model": "llama3"` will: |
| 167 | +
|
| 168 | +1. Resolve to all three endpoints (each has the model under a different name) |
| 169 | +2. Prefer `ollama-rtx4090` (highest priority) |
| 170 | +3. Rewrite the model name to `llama3.1:8b` if routed to Ollama, `llama-3.1-8b-instruct` if routed to LM Studio, etc. |
| 171 | +4. Fall back to the next endpoint if the primary is unhealthy |
| 172 | +
|
| 173 | +## Troubleshooting |
| 174 | +
|
| 175 | +### Alias Not Resolving |
| 176 | +
|
| 177 | +**Issue**: Requests with an alias name return 404 or route incorrectly. |
| 178 | +
|
| 179 | +**Possible Causes**: |
| 180 | +
|
| 181 | +- Actual model names in the alias don't match what backends report |
| 182 | +- Model discovery hasn't run yet |
| 183 | +
|
| 184 | +**Solutions**: |
| 185 | +
|
| 186 | +1. Check discovered models: `curl http://localhost:40114/olla/models` |
| 187 | +2. Verify model names match exactly (including tags like `:latest`) |
| 188 | +3. Wait for model discovery to complete or trigger a refresh |
| 189 | +
|
| 190 | +### Wrong Model Name Sent to Backend |
| 191 | +
|
| 192 | +**Issue**: Backend receives the alias name instead of the actual model name. |
| 193 | +
|
| 194 | +**Possible Causes**: |
| 195 | +
|
| 196 | +- Actual model name in the alias list doesn't exactly match the model name reported by the backend |
| 197 | +- Request body is not JSON |
| 198 | +
|
| 199 | +**Solutions**: |
| 200 | +
|
| 201 | +1. Compare alias model names against discovered models: `curl http://localhost:40114/olla/models` |
| 202 | +2. Ensure requests use `Content-Type: application/json` |
| 203 | +
|
| 204 | +### Alias Overriding a Real Model |
| 205 | +
|
| 206 | +**Issue**: An alias is intercepting requests meant for a real model with the same name. |
| 207 | +
|
| 208 | +**This is by design** — aliases always take priority. If you need to reach the real model directly, either: |
| 209 | +
|
| 210 | +- Remove the alias, or |
| 211 | +- Include the real model name in the alias list (self-referencing) so it stays in the candidate pool |
0 commit comments