Skip to content

Instantly share code, notes, and snippets.

@ntcho
Created February 28, 2026 20:25
Show Gist options
  • Select an option

  • Save ntcho/95ac16c5e6dce6bc437a47c956031993 to your computer and use it in GitHub Desktop.

Select an option

Save ntcho/95ac16c5e6dce6bc437a47c956031993 to your computer and use it in GitHub Desktop.

Fix for using Gemini in screenpipe

The issue stems from the underlying coding agent Pi not properly supporting Gemini API endpoint with OpenAI compatibility. You'll see 400 errors with no details.

1. Setup Gemini in screenpipe

  1. Create new AI preset (Settings > AI > Create Preset)
  2. Click 'Custom'
  3. Add https://generativelanguage.googleapis.com/v1beta/openai for the 'Custom URL'
  4. Add your API key and choose your model

Note

We are using .../openai to pass the connection test in the UI. See below for the actual URL the Pi agent will use.

2. Patch pi-coding-agent

  1. Open ~/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js (it should've been auto-installed via bun when you first open the app)
  2. Apply the following patch
// Separate providers into "full replacement" (has models) vs "override-only" (no models)
const replacedProviders = new Set();
const overrides = new Map();
for (const [providerName, providerConfig] of Object.entries(config.providers)) {

+    if (providerConfig.baseUrl.includes("generativelanguage.googleapis.com/v1beta/openai")) {
+        providerConfig.baseUrl = providerConfig.baseUrl.replace(/\/openai/, '') // remove OpenAI compat
+        providerConfig.api = "google-generative-ai"; // override api type
+    }

    if (providerConfig.models && providerConfig.models.length > 0) {
        // Has custom models -> full replacement
        replacedProviders.add(providerName);
    }
    ...

Note

This patch will make Pi to use google-generative-ai with generativelanguage.googleapis.com/v1beta, instead of openai-completions with generativelanguage.googleapis.com/v1beta/openai which has a lot of quirks that will result in 400 errors.

See this docs for list of apis supported by Pi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment