How to Set Your IDE with Generative AI Environments to Generate Content
Prerequisites
This quickstart assumes that you’re familiar with building applications with Python.
To complete this quickstart, ensure that your development environment meets the following requirements:
- Python 3.9+
Install the Google Cloud client library:
Open your terminal or command prompt and run the following command:
pip install google-cloud-aiplatform
Optional) Create a virtual environment:
It’s generally good practice to use virtual environments to manage dependencies for your Python projects. This helps avoid conflicts between different projects. You can create a virtual environment using venv
python3 -m venv .venv
source .venv/bin/activate
pip install google-cloud-aiplatform
Install the Gemini API SDK
The Python SDK for the Gemini API is contained in the google-generativeai
package. Install the dependency using pip
pip install -q -U google-generativeai
Set up your API key
To use the Gemini API, you'll need an API key. If you don't already have one, create a key in Google AI Studio.
Here is the direct link to navigate https://aistudio.google.com/app/u/2/apikey
Once you click on Create Key it will be asking to select project which project you are going to set
Once your API key is created Then, configure your key.
Note:-It is strongly recommended that you do not check an API key into your version control system but assign it as an environment variable instead
export API_KEY=<YOUR_API_KEY>
Example: you set with your IDE an environment variable like this as follows below screenshot
Now Create a Python file like for example text-generation.py
and write the code
#Import the library
#Import and configure the Google Generative AI library.
import google.generativeai as genai
import os
genai.configure(api_key=os.environ["API_KEY"])
##Make your first request
## Use the generateContent method to generate text.
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content("Write a story about a magic backpack.")
print(response.text)
Follow the below screenshot
Now time to run your script and generate text
Back to your IDE, Go to the Genai directory and put the cmd python3 text-generation.py, follow the below steps on how to run the Python script.
Great, now we can generate the content you can set your environments as per your business needs :)😀👍
About Me
As businesses move towards cloud-based solutions, I provide my expertise to support them in their journey to the cloud. With over 15 years of experience in the industry, I am currently working as a Google Cloud Principal Architect. My specialization is in assisting customers to build highly scalable and efficient solutions on Google Cloud Platform. I am well-versed in infrastructure and zero-trust security, Google Cloud networking, and cloud infrastructure building using Terraform. I hold several certifications such as Google Cloud Certified, HashiCorp Certified, Microsoft Azure Certified, and Amazon AWS Certified.
Multi-Cloud Certified :
1. Google Cloud Certified — Cloud Digital Leader.
2. Google Cloud Certified — Associate Cloud Engineer.
3. Google Cloud Certified — Professional Cloud Architect.
4. Google Cloud Certified — Professional Data Engineer.
5. Google Cloud Certified — Professional Cloud Network Engineer.
6. Google Cloud Certified — Professional Cloud Developer Engineer.
7. Google Cloud Certified — Professional Cloud DevOps Engineer.
8. Google Cloud Certified — Professional Security Engineer.
9. Google Cloud Certified — Professional Database Engineer.
10. Google Cloud Certified — Professional Workspace Administrator.
11. Google Cloud Certified — Professional Machine Learning.
12. HashiCorp Certified — Terraform Associate
13. Microsoft Azure AZ-900 Certified
14. Amazon AWS-Practitioner Certified
I assist professionals and students in building their careers in the cloud. My responsibility is to provide easily understandable content related to Google Cloud and Google Workspace,aws .azure. If you find the content helpful, please like, share and subscribe for more amazing updates. If you require any guidance or assistance, feel free to connect with me.
YouTube:https://www.youtube.com/@growwithgooglecloud
Topmate :https://topmate.io/gcloud_biswanath_giri
Medium:https://bgiri-gcloud.medium.com/
Telegram: https://t.me/growwithgcp
Twitter: https://twitter.com/bgiri_gcloud
Instagram:https://www.instagram.com/multi_cloud_boy/
LinkedIn: https://www.linkedin.com/in/biswanathgiri/
GitHub:https://github.com/bgirigcloud
Facebook:https://www.facebook.com/biswanath.giri/
Linktree:https://linktr.ee/gcloud_biswanath_giri
and DM me,:) I am happy to help!!