NeatlogsNeatlogs

Gemini

Neatlogs offers seamless integration with Gemini, Google's AI platform for large language models.

Installation

To get started with Gemini, you'll need to install the package:

pip install neatlogs google-genai

Setting Up API Keys

Before using Gemini with Neatlogs, you need to set up your API keys. You can obtain:

Then to set them up, you can either export them as environment variables or set them in a .env file:

GEMINI_API_KEY="your_gemini_api_key_here"

Then load the environment variables in your Python code:

from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()

os.getenv("GEMINI_API_KEY")

Usage

Once you've set up your Gemini integration, integrating Neatlogs takes just two lines of code:

import neatlogs
neatlogs.init(api_key="<YOUR_API_KEY>")

Examples

Here's a simple example of how to use Gemini with Neatlogs:

from google import genai
from dotenv import load_dotenv
import os

import neatlogs
import agentops

agentops.init("api_key", )
# Load environment variables from .env file
load_dotenv()

neatlogs.init(
    api_key="<PROJECT_API_KEY>")


# Initialize the GenAI client with the API key
client = genai.Client(api_key=os.getenv('GEMINI_API_KEY'))

# Function to generate content using the GenAI client


def generate_response(prompt, model_name):
    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents=[{
            "role": "user",
            "parts": [{"text": prompt}]
        }])
    return response.text


# Main loop for interacting with the user
while True:
    # Get user input
    query = input("> ")

    # Generate the response
    response = generate_response(query, model_name='gemini-2.5-flash')

    # Print the response
    print(f"🤖: {response}")

After that, every API call is automatically traced and visualized in Neatlogs, perfect for debugging, evaluating and collaborating.

For more information on Gemini, check out their comprehensive documentation.