PRODUCTION SCENARIO
A gateway service hardcodes each model's context window and output limit in a config file. Every model release forces a code change, and a stale entry recently caused prompt-too-long errors.
What should the service use instead?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: The Models API, which returns max_input_tokens, max_tokens, and capabilities
The models overview says the Models API lets you query model capabilities and token limits programmatically, with max_input_tokens, max_tokens, and a capabilities object for every available model. Token counting returns only the token count of a request.
Official Source: https://platform.claude.com/docs/en/models/overview ↗