View Source OpenAi.Chat (OpenAI REST API Client v1.0.1)
Provides API endpoints related to chat
Summary
Functions
Starting a new project? We recommend trying Responses to take advantage of the latest OpenAI platform features. Compare Chat Completions with Responses.
Delete a stored chat completion. Only Chat Completions that have been
created with the store parameter set to true can be deleted.
Get a stored chat completion. Only Chat Completions that have been created
with the store parameter set to true will be returned.
Get the messages in a stored chat completion. Only Chat Completions that
have been created with the store parameter set to true will be
returned.
List stored Chat Completions. Only Chat Completions that have been stored
with the store parameter set to true will be returned.
Modify a stored chat completion. Only Chat Completions that have been
created with the store parameter set to true can be modified. Currently,
the only supported modification is to update the metadata field.
Functions
@spec create_chat_completion( body :: OpenAi.Chat.Completion.CreateRequest.t(), opts :: keyword() ) :: {:ok, OpenAi.Chat.Completion.CreateResponse.t() | OpenAi.Chat.Completion.Stream.CreateResponse.t()} | {:error, OpenAi.Error.error()}
Starting a new project? We recommend trying Responses to take advantage of the latest OpenAI platform features. Compare Chat Completions with Responses.
Creates a model response for the given chat conversation. Learn more in the text generation, vision, and audio guides.
Parameter support can differ depending on the model used to generate the response, particularly for newer reasoning models. Parameters that are only supported for reasoning models are noted below. For the current state of unsupported parameters in reasoning models, refer to the reasoning guide.
@spec delete_chat_completion(completion_id :: String.t(), opts :: keyword()) :: {:ok, OpenAi.Chat.Completion.Deleted.t()} | {:error, OpenAi.Error.error()}
Delete a stored chat completion. Only Chat Completions that have been
created with the store parameter set to true can be deleted.
@spec get_chat_completion(completion_id :: String.t(), opts :: keyword()) :: {:ok, OpenAi.Chat.Completion.CreateResponse.t()} | {:error, OpenAi.Error.error()}
Get a stored chat completion. Only Chat Completions that have been created
with the store parameter set to true will be returned.
@spec get_chat_completion_messages(completion_id :: String.t(), opts :: keyword()) :: {:ok, OpenAi.Chat.Completion.MessageList.t()} | {:error, OpenAi.Error.error()}
Get the messages in a stored chat completion. Only Chat Completions that
have been created with the store parameter set to true will be
returned.
Options
after: Identifier for the last message from the previous pagination request.limit: Number of messages to retrieve.order: Sort order for messages by timestamp. Useascfor ascending order ordescfor descending order. Defaults toasc.
@spec list_chat_completions(opts :: keyword()) :: {:ok, OpenAi.Chat.Completion.List.t()} | {:error, OpenAi.Error.error()}
List stored Chat Completions. Only Chat Completions that have been stored
with the store parameter set to true will be returned.
Options
model: The model used to generate the Chat Completions.metadata: A list of metadata keys to filter the Chat Completions by. Example:metadata[key1]=value1&metadata[key2]=value2after: Identifier for the last chat completion from the previous pagination request.limit: Number of Chat Completions to retrieve.order: Sort order for Chat Completions by timestamp. Useascfor ascending order ordescfor descending order. Defaults toasc.
@spec update_chat_completion( completion_id :: String.t(), body :: map(), opts :: keyword() ) :: {:ok, OpenAi.Chat.Completion.CreateResponse.t()} | {:error, OpenAi.Error.error()}
Modify a stored chat completion. Only Chat Completions that have been
created with the store parameter set to true can be modified. Currently,
the only supported modification is to update the metadata field.