Skip to main content

raindrop-vertex-ai

Raindrop integration for Google Vertex AI / Gen AI (Python). Automatically captures models.generate_content() and aio.models.generate_content() calls.

Installation

pip install raindrop-vertex-ai google-genai

google-genai is a required dependency.

Quick Start

from raindrop_vertex_ai import RaindropVertexAI
from google import genai

raindrop = RaindropVertexAI(api_key="your-write-key", user_id="user-123")

client = genai.Client(api_key="...")
wrapped = raindrop.wrap(client)

response = wrapped.models.generate_content(
    model="gemini-2.0-flash", contents="Hello!"
)
print(response.text)

raindrop.shutdown()

Omitting api_key disables telemetry shipping (a warning is emitted) but does not crash your application.

What Gets Tracked

  • generate_content — input content, output text, model name
  • Token usage — prompt_token_count and candidates_token_count from usage metadata
  • 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 type and message in properties, then re-raised
  • Async support — both models.generate_content (sync) and aio.models.generate_content (async) are instrumented
  • Double-wrap guard — calling wrap() on an already-wrapped client is a safe no-op

Configuration

raindrop = RaindropVertexAI(
    api_key="rk_...",                    # Optional: your Raindrop API key
    user_id="user-123",                  # Optional: associate events with a user
    convo_id="convo-456",                # Optional: conversation/thread ID
    project_id="support-prod",           # Optional: route events to a specific project (slug)
    tracing_enabled=True,                # Optional: enable Raindrop tracing (default: True)
    bypass_otel_for_tools=True,          # Optional: bypass OTEL for tools (default: True)
    debug=True,                          # Optional: enable verbose DEBUG logging
)
Option Type Default Description
api_key str None Raindrop API key
user_id str None Associate all events with a user
convo_id str None Group events into a conversation
project_id str None Route events to a specific project (slug); omit for the default Production project
tracing_enabled bool True Enable Raindrop tracing
bypass_otel_for_tools bool True Bypass OpenTelemetry for tool instrumentation
disable_auto_instrument bool True Library auto-instrumentation is opt-in (see below)
debug bool False Enable verbose DEBUG-level logging

Library auto-instrumentation is opt-in

As of 0.0.4, disable_auto_instrument defaults to True: the integration no longer lets Traceloop monkey-patch every LLM client library it recognizes in your process (google.genai itself, Anthropic, botocore, etc.). The wrapper captures input/output, token usage, model name, and finish_reason directly from the wrapped client's responses, so no library patching is needed for full dashboards.

If you specifically want LLM-call-level spans from library instrumentation and have verified compatibility in your environment, opt back in with disable_auto_instrument=False.

Debug Logging

raindrop = RaindropVertexAI(api_key="rk_...", debug=True)

Async Usage

import asyncio
from raindrop_vertex_ai import RaindropVertexAI
from google import genai

raindrop = RaindropVertexAI(api_key="rk_...")
client = genai.Client(api_key="...")
wrapped = raindrop.wrap(client)

async def main():
    response = await wrapped.aio.models.generate_content(
        model="gemini-2.0-flash", contents="Hello!"
    )
    print(response.text)

asyncio.run(main())
raindrop.shutdown()

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

Always call shutdown() before your process exits to ensure all telemetry is shipped:

raindrop.flush()     # flush pending data
raindrop.shutdown()  # flush + release resources

Projects

Route events to a specific project by passing its slug as project_id:

raindrop = RaindropVertexAI(
    api_key="rk_...",
    project_id="support-prod",
)

project_id sets the X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org's default Production project, which is the existing behavior. The same option is accepted by the create_raindrop_vertex_ai(...) factory. Invalid slugs are ignored with a warning and no header is sent.

Factory Function

A create_raindrop_vertex_ai() factory is also available for convenience:

from raindrop_vertex_ai import create_raindrop_vertex_ai

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

Full Documentation

See the Raindrop docs for complete API reference.

Testing

cd packages/vertex-ai-python
pip install -e ".[dev]"
python -m pytest tests/ -v

License

MIT

Release files for raindrop-vertex-ai 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raindrop-vertex-ai 0.0.9
File Size Uploaded
raindrop_vertex_ai-0.0.9.tar.gz 25.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for raindrop-vertex-ai 0.0.9
File Interpreter ABI Platform
raindrop_vertex_ai-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 36.1 kB

Release files / raindrop_vertex_ai-0.0.9.tar.gz

Download URL raindrop_vertex_ai-0.0.9.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1f500bf0f8379f12448692203ed624c339b1330fb0e10bbe0bcbfe11b9a618c5
BLAKE2b-256 checksum
How to use checksums
49b7ba9e4be8f9055753fb660cf0899eb9fa4f1ca5211ea7b3b5f300694f153d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / raindrop_vertex_ai-0.0.9-py3-none-any.whl

Download URL raindrop_vertex_ai-0.0.9-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdb5de27ae5f712efc68747eb0874d16a54c10e20fe32d7d800f57265323360d
BLAKE2b-256 checksum
How to use checksums
07b0263cd3d3b0078b3752890a7a359dc95768901243e08286f64af673a78d68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

0.0.11

2 release files

0.0.10

2 release files

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page