1
2
Create Google Generative AI API Key
Visit the Google Generative AI API Key page. Follow the instructions to create a new API key. Make sure to save the key as you will need it for the next steps.
3
Set API keys as environment variables
4
Install the Google Generative AI SDK
Ensure you have the necessary packages installed in your Python environment:
5
Import and configure the client
If you’re using Vertex AI integration (with Make sure the
GOOGLE_GENAI_USE_VERTEXAI=True
), you need to modify the target URL to point to the Vertex AI endpoint:GOOGLE_CLOUD_LOCATION
environment variable is set to your Google Cloud region (e.g., us-central1
).6
Generate content using the model