DevKits

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:

Comments

Paste 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.

7
Tokens
-0.129
Avg logprob
1.14
Perplexity
" France"
Least confident
Each token shaded by probability (green = confident, red = uncertain)
The100.0% capital98.0% of100.0% France60.7% is99.9% Paris92.3%.74.1%

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

  1. 1Call the API with logprobs: true (and optionally top_logprobs: 1–20).
  2. 2Paste the response — the viewer accepts the full body or just the content array.
  3. 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

Reference & Guides