Hello, Generative AI API

最終更新日
公開日

無料で使えるAPIがあるんですね。知らなかった

目次

流れ

https://aistudio.google.com/apikey

にアクセスして、APIキーを発行する。

uv add google-genai

from google import genai

client = genai.Client(api_key="YOUR_API_KEY")

response = client.models.generate_content(
    model="gemini-2.0-flash",
    contents="Explain how AI works in a few words",
)

print(response.text)

こんな感じで動かす。

モデルは

とか?

参考