File size: 561 Bytes
840e8fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import google.generativeai as genai
import os

# Prefer environment variable, fallback to hardcoded key
api_key = os.getenv("GEMINI_API_KEY", "AIzaSyC-mxxBvsAvP9XzRcI04dBfVoGFL8wCv2I")

if not api_key:
    raise ValueError("❌ Missing GEMINI_API_KEY. Please set it as environment variable or hardcode it.")

# βœ… Configure Gemini
genai.configure(api_key=api_key)

# Example: Generate text
model = genai.GenerativeModel("gemini-1.5-flash")

response = model.generate_content("Rewrite this paragraph to sound more persuasive and concise.")
print(response.text)