Files
random-proxy-simple/readme.md
T
2026-04-27 11:55:31 +08:00

78 lines
1.8 KiB
Markdown

# Agent Instructions
This repository is a standalone Express API server. It is not intended to be added to a parent workspace.
## Run Exactly
```bash
pnpm install --ignore-workspace
pnpm dev
```
The server starts with built-in defaults even when `config.json` does not exist:
- host: `0.0.0.0`
- port: `8080`
- proxy bearer token: `dev-proxy-key`
Do not create `config.json` unless internal provider endpoints are available.
## Fill Provider Config
Only if internal provider endpoints are available:
```bash
cp config.example.json config.json
```
Then fill only these values:
```json
{
"providers": {
"openai": {
"apiKey": "internal-openai-token",
"baseURL": "https://your-internal-openai-endpoint/v1"
},
"anthropic": {
"apiKey": "internal-anthropic-token",
"baseURL": "https://your-internal-anthropic-endpoint"
}
}
}
```
Use internal endpoints supplied by the runtime/integration. Do not use public official provider endpoints.
If provider endpoints are not available, leave config absent. The dashboard, health check, and model list still work. Chat completion calls return `503` until the target provider has both `apiKey` and `baseURL`.
## 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
```
Expected chat result without provider config: `503` with a message asking for `providers.<name>.apiKey` and `providers.<name>.baseURL`.
## Production
```bash
pnpm build
pnpm start
```