Gemini (Google Generative AI) is a leading provider of AI tools and services.
Explore the Gemini API for more information.
google-generativeai>=0.1.0 is currently supported.
Install the Gemini SDK
google-generativeai>=0.1.0 is required for Gemini integration.
pip install google-generativeai
Add 3 lines of code
Make sure to call agentops.init before calling any openai, cohere, crew, etc models.
import google.generativeai as genai
import agentops
agentops.init(<INSERT YOUR API KEY HERE>)
model = genai.GenerativeModel("gemini-1.5-flash")
...
# End of program (e.g. main.py)
agentops.end_session("Success") # Success|Fail|Indeterminate
Set your API key as an .env variable for easy access.
AGENTOPS_API_KEY=<YOUR API KEY>
GEMINI_API_KEY=<YOUR GEMINI API KEY>
Read more about environment variables in Advanced ConfigurationRun your Agent
Execute your program and visit app.agentops.ai/drilldown to observe your Agent! 🕵️After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard
Clickable link to session
Full Examples
import google.generativeai as genai
import agentops
agentops.init(<INSERT YOUR API KEY HERE>)
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content(
"Write a haiku about AI and humans working together"
)
print(response.text)
agentops.end_session('Success')
You can find more examples in the Gemini Examples section.