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
- Configure
OPENAI_COMPATIBLE_BASE_URL to https://generativelanguage.googleapis.com/v1beta/openai
- Set
OPENAI_COMPATIBLE_API_KEY to a valid Gemini API key
- Add
gemini-2.0-flash-exp to OPENAI_COMPATIBLE_MODELS
- Try to use AI chat feature in Twenty CRM
- 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.
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
OPENAI_COMPATIBLE_BASE_URLtohttps://generativelanguage.googleapis.com/v1beta/openaiOPENAI_COMPATIBLE_API_KEYto a valid Gemini API keygemini-2.0-flash-exptoOPENAI_COMPATIBLE_MODELSExpected Behavior
Gemini should work as an OpenAI-compatible provider since it supports the
/chat/completionsendpoint.Actual Behavior
Twenty makes requests to
/responsesendpoint 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:Proposed Solution
Use
provider.chat(modelId)instead ofprovider(modelId)for OpenAI-compatible providers: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/completionsendpoint directly and it works:But Twenty's container logs show it's calling
/responses:Environment
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.