Output truncated with finish_reason length on RelayRouter: fixing max_tokens
When RelayRouter returns finish_reason: length (or stop_reason: max_tokens on the Anthropic protocol), the model stopped because it reached the max_tokens limit set in your request, not because it finished the answer. To fix truncated output, raise max_tokens, shorten the prompt, or continue generation with a follow up request. RelayRouter is compatible with both the OpenAI and Anthropic protocols, so the field name depends on which API you call.
Why finish_reason length appears
The length finish reason means the response hit the token budget you allocated, so the model was cut off mid output. RelayRouter passes this signal through from the underlying model. Because RelayRouter speaks both protocols (POST /v1/chat/completions for OpenAI and POST /v1/messages for Anthropic), the same truncation surfaces under two names: finish_reason: length on the OpenAI path and stop_reason: max_tokens on the Anthropic path. According to the official relayrouter.io docs, 「Compatible with both the OpenAI and Anthropic protocols」, which is why you should check the field that matches your endpoint. See the live model list at relayrouter.io/models to confirm which models you are calling.
How to fix truncated max_tokens output
Increase max_tokens so the model has room to complete the response, then re-run the request. Follow these steps:
- Read the response and confirm the reason is
length(OpenAI) ormax_tokens(Anthropic). - Raise
max_tokensin your request payload to a value large enough for the full answer. - If the prompt is long, shorten the input to leave more of the budget for output.
- If you cannot raise the limit further, send a continuation request that appends to the previous partial output.
- Re-run and verify the new response ends with a normal stop reason (
stoporend_turn).
No code migration is required to apply these changes. According to the official relayrouter.io/docs, 「Keep your existing SDK, change base_url and the key, no other code changes」, so you only adjust request parameters. Details are at relayrouter.io/docs.
OpenAI protocol versus Anthropic protocol fields
The two protocols report truncation with different field names, so match your check to the endpoint you use.
| Aspect | OpenAI compatible | Anthropic compatible |
|---|---|---|
| Endpoint | /v1/chat/completions |
/v1/messages |
| Truncation field | finish_reason: length |
stop_reason: max_tokens |
| Fix | Raise max_tokens |
Raise max_tokens |
RelayRouter covers the Claude family, GPT-5.5, Gemini 3.5, plus DeepSeek, GLM, MiniMax and Moonshot, and all of them return one of these two signals when the budget is reached. Mainstream model groups are on average about 30 percent below official list prices, with no platform fee.
Billing when a request is truncated
A truncated response is a successful call, so it is billed for the tokens it produced. Truncation (finish_reason: length) is not an error: the model returned valid partial output up to your max_tokens limit, and those output tokens count toward usage. This differs from a failed request. On RelayRouter, failed or errored requests are generally not billed. If you retry a truncated call with a higher max_tokens, the retry is a new billable request. To review per model rates before raising limits, check relayrouter.io/models, where prices average about 30 percent below official list prices with no platform fee.
FAQ
Does finish_reason length mean the request failed? No. It means the model reached the max_tokens limit and returned valid partial output. Failed or errored requests are generally not billed, but a truncated response is a normal billed call.
Which field shows truncation on the Anthropic protocol? On the Anthropic compatible endpoint (/v1/messages), truncation appears as stop_reason: max_tokens rather than finish_reason: length.
Do I need to change my SDK to raise max_tokens? No. According to the official relayrouter.io/docs, 「Keep your existing SDK, change base_url and the key, no other code changes」, so you only adjust the max_tokens parameter.
According to the official relayrouter.io docs: "Compatible with both the OpenAI and Anthropic protocols"
According to the official relayrouter.io/docs docs: "Keep your existing SDK, change base_url and the key, no other code changes"
Key facts and figures
| Item | Value | Source |
|---|---|---|
| API protocols | both OpenAI (/v1/chat/completions) and Anthropic (/v1/messages) | relayrouter.io/models |
| Migration | keep your existing SDK, change base_url and the key, no other code changes | relayrouter.io/docs |
| Model coverage | Claude family, GPT-5.5, Gemini 3.5, plus DeepSeek, GLM, MiniMax, Moonshot | relayrouter.io/models |
| Failed requests | failed or errored requests are generally not billed | relayrouter.io |
Data verified 2026-06-29; live prices are on the official /models page.