OpenAi.Assistants (OpenAI REST API Client v0.2.1)

Provides API endpoints related to assistants

Summary

Functions

Cancels a run that is in_progress.

Create an assistant with a model and instructions.

Create a thread and run it in one request.

Retrieves an assistant.

Retrieves a thread.

Returns a list of assistants.

Returns a list of messages for a given thread.

Returns a list of run steps belonging to a run.

Returns a list of runs belonging to a thread.

When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.

Functions

Link to this function

cancel_run(thread_id, run_id, opts \\ [])

@spec cancel_run(String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

Cancels a run that is in_progress.

Link to this function

create_assistant(body, opts \\ [])

@spec create_assistant(
  OpenAi.Assistant.CreateRequest.t(),
  keyword()
) :: {:ok, OpenAi.Assistant.t()} | {:error, OpenAi.Error.error()}

Create an assistant with a model and instructions.

Link to this function

create_message(thread_id, body, opts \\ [])

@spec create_message(String.t(), OpenAi.Message.CreateRequest.t(), keyword()) ::
  {:ok, OpenAi.Message.t()} | {:error, OpenAi.Error.error()}

Create a message.

Link to this function

create_run(thread_id, body, opts \\ [])

@spec create_run(String.t(), OpenAi.Run.CreateRequest.t(), keyword()) ::
  {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

Create a run.

Link to this function

create_thread(body, opts \\ [])

@spec create_thread(
  OpenAi.Thread.CreateRequest.t(),
  keyword()
) :: {:ok, OpenAi.Thread.t()} | {:error, OpenAi.Error.error()}

Create a thread.

Link to this function

create_thread_and_run(body, opts \\ [])

@spec create_thread_and_run(
  OpenAi.Thread.CreateAndRunRequest.t(),
  keyword()
) :: {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

Create a thread and run it in one request.

Link to this function

delete_assistant(assistant_id, opts \\ [])

@spec delete_assistant(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Assistant.DeleteResponse.t()} | {:error, OpenAi.Error.error()}

Delete an assistant.

Link to this function

delete_message(thread_id, message_id, opts \\ [])

@spec delete_message(String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Message.DeleteResponse.t()} | {:error, OpenAi.Error.error()}

Deletes a message.

Link to this function

delete_thread(thread_id, opts \\ [])

@spec delete_thread(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Thread.DeleteResponse.t()} | {:error, OpenAi.Error.error()}

Delete a thread.

Link to this function

get_assistant(assistant_id, opts \\ [])

@spec get_assistant(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Assistant.t()} | {:error, OpenAi.Error.error()}

Retrieves an assistant.

Link to this function

get_message(thread_id, message_id, opts \\ [])

@spec get_message(String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Message.t()} | {:error, OpenAi.Error.error()}

Retrieve a message.

Link to this function

get_run(thread_id, run_id, opts \\ [])

@spec get_run(String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

Retrieves a run.

Link to this function

get_run_step(thread_id, run_id, step_id, opts \\ [])

@spec get_run_step(String.t(), String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Run.Step.t()} | {:error, OpenAi.Error.error()}

Retrieves a run step.

Link to this function

get_thread(thread_id, opts \\ [])

@spec get_thread(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Thread.t()} | {:error, OpenAi.Error.error()}

Retrieves a thread.

Link to this function

list_assistants(opts \\ [])

@spec list_assistants(keyword()) ::
  {:ok, OpenAi.Assistant.ListResponse.t()} | {:error, OpenAi.Error.error()}

Returns a list of assistants.

Options

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

  • after: A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Link to this function

list_messages(thread_id, opts \\ [])

@spec list_messages(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Message.ListResponse.t()} | {:error, OpenAi.Error.error()}

Returns a list of messages for a given thread.

Options

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

  • after: A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

  • run_id: Filter messages by the run ID that generated them.

Link to this function

list_run_steps(thread_id, run_id, opts \\ [])

@spec list_run_steps(String.t(), String.t(), keyword()) ::
  {:ok, OpenAi.Run.Step.ListResponse.t()} | {:error, OpenAi.Error.error()}

Returns a list of run steps belonging to a run.

Options

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

  • after: A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Link to this function

list_runs(thread_id, opts \\ [])

@spec list_runs(
  String.t(),
  keyword()
) :: {:ok, OpenAi.Run.ListResponse.t()} | {:error, OpenAi.Error.error()}

Returns a list of runs belonging to a thread.

Options

  • limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

  • after: A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Link to this function

modify_assistant(assistant_id, body, opts \\ [])

@spec modify_assistant(String.t(), OpenAi.Assistant.UpdateRequest.t(), keyword()) ::
  {:ok, OpenAi.Assistant.t()} | {:error, OpenAi.Error.error()}

Modifies an assistant.

Link to this function

modify_message(thread_id, message_id, body, opts \\ [])

@spec modify_message(
  String.t(),
  String.t(),
  OpenAi.Message.UpdateRequest.t(),
  keyword()
) ::
  {:ok, OpenAi.Message.t()} | {:error, OpenAi.Error.error()}

Modifies a message.

Link to this function

modify_run(thread_id, run_id, body, opts \\ [])

@spec modify_run(String.t(), String.t(), OpenAi.Run.UpdateRequest.t(), keyword()) ::
  {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

Modifies a run.

Link to this function

modify_thread(thread_id, body, opts \\ [])

@spec modify_thread(String.t(), OpenAi.Thread.UpdateRequest.t(), keyword()) ::
  {:ok, OpenAi.Thread.t()} | {:error, OpenAi.Error.error()}

Modifies a thread.

Link to this function

submit_tool_ouputs_to_run(thread_id, run_id, body, opts \\ [])

@spec submit_tool_ouputs_to_run(
  String.t(),
  String.t(),
  OpenAi.Assistant.Tool.Outputs.RunSubmitRequest.t(),
  keyword()
) :: {:ok, OpenAi.Run.t()} | {:error, OpenAi.Error.error()}

When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.