# --- 必要ライブラリのインストール ---
!pip install -q google-generativeai
# --- Google Gemini APIキーの設定 ---
import google.generativeai as genai
# ★ Google AI Studio で発行した自分のAPIキーを貼り付ける
API_KEY = "ここに自分のAPIキー"
genai.configure(api_key=API_KEY)
# --- モデルの指定(短い話用) ---
model = genai.GenerativeModel("gemini-1.5-flash")
# flashは速くて安い、proは高精度
# --- 物語+英訳を作る関数 ---
def make_story_with_translation(theme="夕暮れの公園での出会い"):
prompt = f"""
以下を作成してください。
1. 日本語で100文字以内の短い物語
2. その英訳
3. 出力形式は次の通り
日本語: (短い物語)
English: (英訳)
テーマ: {theme}
"""
response = model.generate_content(prompt)
return response.text
# --- 実行例 ---
story = make_story_with_translation("猫と少年の心温まる話")
print(story)