Skip to content

feat (provider/perplexity): add reasoning tokens #7429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yilinjuang
Copy link

Background

Perplexity's Sonar Deep Research and other reasoning models return reasoning_tokens in their usage metadata. However, the AI SDK's Perplexity provider was not extracting or exposing these reasoning tokens.

Fixes #5406

Summary

  • Added reasoning_tokens field to Perplexity usage schema (perplexityUsageSchema)
  • Updated doGenerate method to map reasoning_tokens from Perplexity API response to standardized reasoningTokens in main usage object
  • Updated doStream method to handle reasoning tokens in streaming responses

Verification

Run perplexity api and verified the token is in response.

Tasks

  • 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)
  • Formatting issues have been fixed (run pnpm prettier-fix in the project root)

Related Issues

#5406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant