From da5f9bc9bc40537a0c2b451fffa9364efa94dbe1 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 29 Apr 2025 08:35:26 -0500 Subject: [PATCH] Add CompletionRequest.StreamOptions (#959) 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 7a6de30..9c3a64d 100644 --- a/completion.go +++ b/completion.go @@ -215,6 +215,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.