> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Capturing large AI events - Docs Copy page # Capturing large AI events - Docs **Public beta** Large event capture is in public beta, available in [posthog-python](/docs/libraries/python.md#ai-observability) 7.39+ and [posthog-node](/docs/libraries/node.md#ai-observability) 5.49+ (with `@posthog/ai` 8.8+). We'd love to [hear your feedback](https://app.posthog.com/ai-observability#panel=support%3Afeedback%3Allm-analytics%3Alow%3Atrue) as we roll it out. AI events can get big – a single generation can carry megabytes of prompt context or base64-encoded media, more than regular event capture accepts. To handle this, PostHog sends AI events like `$ai_generation` and `$ai_embedding` through a dedicated ingestion path that accepts events up to **8MB**. During the beta, this path is opt-in. How you opt in depends on how you capture AI events today. ## Using the SDK integrations By default, our [SDK integrations](/docs/ai-observability/installation.md) redact base64 media and may truncate very long strings before capture. To capture everything in full, pass a single flag when creating your PostHog client: PostHog AI ### Python ```python from posthog import Posthog posthog = Posthog( "", host="https://us.i.posthog.com", enable_full_ai_capture=True ) ``` ### TypeScript ```typescript const posthog = new PostHog( '', { host: 'https://us.i.posthog.com', enableFullAiCapture: true } ) ``` With the flag on, nothing is truncated or redacted. The one exception is [privacy mode](/docs/ai-observability/privacy-mode.md): when it's enabled, input and output content is still stripped, flag or no flag. ## Calling capture\_ai directly If you build AI events yourself instead of using the integrations, call `capture_ai` (Python) or `captureAi` (Node) instead of `capture`. It takes the same arguments as `capture` and returns the captured event's UUID. PostHog AI ### Python ```python from posthog import Posthog posthog = Posthog("", host="https://us.i.posthog.com") uuid = posthog.capture_ai( "$ai_generation", distinct_id="user_123", properties={ "$ai_trace_id": trace_id, "$ai_model": "gpt-5", "$ai_input": messages, "$ai_output_choices": choices, }, ) ``` ### TypeScript ```typescript import { PostHog } from 'posthog-node' const posthog = new PostHog('', { host: 'https://us.i.posthog.com' }) const uuid = posthog.captureAi({ distinctId: 'user_123', event: '$ai_generation', properties: { $ai_trace_id: traceId, $ai_model: 'gpt-5', $ai_input: messages, $ai_output_choices: choices, }, }) ``` Send content as your provider produced it, including base64 and data URIs – there's no need to reshape payloads. `capture_ai` captures exactly what you pass it, without truncating or redacting anything. [Privacy mode](/docs/ai-observability/privacy-mode.md) doesn't apply here, so leave out any content you don't want stored. In serverless and other short-lived environments, use the awaitable variant in Node so the event is delivered before the runtime exits: TypeScript PostHog AI ```typescript await posthog.captureAiImmediate({ distinctId: 'user_123', event: '$ai_generation', properties }) ``` In Python, call `posthog.flush()` before exit (or enable `sync_mode`), just like with `capture`. ## Other platforms Not on Python or Node? Build events with [manual capture](/docs/ai-observability/installation/manual-capture.md) and point your capture requests at the dedicated AI endpoint instead of the regular one – same request format, different path: Terminal PostHog AI ```shell POST https://us.i.posthog.com/i/v0/ai/batch/ ``` ## Limits Events up to **8MB** are accepted for now. The SDKs drop larger events before sending and log an error instead. The limit will increase as the beta continues. ### Still have questions? Ask PostHog AI ### Was this page useful? HelpfulCould be better