Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat(ai-proxy): add /anthropic endpoint for OpenCode integration

Louis Beaumonte2c24c1a556e
diff --git a/screenpipe-js/ai-proxy/src/index.ts b/screenpipe-js/ai-proxy/src/index.ts
index bdf3a2582..262c67447 100644
--- a/screenpipe-js/ai-proxy/src/index.ts
+++ b/screenpipe-js/ai-proxy/src/index.ts
@@ -128,6 +128,19 @@ async function handleRequest(request: Request, env: Env, ctx: ExecutionContext):
return await handleVertexProxy(request, env);
}
+ // Anthropic-compatible endpoint for OpenCode integration
+ // OpenCode sends requests to baseURL/v1/messages when configured with api: "anthropic"
+ if (path === '/anthropic/v1/messages' && request.method === 'POST') {
+ console.log('OpenCode Anthropic proxy request to /anthropic/v1/messages');
+ return await handleVertexProxy(request, env);
+ }
+
+ // Anthropic models endpoint for OpenCode
+ if (path === '/anthropic/v1/models' && request.method === 'GET') {
+ console.log('OpenCode Anthropic models request');
+ return await handleVertexModels(env);
+ }
+
return createErrorResponse(404, 'not found');
} catch (error: any) {
console.error('error in fetch:', error?.message, error?.stack);