Skip to content

feat: expose serviceTier in CompletionUsage from OpenAI Responses API#1205

Merged
toubatbrian merged 2 commits intolivekit:mainfrom
piyush-gambhir:feat/expose-service-tier
Apr 9, 2026
Merged

feat: expose serviceTier in CompletionUsage from OpenAI Responses API#1205
toubatbrian merged 2 commits intolivekit:mainfrom
piyush-gambhir:feat/expose-service-tier

Conversation

@piyush-gambhir
Copy link
Copy Markdown
Contributor

Summary

Mirrors livekit/agents#5341 for the JavaScript/TypeScript SDK.

OpenAI returns service_tier in every API response, indicating the processing tier actually used (e.g. "default", "priority", "flex"). This is important for accurate cost tracking since priority tier has different billing rates.

Changes

  • agents/src/llm/llm.ts: Add serviceTier?: string to CompletionUsage interface
  • plugins/openai/src/responses/llm.ts: Read event.response.service_tier in handleResponseCompleted and pass it to CompletionUsage

Backward Compatible

  • serviceTier is optional — no impact on existing code

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

🦋 Changeset detected

Latest commit: bcfa8c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@piyush-gambhir piyush-gambhir force-pushed the feat/expose-service-tier branch from 8015d32 to 4a1f9d5 Compare April 4, 2026 23:35
devin-ai-integration[bot]

This comment was marked as resolved.

OpenAI returns service_tier (e.g. "default", "priority", "flex") in
every API response. This adds it to CompletionUsage and reads it in
the Responses plugin's handleResponseCompleted.

Changes:
- Add serviceTier?: string to CompletionUsage interface
- Read event.response.service_tier in Responses LLM
@piyush-gambhir piyush-gambhir force-pushed the feat/expose-service-tier branch from 4a1f9d5 to 91725a5 Compare April 5, 2026 10:30
Copy link
Copy Markdown
Contributor

@toubatbrian toubatbrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG! Can you fix the build error in CI. thanks

Declare service_tier on wsResponseCompletedEventSchema so the WS
Responses handler can read it without a double cast, mirroring the
pattern in responses/llm.ts. Fixes prettier line-length lint error.
@piyush-gambhir
Copy link
Copy Markdown
Contributor Author

piyush-gambhir commented Apr 9, 2026

LG! Can you fix the build error in CI. thanks
Made the CI change, can you run the CI once again.

@toubatbrian

@toubatbrian toubatbrian merged commit a4ed445 into livekit:main Apr 9, 2026
6 checks passed
@github-actions github-actions bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants