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

Link to this function

create_chat_completion(body, opts \\ [])

View Source

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.

Link to this function

delete_chat_completion(completion_id, opts \\ [])

View Source
@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.

Link to this function

get_chat_completion(completion_id, opts \\ [])

View Source
@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.

Link to this function

get_chat_completion_messages(completion_id, opts \\ [])

View Source
@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. Use asc for ascending order or desc for descending order. Defaults to asc.
Link to this function

list_chat_completions(opts \\ [])

View Source
@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]=value2

  • after: 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. Use asc for ascending order or desc for descending order. Defaults to asc.

Link to this function

update_chat_completion(completion_id, body, opts \\ [])

View Source
@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.