1
1
---
2
2
title : Model muxing
3
- description : Configure a per-workspace LLM
3
+ description : Pick the right LLM for the job
4
4
---
5
5
6
+ import useBaseUrl from ' @docusaurus/useBaseUrl' ;
7
+ import ThemedImage from ' @theme/ThemedImage' ;
8
+
6
9
## Overview
7
10
8
11
_ Model muxing_ (or multiplexing), allows you to configure your AI assistant once
@@ -11,12 +14,13 @@ and models without reconfiguring your development environment. This feature is
11
14
especially useful when you're working on multiple projects or tasks that require
12
15
different AI models.
13
16
14
- For each CodeGate workspace, you can select the AI provider and model
15
- combination you want to use. Then, configure your AI coding tool to use the
17
+ In each of your CodeGate workspaces, you can select the AI provider and model
18
+ combinations to use, even dynamically switching the active model based on file
19
+ types found in your prompt. Then, configure your AI coding tool to use the
16
20
CodeGate muxing endpoint ` http://localhost:8989/v1/mux ` as an OpenAI-compatible
17
21
API provider.
18
22
19
- To change the model currently in use, simply switch your active CodeGate
23
+ To change the model(s) currently in use, simply switch your active CodeGate
20
24
workspace.
21
25
22
26
``` mermaid
@@ -44,6 +48,9 @@ flowchart LR
44
48
- You have a project that requires a specific model for a particular task, but
45
49
you also need to switch between different models during the course of your
46
50
work.
51
+ - You're working in a monorepo with several different languages/file types and
52
+ want to dynamically switch to an optimal model as you move between different
53
+ parts of the codebase.
47
54
- You want to experiment with different LLM providers and models without having
48
55
to reconfigure your AI assistant/agent every time you switch.
49
56
- Your AI coding assistant doesn't support a particular provider or model that
@@ -58,7 +65,7 @@ flowchart LR
58
65
## Configure muxing
59
66
60
67
To use muxing with your AI coding assistant, you need to add one or more AI
61
- providers to CodeGate, then select the model you want to use on a workspace.
68
+ providers to CodeGate, then select the model(s) you want to use on a workspace.
62
69
63
70
CodeGate supports the following LLM providers for muxing:
64
71
@@ -93,13 +100,47 @@ For locally-hosted models, you must use `http://host.docker.internal` instead of
93
100
94
101
:::
95
102
96
- ### Select the model for a workspace
103
+ ### Configure workspace models
97
104
98
105
Open the settings of one of your [ workspaces] ( ./workspaces.mdx ) from the
99
- Workspace selection menu or the
106
+ workspace selection menu or the
100
107
[ Manage Workspaces] ( http://localhost:9090/workspaces ) screen.
101
108
102
- In the ** Preferred Model** section, select the model to use with the workspace.
109
+ In the ** Model Muxing** section, select the default ("catch-all") model to use
110
+ with the workspace.
111
+
112
+ To assign a different model based on filename, click ** Add Filter** . In the
113
+ ** Filter by** column, enter a file name or extension string to match. This is a
114
+ simple substring match, wildcards are not supported. For example, to match
115
+ Python files, enter ` .py ` . Then select the model to use with that file type.
116
+
117
+ Filter rules are evaluated top-down. CodeGate selects the active model for a
118
+ request using the first matching rule. If the prompt contains multiple files in
119
+ context, the first rule that matches _ any_ of the files is used. If no filter is
120
+ matched, the catch-all rule applies.
121
+
122
+ <ThemedImage
123
+ alt = ' An example showing several muxing rules for different file types'
124
+ sources = { {
125
+ light: useBaseUrl (' /img/features/muxing-rules-light.webp' ),
126
+ dark: useBaseUrl (' /img/quickstart/muxing-rules-dark.webp' ),
127
+ }}
128
+ title = ' Example muxing rules'
129
+ width = { ' 800px' }
130
+ />
131
+ _ An example showing several muxing rules for different file types_
132
+
133
+ Breaking down the above example:
134
+
135
+ - Markdown files (` .md ` ) use the gpt-4o-mini model from the OpenAI provider.
136
+ - JavaScript and TypeScript files (` .js ` and ` .ts ` , which also matches ` .jsx `
137
+ and ` .tsx ` ) use anthropic/claude-3.5-sonnet via OpenRouter.
138
+ - All other requests use Ollama.
139
+ - A request containing both a JavaScript and Markdown file will match the ` .md `
140
+ rule first and use OpenAI.
141
+
142
+ You can validate which provider was used for a given request by checking the
143
+ ** conversation summary** in the CodeGate dashboard.
103
144
104
145
### Manage existing providers
105
146
0 commit comments