> ## Documentation Index
> Fetch the complete documentation index at: https://docs.weaveos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Oh My Pi

> Connect Oh My Pi to track model, token, session, and OpenRouter cost usage in Weave

Connect [Oh My Pi](https://github.com/can1357/oh-my-pi) to Weave to report AI model usage across your team. Weave receives Pi's OpenTelemetry traces and metrics: traces record completed chat requests, token usage, and sessions, while the cost metric records aggregate reported cost.

## What's tracked

* **Model usage** — the requested or served model from each completed chat request
* **Token usage** — uncached input, cache-read, cache-creation, and output tokens
* **Sessions** — chat requests grouped by Pi conversation ID when Pi provides one
* **Cost** — the cumulative cost metric Pi exports for completed chat calls, including OpenRouter's reported cost when the OpenRouter response provides it. Because this metric has no request or conversation ID, it is used for aggregate cost reporting rather than session assignment
* **People** — usage attributed to the Weave account identified by the telemetry resource email

Weave does not ingest Pi prompts, model responses, tool arguments, or tool results in this integration.

## Prerequisites

* The current Oh My Pi release installed
* An OpenRouter account and API key if your team routes Pi through OpenRouter
* Admin access to your Weave organization to create a Pi telemetry key
* The email address on each user's Weave account

## Setup

<Steps>
  <Step title="Create a Pi telemetry key in Weave">
    Go to **Data** → **Pi** → **Create API key**. The key is organization-wide. Copy the generated environment configuration immediately; Weave shows the full key only when it is created.
  </Step>

  <Step title="Configure each user's identity">
    The API key is shared by the organization, but identity is per person. Each Pi user must set `OTEL_RESOURCE_ATTRIBUTES` with their own Weave account email:

    ```bash theme={null}
    export OTEL_RESOURCE_ATTRIBUTES='user.email=you@yourcompany.com'
    ```

    Do not use another user's email. Requests without a usable identity are accepted by the ingest endpoint but are discarded before attribution.

    If `OTEL_RESOURCE_ATTRIBUTES` is already set, append `user.email` to the existing comma-separated value instead of replacing the existing resource attributes:

    ```bash theme={null}
    export OTEL_RESOURCE_ATTRIBUTES="user.email=you@yourcompany.com${OTEL_RESOURCE_ATTRIBUTES:+,$OTEL_RESOURCE_ATTRIBUTES}"
    ```

    The address must not contain `,` or `=` because those characters are separators in the OpenTelemetry resource-attribute format.
  </Step>

  <Step title="Enable the Weave OTLP exporter">
    Set these variables in the same environment that runs Oh My Pi. The **Data** → **Pi** page generates this block with the real key and signed-in user's email:

    ```bash theme={null}
    export OTEL_EXPORTER_OTLP_ENDPOINT='https://app.workweave.ai/ingest'
    export OTEL_EXPORTER_OTLP_PROTOCOL='http/protobuf'
    export OTEL_EXPORTER_OTLP_HEADERS='x-weave-token=wpikey_<your-weave-key>'
    export OTEL_RESOURCE_ATTRIBUTES='user.email=you@yourcompany.com'
    export OTEL_SERVICE_NAME='oh-my-pi'
    export OTEL_TRACES_EXPORTER='otlp'
    export OTEL_METRICS_EXPORTER='otlp'
    export OTEL_LOGS_EXPORTER='none'
    ```

    Pi appends `/v1/traces` and `/v1/metrics` to the OTLP endpoint for the two enabled signals:

    ```text theme={null}
    https://app.workweave.ai/ingest/v1/traces
    https://app.workweave.ai/ingest/v1/metrics
    ```
  </Step>

  <Step title="Configure OpenRouter in Pi">
    Configure OpenRouter in Oh My Pi using the [current Pi provider instructions](https://github.com/can1357/oh-my-pi). Add the OpenRouter credential to Pi's provider configuration and select the models your team wants to use.

    The OpenRouter credential stays in Pi. Do not send it to Weave or put it in the Weave telemetry header. Weave needs only the `wpikey_` telemetry key.
  </Step>

  <Step title="Verify the connection">
    Run a few Pi chat requests, then check the AI reports in Weave. Telemetry is processed asynchronously, so newly received activity may take time to appear. If a request is not attributed, first check that the user's `OTEL_RESOURCE_ATTRIBUTES` contains their own Weave email.
  </Step>
</Steps>

## Cost reporting

When Pi routes requests through OpenRouter, Pi exports OpenRouter's reported cost through the cumulative `pi.omp.agent.chat.cost.estimated_usd` OTLP metric. Weave converts repeated cumulative exports into deltas and includes those deltas in aggregate Pi cost reporting. The metric has no request or conversation ID, so it cannot be assigned to individual Pi sessions.

The trace path remains the source for per-request tokens and sessions. If Pi does not emit a populated cost metric, Weave retains the trace usage but cannot report aggregate provider cost.

See [OpenRouter usage in Weave](/ai-tools/openrouter) for the cost model, visibility, and reconciliation guidance.

## Visibility in Weave

Pi is the **source** shown in Weave for usage that Pi reports. OpenRouter is the provider Pi uses to fulfill a request. If you also connect [OpenRouter Analytics](/ai-tools/openrouter), the usage it syncs appears under a separate **OpenRouter** source.

After processing and the next reporting refresh, authorized users can see Pi usage in:

* **AI reports** — usage by person, team, time period, and AI tool
* **[AI tool costs](/metrics/ai-tool-costs)** — cost and request metrics, including the Pi source
* **Token usage views** — input, output, and cache-token totals by model and person
* **Session views** — Pi conversation activity when a conversation ID is present
* **Data** → **Pi** — telemetry-key management and the generated setup configuration

The current integration does not expose prompt text or tool-call content for drilldowns. This keeps the first rollout focused on model, token, session, and cost reporting.

## Troubleshooting

<AccordionGroup>
  <Accordion icon="plug" title="The request returns 200 but no activity appears">
    A 200 response means the telemetry was accepted for asynchronous processing; it does not mean the request is already visible in reports. Check the user's identity attribute, then allow time for ingest and reporting refreshes to complete.
  </Accordion>

  <Accordion icon="user" title="The request is not attributed to a person">
    Check that `OTEL_RESOURCE_ATTRIBUTES` contains `user.email=<the user's Weave email>`. Each person must set their own value. Do not share the email from another user's generated configuration.
  </Accordion>

  <Accordion icon="key" title="OpenRouter authentication fails">
    OpenRouter authentication is configured in Pi and is independent of the Weave telemetry key. Check Pi's provider configuration and OpenRouter credential; the Weave header should contain only the `wpikey_` value.
  </Accordion>

  <Accordion icon="dollar-sign" title="Requests have tokens but no cost">
    Aggregate Pi cost comes from the OTLP metrics signal. Pi also reports a cost on each chat span, which Weave uses for session costs but leaves out of aggregate AI tool cost so the same spend isn't counted twice. Confirm `OTEL_METRICS_EXPORTER='otlp'` is set and that Pi emits a populated `pi.omp.agent.chat.cost.estimated_usd` metric; if that metric is absent or zero, Weave keeps the usage data but has no aggregate cost to report.
  </Accordion>
</AccordionGroup>

## Related integrations

* [AI tool costs](/metrics/ai-tool-costs) — understand cost fidelity across AI tools
* [OpenTelemetry Collector](/ai-tools/otel-collector) — route Pi telemetry to Weave and other destinations
* [Ingest API](/integrations/ingest-api) — inspect the OTLP trace contract
* [Claude Code](/ai-tools/claude-code) — CLI-based AI assistant
* [Codex](/ai-tools/codex) — terminal AI assistant


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.