79683855

Date: 2025-06-29 15:39:58
Score: 1
Natty:
Report link

I was looking for that but it seems Vercel AI SDK doesn't support it. I use Anthropic's SDK to count tokens:
https://docs.anthropic.com/en/docs/build-with-claude/token-counting#how-to-count-message-tokens

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const response = await client.messages.countTokens({
  model: 'claude-opus-4-20250514',
  system: 'You are a scientist',
  messages: [{
    role: 'user',
    content: 'Hello, Claude'
  }]
});

console.log(response);

Result:
{ "input_tokens": 14 }

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Dmitriy Green