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
| Field | Description |
|---|---|
| Model | Gemini model identifier |
| Temperature | Temperature parameter |
| Max Tokens | Maximum output tokens |
| Prompt | Input prompt text |
| Prompt Hash | Hash of the prompt |
| Response Time | API call duration |
| Token Usage | Input/output tokens |
| Cost | Estimated 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.