Skip to content

expose xAI realtime provider correlation ids through a non-deprecated API #6333

Description

@gianpaj

Feature Type

Would make my life easier

Feature Description

Problem

I'm using livekit-plugins-xai with xai.realtime.RealtimeModel.
I can see calls/responses in the xAI console, but I need to correlate those provider-side logs with my app's call/session ids.

Image

Currently, the only provider id I can find is RealtimeModelMetrics.request_id, which appears to map to the xAI/OpenAI realtime response.id. However, the AgentSession metrics_collected event is marked deprecated:

Use session_usage_updated for usage tracking and ChatMessage.metrics for per-turn latency.

Neither session_usage_updated nor ChatMessage.metrics appears to expose the provider response id or any provider session/conversation id.

Request

Please expose xAI realtime provider correlation ids through a non-deprecated API.

Useful fields would be:

  • provider response id, e.g. response.id
  • provider session/conversation id, if xAI returns one
  • possibly provider event id / client event id mapping

Possible places:

  • ChatMessage.metrics["llm_response_id"]
  • a field on assistant ChatMessage.extra
  • a non-deprecated AgentSession event for provider request/response metadata
  • session_usage_updated including request ids, if that fits the API design

Workarounds / Alternatives

Current workaround

Listen to deprecated metrics_collected and inspect:

from livekit.agents.metrics import RealtimeModelMetrics

@session.on("metrics_collected")
def on_metrics_collected(event):
    metrics = event.metrics
    if isinstance(metrics, RealtimeModelMetrics):
        print(metrics.request_id)

### Additional Context

- `livekit-agents`: 1.6.4+
- `livekit-plugins-xai`: 1.6.4+
- model: `grok-voice-think-fast-1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions