Why Do LLM APIs Perform Worse Than the Web Interface?
This article explains why the same large language model can seem less capable through an API than in a web chat interface. The gap usually comes from missing product-layer orchestration rather than a smaller model or poor prompts. It covers what the web interface handles behind the scenes, why chat and structured extraction need different prompting strategies, a five-part prompt structure for relation extraction, how to run controlled evaluations, and how to rebuild the orchestration pipeline in your own API calls.
1. The Symptom: Same Model, Different Behavior
Many developers have had this experience: in a web chat window, a few follow-up questions are enough for the model to grasp the intent, fill in missing background, and return a well-structured answer. Send the same sentences through your own API call, and the output feels stiff, drifts off target, or turns a structured task like relation extraction into free-form prose. The natural suspicion is that the API serves a “reduced” model, or that your prompt is simply wrong.
Usually, neither is the case. A more plausible explanation: the answer you see in the web interface is produced by the model plus a whole product layer of orchestration, while the API by default does one thing only — execute the single request you submit. Whatever the web interface quietly did for you must now be supplied by the caller.
2. Root Causes: What the Web Interface Does Extra
Laid out side by side, a single web answer is backed by at least several categories of information:
- System-level instructions: role, tone, refusal boundaries, output style.
- Conversation history: multi-turn context fully concatenated, so references and ellipses can be resolved.
- Parsed attachments and links: documents chunked, extracted, and summarized, then injected as material.
- Retrieval material: web search snippets trimmed and ranked before being placed in context.
- Output protocol: when to think, when to call a tool, what format to close with.
- Safety policies: sensitive content filtering and compliance rewriting.
An API call by default contains only the message array and parameters you pass explicitly. Every missing sentence of background, every constraint, every boundary condition has to be filled in by the caller. So “asking the web interface directly works better” can be entirely true, but it does not prove the web interface uses a smarter model — only that it gives the model more usable context and stronger constraints.
Two variables are easy to overlook. The first is sampling randomness: the same input can yield different results across calls, so a single comparison carries no statistical meaning. The second is that product-layer policies keep changing, so the behavioral baselines of the web interface and the API are themselves shifting, which makes comparisons across time equally unreliable.
3. Task Nature: Chat Rewards Filling In, Extraction Requires Restraint
Relation extraction and casual chat are tasks with opposite goals. Chat encourages the model to complete the context and make reasonable inferences; extraction demands extreme restraint:
- Relations not expressed in the source text must not be added.
- The direction between entities must not be reversed.
- Fields outside the schema must not be introduced.
- When uncertain, leave the field empty instead of guessing the most plausible answer.
With a chat-style prompt, the model easily misreads “understand this passage” as “interpret this passage freely,” producing a pile of plausible-looking relations that cannot be traced back to the text. This is not a capability problem but a systematic bias caused by missing task constraints.
4. A Five-Part Prompt Structure for Structured Extraction
Treat the prompt as an interface contract, and split it into five fixed parts:
- Entity types and relation whitelist: state the allowed categories; output nothing outside that range.
- Direction and decision criteria for each relation: specify which entity is the subject, which is the object, and the semantic condition under which the relation holds.
- Fallback rule: output an empty value when a decision cannot be made; guessing is forbidden.
- Evidence requirement: every relation must carry a source text snippet so it can be validated automatically.
- Output protocol: a fixed JSON Schema, plus two or three boundary examples (including counter-examples).
A skeleton prompt:
[TASK] Extract structured relations from the given text. Extraction only; no inference or summarization.[ENTITY TYPES] PERSON, ORG, PRODUCT, LOCATION[RELATION WHITELIST] FOUNDED_BY(ORG<-PERSON), WORKS_AT(PERSON->ORG), LOCATED_IN(ORG->LOCATION)[CRITERIA]- Output a relation only when the text explicitly expresses a membership/belonging semantic;- Follow the direction defined in the whitelist strictly; do not reverse it;- If evidence is insufficient, do not output the relation; do not fill in an omitted subject.[OUTPUT] Return only the following JSON, with no explanatory text:{"relations":[{"head":"","head_type":"","relation":"","tail":"","tail_type":"","evidence":""}]}[EXAMPLES] One input/output pair each, including one counter-example that should return an empty array.
Tightening decoding parameters (low temperature, fixed max length, disabling unnecessary extended generation) noticeably improves output stability.
5. Evaluation Requires Controlled Variables
To judge whether a prompt has actually improved, evaluation design matters more than parameter tuning. Fix the same model version, the same thinking mode, the same set of sentences, and the same output protocol; call repeatedly, then compute Precision, Recall, and F1, and separately track two metrics that matter in extraction: the direction error rate and the evidence-missing rate. Comparing one web chat session against one API output measures no real difference.
A practical evaluation loop:
# Pseudocode: batch evaluation with controlled variablesfor sample in dataset:preds = [call_api(build_prompt(sample), temperature=0.1) for _ in range(3)]record(sample.gold, preds) # take the majority-consistent result across multiple samplesreport(precision, recall, f1, direction_error_rate, evidence_missing_rate)
6. Moving Product-Layer Capabilities into the API
The industry trend is that model services and productized orchestration are being opened up at the same time: some platforms already offer toggleable capabilities such as web retrieval, deep thinking, file input, and link reading, with tool calling and context assembly handled server-side. In other words, part of what the web interface does can now enter programmatic calls, but it is not enabled for you by default and must be configured explicitly.
Engineering-wise, it helps to complete the call chain into a pipeline: input cleaning → retrieval or document parsing → context assembly → system instruction and schema injection → model call → structured validation (schema validation, evidence re-check, direction consistency) → retry and fallback on failure. Samples that fail validation are fed back as new boundary examples, forming a continuous loop of prompt and evaluation-set iteration.
7. Conclusion
What you pay for is never just model calls; it also includes how much product-layer orchestration you get. When an API feels “dumb,” it is usually not a bad prompt but the fact that all the work the web interface quietly did has been left to the model. Fill in system instructions, context, constraints, validation, and evaluation, and API output can stay close to — or even exceed — the results of casual chat. In practice with model services on platforms such as Baidu AI Cloud, the same “fill in the orchestration” approach applies, and it can be combined with general cloud capabilities like log services and monitoring alerts to track results and keep optimizing.
