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

2.5 KiB

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:
pnpm install
  1. Fill config.json.

Keep the server runnable with the existing defaults, but replace provider values when internal endpoints are available:

{
  "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.

  1. Start the server:
pnpm dev

The default config path is config.json. To use a different file:

pnpm dev -- --config ./config.local.json

Hosted Deployment

For a hosted runtime that must bind all interfaces, set:

{
  "server": {
    "host": "0.0.0.0",
    "port": 8080
  }
}

Build and run production output:

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:

Authorization: Bearer <proxy.apiKey>

Verification

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:

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.