Skip to main content
Portkey supports the AWS Bedrock CountTokens API, which returns the token count for a given inference request. This helps you estimate token usage before sending requests to foundation models, allowing you to estimate costs, optimize prompts to fit within token limits, and plan for token usage in your applications. The token count returned by this operation matches the token count that would be charged if the same input were sent to the model in an InvokeModel or Converse request.

Using Count Tokens with Portkey

Portkey supports Bedrock’s CountTokens endpoint through the Anthropic-compatible format, allowing you to use the same API signature across Bedrock, Vertex AI, and Anthropic providers.

Use Cases

  • Estimate costs before sending inference requests
  • Optimize prompts to fit within token limits
  • Plan for token usage in your applications

Portkey is now PRISMA AIRS AI Gateway. See it in action.

Contact Us
Last modified on August 6, 2026