11---
22title : Model muxing
3- description : Configure a per-workspace LLM
3+ description : Pick the right LLM for the job
44---
55
6+ import useBaseUrl from ' @docusaurus/useBaseUrl' ;
7+ import ThemedImage from ' @theme/ThemedImage' ;
8+
69## Overview
710
811_ 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
1114especially useful when you're working on multiple projects or tasks that require
1215different AI models.
1316
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
1620CodeGate muxing endpoint ` http://localhost:8989/v1/mux ` as an OpenAI-compatible
1721API provider.
1822
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
2024workspace.
2125
2226``` mermaid
@@ -44,6 +48,9 @@ flowchart LR
4448- You have a project that requires a specific model for a particular task, but
4549 you also need to switch between different models during the course of your
4650 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.
4754- You want to experiment with different LLM providers and models without having
4855 to reconfigure your AI assistant/agent every time you switch.
4956- Your AI coding assistant doesn't support a particular provider or model that
@@ -58,7 +65,7 @@ flowchart LR
5865## Configure muxing
5966
6067To 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.
6269
6370CodeGate supports the following LLM providers for muxing:
6471
@@ -93,13 +100,47 @@ For locally-hosted models, you must use `http://host.docker.internal` instead of
93100
94101:::
95102
96- ### Select the model for a workspace
103+ ### Configure workspace models
97104
98105Open the settings of one of your [ workspaces] ( ./workspaces.mdx ) from the
99- Workspace selection menu or the
106+ workspace selection menu or the
100107[ Manage Workspaces] ( http://localhost:9090/workspaces ) screen.
101108
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.
103144
104145### Manage existing providers
105146
0 commit comments