Skip to content

createVercelAISDKTokenUsage incompatible with AI SDK v5 #925

@cvolawless

Description

@cvolawless

Describe the bug
AI SDK v5’s streamText and generateText functions return usage with inputTokens/outputTokens/totalTokens. The LD helper trackVercelAISDKStreamTextMetrics and createVercelAISDKTokenUsage is still looking for promptTokens/completionTokens from v4, so it reads undefined and emits 0.

To reproduce
wrap streamText in trackVercelAISDKStreamTextMetrics - duration metrics are tracked but token use is not

Expected behavior
Token use is appropriately tracked in Vercel AI SDK v4 and v5

Logs
n/a

SDK version
"@launchdarkly/server-sdk-ai": "^0.11.0"

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpackage: sdk/server-aiLabel for issues affecting the server AI package.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions