Repository navigation
feat: add API proxy port 10004 for OpenCode engine #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,30 @@ | |
| console.log('[API Proxy] GitHub Copilot proxy listening on port 10002'); | ||
| }); | ||
| } | ||
|
|
||
| // OpenCode API proxy (port 10004) — routes to Anthropic (default BYOK provider) | ||
| if (ANTHROPIC_API_KEY) { | ||
| const opencodeServer = http.createServer((req, res) => { | ||
| if (req.url === '/health' && req.method === 'GET') { | ||
| res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
| res.end(JSON.stringify({ status: 'healthy', service: 'opencode-proxy' })); | ||
| return; | ||
| } | ||
|
|
||
| console.log(`[OpenCode Proxy] ${sanitizeForLog(req.method)} ${sanitizeForLog(req.url)}`); | ||
| console.log(`[OpenCode Proxy] Injecting x-api-key header with ANTHROPIC_API_KEY`); | ||
| const anthropicHeaders = { 'x-api-key': ANTHROPIC_API_KEY }; | ||
| if (!req.headers['anthropic-version']) { | ||
| anthropicHeaders['anthropic-version'] = '2023-06-01'; | ||
| } | ||
| proxyRequest(req, res, 'api.anthropic.com', anthropicHeaders); | ||
| }); | ||
|
|
||
| opencodeServer.listen(10004, '0.0.0.0', () => { | ||
| console.log('[API Proxy] OpenCode proxy listening on port 10004 (-> Anthropic)'); | ||
| }); | ||
| } | ||
|
Comment on lines
+262
to
+288
|
||
|
|
||
| // Graceful shutdown | ||
| process.on('SIGTERM', () => { | ||
| console.log('[API Proxy] Received SIGTERM, shutting down gracefully...'); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.