Skip to content

feat(ai): add missing usage attributes#13129

Merged
aayush-kapoor merged 5 commits intomainfrom
aayush/usage-telemtry
Mar 5, 2026
Merged

feat(ai): add missing usage attributes#13129
aayush-kapoor merged 5 commits intomainfrom
aayush/usage-telemtry

Conversation

@aayush-kapoor
Copy link
Collaborator

@aayush-kapoor aayush-kapoor commented Mar 5, 2026

Background

  • our telemetry span creation didn't account for certain usage metrics.
  • there were inconsistencies with how telemetry was captured in streamText and generateText.
  • there was also a bug where the top level span in generateText didn't calculate the total usage (and just accounted for the step usage)

Summary

  • add missing attributes such as:

    • "ai.usage.inputTokenDetails.noCacheTokens"
    • "ai.usage.inputTokenDetails.cacheReadTokens"
    • "ai.usage.inputTokenDetails.cacheWriteTokens"
    • "ai.usage.outputTokenDetails.textTokens"
  • got rid of the completionTokens and promptTokens (there was a TODO to rename them)

  • make the pattern consistent

  • bug fix

Manual Verification

na

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

@tigent tigent bot added ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. ai/telemetry feature New feature or request labels Mar 5, 2026
@aayush-kapoor aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 5, 2026
@aayush-kapoor aayush-kapoor merged commit ebd4da2 into main Mar 5, 2026
18 checks passed
@aayush-kapoor aayush-kapoor deleted the aayush/usage-telemtry branch March 5, 2026 22:35
vercel-ai-sdk bot pushed a commit that referenced this pull request Mar 5, 2026
## Background

- our telemetry span creation didn't account for certain usage metrics. 
- there were inconsistencies with how telemetry was captured in
streamText and generateText.
- there was also a bug where the top level span in generateText didn't
calculate the total usage (and just accounted for the step usage)

## Summary

- add missing attributes such as: 
  - "ai.usage.inputTokenDetails.noCacheTokens"
  - "ai.usage.inputTokenDetails.cacheReadTokens"
  - "ai.usage.inputTokenDetails.cacheWriteTokens"
  - "ai.usage.outputTokenDetails.textTokens"
  
- got rid of the completionTokens and promptTokens (there was a TODO to
rename them)
- make the pattern consistent
- bug fix

## Manual Verification

na

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)
@vercel-ai-sdk vercel-ai-sdk bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Mar 5, 2026
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Mar 5, 2026

✅ Backport PR created: #13142

@gr2m gr2m removed the ai/telemetry label Mar 6, 2026
vercel-ai-sdk bot added a commit that referenced this pull request Mar 6, 2026
This is an automated backport of #13129 to the release-v6.0 branch. FYI
@aayush-kapoor

Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com>
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Mar 6, 2026

🚀 Published in:

Package Version
ai 7.0.0-beta.5
@ai-sdk/alibaba 2.0.0-beta.2
@ai-sdk/angular 3.0.0-beta.5
@ai-sdk/azure 4.0.0-beta.3
@ai-sdk/baseten 2.0.0-beta.2
@ai-sdk/cerebras 3.0.0-beta.2
@ai-sdk/deepinfra 3.0.0-beta.2
@ai-sdk/deepseek 3.0.0-beta.2
@ai-sdk/fireworks 3.0.0-beta.2
@ai-sdk/groq 4.0.0-beta.2
@ai-sdk/huggingface 2.0.0-beta.2
@ai-sdk/langchain 3.0.0-beta.5
@ai-sdk/llamaindex 3.0.0-beta.5
@ai-sdk/moonshotai 3.0.0-beta.2
@ai-sdk/openai 4.0.0-beta.3
@ai-sdk/openai-compatible 3.0.0-beta.2
@ai-sdk/react 4.0.0-beta.5
@ai-sdk/rsc 3.0.0-beta.5
@ai-sdk/svelte 5.0.0-beta.5
@ai-sdk/togetherai 3.0.0-beta.2
@ai-sdk/vercel 3.0.0-beta.2
@ai-sdk/vue 4.0.0-beta.5
@ai-sdk/xai 4.0.0-beta.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/core core functions like generateText, streamText, etc. Provider utils, and provider spec. feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants