Skip to main content
Google BigQuery is a serverless cloud data warehouse. OpenRouter can stream traces directly into a BigQuery table for custom analytics, long-term storage, and business intelligence. Each trace becomes exactly one row, so the table can be queried directly without grouping or deduplicating by trace_id.

Step 1: Choose a project and enable the BigQuery API

  1. Open the Google Cloud Console and create or select a project.
  2. Copy the project ID (not the project name). It is the lowercase identifier shown in IAM & Admin > Settings.
  3. In APIs & Services > Library, search for BigQuery API and click Enable.

Step 2: Create the dataset

  1. Open BigQuery > Explorer, select the project, and choose Create dataset.
  2. Choose a dataset ID, such as openrouter.
  3. Choose the dataset location carefully. A dataset’s region cannot be changed after creation, so pick a location allowed by your data-residency requirements.
BigQuery Datasets

Step 3: Create the traces table

Create the openrouter_traces table in your dataset. You can find the exact SQL in the OpenRouter dashboard when configuring the destination — click View Setup Instructions. Replace my-gcp-project in the DDL with your project ID (and the dataset or table IDs if you chose different ones), then run it in the BigQuery SQL workspace:
BigQuery Table Setup
Once created, the table appears in your dataset:
BigQuery Dataset Tables

Step 4: Create a service account

  1. Open IAM & Admin > Service Accounts in the project and click Create service account (e.g., openrouter-broadcast).
  2. Grant it the BigQuery Data Editor role on the trace dataset (not at the organization or project level): open the dataset’s menu in BigQuery, choose Share > Permissions, add the service account email, and select BigQuery Data Editor. Do not grant BigQuery Job User — this destination uses streaming inserts and does not create query jobs.
  3. Open the service account’s Keys tab, choose Add key > Create new key, select JSON, and download the key.
Keep the downloaded key private. It contains a private signing key and should not be committed to source control.

Step 5: Enable Broadcast in OpenRouter

Go to Settings > Observability and toggle Enable Broadcast.
Enable Broadcast

Step 6: Configure BigQuery

Click the edit icon next to Google BigQuery and enter:
BigQuery Configuration
  • Google Cloud project ID: The project ID containing the dataset.
  • Service-account key JSON: The complete contents of the downloaded JSON key file.
  • BigQuery dataset: The dataset ID created above (default: openrouter).
  • BigQuery table: The table ID created above (default: openrouter_traces).

Step 7: Test and save

Click Test Connection to verify the setup. The connection test reads the table’s metadata to verify the project, dataset, table, and credentials, then checks that the credentials hold the row-insert permission, so read-only access fails the test rather than failing on every later trace. The configuration only saves if the test passes.

Step 8: Send a test trace

Click Send Trace, or make an API request through OpenRouter, and query your BigQuery table to verify the trace was received:
BigQuery Table Preview

Example queries

Cost analysis by model

User activity analysis

Error analysis

Provider performance comparison

Usage by API key

Accessing JSON columns

The attributes, input, output, metadata, model_parameters, and resource_attributes columns are JSON typed. Use BigQuery’s JSON functions to query nested fields:
To parse input messages:

Schema design

Typed columns

The schema extracts commonly-queried fields as typed columns for efficient filtering and aggregation:
  • Identifiers: trace_id, user_id, session_id, etc.
  • Timestamps: TIMESTAMP columns for time-series analysis
  • Model Info: For cost and performance analysis
  • Metrics: Tokens and costs for billing

JSON columns

Less commonly-accessed and variable-structure data is stored in JSON columns:
  • attributes: Full OTEL attribute set
  • input/output: Variable message structures
  • metadata: User-defined key-values
  • model_parameters: Model-specific configurations
The tags column is a repeated STRING column (ARRAY<STRING>). Use BigQuery’s JSON_VALUE and JSON_QUERY functions to query the JSON fields.

Custom Metadata

Custom metadata from the trace field is stored in the metadata JSON column. You can query it using BigQuery’s JSON functions.

Supported Metadata Keys

Example

Querying Custom Metadata

Additional Context

  • The user field maps to the user_id typed column
  • The session_id field maps to the session_id typed column
  • All custom metadata keys from trace are stored in the metadata JSON column for flexible querying

Troubleshooting

  • Project not found or permission denied: Confirm that the configured project ID is the project containing the dataset and that the service account belongs to the expected project.
  • Table not found: Confirm the dataset and table IDs and that the table was created in the configured dataset location.
  • 403 permission denied: Grant the service account BigQuery Data Editor on the dataset. Project-level access may be restricted by organization policy, so verify the dataset permission directly.
  • 400 invalid or schema mismatch: Compare the table schema with the DDL from the setup instructions. In particular, timestamps must be TIMESTAMP, nested trace fields must be JSON, and tags must be ARRAY<STRING>.

Additional resources

Privacy Mode

When 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.