ClickHouse is a fast, open-source columnar database for real-time analytics. OpenRouter can stream traces directly to your ClickHouse database for high-performance analytics and custom dashboards.
Before connecting OpenRouter, create the OPENROUTER_TRACES table in your ClickHouse database. You can find the exact SQL in the OpenRouter dashboard when configuring the destination:

Ensure your ClickHouse user has CREATE TABLE permissions:
Go to Settings > Observability and toggle Enable Broadcast.

Click the edit icon next to ClickHouse and enter:

https://clickhouse.example.com:8123)default)OPENROUTER_TRACES)default)For ClickHouse Cloud, your host URL is typically https://{instance}.{region}.clickhouse.cloud:8443. You can find this in your ClickHouse Cloud console under Connect.
Click Test Connection to verify the setup. The configuration only saves if the test passes.
Make an API request through OpenRouter and query your ClickHouse table to verify the trace was received.
ClickHouse stores JSON data as strings. Use JSONExtract functions to query
nested fields:
To parse input messages:
The schema extracts commonly-queried fields as typed columns for efficient filtering and aggregation:
Less commonly-accessed and variable-structure data is stored as JSON strings:
Use ClickHouse’s JSONExtract* functions to query these fields.
Custom metadata from the trace field is stored in the METADATA column as a JSON string. You can query it using ClickHouse’s JSONExtract functions.
Use ClickHouse’s JSON functions to query your custom metadata:
user field maps to the USER_ID typed columnsession_id field maps to the SESSION_ID typed columntrace are stored in the METADATA JSON string columnALTER TABLE ... ADD COLUMNWhen Privacy Mode is enabled for this destination, prompt and completion content is excluded from traces. All other trace data — token usage, costs, timing, model information, and custom metadata — is still sent normally. See Privacy Mode for details.