diff --git a/examples/count-tokens.ts b/examples/count-tokens.ts index e69de29b..22fae1f1 100755 --- a/examples/count-tokens.ts +++ b/examples/count-tokens.ts @@ -0,0 +1,20 @@ +#!/usr/bin/env -S npm run tsn -T + +import Anthropic from '@anthropic-ai/sdk'; + +const client = new Anthropic(); // gets API Key from environment variable ANTHROPIC_API_KEY + +async function main() { + const result = await client.messages.countTokens({ + messages: [ + { + role: 'user', + content: 'Hey Claude!?', + }, + ], + model: 'claude-3-5-sonnet-latest', + }); + console.dir(result); +} + +main();