Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
import anthropic client = anthropic.Anthropic( api_key="dummy", # we will use portkey's provider slug default_headers={"x-portkey-api-key": "YOUR_PORTKEY_API_KEY"}, base_url="https://api.portkey.ai/v1" ) response = client.messages.count_tokens( model="@your-provider-slug/your-model-name", system="You are a scientist", messages=[{ "role": "user", "content": "Hello, Claude" }], ) print(response.json())
import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic({ apiKey: 'dummy', // we will use portkey's provider slug baseURL: "https://api.portkey.ai/v1", defaultHeaders: { "x-portkey-api-key": "YOUR_PORTKEY_API_KEY" } }); const response = await client.messages.countTokens({ model: '@your-provider-slug/your-model-name', system: 'You are a scientist', messages: [{ role: 'user', content: 'Hello, Claude' }] }); console.log(response);
curl https://api.portkey.ai/v1/messages/count_tokens \ --header "x-portkey-api-key: $PORTKEY_API_KEY" \ --header "content-type: application/json" \ --data '{ "model": "@your-provider-slug/your-model-name", "system": "You are a scientist", "messages": [{ "role": "user", "content": "Hello, Claude" }] }'
Was this page helpful?