Initial random proxy server
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
# Agent Setup
|
||||
|
||||
This artifact is a standalone Express API server. It exposes a static model dashboard and OpenAI-compatible proxy routes backed by internally supplied provider endpoints.
|
||||
|
||||
## Required Agent Actions
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
2. Fill `config.json`.
|
||||
|
||||
Keep the server runnable with the existing defaults, but replace provider values when internal endpoints are available:
|
||||
|
||||
```json
|
||||
{
|
||||
"server": {
|
||||
"host": "127.0.0.1",
|
||||
"port": 8080
|
||||
},
|
||||
"proxy": {
|
||||
"apiKey": "dev-proxy-key"
|
||||
},
|
||||
"providers": {
|
||||
"openai": {
|
||||
"apiKey": "internal-openai-token",
|
||||
"baseURL": "https://your-internal-openai-endpoint/v1"
|
||||
},
|
||||
"anthropic": {
|
||||
"apiKey": "internal-anthropic-token",
|
||||
"baseURL": "https://your-internal-anthropic-endpoint"
|
||||
}
|
||||
},
|
||||
"logging": {
|
||||
"level": "info",
|
||||
"pretty": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Use only internal endpoints supplied by the runtime/integration. Do not use public official provider endpoints in this proxy config.
|
||||
|
||||
If no provider endpoints are available, leave `providers.*.apiKey` and `providers.*.baseURL` empty. The server still boots, `/dashboard` works, `/api/healthz` works, and `/v1/models` works. Chat completion calls return `503` until the target provider has both `apiKey` and `baseURL`.
|
||||
|
||||
3. Start the server:
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
The default config path is `config.json`. To use a different file:
|
||||
|
||||
```bash
|
||||
pnpm dev -- --config ./config.local.json
|
||||
```
|
||||
|
||||
## Hosted Deployment
|
||||
|
||||
For a hosted runtime that must bind all interfaces, set:
|
||||
|
||||
```json
|
||||
{
|
||||
"server": {
|
||||
"host": "0.0.0.0",
|
||||
"port": 8080
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Build and run production output:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
pnpm start
|
||||
```
|
||||
|
||||
## Routes
|
||||
|
||||
- `GET /` and `GET /dashboard` - static model dashboard
|
||||
- `GET /api/healthz` - health check
|
||||
- `GET /v1/models` - OpenAI-compatible model list
|
||||
- `POST /v1/chat/completions` - OpenAI-compatible chat proxy
|
||||
|
||||
The `/v1/*` routes require:
|
||||
|
||||
```text
|
||||
Authorization: Bearer <proxy.apiKey>
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
curl -s http://localhost:8080/dashboard | head
|
||||
curl -s http://localhost:8080/api/healthz
|
||||
curl -s -H "Authorization: Bearer dev-proxy-key" http://localhost:8080/v1/models
|
||||
```
|
||||
|
||||
Chat completion check:
|
||||
|
||||
```bash
|
||||
curl -s http://localhost:8080/v1/chat/completions \
|
||||
-H "Authorization: Bearer dev-proxy-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"model":"gpt-5.2","messages":[{"role":"user","content":"hello"}]}'
|
||||
```
|
||||
|
||||
Expected result without provider config: `503` with a message asking for `providers.<name>.apiKey` and `providers.<name>.baseURL`.
|
||||
Reference in New Issue
Block a user