Why LLM APIs Feel Less Intuitive Than Web UIs: Requests, Orchestration, and Extraction
Users often find that large language model (LLM) web interfaces provide more accurate and complete answers than direct API calls. This discrepancy usually stems from the product layer rather than the model itself. This article explores the differences between model capabilities and product capabilities, explains how to structure API requests effectively, provides best practices for information extraction, discusses building orchestration layers, and outlines how to evaluate performance using controlled variables.
For the same question, the answer obtained from a web chat product is often more appropriate and complete. However, switching to direct API calls might yield rigid results with significant omissions. This gap is often attributed to different models, but the more specific reasons usually lie in the product layer. A web product is a complete application system where the model is just one component. Understanding the differences between the two is a prerequisite for using APIs effectively.
1. Distinguishing Model Capabilities from Product Capabilities
Model capabilities refer to the understanding and generation levels brought by parameter size, training data, and inference algorithms. Product capabilities refer to the engineering and interaction design built around the model, typically including the following:
- System instructions: Pre-setting roles, tone, safety boundaries, and output specifications.
- History management: Determining which turns to retain and how to compress overly long contexts.
- File parsing: Converting uploaded documents, spreadsheets, and images into model-readable text.
- Retrieval materials: Supplementing external data before answering and citing sources.
- Thinking mode: Determining whether a question requires a longer reasoning process.
- Tool calling: Invoking calculation, retrieval, or other external functions when needed, and backfilling the results into the context.
- Output format control: Unifying layout, structure, and field definitions.
On the web interface, these processes are usually handled automatically by the server without user awareness. When calling an API, they do not appear by default and must be implemented by the caller or explicitly enabled.
2. APIs Only Execute the Single Request You Submit
The core contract of an API is simple: the model sees exactly what you send. The model does not remember the previous session and knows nothing about your business background. Here is a typical message structure:
messages = [{"role": "system", "content": "You are a customer service knowledge base assistant. Answer only based on the provided materials. Explicitly state if the information is not in the materials."},{"role": "user", "content": "Can this plan be refunded?"}]
This request seems complete but lacks critical information: which plan the user refers to, where the materials are, and when the refund policy takes effect. In a web chat, this information might have already been provided through conversation history or uploaded files. In an API, they must be assembled into the request by the caller every time.
Therefore, the core task of using an API well is request assembly. It is recommended to achieve the following four points:
- Carry necessary system instructions with every request.
- Place retrieved materials into the context by index and require the model to cite the index.
- Truncate or summarize conversation history to control the total length.
- Write output formats as explicit field definitions rather than verbal expectations.
3. Why Information Extraction Requires Restraint
Chat scenarios allow the model to supplement context. When users ask broad questions, the model can infer intent and fill in background information. Information extraction is the opposite; it requires output to be strictly constrained by the original text. Relationships not stated in the text cannot be added, entity directions cannot be reversed, and fields outside the schema cannot be introduced. If the model actively fills in the blanks, it generates incorrect business data.
It is recommended to split the extraction prompt into five parts:
(1) Entity types and relationship whitelist: List only the allowed entity types and relationship names to prevent the model from inventing labels.
(2) Relationship direction and criteria: Specify the subject and object directions for each relationship, as well as sufficient conditions for its establishment. For example, the subject of “employed by” must be a person, and the object must be an organization.
(3) Output null values when uncertain: Explicitly state “return an empty list when evidence is insufficient; do not guess.” This rule is the most effective at reducing false positives.
(4) Attach original text evidence for each relationship: Require the model to provide the original sentence or text snippet for manual review and automated validation.
(5) Fixed output structure with boundary samples: Constrain output with a JSON Schema and provide two or three sets of positive and negative examples, focusing on easily confused cases.
Below is a schematic output constraint:
{"relations": [{"head": "Entity A","relation": "employed by","tail": "Entity B","evidence": "The complete sentence in the original text supporting this relationship"}]}
If the original text is insufficient to support any relationship, it should return {"relations": []}.
4. Bridging the Orchestration Layer: Self-Built vs. Managed
If a business requires an experience similar to web products, the team must bridge an orchestration layer. Common components include:
- File processing: Object storage to save original files, and parsing services responsible for chunking and extracting text.
- Retrieval layer: Vector indexing or full-text indexing for recall, followed by relevance ranking.
- Session management: Using caches or databases to save historical turns, and implementing truncation and summarization strategies.
- Tool calling orchestration: Executing external operations based on function call requests returned by the model, and backfilling the results.
- Observability: Using logging services to record requests and responses, and monitoring alerts to track latency, error rates, and costs.
On cloud platforms like Baidu AI Cloud, you can build the above structure using general categories such as object storage, message queues, container platforms, logging services, and monitoring alerts. When selecting services, prioritize data boundaries, latency requirements, and the team’s operational capabilities rather than just comparing the cost of a single API call.
Every step of the orchestration layer introduces new failure points. For example, if the retrieval recalls irrelevant paragraphs, the model might provide an incorrect answer based on them. Therefore, orchestration design requires supporting quality checks, including recall rate monitoring, citation consistency checks, and manual sampling mechanisms.
5. Evaluation Using Controlled Variables
After modifying prompts or orchestration schemes, whether the effect has actually improved requires reproducible evaluation. Information extraction tasks commonly use the following metrics:
- Precision = Correct extractions / Total extractions
- Recall = Correct extractions / Total ground truth answers
- F1 = 2 × Precision × Recall / (Precision + Recall)
Variables must be controlled during evaluation:
- Use the same model version.
- Use the same thinking mode settings.
- Use the same batch of sentences.
- Use the same output protocol and parsing rules.
Model outputs have randomness, so the same input should be called multiple times to take the mean and record the fluctuation range. A schematic script is as follows:
def evaluate(predictions, gold):tp = fp = fn = 0for pred, ref in zip(predictions, gold):pred_set = set(normalize(r) for r in pred)ref_set = set(normalize(r) for r in ref)tp += len(pred_set & ref_set)fp += len(pred_set - ref_set)fn += len(ref_set - pred_set)precision = tp / (tp + fp) if tp + fp else 0.0recall = tp / (tp + fn) if tp + fn else 0.0f1 = 2 * precision * recall / (precision + recall) if (precision + recall) else 0.0return precision, recall, f1
