Skip to content

[Bug] 400 Bad Request error when using Google Gemini API via Custom Provider (OpenAI Chat protocol) #175

@CaioGS06

Description

@CaioGS06

Description

When attempting to use a Google Gemini API key through the "Custom provider" option using the OpenAI Chat wire protocol, the initial connection and model fetching succeed, but generating a design fails immediately with a 400 status code (no body) error.

Note for triage: Based on the logs, there are two likely culprits regarding Gemini's strict OpenAI wrapper:

  1. Model Name Prefix: The connection test successfully fetches models, but they are returned with the models/ prefix (e.g., models/gemini-3.1-pro-preview). Passing this prefix back in the generation payload might be causing the API to reject the request.
  2. Unsupported Agent Parameters: Gemini's OpenAI compatibility wrapper is very strict. If Open CoDesign's agent runtime is passing specific OpenAI parameters in the payload (like presence_penalty, frequency_penalty, or strict JSON schema enforcement) that Google hasn't mapped, it will reject the entire request with a 400 error regardless of prompt size.

Steps to reproduce

  1. Go to Settings -> Models -> + Add provider.
  2. Select Custom provider.
  3. Set Wire protocol to OpenAI Chat.
  4. Set Base URL to https://generativelanguage.googleapis.com/v1beta/openai/.
  5. Enter a valid Google Gemini API key.
  6. Click Test connection (this succeeds and populates the model dropdown).
  7. Select a model from the dropdown (e.g., models/gemini-3.1-pro-preview).
  8. Return to the chat and attempt to generate a design prompt.

Expected behavior

The app should successfully pass the prompt to the Gemini API via the OpenAI compatibility layer and return a generated design.

Actual behavior

The generation fails immediately. The UI displays an error dialog stating: Error invoking remote method 'codesign:v1:generate': CodesignError: 400 status code (no body).

open-codesign version

0.1.3

Platform

Windows

OS version

Windows 10

Model provider (if relevant)

Other

Error code

PROVIDER_ERROR

Diagnostics bundle

open-codesign-diagnostics-2026-04-22T21-30-40.zip

Logs

[2026-04-22 18:02:54.037] [info]   (main:ipc) [generate] step=load_config.ok {
  generationId: 'moajhfkr-0krhrt',
  ms: 0,
  hasApiKey: true,
  baseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai/'
}
...
[2026-04-22 18:02:54.419] [error]  (main:ipc) [title] step=send_request.fail { ms: 424, errorClass: 'CodesignError' }
[2026-04-22 18:02:54.419] [error]  (main:ipc) [title] generate-title.fail {
  provider: 'custom-gemini-api-dnpm',
  modelId: 'models/gemini-3.1-pro-preview',
  baseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai/',
  message: '400 status code (no body)',
  code: 'PROVIDER_ERROR'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageAwaiting maintainer review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions