Skip to main content

Installation

pip install raindrop-dspy dspy

Quick Start

import dspy
from raindrop_dspy import create_raindrop_dspy

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

lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)

predict = dspy.Predict("question -> answer")
wrapped = raindrop["wrap"](predict)

result = wrapped(question="What is the capital of France?")
print(result.answer)

raindrop["shutdown"]()

What Gets Traced

  • Module calls — input kwargs, output text (from Prediction result), configured model name
  • Token usage — prompt/completion tokens if available in the result
  • Errors — captured and re-raised
Works with dspy.Predict, dspy.ChainOfThought, and custom dspy.Module subclasses.

Configuration

raindrop = create_raindrop_dspy(
    api_key="rk_...",           # Required: your Raindrop API key
    user_id="user-123",        # Optional: associate events with a user
    convo_id="convo-456",      # Optional: conversation/thread ID
)

Flushing and Shutdown

raindrop["flush"]()     # flush pending data
raindrop["shutdown"]()  # flush + release resources