finish_reason length Meaning: 4 Causes of Cut-Off Replies + Fix
A reply that stops mid-sentence usually means finish_reason is length (max_tokens on Anthropic). See the values, 4 causes, and Python continuation code.
Blog
与「LLM API」相关的文章。
A reply that stops mid-sentence usually means finish_reason is length (max_tokens on Anthropic). See the values, 4 causes, and Python continuation code.
max_tokens caps how long one reply can be, so bigger isn't better. Learn how it relates to the context window, which APIs require it, and how to pick a value.
Call an LLM API without code: set up variables, an Authorization header and a JSON body in Postman or Apifox, then debug by status code, with an error table.
LLM API free tiers vary by vendor and change often. Verify yours in 5 steps, from pricing page to overage rules, then set a spend cap.
Temperature and top_p explained with a next-word lottery example, plus value guidance for coding, translation, and writing and a step-by-step tuning method.
Prompts only lower JSON errors, JSON mode guarantees valid syntax, and structured outputs enforce your schema. Includes Python validation and retry code.
Function calling means the model proposes a call and your code runs it. See the tools definition, the returned tool_calls, and the result you send back.
How to use an LLM API in five steps: get a key, pick a base URL, choose a model, send a request, read the response. Minimal curl, Python and Node examples.
How an AI aggregation platform puts many models behind one endpoint and one balance, how it differs from official APIs, and 6 checks to run before you connect.
Control API spending in four steps: pick a billing model, set hard caps and alerts, split keys per project, and log usage in code. Checklist and script included.
A 524 timeout on an LLM API means Cloudflare gave up after about 100 seconds without an origin response. How to diagnose it, a timeout table per layer, and three fixes.
Are your prompts and code retained or used for training when you call an LLM API? Six terms to check, search keywords, gateway questions, and a checklist.
How to build LLM API failover: which errors trip a circuit breaker, how to order fallback providers, mid-stream switching, quality drops, with Python code.
How to retry LLM API calls: full jitter backoff, total time caps, retry budgets and SDK double-retry amplification, with Python and TypeScript code.
How to choose an LLM by task, not leaderboard: speed and price for completion, long context for refactors, token cost for Chinese text, uptime for agents.
How to choose an LLM API: compare official, cloud-hosted and gateway access across six factors, with test commands, public data sources and a decision flow.
How to compare LLM API pricing without a stale table: input vs. output cost, output-to-input ratio, context, caching, batching, tokenizers, plus a checklist.
Monitor the LLM APIs your app relies on in three layers: reachability probes, real-request success and latency, and output checks. Includes a curl script.
Choosing an API relay? Verify, don't trust: 8 checks on uptime method, billing units, data policy, API format, postmortems and latency, with curl examples.
How to track LLM API price changes, new models and deprecations: three sources to watch, cdnping's /changes RSS and /models, and team alerts.