Skip to content

fix: change logprobs type from bool to int in Completions endpoint#5343

Open
extrasmall0 wants to merge 1 commit intollamastack:mainfrom
extrasmall0:fix/completions-logprobs-type
Open

fix: change logprobs type from bool to int in Completions endpoint#5343
extrasmall0 wants to merge 1 commit intollamastack:mainfrom
extrasmall0:fix/completions-logprobs-type

Conversation

@extrasmall0
Copy link
Copy Markdown

Fixes #5253

The logprobs field in OpenAICompletionRequestWithExtraBody was typed as bool but the OpenAI Completions API expects an integer (0–5) indicating how many top log probabilities to include per output token. This caused a 400 error when callers passed an int:

openai.BadRequestError: ... 'Input should be a valid boolean, unable to interpret input'

Changes:

  • models.py: logprobs: bool | Nonelogprobs: int | None with ge=0, le=5
  • llama-stack-spec.yaml: matching schema update (booleaninteger with min/max)

The Chat Completions model (OpenAIChatCompletionRequestWithExtraBody) is unchanged — its logprobs is correctly a boolean there.

The OpenAI Completions API expects logprobs as an integer (0-5)
specifying how many top log probabilities to return per token.
The Chat Completions endpoint correctly uses bool, but the legacy
Completions model had the wrong type, causing 400 errors when
passing an integer value.

Fixes llamastack#5253
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Mar 27, 2026

Hi @extrasmall0!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI Completions endpoint logprobs should be int, not bool

1 participant