Skip to content

Commit 355c11f

Browse files
committed
feat(openrouter): plumb OPENAI_BASE_URL and OpenRouter headers through installer and compose; docs: add OpenRouter usage
1 parent da06562 commit 355c11f

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Get PCAS up and running in minutes with our modern development workflow.
5959

6060
- Go 1.24+
6161
- Docker and Docker Compose
62-
- An OpenAI API key (for GPT-4 integration)
62+
- An OpenAI API key (OpenAI or OpenRouter key)
6363

6464
### 1. Clone and Setup
6565

@@ -140,6 +140,10 @@ Prefer a lightweight, interactive flow without Compose?
140140
- Send a test event: `pcasctl emit --type pcas.test.echo.v1 --data "{\"prompt\":\"hello\"}"`
141141
- One‑click Docker install/update pulls newest build by default (edge channel). Use `--channel stable` to pin releases.
142142

143+
Using OpenRouter instead of OpenAI:
144+
- Set env: `OPENAI_BASE_URL=https://openrouter.ai/api/v1` and use an OpenRouter API key in `OPENAI_API_KEY`.
145+
- Optional headers (recommended by OpenRouter): `OPENROUTER_SITE_URL=https://your.site` and `OPENROUTER_APP_NAME=PCAS`.
146+
143147
## 🤝 Community & Contribution
144148

145149
PCAS is an open-source project driven by the community. We sincerely invite you to join us.

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ services:
3030
- /app/vendor # Prevent vendor directory from being overwritten
3131
environment:
3232
- OPENAI_API_KEY=${OPENAI_API_KEY:-dummy-key}
33+
- OPENAI_BASE_URL=${OPENAI_BASE_URL:-}
34+
- OPENROUTER_SITE_URL=${OPENROUTER_SITE_URL:-}
35+
- OPENROUTER_APP_NAME=${OPENROUTER_APP_NAME:-}
3336
- PG_DSN=postgres://pcas:pcas_vector_db@postgres:5432/pcas_vectors?sslmode=disable
3437
- PCAS_ENV=development
3538
- GOFLAGS=-mod=readonly -buildvcs=false
@@ -44,4 +47,4 @@ volumes:
4447

4548
networks:
4649
default:
47-
name: pcas-network
50+
name: pcas-network

docs/getting-started/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Before you begin, ensure you have the following installed:
1616
- **Go**: Version 1.24 or later. You can download it from [golang.org](https://golang.org/dl/).
1717
- **Docker & Docker Compose**: Required for running PCAS with its default PostgreSQL and ChromaDB dependencies. Follow the official Docker installation guide for your operating system.
1818
- **Git**: For cloning the PCAS repository.
19+
- Optional: OpenRouter – if you prefer OpenRouter, set `OPENAI_BASE_URL=https://openrouter.ai/api/v1` and provide your OpenRouter API key in `OPENAI_API_KEY`.
1920

2021
## Step 1: Clone the PCAS Repository
2122

@@ -102,6 +103,7 @@ Options:
102103
- `-y/--yes` auto-accept prompts (where applicable)
103104
- `--apply-policy` replace `/data/policy.yaml` inside the running container and restart
104105
- `--reset-policy` remove existing `/data/policy.yaml` before applying (avoids permission/merge issues)
106+
- `--openai-base-url URL` override OpenAI base URL (e.g., `https://openrouter.ai/api/v1`)
105107

106108
What it does:
107109
- Pulls the image (unless `--no-pull`), ensures a data volume, prepares `policy.yaml`, and runs the container with restart policy.

scripts/install-or-update.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ VOLUME="pcas_data"
2424
POLICY_PATH=""
2525
POLICY_URL=""
2626
OPENAI_KEY="${OPENAI_API_KEY:-}"
27+
OPENAI_BASE_URL="${OPENAI_BASE_URL:-}"
2728
ADMIN_TOKEN=""
2829
PULL_IMAGE=1
2930
START_CONTAINER=1
@@ -54,6 +55,7 @@ Options:
5455
--policy PATH Local policy.yaml to mount
5556
--policy-url URL Download policy.yaml from URL to --dir/policy.yaml
5657
--openai-key KEY Provide OpenAI API key (or set OPENAI_API_KEY env)
58+
--openai-base-url URL Override base URL (e.g., https://openrouter.ai/api/v1)
5759
--admin-token KEY Set admin token for dynamic policy updates (PCAS_ADMIN_TOKEN)
5860
--channel CH Image channel (default: edge). Use 'stable' for latest release or 'edge' for newest main build
5961
--update Force refresh to newest build (edge if available, else latest). Usually unnecessary since default channel=edge
@@ -85,6 +87,7 @@ while [[ $# -gt 0 ]]; do
8587
--policy) POLICY_PATH="$2"; shift 2 ;;
8688
--policy-url) POLICY_URL="$2"; shift 2 ;;
8789
--openai-key) OPENAI_KEY="$2"; shift 2 ;;
90+
--openai-base-url) OPENAI_BASE_URL="$2"; shift 2 ;;
8891
--admin-token) ADMIN_TOKEN="$2"; shift 2 ;;
8992
--channel) CHANNEL="$2"; shift 2 ;;
9093
--no-pull) PULL_IMAGE=0; shift ;;
@@ -222,6 +225,7 @@ if [[ ${#ORIG_ARGS[@]} -gt 0 ]]; then
222225
--policy) POLICY_PATH="$2"; shift 2 ;;
223226
--policy-url) POLICY_URL="$2"; shift 2 ;;
224227
--openai-key) OPENAI_KEY=$(sanitize_secret "$2"); shift 2 ;;
228+
--openai-base-url) OPENAI_BASE_URL="$2"; shift 2 ;;
225229
--admin-token) ADMIN_TOKEN=$(sanitize_secret "$2"); shift 2 ;;
226230
--channel) CHANNEL="$2"; shift 2 ;;
227231
--no-pull) PULL_IMAGE=0; shift ;;
@@ -344,6 +348,19 @@ else
344348
warn "OPENAI_API_KEY not provided; search/RAG will be disabled (server still runs)"
345349
fi
346350

351+
# Optional: custom base URL (e.g., OpenRouter)
352+
if [[ -n "${OPENAI_BASE_URL}" ]]; then
353+
RUN_ARGS+=(-e "OPENAI_BASE_URL=${OPENAI_BASE_URL}")
354+
fi
355+
356+
# Optional: OpenRouter headers (if provided in env)
357+
if [[ -n "${OPENROUTER_SITE_URL:-}" ]]; then
358+
RUN_ARGS+=(-e "OPENROUTER_SITE_URL=${OPENROUTER_SITE_URL}")
359+
fi
360+
if [[ -n "${OPENROUTER_APP_NAME:-}" ]]; then
361+
RUN_ARGS+=(-e "OPENROUTER_APP_NAME=${OPENROUTER_APP_NAME}")
362+
fi
363+
347364
if [[ -n "${ADMIN_TOKEN}" ]]; then
348365
RUN_ARGS+=(-e "PCAS_ADMIN_TOKEN=${ADMIN_TOKEN}")
349366
fi

0 commit comments

Comments
 (0)