Tips // Claude in practice

Tips for working better with Claude

One short tip at a time, with an example you can copy. Move through them at random or search for what you need.

APIAdvancedClaude API

A prompt that does not fit ≠ a response cut off by the window

A prompt that does not fit is rejected before generating; one that fits but hits the window ceiling cuts the output: they are diagnosed differently.

According to the course, a prompt that exceeds the token limit returns 400 invalid_request_error, and a body that exceeds the byte limit returns 413 request_too_large. If the prompt fits but generation hits the window, the response comes back truncated with stop reason model_context_window_exceeded. To stay ahead of it, look at the usage field of each response and the token counting API. Error names and stop reasons change: check them in the docs.

Example
Check in your code:
- status 400/413 → shrink or split the input before resending
- stop_reason == model_context_window_exceeded → the output was cut off, do not treat it as complete
#context#errors#stop-reason#tokens