From ec76779e7f1e512688454de3a7d053ea6f88362e Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Thu, 27 Mar 2025 13:20:04 -0500 Subject: [PATCH] Add CompletionRequest.StreamOptions The legacy completion API supports a `stream_options` object when `stream` is set to true [0]. This adds a StreamOptions property to the CompletionRequest struct to support this setting. [0] https://platform.openai.com/docs/api-reference/completions/create#completions-create-stream_options Signed-off-by: Sean McGinnis --- completion.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/completion.go b/completion.go index 015fa2a9f..4e9f1f301 100644 --- a/completion.go +++ b/completion.go @@ -194,6 +194,8 @@ type CompletionRequest struct { Temperature float32 `json:"temperature,omitempty"` TopP float32 `json:"top_p,omitempty"` User string `json:"user,omitempty"` + // Options for streaming response. Only set this when you set stream: true. + StreamOptions *StreamOptions `json:"stream_options,omitempty"` } // CompletionChoice represents one of possible completions.