Export to PostHog

Send LLM usage events from Future AGI's Prism Gateway to PostHog for product analytics.

📝
TL;DR

Connect your PostHog project and Future AGI will push LLM usage events from the Prism Gateway on every sync cycle. Each gateway request becomes a PostHog event you can use in funnels, trends, and dashboards.

What this does

This integration sends your Prism Gateway traffic to PostHog as product analytics events. Every API call that passes through the gateway becomes a prism_request event with properties like model, provider, latency, token counts, and cost.

This is useful when your product team wants to understand LLM usage patterns alongside other product events in PostHog - which features trigger the most LLM calls, or how costs break down by user segment.

What gets exported

Each Prism Gateway request becomes a PostHog event:

PropertyExampleDescription
eventprism_requestEvent name
distinct_idprism-gatewayIdentifies the source
properties.modelgpt-4oModel used
properties.provideropenaiProvider
properties.latency_ms842End-to-end latency
properties.input_tokens1200Prompt tokens
properties.output_tokens323Completion tokens
properties.total_tokens1523Total tokens
properties.cost0.02Cost in USD
properties.status_code200HTTP status
properties.is_errorfalseWhether the request failed
properties.cache_hittrueWhether the response was cached

Events are sent via PostHog’s Batch API, so they appear in your PostHog project like any other tracked event.


Before you start

You’ll need:

  • A PostHog account (cloud or self-hosted)
  • Your Project API Key (phc_...), found in PostHog > Project Settings > Project API Key
  • Admin or Owner role in your Future AGI workspace
  • The Prism Gateway set up and receiving traffic

Note

PostHog Cloud runs in two regions: US and EU. Make sure you select the right one during setup, or events will be sent to the wrong endpoint.


Connect PostHog

Open Integrations

Go to Settings > Integrations in your Future AGI workspace. Click Add Integration or click the PostHog card.

Integrations list page

Enter your PostHog credentials

On the Credentials step, fill in:

FieldRequiredDescription
PostHog RegionYesUS Cloud or EU Cloud. Not shown if self-hosted.
Project API KeyYesYour PostHog project API key (phc_...).

If you’re running a self-hosted PostHog instance, click “Using self-hosted PostHog?” to switch to a custom host URL field.

PostHog credentials form

Click Validate & Continue.

Configure sync settings

Set how often Future AGI batches and sends events to PostHog, and whether to backfill historical gateway data.

PostHog sync settings

Click Connect Integration.

Done

Events start flowing to PostHog on the next sync cycle.

Integration connected


Verify in PostHog

Once the first sync completes:

  • Go to PostHog > Events and filter for event name prism_request
  • Or go to PostHog > Insights and create a trend for prism_request events to see request volume over time

If nothing shows up after 10 minutes, check the sync status in Settings > Integrations.


Sync status

Monitor your integration from the detail page (Settings > Integrations > click your PostHog connection).

StatusMeaningAction
ActiveExporting on scheduleNone needed
SyncingA batch is being sent right nowWait for it to finish
PausedYou paused the export manuallyClick Resume when ready
ErrorAPI key invalid or PostHog rejected the requestCheck your API key and region

Troubleshooting

No events appearing in PostHog

Check that you selected the correct region (US vs EU). If your PostHog project is on EU Cloud but you selected US Cloud, events are being sent to the wrong endpoint. Edit the integration and switch the region.

Events appear but properties are missing

Make sure your Prism Gateway requests include model and provider information. If you’re using custom routing, some properties may be empty for requests that didn’t complete successfully.

Connection shows Error status

Your PostHog API key may have been revoked or rotated. Get a new key from PostHog > Project Settings > Project API Key, then edit the integration to update it.


What’s next

Was this page helpful?

Questions & Discussion