Skip to content

/v1/completions accepts n and silently returns one choice; /v1/chat/completions refuses n != 1 with 400 #682

Open

Description

@Yunzez

Before you start

  • I have read the FAQ and my problem is not answered there.
  • I have read the Roadmap and this is not already planned there.
  • I have searched existing issues and found no duplicate.
  • I am on the latest release, or on a freshly rebuilt main when building from source.

What happened

CompletionRequest declares n, and /v1/completions answers n=2 (or any n) with HTTP 200 and a single choice. /v1/chat/completions handles the same field by refusing it: 400 "Only n=1 is supported". A client that asks the completions route for several samples (best-of selection, self-consistency, eval harnesses that pass n) silently gets one and has no way to tell. Reproduced 8/8 on main 377a3bc (n=2 and n=3, greedy and temperature 1.0, streamed and not); the code is unchanged on 74a3877.

Reproduction

curl -s localhost:1941/v1/completions -H 'Content-Type: application/json' -d '{"model": "gpt-oss-20b", "prompt": "Write one word that rhymes with cat:", "max_tokens": 6, "n": 2, "temperature": 1.0}'
# {"id":"cmpl-29c9...","object":"text_completion","created":...,"model":"gpt-oss-20b",
#  "choices":[{"index":0,"text":" Possibly not provided: \"That","finish_reason":"length","logprobs":null}],
#  "usage":{"prompt_tokens":9,"completion_tokens":6,"total_tokens":15}}          <- one choice, usage of one

curl -s localhost:1941/v1/chat/completions -H 'Content-Type: application/json' -d '{"model": "gpt-oss-20b", "max_tokens": 6, "n": 2, "messages": [{"role": "user", "content": "Write one word that rhymes with cat:"}]}'
# {"error":{"message":"Only n=1 is supported","type":"invalid_request_error","param":"n","code":null}}

repro_completions_n_ignored.py
The attached repro_completions_n_ignored.py (stdlib only) checks six shapes:

PASS  [control] completions n=1                  n=1  HTTP 200  choices [0]
PASS  [control] chat n=2 (documented refusal)    n=2  HTTP 400  choices -  body: '{"error":{"message":"Only n=1 is supported",...}}'
FAIL  completions n=2 greedy                     n=2  HTTP 200  choices [0]
FAIL  completions n=2 temperature 1.0            n=2  HTTP 200  choices [0]
FAIL  completions n=3 temperature 1.0            n=3  HTTP 200  choices [0]
FAIL  completions n=2 stream                     n=2  HTTP 200  choices [0]

How did you install FreeToken

Built from source

FreeToken version

ft --version: freetoken version 0.1.3 git rev-parse --short HEAD: 377a3bc (main, 2026-10-07)

OS

Arch Linux

OS details

Ubuntu 20.04.6 LTS, kernel 5.15.0-138-generic, Python 3.12.8.

GPU and driver

NVIDIA GeForce RTX 4090 24 GB (sm_89), driver 580.126.09, CUDA 13.0.

CPU and system RAM

AMD Ryzen Threadripper PRO 5955WX (16 cores / 32 threads), 440 GiB RAM

Checkpoint

openai/gpt-oss-20b (Hugging Face, revision 6cee5e81ee83917806bbde320786a8fb61efebee)

Command

Full log


Anything else

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglinux

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions