Repository navigation
Expand file tree
/
Copy path.env.example
More file actions
222 lines (183 loc) · 9.92 KB
/
Copy path.env.example
File metadata and controls
222 lines (183 loc) · 9.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# OpenCode API — example environment file.
#
# Create `.env` and fill in a generated API key:
#
# pnpm setup
#
# ...or copy this file yourself and edit the values:
#
# cp .env.example .env
#
# The gateway loads `.env` from the project root (and from the working directory)
# automatically at startup. Every variable below is read by `src/config.ts`; the
# uncommented values are the built-in defaults and the commented lines are
# examples or optional settings.
# ---------------------------------------------------------------------------
# Authentication
# ---------------------------------------------------------------------------
# API keys callers must present. The gateway accepts them from
# `Authorization: Bearer <key>`, `x-api-key: <key>` or
# `Authorization: Basic <base64(key:)>`. A bare value in `Authorization` with no
# scheme is not accepted.
#
# Default: sk-dummy-123. When neither OPENCODE_API_KEYS nor OPENCODE_API_KEY is
# set, the gateway uses that built-in development key and logs a warning, so it
# starts out of the box. It is public knowledge — anyone who can reach the port
# can use it. Replace it before exposing the gateway beyond localhost: the
# gateway refuses to start when the built-in key is still in use on a
# non-loopback HOST.
#
# Comma-separated list. Generate a strong key with:
# node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))"
# or run: pnpm setup -- --random
OPENCODE_API_KEYS=sk-dummy-123
# Single-key alias, appended to OPENCODE_API_KEYS. Handy for local use.
# OPENCODE_API_KEY=
# Set to true to disable authentication entirely. Only for a trusted loopback host.
# OPENCODE_ALLOW_NO_AUTH=false
# Optional operator credential tier: when this list is non-empty, `/admin/*`
# requires one of these keys and no longer accepts a general API key. Unset keeps
# today's behaviour (any configured API key can call the admin routes).
# OPENCODE_ADMIN_API_KEYS=
# ---------------------------------------------------------------------------
# HTTP listener
# ---------------------------------------------------------------------------
# Interface and port the gateway binds. Use HOST=0.0.0.0 inside a container.
HOST=127.0.0.1
PORT=20123
# Maximum accepted request body size in bytes (default 64 MiB). Base64 media
# inflates the body by ~33%, so keep this above OPENCODE_MAX_ATTACHMENT_BYTES.
# OPENCODE_MAX_BODY_BYTES=67108864
# Trust `x-forwarded-*` headers from a reverse proxy. Accepts `true` (every hop),
# a positive hop count (`1` = the immediate peer only), or a comma-separated list
# of trusted IPs/CIDRs. Enable only behind a proxy you control that overwrites the
# forwarded headers: with a plain `true` the client address, and therefore the
# per-address rate-limit bucket, is caller-controlled.
# OPENCODE_TRUST_PROXY=false
# Wall-clock budget for receiving one request body. A caller that never finishes
# sending is disconnected once it expires. Streamed responses are unaffected.
# OPENCODE_BODY_TIMEOUT_MS=300000
# Comma-separated CORS allow-list. `*` allows every origin.
# OPENCODE_CORS_ORIGINS=
# Serve GET /metrics without authentication.
# OPENCODE_METRICS_PUBLIC=false
# Dedicated scrape credential for GET /metrics. When set, the endpoint requires
# it (timing-safe compare) even when OPENCODE_METRICS_PUBLIC=true, so a scraper
# never needs a general-purpose API key.
# OPENCODE_METRICS_TOKEN=
# In-process rate limit per authenticated API key. RPM is requests per minute;
# BURST is the bucket capacity (0 derives max(1, ceil(rpm / 6))). RPM=0 disables
# the limiter. /admin/* uses a separate bucket. Rejections answer 429 with a
# retry-after header. Failed authentication is throttled separately (at least 60
# attempts per minute per client address) even when the limiter is disabled here.
# OPENCODE_RATE_LIMIT_RPM=0
# OPENCODE_RATE_LIMIT_BURST=0
# ---------------------------------------------------------------------------
# Upstream OpenCode server
# ---------------------------------------------------------------------------
# Resolution order when OPENCODE_SERVER_URL is unset:
# 1. OPENCODE_SERVER_URL (explicit server, must answer),
# 2. a private `opencode serve` child process (when OPENCODE_AUTOSTART=true),
# 3. a background OpenCode service discovered through `service.json`.
# OPENCODE_SERVER_URL=http://127.0.0.1:20124
# Password of the explicit server. `opencode serve` prints it at startup.
# OPENCODE_SERVER_PASSWORD=
# Spawn a private `opencode serve` when no explicit server is configured.
# OPENCODE_AUTOSTART=true
# Full path to the OpenCode CLI executable. When unset, the gateway searches
# PATH and the well-known global install locations.
# OPENCODE_BIN=/usr/local/bin/opencode
# Hostname and first port used for the private server. If the port is busy the
# gateway retries the next nine ports.
# OPENCODE_INTERNAL_HOST=127.0.0.1
# OPENCODE_INTERNAL_PORT=20124
# Extra arguments appended to `opencode serve ...`. Note: `--standalone` is NOT
# accepted by opencode 2.x.
# OPENCODE_SERVER_ARGS=
# Time allowed for the private server to report readiness (default 30 s).
# OPENCODE_START_TIMEOUT_MS=30000
# Wall-clock budget for one upstream turn (default 10 min).
# OPENCODE_REQUEST_TIMEOUT_MS=600000
# Budget for the first text/reasoning delta (default 3 min).
# OPENCODE_FIRST_TOKEN_TIMEOUT_MS=180000
# Cap on `<dataDir>/logs/opencode-<port>.log` (default 32 MiB). The supervised
# server's stdout/stderr is appended for its whole life and across restarts, so
# the file is rotated (truncated) once it would exceed this many bytes. Set 0 to
# keep it unbounded.
# OPENCODE_UPSTREAM_LOG_MAX_BYTES=33554432
# ---------------------------------------------------------------------------
# Agent and workspace
# ---------------------------------------------------------------------------
# Directory handed to OpenCode as the session `location`. The agent can read
# and write here. In Docker this is mounted at /workspace.
# OPENCODE_WORKDIR=./.opencode-api/workspace
# OpenCode agent used for API-driven turns.
# OPENCODE_AGENT=build
# Maximum agent steps per turn.
# OPENCODE_AGENT_MAX_STEPS=
# Permission ruleset applied to every API session, as a JSON array. Unset means
# the OpenCode default (build agent prompts/denies per its own policy).
# Deny first, then fall back to `ask`: an `allow` catch-all would grant the agent
# unrestricted tool access, so the built-in shell/web tools stay denied and
# everything else asks.
# OPENCODE_AGENT_PERMISSIONS=[{"action":"bash","resource":"*","effect":"deny"},{"action":"webfetch","resource":"*","effect":"deny"},{"action":"websearch","resource":"*","effect":"deny"},{"action":"*","resource":"*","effect":"ask"}]
# ---------------------------------------------------------------------------
# Gateway state, sticky sessions and model cache
# ---------------------------------------------------------------------------
# Data directory: gateway logs and the upstream `/data` mount in Docker.
# OPENCODE_DATA_DIR=./.opencode-api
# Reuse the OpenCode session that already holds a conversation prefix.
# OPENCODE_SESSION_CACHE=true
# OPENCODE_SESSION_TTL_MS=1800000
# OPENCODE_SESSION_MAX=500
# Persist the session cache to `<OPENCODE_DATA_DIR>/sessions.json`.
# OPENCODE_SESSION_PERSIST=false
# Model catalog cache lifetime (default 5 min).
# OPENCODE_MODEL_CACHE_TTL_MS=300000
# Alias map applied before model resolution, as a JSON object.
# OPENCODE_MODEL_ALIASES={"gpt-4o":"opencode/big-pickle","claude-3-5-sonnet":"opencode/seaglass-alpha-free"}
# ---------------------------------------------------------------------------
# Media / vision input
# ---------------------------------------------------------------------------
# Local file paths are OFF by default. When enabled, the real path must stay
# inside OPENCODE_ALLOWED_FILE_ROOTS (which defaults to OPENCODE_WORKDIR).
# OPENCODE_ALLOW_LOCAL_FILES=false
# OPENCODE_ALLOWED_FILE_ROOTS=
# Fetch `http(s)://` media server-side, then inline it as a data URI.
# OPENCODE_ALLOW_REMOTE_MEDIA_URLS=true
# Allow remote media on private/loopback addresses. Disabling it prevents SSRF
# against the host network. Default: false. Set it to true only when every media
# URL source is trusted; when it is enabled while HOST is not loopback the
# gateway logs a startup error naming the SSRF exposure.
# OPENCODE_ALLOW_PRIVATE_MEDIA_URLS=false
# Size and count limits. The same byte budget applies to one attachment and to
# the combined total per request: an attachment that would push the request over
# the budget is dropped entirely and its name is recorded in the prompt.
# OPENCODE_MAX_ATTACHMENT_BYTES=20971520
# OPENCODE_MAX_ATTACHMENTS=16
# OPENCODE_MEDIA_FETCH_TIMEOUT_MS=15000
# ---------------------------------------------------------------------------
# Reasoning / thinking effort
# ---------------------------------------------------------------------------
# off - never surface reasoning, ignore caller requests
# on-request - surface reasoning only when the caller asks (default)
# always - always select a thinking-effort variant
# OPENCODE_REASONING_DEFAULT=on-request
# Chat-surface only: also emit a `reasoning` alias next to `reasoning_content`.
# Set to `both`, or leave unset for `reasoning_content` only.
# OPENCODE_REASONING_FIELD=both
# Deny OpenCode's built-in tools (bash, webfetch, websearch, edit, write, patch,
# task, skill) for sessions whose client tools are bridged through the prompt,
# so the model emits a bridged tool call instead of using its own tools.
# OPENCODE_TOOL_BRIDGE_DENY_NATIVE_TOOLS=true
# Stream native OpenCode tool activity as SSE `opencode.tool_call` events.
# OPENCODE_EXPOSE_NATIVE_TOOLS=false
# OPENCODE_NATIVE_TOOL_EVENT=opencode.tool_call
# ---------------------------------------------------------------------------
# Observability
# ---------------------------------------------------------------------------
# OPENCODE_LOG_LEVEL=info
# Pretty-print logs. Defaults to true only when stdout is a TTY.
# OPENCODE_LOG_PRETTY=false
# OPENCODE_METRICS_ENABLED=true
# OPENCODE_INSTANCE_ID=opencode-api-<pid>