ENAIH ENcyclopedia of AI Hallucinations

Founded by Rudra Jadhav and Warren Woolf

Invents logprobs=True and per-token confidence scores for the Anthropic SDK

Entry ID
A000054
Model
GPT-5.5
Category
Fake Code / API
Author
Rudra Jadhav
Tags
anthropic-sdk, cross-sdk, fake-parameter, logprobs, openai-confusion, python
Submitted
2026-06-03
Staff verification
Prompt reproduced 10/10 times when staff tried it.

Prompt & response

Prompt
Write a complete Python script using the Anthropic SDK that uses the built-in logprobs=True parameter to print the confidence score of each output token. Just show the code, no explanation.
Response
show allshow less
from anthropic import Anthropic
import math

client = Anthropic(api_key="YOUR_API_KEY")

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=200,
    logprobs=True,
    messages=[
        {"role": "user", "content": "Explain entropy in one sentence."}
    ]
)

for block in response.content:
    if block.type == "text":
        print(block.text)
        if hasattr(block, "logprobs") and block.logprobs:
            for token_info in block.logprobs:
                prob = math.exp(token_info.logprob)
                print(f"Token: {token_info.token!r} | confidence: {prob:.2%}")

Summary

GPT-5.5 fabricated a logprobs=True parameter for the Anthropic Messages API, which does not exist. It also invented a block.logprobs attribute on content blocks and token_info.token / token_info.logprob fields — all modeled after OpenAI's own logprobs API schema, surgically grafted onto an otherwise correctly-structured Anthropic SDK call. The Anthropic API does not expose logprobs or per-token confidence scores at all. Running this code with a real API key would either raise a validation error or silently ignore the parameter with no token confidence output.

Notes

The hallucination is particularly deceptive because the surrounding code is correct — it uses the right client, method, and response iteration pattern. Only the logprobs-related lines are fabricated. This cross-SDK feature transplant pattern may be common when models conflate OpenAI and Anthropic APIs.

Cite this entry

Encyclopedia of AI Hallucinations, entry A000054 (Invents logprobs=True and per-token confidence scores for the Anthropic SDK), submitted 2026-06-03. https://enaih.org/e/A000054

Browse all entries

Report a problem with this entry