rudderstack-ai
What it is
Product analytics for the AI features of a Python backend. rudderstack-ai observes
your OpenAI, OpenAI Agents SDK, Anthropic, Amazon Bedrock, Google Gen AI, LiteLLM,
LangChain / LangGraph or Claude Agent SDK calls, and your MCP servers, and sends the
standard AI events (spec v0.4) through the
RudderStack client your app already uses.
your request handler ── ai_interaction ── wrapped client / LangChain handler / tracked_query
│
└─ your rudder-sdk-python client ─▶ RudderStack ─▶ warehouse, destinations, audiences
Server-side only. Events land alongside your product events with the same userId
for funnels, retention and audiences ("users whose refund questions went unresolved").
Install
Python 3.12 or later. Install the extra for each library you use (extras and compatibility).
pip install "rudderstack-ai[openai]==0.15.0" # or: uv add "rudderstack-ai[openai]==0.15.0"
No dependencies of its own. Events use your
rudder-sdk-python client
(rudderstack.analytics), 2.1.4 or later: earlier releases refuse a message over 32 KiB as they send it (ASCII-escaped, with their own fields), so a non-ASCII event within the budget can be refused. The package never creates one.
Quickstart
import rudderstack.analytics as rudder_analytics
from openai import OpenAI
import rudderstack.ai
from rudderstack.ai import ai_interaction
from rudderstack.ai.openai import wrap_openai
rudder_analytics.write_key = "<WRITE_KEY>"
rudder_analytics.dataPlaneUrl = "<DATA_PLANE_URL>"
rudderstack.ai.configure(analytics=rudder_analytics) # once, at startup
client = wrap_openai(OpenAI())
def answer(user_id: str, chat_id: str, question: str) -> dict[str, str | None]:
with ai_interaction(user_id=user_id, conversation_id=chat_id, feature="support_bot") as interaction:
reply = client.chat.completions.create(
model="gpt-4.1-mini", messages=[{"role": "user", "content": question}]
)
interaction.set_outcome("resolved")
return {"answer": reply.choices[0].message.content, "interaction_id": interaction.id}
This sends ai_user_prompt_created and ai_response_received for the answer. Return
interaction.id with the answer, then report what the user did with it through
track_action().
In a script, worker or serverless handler, call rudderstack.ai.flush() before exiting
(Serverless and workers).
Integrations
Use one integration per call path.
| Integration | Entry point | Page |
|---|---|---|
| OpenAI / Azure / compatible gateways | wrap_openai |
Reference |
| Anthropic | wrap_anthropic |
Reference |
| Google Gen AI | wrap_google_genai |
Reference |
| Bedrock Converse | wrap_bedrock |
Reference |
| LangChain / LangGraph / Deep Agents | RudderStackCallbackHandler |
Reference |
| Claude Agent SDK | tracked_query, tracked_messages |
Reference |
| OpenAI Agents SDK | tracked_run, tracked_run_sync, tracked_run_streamed |
Reference |
| CrewAI | instrument_crewai |
Reference |
| LiteLLM | instrument_litellm |
Reference |
| DSPy tools | instrument_dspy |
Reference |
| MCP servers | wrap_mcp_server |
Reference |
| Native OpenTelemetry frameworks | register_tracing(product_events=True) |
Reference |
Documentation
| Page | What it covers |
|---|---|
| API | Configuration, identity, interactions, recording, streaming, flush, shutdown and troubleshooting |
| Events | Event properties, classification, scores, sampling, pricing and credits |
| Integrations | Adapters, extras, compatibility and known limits |
| MCP servers | Setup, protocols, identity, tool events and observation limits |
| Tracing | SDK spans, OpenTelemetry export, joins, setup and limits |
| Privacy | Capture policy, masking, custom properties, serialization and limits |
| Migration | Upgrade notes, recorder and exact migration-check commands |
| Client events | Client/server ownership and joins |
| Performance | Overhead, benchmarks, load, delivery and memory limits |
| Examples | Runnable apps and test commands |
examples/ includes an app per integration, a background agent,
three tracing apps and a full-stack chat app using FastAPI, Anthropic and the
RudderStack JavaScript SDK. Run with your API keys or offline with the bundled mock server.
Compatibility
Python 3.12 or later; tested in CI on 3.12, 3.13 and 3.14. See the supported and tested versions, adapter limits, MCP limits and tracing limits.
Contributing, security and license
See CONTRIBUTING.md and RELEASING.md. Report security issues as described in SECURITY.md.
Metadata
Release files for rudderstack-ai 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rudderstack_ai-0.17.0.tar.gz | 391.7 kB | With provenance | Details for rudderstack_ai-0.17.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rudderstack_ai-0.17.0-py3-none-any.whl | Python 3 | none | any | Details for rudderstack_ai-0.17.0-py3-none-any.whl |
Total release size: 810.5 kB
Release files / rudderstack_ai-0.17.0.tar.gz
| Download URL | rudderstack_ai-0.17.0.tar.gz |
|---|---|
| Size | 391.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bca040866dc64b9a6a639422f13a0e6f3c2560c95f8af71bdfb3bf4e64d9901a
|
|
BLAKE2b-256 checksum How to use checksums |
8eea6dd137cb76443966931f6bd0e769d374b216e00348e1940ea6ebe9750f52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / rudderstack_ai-0.17.0-py3-none-any.whl
| Download URL | rudderstack_ai-0.17.0-py3-none-any.whl |
|---|---|
| Size | 418.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8aa3ddeacd85e49a01394e2958555f7ef1b7ecd9b2982755eb730cf0e43d736a
|
|
BLAKE2b-256 checksum How to use checksums |
34b63efdf7055623d7e189f628f8ae02349b1bc11d2dab3a0f0ad9250fdb6ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for rudderstack-ai 0.17.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for rudderstack_ai-0.17.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.