Logprobs Viewer — Visualize OpenAI Token Probabilities & Confidence
Paste an OpenAI logprobs response and see each token shaded by probability, plus perplexity and the least-confident token. Spot where the model was guessing. 100% local.
Last updated:
CommentsPaste an OpenAI logprobs response and this viewer shades every generated token by its probability — green where the model was confident, red where it was guessing — and reports the overall perplexity plus the least-confident token. A logprob is the natural log of a token's probability, so probability = exp(logprob). Everything runs in your browser.
Accepts the full response, choices[0].logprobs, or just the content array.
Parsing runs in your browser — nothing is uploaded. Probability = exp(logprob); perplexity = exp(−mean logprob).
What is Logprobs Viewer?
When you request logprobs: true from the OpenAI Chat Completions API, each generated token comes back with the log-probability the model assigned to it, under choices[].logprobs.content[]. Those numbers are a direct window into the model's confidence: a logprob near 0 means it was almost certain, while a large negative value means the token was a long shot. This viewer parses that response (the full body, just choices[0].logprobs, or the bare content array) and turns it into something readable — each token is highlighted on a confidence gradient, hovering shows the exact logprob and any top_logprobs alternatives, and summary stats give you the average logprob, the perplexity (exp of the negative mean logprob), and the single least-confident token. That makes it easy to spot the span where a model started hallucinating, to debug a classifier built on the first token, or to calibrate a confidence threshold. Parsing is entirely local, so you can inspect production responses without sending them anywhere.
How to read a logprobs response
- 1Call the API with logprobs: true (and optionally top_logprobs: 1–20).
- 2Paste the response — the viewer accepts the full body or just the content array.
- 3Scan for red tokens and watch perplexity; a spike marks where the model was unsure.
Key Concepts
- Logprob
- Natural log of a token's probability; probability = exp(logprob).
- Perplexity
- exp(−mean logprob) — lower means the model was more confident.
- Tokenization
- Logprobs are per token; see how text splits into tokens.
Tips & Best Practices
- ▸top_logprobs shows the alternatives the model almost picked — great for confidence and classification.
- ▸A sudden drop in token probability often marks an ambiguous or hallucination-prone span.
Frequently Asked Questions
What are logprobs?
A logprob is the natural log of the probability the model assigned to a token it generated. OpenAI returns them in choices[].logprobs.content[] when you set logprobs: true. Convert to a probability with exp(logprob): logprob 0 means 100% certain, -0.69 means ~50%, and very negative values mean the token was unlikely.
What is top_logprobs?
Set top_logprobs (1–20) to also receive the most likely alternative tokens at each position with their logprobs. It shows what else the model almost said — useful for confidence estimation, classification via the first token, and debugging.
What is perplexity here?
Perplexity = exp(−mean logprob) across the returned tokens. Lower perplexity means the model was more confident in its own output; a spike often marks a hallucination-prone or ambiguous span.
Is my response uploaded?
No. The JSON is parsed entirely in your browser — nothing leaves your device.
Try Next
Prompt Token Breakdown
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Related Tools
Text Chunker
Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.
Cosine Similarity
Compute cosine similarity, dot product, and Euclidean distance between two vectors online. Perfect for debugging LLM embeddings, semantic search, and RAG pipelines. 100% local — vectors never leave your browser.
AI Cost Calculator
Estimate monthly LLM API cost across GPT-4o, Claude 3.5, Gemini, DeepSeek and 100+ models. Compare providers side-by-side with prompt-caching and batch discounts. Free, no signup — prices refreshed daily from the public LiteLLM catalog.
Token Counter
Count tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini and predict API cost before you spend. Free, no signup — all counting runs locally, your prompt stays in your browser.
LLM JSON Extractor
Extract every JSON object or array buried inside an LLM reply — even when it's wrapped in markdown fences, mixed with explanation text, or has trailing commas and single quotes. Auto-repairs each block. 100% local.
Context Window Checker
Check whether your prompt fits a model's context window before you send it. Estimates prompt tokens, reserves room for the response, and shows remaining headroom across GPT-4o, o1, Claude, Gemini, DeepSeek and more. 100% local.