Function setGlobalLlmObserver

  • Register (or clear) the process-wide LLM usage observer.

    Hosts typically call this once at app boot:

    setGlobalLlmObserver((event) => {
    recordFoundationUsageEvent({
    meterKey: event.source ?? 'llm.call',
    providerKey: event.provider,
    modelKey: event.model,
    quantity: event.usage.costUSD ?? 0,
    unit: 'usd',
    });
    });

    Passing null clears the observer (useful in tests).

    While content-safe telemetry is on (enableContentSafeTelemetry), the observer is not called; read usage from the call's result instead.

    Parameters

    Returns void