BaseCompletion Objects
both synchronously and asynchronously, and both streaming and non-streaming. Attributes:
endpointstr - API endpoint for the completion request.response_classType - Class used for parsing the non-streaming response.stream_response_classType - Class used for parsing the streaming response.
create
modelstr - Model name to use for the completion.prompt_or_messagesUnion[str, List[ChatMessage]] - The prompt for Completion or a list of chat messages for ChatCompletion. If not specified, must specify eitherpromptormessagesin kwargs.request_timeoutint, optional - Request timeout in seconds. Defaults to 600.streambool, optional - Whether to use streaming or not. Defaults to False.**kwargs- Additional keyword arguments.
Union[CompletionResponse, Generator[CompletionStreamResponse, None, None]]:Depending on the
stream argument, either returns a CompletionResponseor a generator yielding CompletionStreamResponse.
acreate
modelstr - Model name to use for the completion.request_timeoutint, optional - Request timeout in seconds. Defaults to 600.streambool, optional - Whether to use streaming or not. Defaults to False.**kwargs- Additional keyword arguments.
Union[CompletionResponse, AsyncGenerator[CompletionStreamResponse, None]]:Depending on the
stream argument, either returns a CompletionResponse or an async generator yielding CompletionStreamResponse.
completion
Completion Objects
chat_completion
ChatCompletion Objects
api
Choice Objects
indexint - The index of the completion choice.textstr - The completion response.logprobsfloat, optional - The log probabilities of the most likely tokens.finish_reasonstr - The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.
CompletionResponse Objects
idstr - A unique identifier of the response.objectstr - The object type, which is always “text_completion”.createdint - The Unix time in seconds when the response was generated.choicesList[Choice] - The list of generated completion choices.
CompletionResponseStreamChoice Objects
indexint - The index of the completion choice.textstr - The completion response.logprobsfloat, optional - The log probabilities of the most likely tokens.finish_reasonstr - The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.
CompletionStreamResponse Objects
idstr - A unique identifier of the response.objectstr - The object type, which is always “text_completion”.createdint - The Unix time in seconds when the response was generated.modelstr - The model used for the chat completion.
choices (List[CompletionResponseStreamChoice]):
The list of streamed completion choices.
Model Objects
idstr - The model name.objectstr - The object type, which is always “model”.createdint - The Unix time in seconds when the model was generated.
ListModelsResponse Objects
objectstr - The object type, which is always “list”.dataList[Model] - The list of models.
ChatMessage Objects
rolestr - The role of the author of this message.contentstr - The contents of the message.
ChatCompletionResponseChoice Objects
indexint - The index of the chat completion choice.messageChatMessage - The chat completion message.finish_reasonOptional[str] - The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.
UsageInfo Objects
prompt_tokensint - The number of tokens in the prompt.total_tokensint - The total number of tokens used in the request (prompt + completion).completion_tokensOptional[int] - The number of tokens in the generated completion.
ChatCompletionResponse Objects
idstr - A unique identifier of the response.objectstr - The object type, which is always “chat.completion”.createdint - The Unix time in seconds when the response was generated.modelstr - The model used for the chat completion.choicesList[ChatCompletionResponseChoice] - The list of chat completion choices.usageUsageInfo - Usage statistics for the chat completion.
DeltaMessage Objects
rolestr - The role of the author of this message.contentstr - The contents of the chunk message.
ChatCompletionResponseStreamChoice Objects
indexint - The index of the chat completion choice.deltaDeltaMessage - The message delta.finish_reasonstr - The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.
ChatCompletionStreamResponse Objects
idstr - A unique identifier of the response.objectstr - The object type, which is always “chat.completion”.createdint - The Unix time in seconds when the response was generated.modelstr - The model used for the chat completion.
choices (List[ChatCompletionResponseStreamChoice]):
The list of streamed chat completion choices.
model
Model Objects
list
request_timeoutint, optional - The request timeout in seconds. Default is 60.
ListModelsResponse- A list of available models.
log
set_console_log_level
level- the minimum level that prints out to console.
Supported values: [CRITICAL, FATAL, ERROR, WARN,
WARNING, INFO, DEBUG]