Use fetch, AbortController and a proper SSE parser to handle UTF-8, incomplete events, partial answers and connection failures in an LLM chat interface.
deepweight
A journal for people who build with AI.
Models, APIs, and the details that matter.
Streaming without losing the text
A network chunk is not a token, an SSE event or a line of JSON. That distinction explains many chat bugs: broken characters, incomplete JSON and answers that keep appearing after the user presses Stop.
Read the guideA response arrives in fragments.
Your interface has to hold them together.
The reading list
From the first API call to the problems that only show up in production.
Verified differences between DeepSeek V4.1 Flash and V4 Pro, including API aliases, vision and reasoning, plus a practical evaluation method for your traffic.
How to evaluate abliterated model APIs: verified Uncensured AI pricing, OpenAI compatibility, reported throughput and the checks that matter before switching.
Organize prompts and documents for DeepSeek context caching, inspect real cache hits and calculate savings without assuming the cache is guaranteed.
Use abliterated models through an API without managing GPUs: Uncensured AI endpoint, OpenAI Python SDK, DeepSeek and GLM IDs, costs and migration checks.
Use backoff with jitter, Retry-After, time budgets and concurrency limits to recover from temporary LLM API failures without multiplying traffic.
Three traffic scenarios and a transparent formula for estimating a GPT-to-DeepSeek migration, including output length, cache hits, retries and integration work.
A reproducible method for separating model refusals, API failures and unhelpful answers. Build a dataset, define the denominator and report the limits.
How to distinguish rights in AI outputs, model weight licenses and DeepSeek API terms without assuming generated text inherits the model’s license.
Run the numbers.
A price per million tokens only tells half the story. Put it in the context of your traffic.
20M input tokens + 5M output tokens
Example: DeepSeek Flash, off-peak, no caching. Edit the prices. Excludes taxes, tools and retries.
Formula: requests × (input tokens × input price + output tokens × output price) / 1,000,000. Assumptions and details.
Inside the models.
The interesting part starts after the announcement: choosing an endpoint, handling a failure, making sense of the bill.
Deepweight is a journal for curious developers. Public sources, transparent calculations and code to take into your next experiment. Provider claims are kept separate from editorial measurements.
How we work