A comprehensive FastAPI starter template for working with Google's Gemini AI models, supporting text, image, and audio processing.
-
Text Processing
- Text generation with prompts
- Structured chat conversations
- Context-aware text generation
-
Image Processing
- Single image analysis
- Multiple image analysis
- Image comparison
-
Audio Processing
- Audio transcription
- Content analysis
- Audio summarization
- Clone the repository:
git clone https://github.com/yourusername/google-genai-starter-template.git
cd google-genai-starter-template
- Install dependencies:
pip install -r requirements.txt
- Install additional audio dependencies:
# For Ubuntu/Debian
sudo apt-get install ffmpeg
# For macOS
brew install ffmpeg
# For Windows
# Download ffmpeg from https://ffmpeg.org/download.html
- Set up environment variables:
export GOOGLE_API_KEY="your_api_key_here"
- Start the server:
uvicorn app.main:app --reload
- Access the API documentation:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
POST /api/text/generate
POST /api/text/chat
POST /api/text/context
POST /api/image/analyze
POST /api/image/analyze-multiple
POST /api/image/compare
POST /api/audio/transcribe
POST /api/audio/analyze
POST /api/audio/summarize
import requests
response = requests.post(
"http://localhost:8000/api/text/generate",
json={
"prompt": "Write a short story about AI",
"temperature": 0.7
}
)
print(response.json())
import requests
files = {
'image': open('image.jpg', 'rb'),
'prompt': (None, 'Describe this image'),
'temperature': (None, '0.7')
}
response = requests.post(
"http://localhost:8000/api/image/analyze",
files=files
)
print(response.json())
import requests
files = {
'audio_file': open('audio.mp3', 'rb'),
'language': (None, 'en-US')
}
response = requests.post(
"http://localhost:8000/api/audio/transcribe",
files=files
)
print(response.json())
- FastAPI
- google-generativeai
- Pillow
- SpeechRecognition
- pydub
- python-multipart
- uvicorn
- Install development dependencies:
pip install pytest black isort flake8
- Run tests:
pytest
- Format code:
black .
isort .
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository.