@@ -9,6 +9,7 @@ Codegate is a configurable Generative AI gateway designed to protect developers
9
9
- Secure coding recommendations
10
10
- Prevention of AI recommending deprecated/malicious libraries
11
11
- Modular system prompts configuration
12
+ - Multiple AI provider support with configurable endpoints
12
13
13
14
## Development Setup
14
15
@@ -53,7 +54,11 @@ codegate/
53
54
│ ├── logging.py # Logging setup
54
55
│ ├── prompts.py # Prompts management
55
56
│ ├── server.py # Main server implementation
56
- │ └── providers/* # External service providers (anthropic, openai, etc.)
57
+ │ └── providers/ # External service providers
58
+ │ ├── anthropic/ # Anthropic provider implementation
59
+ │ ├── openai/ # OpenAI provider implementation
60
+ │ ├── vllm/ # vLLM provider implementation
61
+ │ └── base.py # Base provider interface
57
62
├── tests/ # Test files
58
63
└── docs/ # Documentation
59
64
```
@@ -128,9 +133,87 @@ Codegate uses a hierarchical configuration system with the following priority (h
128
133
- Log Level: Logging level (ERROR|WARNING|INFO|DEBUG)
129
134
- Log Format: Log format (JSON|TEXT)
130
135
- Prompts: System prompts configuration
136
+ - Provider URLs: AI provider endpoint configuration
131
137
132
138
See [ Configuration Documentation] ( configuration.md ) for detailed information.
133
139
140
+ ## Working with Providers
141
+
142
+ Codegate supports multiple AI providers through a modular provider system.
143
+
144
+ ### Available Providers
145
+
146
+ 1 . ** vLLM Provider**
147
+ - Default URL: http://localhost:8000
148
+ - Supports OpenAI-compatible API
149
+ - Automatically adds /v1 path to base URL
150
+ - Model names are prefixed with "hosted_vllm/"
151
+
152
+ 2 . ** OpenAI Provider**
153
+ - Default URL: https://api.openai.com/v1
154
+ - Standard OpenAI API implementation
155
+
156
+ 3 . ** Anthropic Provider**
157
+ - Default URL: https://api.anthropic.com/v1
158
+ - Anthropic Claude API implementation
159
+
160
+ ### Configuring Providers
161
+
162
+ Provider URLs can be configured through:
163
+
164
+ 1 . Config file (config.yaml):
165
+ ``` yaml
166
+ provider_urls :
167
+ vllm : " https://vllm.example.com"
168
+ openai : " https://api.openai.com/v1"
169
+ anthropic : " https://api.anthropic.com/v1"
170
+ ` ` `
171
+
172
+ 2. Environment variables:
173
+ ` ` ` bash
174
+ export CODEGATE_PROVIDER_VLLM_URL=https://vllm.example.com
175
+ export CODEGATE_PROVIDER_OPENAI_URL=https://api.openai.com/v1
176
+ export CODEGATE_PROVIDER_ANTHROPIC_URL=https://api.anthropic.com/v1
177
+ ```
178
+
179
+ 3 . CLI flags:
180
+ ``` bash
181
+ codegate serve --vllm-url https://vllm.example.com
182
+ ```
183
+
184
+ ### Implementing New Providers
185
+
186
+ To add a new provider:
187
+
188
+ 1 . Create a new directory in ` src/codegate/providers/ `
189
+ 2 . Implement required components:
190
+ - ` provider.py ` : Main provider class extending BaseProvider
191
+ - ` adapter.py ` : Input/output normalizers
192
+ - ` __init__.py ` : Export provider class
193
+
194
+ Example structure:
195
+ ``` python
196
+ from codegate.providers.base import BaseProvider
197
+
198
+ class NewProvider (BaseProvider ):
199
+ def __init__ (self , ...):
200
+ super ().__init__ (
201
+ InputNormalizer(),
202
+ OutputNormalizer(),
203
+ completion_handler,
204
+ pipeline_processor,
205
+ fim_pipeline_processor
206
+ )
207
+
208
+ @ property
209
+ def provider_route_name (self ) -> str :
210
+ return " provider_name"
211
+
212
+ def _setup_routes (self ):
213
+ # Implement route setup
214
+ pass
215
+ ```
216
+
134
217
## Working with Prompts
135
218
136
219
### Default Prompts
@@ -188,8 +271,9 @@ codegate serve --port 8989 --host localhost --log-level DEBUG
188
271
189
272
# Start with custom prompts
190
273
codegate serve --prompts my-prompts.yaml
274
+
275
+ # Start with custom provider URL
276
+ codegate serve --vllm-url https://vllm.example.com
191
277
```
192
278
193
279
See [ CLI Documentation] ( cli.md ) for detailed command information.
194
-
195
- [ Rest of development.md content remains unchanged...]
0 commit comments