Skip to content

Gemini OpenAI-Compatible API Not Working - Uses Responses API Instead of Chat Completions #16213

Description

@samihalawa

Gemini OpenAI-Compatible API Not Working - Uses Responses API Instead of Chat Completions

Description

Twenty CRM's OpenAI-compatible AI integration doesn't work with Google's Gemini API because it uses the Responses API (/responses) endpoint, but Gemini only supports the Chat Completions API (/chat/completions).

Steps to Reproduce

  1. Configure OPENAI_COMPATIBLE_BASE_URL to https://generativelanguage.googleapis.com/v1beta/openai
  2. Set OPENAI_COMPATIBLE_API_KEY to a valid Gemini API key
  3. Add gemini-2.0-flash-exp to OPENAI_COMPATIBLE_MODELS
  4. Try to use AI chat feature in Twenty CRM
  5. Observe 404 Not Found error in container logs

Expected Behavior

Gemini should work as an OpenAI-compatible provider since it supports the /chat/completions endpoint.

Actual Behavior

Twenty makes requests to /responses endpoint which Gemini doesn't support, resulting in 404 errors.

Root Cause

In packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts:

private registerOpenAICompatibleModels(
  baseUrl: string,
  modelNamesString: string,
): void {
  const provider = createOpenAI({
    baseURL: baseUrl,
    apiKey: apiKey,
  });

  modelNames.forEach((modelId) => {
    this.modelRegistry.set(modelId, {
      modelId,
      provider: ModelProvider.OPENAI_COMPATIBLE,
      model: provider(modelId),  // ← PROBLEM: Uses Responses API
    });
  });
}

Proposed Solution

Use provider.chat(modelId) instead of provider(modelId) for OpenAI-compatible providers:

model: provider.chat(modelId),  // Uses /chat/completions instead of /responses

According to Vercel AI SDK v2.x documentation:

  • provider(modelId) → Responses API (/responses)
  • provider.chat(modelId) → Chat Completions API (/chat/completions)

Verification

I tested Gemini's /chat/completions endpoint directly and it works:

curl https://generativelanguage.googleapis.com/v1beta/openai/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-2.0-flash-exp","messages":[{"role":"user","content":"Hi"}]}'

But Twenty's container logs show it's calling /responses:

POST https://generativelanguage.googleapis.com/v1beta/openai/responses
→ 404 Not Found

Environment

  • Twenty CRM version: Latest (as of December 2025)
  • Vercel AI SDK: @ai-sdk/openai v2.0.30
  • AI Provider: Google Gemini (OpenAI-compatible endpoint)

Impact

Users cannot use Gemini as an AI provider, which is a popular and cost-effective option with generous free tier.

Workaround

Use OpenAI, Anthropic, or xAI instead of Gemini until this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Dev status

    None yet

    Start date

    None yet

    Target date

    None yet

    Quarter

    None yet

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions