Skip to content

feat: add OpenAI-compatible Gemini TTS speech endpoint - #236

Open
MaziarAshtari wants to merge 1 commit into
iBUHub:mainfrom
MaziarAshtari:main
Open

feat: add OpenAI-compatible Gemini TTS speech endpoint#236
MaziarAshtari wants to merge 1 commit into
iBUHub:mainfrom
MaziarAshtari:main

Conversation

@MaziarAshtari

Copy link
Copy Markdown
Contributor

Summary

Adds OpenAI-compatible POST /v1/audio/speech support for Gemini TTS models.

The endpoint translates OpenAI Speech API requests to Gemini native
generateContent TTS requests, decodes Gemini inline PCM audio, and returns
binary WAV or raw PCM responses.

Supported

  • Gemini TTS models, including gemini-3.1-flash-tts-preview
  • response_format: "wav" (default)
  • response_format: "pcm"

Validation

  • Unsupported formats (mp3, aac, flac, opus) return 400
  • Unsupported fields such as speed, instructions, stream, and
    stream_format return 400
  • Missing or malformed Gemini audio responses return OpenAI-style errors

Tests

  • Added 16 tests for validation, request conversion, WAV generation,
    PCM responses, upstream errors, malformed audio responses, and chat-route
    regression coverage.
  • npm test passes
  • npm run lint passes, aside from one pre-existing vue/no-v-html warning
  • git diff --check passes

Notes

Responses are buffered because Gemini returns base64 PCM through
generateContent, and WAV output requires container metadata.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0aba30063

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1096 to +1097
},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor configured safety settings for speech requests

When operators set SAFETY_SETTINGS_THRESHOLD (the documented default is OFF), the chat and native generateContent paths add safetySettings before forwarding, but this new speech request is sent without ever going through _finalizeGoogleRequest or adding the default safety settings. In deployments relying on relaxed safety settings, TTS prompts that Google’s defaults would block can fail here even though the same generation configuration works through the other proxy paths; add the configured safety settings before returning/sending this Gemini request.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant