https://github.com/allanotieno254/text-generation-with-google-gemini
This project demonstrates text generation using Google Gemini, Google's state-of-the-art generative AI model. Using Python and the official google-generativeai SDK
https://github.com/allanotieno254/text-generation-with-google-gemini
api generative-ai python sdk-python textwrap
Last synced: 14 days ago
JSON representation
This project demonstrates text generation using Google Gemini, Google's state-of-the-art generative AI model. Using Python and the official google-generativeai SDK
- Host: GitHub
- URL: https://github.com/allanotieno254/text-generation-with-google-gemini
- Owner: AllanOtieno254
- Created: 2025-09-01T22:13:52.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-09-01T22:54:36.000Z (9 months ago)
- Last Synced: 2025-10-11T05:19:40.777Z (8 months ago)
- Topics: api, generative-ai, python, sdk-python, textwrap
- Language: Jupyter Notebook
- Homepage: https://colab.research.google.com/github/google/generative-ai-docs/blob/main/site/en/tutorials/quickstart_colab.ipynb?utm_source=chatgpt.com#scrollTo=tuOe1ymfHZPu
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Text Generation with Google Gemini

## Table of Contents
1. [Project Overview](#project-overview)
2. [Motivation](#motivation)
3. [Key Features](#key-features)
4. [Technology Stack](#technology-stack)
5. [Installation and Setup](#installation-and-setup)
6. [Google Gemini API Key Setup](#google-gemini-api-key-setup)
7. [Usage Guide](#usage-guide)
- [Listing Available Models](#listing-available-models)
- [Generating Text](#generating-text)
- [Formatting Output with Markdown](#formatting-output-with-markdown)
8. [Code Explanation](#code-explanation)
9. [Examples](#examples)
10. [Contributing](#contributing)
11. [References](#references)
12. [License](#license)
---
## Project Overview
This project demonstrates **text generation using Google Gemini**, Google's state-of-the-art generative AI model. Using Python and the official `google-generativeai` SDK, this notebook allows users to:

- Connect securely to Google Gemini using an API key
- Explore available models for text generation
- Generate creative or professional text based on prompts
- Display output in a formatted Markdown style within Google Colab
This project is ideal for **data scientists, AI enthusiasts, and developers** who want hands-on experience with Google Gemini’s text generation capabilities.
---
## Motivation
With the rapid rise of generative AI models like GPT, Claude, and Gemini, it's increasingly important for developers to experiment and understand the capabilities of these models. Google Gemini provides a flexible and powerful platform for generating **high-quality text** that can be used in:
- Content creation
- Question-answering
- Interview preparation
- Summarization
- Brainstorming ideas
This project serves as a **step-by-step guide** for beginners to advanced users to integrate Gemini into their workflows.
---
## Key Features
- ✅ **Easy setup in Google Colab**
- ✅ **Secure API key handling** using Colab `userdata`
- ✅ **Listing all available Gemini models** that support text generation
- ✅ **Text generation with configurable prompts**
- ✅ **Formatted Markdown display** of generated content
- ✅ **Optional streaming support** for long outputs
- ✅ **Extensive code comments** for beginners
---
## Technology Stack
- **Python 3.10+**
- **Google Colab** (for easy cloud execution)
- **google-generativeai SDK** (official Python SDK for Google Gemini)
- **IPython.display** (Markdown formatting)
- **textwrap & pathlib** (text formatting and path handling)
---
##incase you dont get how this is achieved use the video below
https://www.kodeco.com/ai/paths/cloud-based-ai/45598500-text-generation-with-google-gemini/01-introduction-to-google-gemini/07?utm_source=chatgpt.com
## Installation and Setup
1. Open **Google Colab**: [https://colab.research.google.com](https://colab.research.google.com)
2. Install the required Python package:
```python
!pip install -q -U google-generativeai