Log Probabilities
Log probabilities expose token-level likelihood metadata for supported models and providers.
They can help with token inspection, ranking alternative tokens, debugging generation behavior, uncertainty heuristics, and custom sampling analysis.
Important: Log probabilities are model-generated likelihood values and should not be treated as calibrated confidence scores. A highly probable token can still be factually wrong, biased, or inappropriate for the application.
Request controls
Pass the following parameters to the OpenAI-compatible Chat Completions endpoint to request token metadata.
logprobs
Default: false
Purpose: Enables the return of log probability metadata for each generated token.
Model dependency: Must be supported by the upstream provider.
top_logprobs
Requirements: Requires logprobs: true
Purpose: Requests the most likely alternative tokens and their probabilities at each position.
Range: Provider-specific (often restricted to a small integer to limit payload size).
OpenAI-compatible Chat Completions
Request log probabilities by setting the appropriate fields when calling POST https://api.devupai.com/v1/chat/completions.
Response anatomy
Interpretation
- Log probabilities are usually natural logarithms (base
e). - Values closer to zero represent higher token likelihood.
- More negative values represent lower likelihood.
- Token probability may be derived with
exp(logprob).
Token Anatomy
{
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello"
},
"logprobs": {
"content": [
{
"token": "Hello",
"logprob": -0.0023,
"bytes": [72, 101, 108, 108, 111],
"top_logprobs": [
{
"token": "Hello",
"logprob": -0.0023,
"bytes": [72, 101, 108, 108, 111]
},
{
"token": "Hi",
"logprob": -1.42,
"bytes": [72, 105]
}
]
}
]
}
}
]
}Streaming behavior
When stream: true is provided, log probabilities (if supported) are typically returned per chunk inside choices[].logprobs. However, streaming metadata formatting may differ by provider. Some models may omit logprobs entirely during streaming, or only return them on the final chunk. Always handle streaming fields defensively.
Model support
Check the selected model page or live catalog for current log-probability support. Not all models or providers support logprobs or top_logprobs. The DEVUP AI transparent proxy forwards your request, but if the upstream model does not support token metadata, it may ignore the parameters or return an error.
Use cases and limitations
Practical use cases
- Inspect token alternatives
- Build ranking heuristics
- Compare generation uncertainty
- Debug constrained outputs
- Analyze token selection
Limitations
- Not calibrated confidence scores
- Provider and model-dependent availability
- Tokenization boundaries vary by model
- Top alternatives may drastically increase response payload size
- Unavailable fields (like
bytes) must be handled safely