Skip to content

Set object to "chat.completion" for non-streaming chat completions#788

Open
lollinng wants to merge 1 commit into
predibase:mainfrom
lollinng:fix/chat-completion-object-type
Open

Set object to "chat.completion" for non-streaming chat completions#788
lollinng wants to merge 1 commit into
predibase:mainfrom
lollinng:fix/chat-completion-object-type

Conversation

@lollinng

@lollinng lollinng commented Jun 5, 2026

Copy link
Copy Markdown

Problem

ChatCompletionResponse::new (non-streaming /v1/chat/completions) hardcodes:

ChatCompletionResponse {
    id: "null".to_string(),
    object: "text_completion".to_string(),   // <-- wrong
    ...
}

Per the OpenAI API, a non-streaming chat completion has object: "chat.completion" ("text_completion" is the legacy /v1/completions object). The streaming path in the same file already uses the correct "chat.completion.chunk", so this is an inconsistency: OpenAI-compatible clients that branch on object get the wrong type from the non-streaming chat endpoint.

Fix

Set object to "chat.completion" for the non-streaming chat response. The two CompletionResponse constructions (the /v1/completions endpoint) keep "text_completion", which is correct.

The non-streaming /v1/chat/completions response set object to
"text_completion" instead of "chat.completion" (the value the OpenAI API
returns, and consistent with the streaming chunk's "chat.completion.chunk").
This broke OpenAI-compatible clients that branch on the object type.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant