Implement a reusable Google Gemini client integration using the AI Studio API (google-generativeai SDK). This is foundational infrastructure for translation features, supporting configurable model selection with gemini-2.5-flash-lite as the default.
We can also use the gemini-3.1-flash-lite model if the above is not available.
Acceptance Criteria
Configuration & Setup
Client Implementation
Tests
Contract
# src/app/core/ai_clients/google_gemini.py
class GoogleGeminiClient:
async def generate_content(self, prompt: str) -> str: ...
Out of Scope (Future Tickets)
- Actual translation endpoints/routers
- Prompt templates for translation
- Response streaming
- Rate limiting / retry logic
- Structured logging integration (separate ticket in progress)
Testing Commands
./fai.sh test src/tests/test_google_gemini.py -v
./fai.sh lint
./fai.sh typecheck
References
Implement a reusable Google Gemini client integration using the AI Studio API (
google-generativeaiSDK). This is foundational infrastructure for translation features, supporting configurable model selection withgemini-2.5-flash-liteas the default.We can also use the
gemini-3.1-flash-litemodel if the above is not available.Acceptance Criteria
Configuration & Setup
google-generativeaito pyproject.toml dependenciesGOOGLE_AI_API_KEYto Settings class in src/app/config.pyGOOGLE_AI_MODELsetting with default"gemini-2.5-flash-lite"./fai.sh buildto verify dependency installationClient Implementation
src/app/core/ai_clients/google_gemini.pywith:GoogleGeminiClientclass wrappinggoogle.generativeai.GenerativeModelgenai.configure(api_key=...)generate_content(prompt: str) -> strasync methodHTTPException(status.HTTP_502_BAD_GATEWAY)with detail messageTests
src/tests/test_google_gemini.pywith:generate_contentwith mocked SDK response (patchgenai.GenerativeModel.generate_content_async)HTTPExceptionwith 502 statusContract
Out of Scope (Future Tickets)
Testing Commands
./fai.sh test src/tests/test_google_gemini.py -v ./fai.sh lint ./fai.sh typecheckReferences
gemini-2.5-flash-lite(AI Studio tier)