Back to Guides

Google Generative AI

Google's Generative AI SDK for Python and Node.js

Pythoneasy

The Google Generative AI SDK provides access to Gemini models. Decyra's proxy captures all Gemini API calls, enabling observability and control over your Google AI interactions.

Prerequisites

  • Decyra account with API key
  • Node.js 18+ installed
  • @google/generative-ai package installed

Installation

npm install @google/generative-ai @decyra/sdk

Integration

Wrap fetch to route through Decyra:

import { GoogleGenerativeAI } from '@google/generative-ai';
import { wrapFetch } from '@decyra/sdk';

const customFetch = wrapFetch(fetch, {
  baseURL: 'https://proxy.decyra.com',
  apiKey: process.env.DECYRA_API_KEY!,
});

const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY!);

// Note: You may need to configure the client to use custom fetch
// This depends on the SDK's internal implementation

Use the client for content generation:

const model = genAI.getGenerativeModel({ model: 'gemini-pro' });

const result = await model.generateContent('Explain neural networks');
const response = await result.response;
console.log(response.text());

What Gets Captured

FieldDescription
ModelGemini model identifier
TemperatureTemperature parameter
Max TokensMaximum output tokens
PromptInput prompt text
Prompt HashHash of the prompt
Response TimeAPI call duration
Token UsageInput/output tokens
CostEstimated API cost

Verify

Check your Decyra dashboard to see Google AI API calls in the traces view. Each generation request will appear with full details.

Next Steps