Your Claude integration returns a successful HTTP status. The application displays several paragraphs. The billing record shows that tokens were consumed.

Yet the answer stops halfway through a sentence.

For a developer, this is frustrating. For a business application, it can be more serious: a customer receives an unfinished explanation, a generated document loses its final section, or a downstream service tries to parse half of a JSON object.

The first question should not be whether Claude needs a different prompt.

It should be whether the model finished, the transport finished, and the application correctly recognized both events.

When Claude is accessed through an API gateway, there is another boundary to inspect. The gateway may forward the native response, translate it into another format, or stream it through additional infrastructure. Each route needs to preserve enough information for your application to distinguish a completed answer from an interrupted one.

This guide develops a practical investigation process. The examples are illustrative, not measurements from a production incident.

Start with the evidence that the request actually finished

Imagine a report-generation service that asks Claude to produce five sections. Users repeatedly receive only three.

The engineering team might immediately increase the output allowance. That can help when the allowance is the actual constraint. It will not repair a connection that closes early or a client that stops reading the stream.

Before changing settings, capture three independent outcomes:

  1. The HTTP request outcome.
  2. The model’s termination information.
  3. The application’s validation result.

These outcomes answer different questions.

An HTTP success means the server accepted and responded to the request at that layer. It does not prove the requested report contains every required section. A model termination signal explains why generation ended. Application validation determines whether the result satisfies the business contract.

Keep these fields separate in logs and dashboards. Combining them into one green “success” indicator makes incomplete work difficult to detect.

Read the stop reason before increasing the budget

Anthropic documents several termination reasons. Relevant examples include end_turn, max_tokens, stop_sequence, and tool_use. Reaching max_tokens indicates an output limit; a custom stop sequence can also end generation. A tool-use response requires a different workflow from a finished text answer. Consult the official stop-reason documentation for the complete behavior. Claude Platform Docs

This creates a simple investigation rule: classify the response before deciding how to recover.

Do not send every nonempty response to the user as a finished answer. Equally, do not treat every response without final prose as a failed request. An application that expects tool use needs to recognize that intermediate state.

For native Messages responses, preserve the original termination value. For a compatibility interface, document the gateway’s mapping and keep the original value if the service exposes it.

An unexplained missing termination field is a compatibility question worth resolving before production.

Build an evidence record that support can use

A useful incident record does not need to contain confidential prompts.

Start with operational metadata:

FieldWhy it matters
Application request IDConnects the user action to backend activity
Provider or gateway request ID, if availableHelps the service locate the request
Requested model and routeIdentifies the configuration under investigation
Input size estimateHelps distinguish short and large requests
Requested output allowanceRecords what the application asked for
Observed termination informationExplains the reported end state
Stream completion statusDistinguishes complete and interrupted delivery
Output validation resultRecords whether the answer was usable

Also record the client version and relevant timeout settings. A problem introduced by a deployment may otherwise look like random model behavior.

Avoid logging API keys or unrestricted customer content. When a reproduction requires the original input, store it through an approved debugging process with appropriate access controls.

The objective is a request that another engineer can investigate without guessing.

Reproduce the smallest failing request

Reduce the original task until you can see the boundary clearly.

For example, replace a customer document with a synthetic request:

> Produce five numbered sections. Give each section a heading and two short paragraphs. End with a section titled “Delivery checklist.”

Run this request using the same model, gateway route, client, and output settings as the application.

Then change one variable at a time:

  • Increase the allowed output.
  • Reduce the requested document length.
  • Compare streaming and non-streaming delivery where both are supported.
  • Remove an application-defined stop sequence.
  • Bypass only your own rendering layer while keeping the same API route.

This is a diagnostic experiment, not a benchmark. A single successful request does not establish reliability, but controlled changes can reveal which layer deserves attention.

If the command-line response is complete while the application view is incomplete, investigate parsing, buffering, rendering, and client cancellation before blaming the model.

If both are incomplete, inspect termination information and upstream delivery more closely.

Treat streaming as a lifecycle, not a sequence of text fragments

A stream can produce useful text and still fail before completion.

Your application should maintain a lifecycle such as:

started → receiving → completed

with separate states for interruption, cancellation, and validation failure.

This prevents the interface from displaying a “finished” badge merely because some text arrived.

Anthropic’s streaming documentation describes message and content-block events, including the end of a message. Use the documented event lifecycle rather than treating a closed connection as equivalent to successful model completion. Claude Platform Docs

If a gateway translates the stream, ask which completion signal your client should expect. Test the actual route, because a native Messages stream and a compatibility stream may expose different event shapes.

For an interrupted response, preserve the partial output as a draft if it is useful. Do not silently promote it to a completed business result.

Protect JSON, code, and tool arguments from partial output

Incomplete prose is visible. Incomplete structured output can fail less obviously.

Suppose the application receives an object that contains the expected opening fields but lacks the final entries. A permissive repair library may produce syntactically valid JSON while silently dropping missing business information.

Parsing and completeness are different checks.

For structured output, validate:

  • Whether the response finished normally.
  • Whether the complete payload parses.
  • Whether required fields exist.
  • Whether expected record counts are satisfied.
  • Whether identifiers and values match the requested task.

For tool execution, never execute arguments assembled from an unfinished stream. Wait for the complete tool call and validate it against your application’s allowed operation.

Anthropic specifically notes that a tool-use block cut off by the output limit may require a retry with a larger allowance. That does not authorize guessing the missing arguments. Claude Platform Docs

For evidence-bearing documents, the same principle applies to references. The Claude native citations guide covers a separate requirement: preserving the connection between claims and source material.

Choose continuation, regeneration, or manual review deliberately

“Please continue” is convenient, but it should not be your only recovery policy.

Continuation can work for a draft article or a report that has clearly separated sections. It is less attractive when the output must be one exact structured object or when duplicated text creates downstream problems.

Use the task’s acceptance criteria to choose a recovery method.

For a long document, request the missing section by name and assemble the final result only after checking the complete outline.

For an incomplete JSON object, regenerating the entire bounded object may be safer than concatenating a second response onto a broken first response.

For code, retain the partial output for inspection but run validation on the complete candidate. Never assume that reaching the end of a response makes the generated program correct.

For consequential actions, route uncertain cases to review instead of automatically issuing another action.

Set a maximum number of recovery attempts and an overall cost ceiling. A recovery loop without boundaries can turn an isolated truncation into repeated charges.

Investigate the gateway without assuming it caused the problem

A gateway is one component in the delivery path. It should be evaluated with the same evidence-based approach as the client and model.

Check whether the route preserves:

  • Output-limit parameters.
  • Relevant stop information.
  • Complete content blocks.
  • Streaming completion events.
  • Error details and request identifiers.
  • Usage information needed for reconciliation.

These are questions to verify, not claims that every service necessarily exposes every field.

If your application uses a compatibility interface, identify which native features have been translated. A mapping that is adequate for a short chatbot reply may not be adequate for tool orchestration or structured document generation.

The Claude gateway purchasing guide provides a broader procurement framework. Here, narrow the decision to one operational requirement: can the route help your application reliably distinguish finished work from unfinished work?

That question is more useful than asking whether the gateway merely “supports Claude.”

Measure the cost of completed work

A low cost per request can hide a high recovery cost.

Track the following separately:

  • Original generation charges.
  • Continuation or regeneration charges.
  • Outputs rejected by validation.
  • Human review time.
  • Successfully delivered results.

Then calculate:

Cost per accepted result = total attributable processing cost ÷ accepted results

This is an application-level measure, not a replacement for the provider’s token accounting.

For example, a route that frequently requires a second generation may be less economical for your workload even if its initial request is cheaper. Conversely, a longer output budget may improve completion enough to reduce total cost.

Those outcomes need measurement. Do not assume either one in advance.

Use the platform’s usage-record guide to locate request consumption, then associate it with your own application result. Billing records and business outcomes should be connected, while remaining separate sources of evidence.

Turn the investigation into a release test

After identifying the likely cause, add a small regression suite.

Include a short answer, a longer document, a structured payload, and a tool response if your application uses tools. Include at least one deliberately constrained request so you know the application recognizes an incomplete outcome.

Your release criteria should state observable behavior:

  • Partial responses are not labeled complete.
  • Structured outputs are validated before use.
  • Recovery attempts are bounded.
  • Missing termination information is visible.
  • Request IDs connect failures to operational logs.

Run these cases after changing model versions, gateway routes, SDKs, streaming parsers, or timeout settings.

The goal is not to prove that a language model will always satisfy every instruction. It is to ensure your application handles the outcomes it can actually receive.

This is especially important when several teams share a gateway configuration. One team’s apparently harmless client update should not change another team’s completion semantics without detection.

Start a Claude route evaluation with a real acceptance task

If you are considering TreeRouter, begin with a task that currently fails or requires manual repair.

Follow the API-key setup instructions, confirm the available Claude model and interface for your account, and create a limited evaluation configuration. Use the base-URL guidance to avoid confusing a client base address with a full operation path.

Evaluate three outcomes: a complete answer, an intentionally limited answer, and a client interruption.

Before moving production traffic, confirm how each outcome appears in your client and usage records. Availability, parameter support, and billing terms depend on the selected route and should be checked directly.

Your first milestone is not a successful greeting. It is a Claude response whose completion status your application can trust.