Skip to main content

Raindrop integration for Google Vertex AI / Gen AI

Project description

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
    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
tracing_enabled bool True Enable Raindrop tracing
bypass_otel_for_tools bool True Bypass OpenTelemetry for tool instrumentation
debug bool False Enable verbose DEBUG-level logging

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raindrop_vertex_ai-0.0.3.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raindrop_vertex_ai-0.0.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file raindrop_vertex_ai-0.0.3.tar.gz.

File metadata

  • Download URL: raindrop_vertex_ai-0.0.3.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for raindrop_vertex_ai-0.0.3.tar.gz
Algorithm Hash digest
SHA256 eb98027bae301c2ca8ae96fb9edcac6e37c3977fa884fceb17a53f03a8115033
MD5 a83d1fed3c1e6c8c79c47052e55145ce
BLAKE2b-256 590797ed65daf3985607ccbd03af39a859f344b48190d9cdc0a09c2acc8461b8

See more details on using hashes here.

File details

Details for the file raindrop_vertex_ai-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for raindrop_vertex_ai-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e2df0f4e37064174c723e87e0e175d80d0d4b0facb387277c578f4b058f6d8
MD5 35be45c9a1c19429cdd1d91d68f0136d
BLAKE2b-256 4bb5ba8e45493c1f51ea7860fae6aec807bbe96a123d52b83a335e1f839328fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page