short · 3 min
Logprobs
The log-probability the model gave each token. Some APIs return them; many newer models don't.
updated 23 Sept 2026
Let's ask a model to sort a headline into Technology, Politics, Sports or Art: "Tennis Champion Showcases Hidden Talents in Symphony Orchestra Debut". It says Art. Fair enough. But it's a tennis player, so was it torn? The answer text can't tell us. Logprobs can.
Where the number comes from
Each time a model writes a token, it first scores every token in its vocabulary, turns the scores into probabilities with softmax, and picks one. That's the loop from next-token prediction. A logprob is the log of the probability the chosen token had at that moment.
In OpenAI's cookbook, gpt-4o-mini wrote "Art" with a logprob of -0.028. Take e to that power and you get 97.2%. Ask for the runners-up too and you see "Sports" sitting at -4.28, about 1.4%. So it wasn't really torn.
A few conversions to get a feel for it:
| Probability | Logprob |
|---|---|
| 100% | 0 |
| 97% | -0.03 |
| 50% | -0.69 |
| 1% | -4.6 |
So a logprob is always 0 or below, and closer to 0 means more sure.
Why logs at all? The probability of a whole answer is every token's probability multiplied together, and those products get tiny fast. Logs turn the multiplying into adding. Add up the token logprobs, and if you want the overall probability back, exponentiate the sum.
What you get from the API
On OpenAI's Chat Completions, turning on logprobs gives you, for every
token in the reply, the token, its logprob and its raw bytes (handy when
one emoji gets split across two tokens). Set top_logprobs and you also
get the next few alternatives at each spot. The cookbook allowed 0 to 5;
check the current reference for your model.
Once you have the number, a few uses fall out:
- Thresholds. Accept a classification automatically above some probability, and send the rest to a person.
- A self-check on retrieval. Ask the model a one-word True or False, "does this text answer the question?", and read the probability on that word.
- Autocomplete. Suggest the next word only when it's very likely. The cookbook used 95%.
- Scoring whole answers. Average the token logprobs. Perplexity is the same idea turned around (e to the minus average logprob): higher means less sure.
So high logprob means right?
No, and this is the part people get wrong. In that same cookbook, the model was asked whether an article had enough to answer two questions it only partly covered. It said False with 99.1% for one and True with 99.6% for the other. Both very sure. The number measures how sure the model was, not whether it was right, which is the same gap that makes hallucination hard to spot. Treat a logprob as one signal among others, and test any threshold on your own data before trusting it.
And newer models?
Here's where it gets awkward. As of 2026-09, OpenAI's migration guide for
GPT-6 says to remove logprobs and top_logprobs whenever reasoning is
on. GPT-6 Astra can't turn reasoning off, so you never get them there;
Sol and Luna can, with reasoning set to none. Claude's Messages API
reference lists no logprobs option at all. And the cookbook with all those
examples is now marked archived.
So if a feature leans on logprobs, check your model returns them before designing around it. If it doesn't, you can still run the same prompt several times and see how often the answers agree, or run an open model yourself and read the probabilities directly. Getting a model to actually say when it isn't sure, without peeking at its numbers, is the subject of saying "I don't know".
Further reading
- Using logprobs, Hills and Anadkat (OpenAI), 2023. Five worked uses with real outputs, including the headline example. Archived, but still the best hands-on intro.
- Model guidance (GPT-6), OpenAI docs, 2026. Check the migration list here before you plan on logprobs with a reasoning model.
- Create a Message, Anthropic API reference, 2026. Claude's request options, where you'll notice there's no logprobs setting.