Calculate Streaming Token Usage Costs

Read the full interview experience this question came from →

Quick Overview

Implement an exact usage calculator for language-model API requests with separate input and output token prices. Normalize streaming chunk deltas and non-streaming totals, reject malformed counts, avoid floating-point billing errors, and handle empty or very large workloads.

Calculate Streaming Token Usage Costs

Company: Anthropic

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

Overview: Implement an exact usage calculator for language-model API requests with separate input and output token prices. Normalize streaming chunk deltas and non-streaming totals, reject malformed counts, avoid floating-point billing errors, and handle empty or very large workloads.

Read the full Anthropic Software Engineer interview experience this question came from

|Home/Coding & Algorithms/Anthropic
Anthropic logo
Anthropic
Jul 8, 2026
hardSoftware EngineerOnsiteCoding & Algorithms
27
0
Loading...

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...