Commit 08045c2
authored
feat: configure multiple AI Bridge providers of the same type (#23948)
_Disclaimer: produced mostly by Claude Opus 4.6 following detailed
planning._
## Summary
- Support multiple instances of the same AI Bridge provider type via
indexed env vars (`CODER_AIBRIDGE_PROVIDER_<N>_<KEY>`), following the
`CODER_EXTERNAL_AUTH_<N>_<KEY>` pattern
- Existing single-provider env vars (`CODER_AIBRIDGE_OPENAI_KEY`, etc.)
continue to work unchanged
- Setting both a legacy env var and an indexed provider with the same
name errors at startup to prevent silent misconfiguration
- Mark legacy provider fields (`OpenAI`, `Anthropic`, `Bedrock`) as
deprecated in `AIBridgeConfig` in favor of `Providers`
## Example
```sh
CODER_AIBRIDGE_PROVIDER_0_TYPE=anthropic
CODER_AIBRIDGE_PROVIDER_0_NAME=anthropic-corp
CODER_AIBRIDGE_PROVIDER_0_KEY=sk-ant-corp-xxx
CODER_AIBRIDGE_PROVIDER_0_BASE_URL=https://llm-proxy.internal.example.com/anthropic
CODER_AIBRIDGE_PROVIDER_1_TYPE=anthropic
CODER_AIBRIDGE_PROVIDER_1_NAME=anthropic-direct
CODER_AIBRIDGE_PROVIDER_1_KEY=sk-ant-direct-yyy
```
Each instance is routed by name:
- /api/v2/aibridge/**anthropic-corp**/v1/messages
- /api/v2/aibridge/**anthropic-direct**/v1/messages
Closes
[AIGOV-157](https://linear.app/codercom/issue/AIGOV-157/spike-to-understand-if-there-is-a-simple-way-to-handle-multi-api-key)
---------
Signed-off-by: Danny Kopping <danny@coder.com>1 parent 730edba commit 08045c2Copy full SHA for 08045c2
17 files changed
+1,323-160Lines changed: 1323 additions & 160 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- cli
- testdata
- coderd
- apidoc
- codersdk
- docs
- ai-coder/ai-gateway
- clients
- reference/api
- enterprise
- aibridgeproxyd
- cli
- site/src/api
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+123Lines changed: 123 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
56 | 56 | |
57 | 57 | |
58 | 58 | |
| 59 | + |
59 | 60 | |
60 | 61 | |
61 | 62 | |
| ||
842 | 843 | |
843 | 844 | |
844 | 845 | |
| 846 | + |
| 847 | + |
| 848 | + |
| 849 | + |
| 850 | + |
| 851 | + |
845 | 852 | |
846 | 853 | |
847 | 854 | |
| ||
2901 | 2908 | |
2902 | 2909 | |
2903 | 2910 | |
| 2911 | + |
| 2912 | + |
| 2913 | + |
| 2914 | + |
| 2915 | + |
| 2916 | + |
| 2917 | + |
| 2918 | + |
| 2919 | + |
| 2920 | + |
| 2921 | + |
| 2922 | + |
| 2923 | + |
| 2924 | + |
| 2925 | + |
| 2926 | + |
| 2927 | + |
| 2928 | + |
| 2929 | + |
| 2930 | + |
| 2931 | + |
| 2932 | + |
| 2933 | + |
| 2934 | + |
| 2935 | + |
| 2936 | + |
| 2937 | + |
| 2938 | + |
| 2939 | + |
| 2940 | + |
| 2941 | + |
| 2942 | + |
| 2943 | + |
| 2944 | + |
| 2945 | + |
| 2946 | + |
| 2947 | + |
| 2948 | + |
| 2949 | + |
| 2950 | + |
| 2951 | + |
| 2952 | + |
| 2953 | + |
| 2954 | + |
| 2955 | + |
| 2956 | + |
| 2957 | + |
| 2958 | + |
| 2959 | + |
| 2960 | + |
| 2961 | + |
| 2962 | + |
| 2963 | + |
| 2964 | + |
| 2965 | + |
| 2966 | + |
| 2967 | + |
| 2968 | + |
| 2969 | + |
| 2970 | + |
| 2971 | + |
| 2972 | + |
| 2973 | + |
| 2974 | + |
| 2975 | + |
| 2976 | + |
| 2977 | + |
| 2978 | + |
| 2979 | + |
| 2980 | + |
| 2981 | + |
| 2982 | + |
| 2983 | + |
| 2984 | + |
| 2985 | + |
| 2986 | + |
| 2987 | + |
| 2988 | + |
| 2989 | + |
| 2990 | + |
| 2991 | + |
| 2992 | + |
| 2993 | + |
| 2994 | + |
| 2995 | + |
| 2996 | + |
| 2997 | + |
| 2998 | + |
| 2999 | + |
| 3000 | + |
| 3001 | + |
| 3002 | + |
| 3003 | + |
| 3004 | + |
| 3005 | + |
| 3006 | + |
| 3007 | + |
| 3008 | + |
| 3009 | + |
| 3010 | + |
| 3011 | + |
| 3012 | + |
| 3013 | + |
| 3014 | + |
| 3015 | + |
| 3016 | + |
| 3017 | + |
| 3018 | + |
| 3019 | + |
| 3020 | + |
| 3021 | + |
| 3022 | + |
| 3023 | + |
| 3024 | + |
| 3025 | + |
| 3026 | + |
2904 | 3027 | |
2905 | 3028 | |
2906 | 3029 | |
|
0 commit comments