Skip to content

Commit b4d127c

Browse files
Merge pull request #248 from openai/brianz/stream-options-2
Add stream_options param; add usage in ChatCompletionChunk
2 parents 25d9dac + 3bbc26b commit b4d127c

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

openapi.yaml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7212,6 +7212,8 @@ components:
72127212
type: boolean
72137213
nullable: true
72147214
default: false
7215+
stream_options:
7216+
$ref: "#/components/schemas/ChatCompletionStreamOptions"
72157217
suffix:
72167218
description: |
72177219
The suffix that comes after a completion of inserted text.
@@ -7697,6 +7699,18 @@ components:
76977699
- tool
76987700
- function
76997701

7702+
ChatCompletionStreamOptions:
7703+
description: |
7704+
Options for streaming response. Only set this when you set `stream: true`.
7705+
type: object
7706+
nullable: true
7707+
default: null
7708+
properties:
7709+
include_usage:
7710+
type: boolean
7711+
description: |
7712+
If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.
7713+
77007714
ChatCompletionResponseMessage:
77017715
type: object
77027716
description: A chat completion message generated by the model.
@@ -7891,6 +7905,8 @@ components:
78917905
type: boolean
78927906
nullable: true
78937907
default: false
7908+
stream_options:
7909+
$ref: "#/components/schemas/ChatCompletionStreamOptions"
78947910
temperature:
78957911
type: number
78967912
minimum: 0
@@ -8150,7 +8166,9 @@ components:
81508166
description: A unique identifier for the chat completion. Each chunk has the same ID.
81518167
choices:
81528168
type: array
8153-
description: A list of chat completion choices. Can be more than one if `n` is greater than 1.
8169+
description: |
8170+
A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the
8171+
last chunk if you set `stream_options: {"include_usage": true}`.
81548172
items:
81558173
type: object
81568174
required:
@@ -8191,6 +8209,25 @@ components:
81918209
type: string
81928210
description: The object type, which is always `chat.completion.chunk`.
81938211
enum: [chat.completion.chunk]
8212+
usage:
8213+
type: object
8214+
description: |
8215+
An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request.
8216+
When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.
8217+
properties:
8218+
completion_tokens:
8219+
type: integer
8220+
description: Number of tokens in the generated completion.
8221+
prompt_tokens:
8222+
type: integer
8223+
description: Number of tokens in the prompt.
8224+
total_tokens:
8225+
type: integer
8226+
description: Total number of tokens used in the request (prompt + completion).
8227+
required:
8228+
- prompt_tokens
8229+
- completion_tokens
8230+
- total_tokens
81948231
required:
81958232
- choices
81968233
- created

0 commit comments

Comments
 (0)