main
1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3from typing import List, Optional
4from typing_extensions import Literal
5
6from ..._models import BaseModel
7from ..completion_usage import CompletionUsage
8from .chat_completion_message import ChatCompletionMessage
9from .chat_completion_token_logprob import ChatCompletionTokenLogprob
10
11__all__ = ["ChatCompletion", "Choice", "ChoiceLogprobs"]
12
13
14class ChoiceLogprobs(BaseModel):
15 content: Optional[List[ChatCompletionTokenLogprob]] = None
16 """A list of message content tokens with log probability information."""
17
18 refusal: Optional[List[ChatCompletionTokenLogprob]] = None
19 """A list of message refusal tokens with log probability information."""
20
21
22class Choice(BaseModel):
23 finish_reason: Literal["stop", "length", "tool_calls", "content_filter", "function_call"]
24 """The reason the model stopped generating tokens.
25
26 This will be `stop` if the model hit a natural stop point or a provided stop
27 sequence, `length` if the maximum number of tokens specified in the request was
28 reached, `content_filter` if content was omitted due to a flag from our content
29 filters, `tool_calls` if the model called a tool, or `function_call`
30 (deprecated) if the model called a function.
31 """
32
33 index: int
34 """The index of the choice in the list of choices."""
35
36 logprobs: Optional[ChoiceLogprobs] = None
37 """Log probability information for the choice."""
38
39 message: ChatCompletionMessage
40 """A chat completion message generated by the model."""
41
42
43class ChatCompletion(BaseModel):
44 id: str
45 """A unique identifier for the chat completion."""
46
47 choices: List[Choice]
48 """A list of chat completion choices.
49
50 Can be more than one if `n` is greater than 1.
51 """
52
53 created: int
54 """The Unix timestamp (in seconds) of when the chat completion was created."""
55
56 model: str
57 """The model used for the chat completion."""
58
59 object: Literal["chat.completion"]
60 """The object type, which is always `chat.completion`."""
61
62 service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]] = None
63 """Specifies the processing type used for serving the request.
64
65 - If set to 'auto', then the request will be processed with the service tier
66 configured in the Project settings. Unless otherwise configured, the Project
67 will use 'default'.
68 - If set to 'default', then the request will be processed with the standard
69 pricing and performance for the selected model.
70 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
71 '[priority](https://openai.com/api-priority-processing/)', then the request
72 will be processed with the corresponding service tier.
73 - When not set, the default behavior is 'auto'.
74
75 When the `service_tier` parameter is set, the response body will include the
76 `service_tier` value based on the processing mode actually used to serve the
77 request. This response value may be different from the value set in the
78 parameter.
79 """
80
81 system_fingerprint: Optional[str] = None
82 """This fingerprint represents the backend configuration that the model runs with.
83
84 Can be used in conjunction with the `seed` request parameter to understand when
85 backend changes have been made that might impact determinism.
86 """
87
88 usage: Optional[CompletionUsage] = None
89 """Usage statistics for the completion request."""