Inspect the final stream event, distinguish an output limit from a disconnect, and decide whether retrying a tool call could duplicate work.
Your client prints half a file, pauses and starts again from the first line. Both requests show HTTP 200. Headers arrived before the first token, so that status tells you little about the end of the response.
Read the final event
In native Anthropic Messages, inspect stop_reason on message_delta and look for message_stop. In OpenAI-compatible Chat Completions, check finish_reason and the SSE termination specified by your provider. A length finish indicates an output limit. A socket closing in the middle of a JSON fragment leaves the cause open.
Capture a useful trace
Record the request ID, send time, first text time, final event type and time. Compare a short generation and a long one in the same client. A disconnect after a consistent idle interval is a reason to inspect client and proxy idle timeouts. If timing varies, send both traces to support without including your repository contents.
Check for side effects before retrying
A fresh text generation may be fine. A tool that already created an order or sent a message needs a state check before another attempt. Losing the final stream event does not undo an action that already ran.
Anthropic Messages · API errors
- Codex Auto Review pricing: what does one pull request cost?
Estimate small, medium and large reviews at current CheapAI rates. Include the follow-up pass and compare the bill with findings your team can reproduce.
- Claude Fable API pricing for a 100k-token document
Price an initial Fable response and five follow-up questions. Separate uncached input, cache reads and output and check the exact model version.
- Opus vs Sonnet for coding: when does the higher price pay off?
Compare cost per accepted patch, include failed runs and calculate a break-even point before choosing a Claude model for your repository.
- Codex 401 with a custom API key: check the host before buying credits
Diagnose invalid_api_key with the request URL, a catalog check and three provider settings. Keep the key out of terminal output and support tickets.
- Do Russian prompts cost more than English? Measure your own API tokens
Run a paired Claude token-count test, keep the code and tools fixed, then convert the difference to dollars before changing your team’s working language.
- What can a pelican SVG tell you about a coding model?
Evaluate rendering, instruction following and animation separately. Then compare the result with a reproducible patch in your own repository.
- How much does a Codex coding task cost through the API?
Estimate the cost of one bug fix and a batch of twenty using live API rates. Compare models by the cost of a passing patch, including retries.
- Claude wrote the prompt cache. Why did the next request read zero?
Read Claude usage fields, price a cache miss and run a controlled two-request check before changing your prompts or your API provider.
- How to check Gemini input token counts on long requests
Compare countTokens with usageMetadata on the same Gemini payload. Isolate chat history, tools, cached input and multilingual text before disputing a bill.