Skip to main content

Documentation Index

Fetch the complete documentation index at: https://raindrop.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Installation

npm install @raindrop-ai/vertex-ai @google/genai

Quick Start

import { createRaindropVertexAI } from "@raindrop-ai/vertex-ai";
import { GoogleGenAI } from "@google/genai";

const raindrop = createRaindropVertexAI({
  writeKey: "your-write-key",
  userId: "user-123",
});

const client = new GoogleGenAI({ apiKey: "..." });
const wrapped = raindrop.wrap(client);

const response = await wrapped.models.generateContent({
  model: "gemini-2.0-flash",
  contents: "What is the capital of France?",
});

console.log(response.text);
await raindrop.shutdown();

What Gets Traced

  • generateContent — input text (user messages only), output, model, token usage (promptTokenCount/candidatesTokenCount)
  • Cached tokenscached_content_token_count from usage metadata → ai.usage.cached_tokens
  • Thinking tokensthoughts_token_count from usage metadata (Gemini 2.5) → ai.usage.thoughts_tokens
  • Finish reasoncandidate.finish_reason (STOP, MAX_TOKENS, SAFETY, RECITATION) → vertex_ai.finish_reason
  • Errors — captured with error status, re-thrown to caller

Configuration

const raindrop = createRaindropVertexAI({
  writeKey: "your-write-key",       // Optional: omit to disable telemetry
  endpoint: "...",          // Optional: custom Raindrop API endpoint
  userId: "user-123",      // Optional: associate events with a user
  convoId: "convo-456",    // Optional: conversation/thread ID
  debug: false,             // Optional: enable verbose logging
});

identify()

raindrop.identify(user_id="user-123", traits={"plan": "pro", "org": "acme"})

track_signal()

raindrop.track_signal(
    event_id="evt-abc",
    name="thumbs_up",
    signal_type="feedback",
    sentiment="POSITIVE",
    comment="Great response!",
)

Flushing and Shutdown

await raindrop.flush();     // flush pending data
await raindrop.shutdown();  // flush + release resources

finish_reason Tracking

The Python wrapper captures candidate.finish_reason from Vertex AI responses and maps it to vertex_ai.finish_reason in event properties. Possible values: STOP, MAX_TOKENS, SAFETY, RECITATION.

Token Tracking

The following token usage fields are captured from usage_metadata:
FieldProperty KeyDescription
prompt_token_countai.usage.prompt_tokensInput tokens
candidates_token_countai.usage.completion_tokensOutput tokens
cached_content_token_countai.usage.cached_tokensCached input tokens
thoughts_token_countai.usage.thoughts_tokensThinking tokens (Gemini 2.5)

Factory Function

A create_raindrop_vertex_ai() factory is also available:
from raindrop_vertex_ai import create_raindrop_vertex_ai

raindrop = create_raindrop_vertex_ai(api_key="rk_...", user_id="user-123")

Known Limitations

  • Python SDK: No events.* API — use raindrop.analytics directly. identify() and track_signal() are available on the wrapper instance.
  • Streaming: generateContentStream() is not instrumented. Only generateContent() is traced.