OpenAI.OpenAI (oapi_oai v0.1.0)

Provides API endpoints related to open ai

Link to this section Summary

Functions

Immediately cancel a fine-tune job.

Answers the specified question using the provided documents and examples.

Creates a completion for the chat message

Classifies the specified query using provided examples.

Creates a completion for the provided prompt and parameters

Creates a new edit for the provided input, instruction, and parameters.

Creates an embedding vector representing the input text.

Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

Creates a job that fine-tunes a specified model from a given dataset.

Creates an image given a prompt.

Creates an edited or extended image given an original image and a prompt.

Creates a variation of a given image.

Classifies if text violates OpenAI's Content Policy

The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.

Transcribes audio into the input language.

Translates audio into into English.

Delete a fine-tuned model. You must have the Owner role in your organization.

Returns the contents of the specified file

Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.

Returns a list of files that belong to the user's organization.

Get fine-grained status updates for a fine-tune job.

List your organization's fine-tuning jobs

Lists the currently available models, and provides basic information about each one such as the owner and availability.

Retrieves a model instance, providing basic information about it such as the owner and availability.

Returns information about a specific file.

Gets info about the fine-tune job.

Retrieves a model instance, providing basic information about the model such as the owner and permissioning.

Link to this section Functions

Link to this function

cancel_fine_tune(fine_tune_id, opts \\ [])

@spec cancel_fine_tune(
  String.t(),
  keyword()
) :: {:ok, map()} | :error

Immediately cancel a fine-tune job.

Link to this function

create_answer(body, opts \\ [])

@spec create_answer(
  OpenAI.CreateAnswerRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateAnswerResponse.t()} | :error

Answers the specified question using the provided documents and examples.

The endpoint first searches over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for completion.

Link to this function

create_chat_completion(body, opts \\ [])

@spec create_chat_completion(
  OpenAI.CreateChatCompletionRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateChatCompletionResponse.t()} | :error

Creates a completion for the chat message

Link to this function

create_classification(body, opts \\ [])

@spec create_classification(
  OpenAI.CreateClassificationRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateClassificationResponse.t()} | :error

Classifies the specified query using provided examples.

The endpoint first searches over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the completions endpoint.

Labeled examples can be provided via an uploaded file, or explicitly listed in the request using the examples parameter for quick tests and small scale use cases.

Link to this function

create_completion(body, opts \\ [])

@spec create_completion(
  OpenAI.CreateCompletionRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateCompletionResponse.t()} | :error

Creates a completion for the provided prompt and parameters

Link to this function

create_edit(body, opts \\ [])

@spec create_edit(
  OpenAI.CreateEditRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateEditResponse.t()} | :error

Creates a new edit for the provided input, instruction, and parameters.

Link to this function

create_embedding(body, opts \\ [])

@spec create_embedding(
  OpenAI.CreateEmbeddingRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateEmbeddingResponse.t()} | :error

Creates an embedding vector representing the input text.

Link to this function

create_file(body, opts \\ [])

@spec create_file(
  OpenAI.CreateFileRequest.t(),
  keyword()
) :: {:ok, map()} | :error

Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

Link to this function

create_fine_tune(body, opts \\ [])

@spec create_fine_tune(
  OpenAI.CreateFineTuneRequest.t(),
  keyword()
) :: {:ok, map()} | :error

Creates a job that fine-tunes a specified model from a given dataset.

Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

Learn more about Fine-tuning

Link to this function

create_image(body, opts \\ [])

@spec create_image(
  OpenAI.CreateImageRequest.t(),
  keyword()
) :: {:ok, map()} | :error

Creates an image given a prompt.

Link to this function

create_image_edit(body, opts \\ [])

@spec create_image_edit(
  OpenAI.CreateImageEditRequest.t(),
  keyword()
) :: {:ok, map()} | :error

Creates an edited or extended image given an original image and a prompt.

Link to this function

create_image_variation(body, opts \\ [])

@spec create_image_variation(
  OpenAI.CreateImageVariationRequest.t(),
  keyword()
) :: {:ok, map()} | :error

Creates a variation of a given image.

Link to this function

create_moderation(body, opts \\ [])

@spec create_moderation(
  OpenAI.CreateModerationRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateModerationResponse.t()} | :error

Classifies if text violates OpenAI's Content Policy

Link to this function

create_search(engine_id, body, opts \\ [])

@spec create_search(String.t(), OpenAI.CreateSearchRequest.t(), keyword()) ::
  {:ok, OpenAI.CreateSearchResponse.t()} | :error

The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.

To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When file is set, the search endpoint searches over all the documents in the given file and returns up to the max_rerank number of documents. These documents will be returned along with their search scores.

The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.

Link to this function

create_transcription(body, opts \\ [])

@spec create_transcription(
  OpenAI.CreateTranscriptionRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateTranscriptionResponse.t()} | :error

Transcribes audio into the input language.

Link to this function

create_translation(body, opts \\ [])

@spec create_translation(
  OpenAI.CreateTranslationRequest.t(),
  keyword()
) :: {:ok, OpenAI.CreateTranslationResponse.t()} | :error

Translates audio into into English.

Link to this function

delete_file(file_id, opts \\ [])

@spec delete_file(
  String.t(),
  keyword()
) :: {:ok, OpenAI.DeleteFileResponse.t()} | :error

Delete a file.

Link to this function

delete_model(model, opts \\ [])

@spec delete_model(
  String.t(),
  keyword()
) :: {:ok, OpenAI.DeleteModelResponse.t()} | :error

Delete a fine-tuned model. You must have the Owner role in your organization.

Link to this function

download_file(file_id, opts \\ [])

@spec download_file(
  String.t(),
  keyword()
) :: {:ok, String.t()} | :error

Returns the contents of the specified file

Link to this function

list_engines(opts \\ [])

@spec list_engines(keyword()) :: {:ok, OpenAI.ListEnginesResponse.t()} | :error

Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.

Link to this function

list_files(opts \\ [])

@spec list_files(keyword()) :: {:ok, OpenAI.ListFilesResponse.t()} | :error

Returns a list of files that belong to the user's organization.

Link to this function

list_fine_tune_events(fine_tune_id, opts \\ [])

@spec list_fine_tune_events(
  String.t(),
  keyword()
) :: {:ok, OpenAI.ListFineTuneEventsResponse.t()} | :error

Get fine-grained status updates for a fine-tune job.

options

Options

  • stream (boolean): Whether to stream events for the fine-tune job. If set to true, events will be sent as data-only server-sent events as they become available. The stream will terminate with a data: [DONE] message when the job is finished (succeeded, cancelled, or failed).

If set to false, only events generated so far will be returned.

Link to this function

list_fine_tunes(opts \\ [])

@spec list_fine_tunes(keyword()) :: {:ok, OpenAI.ListFineTunesResponse.t()} | :error

List your organization's fine-tuning jobs

Link to this function

list_models(opts \\ [])

@spec list_models(keyword()) :: {:ok, OpenAI.ListModelsResponse.t()} | :error

Lists the currently available models, and provides basic information about each one such as the owner and availability.

Link to this function

retrieve_engine(engine_id, opts \\ [])

@spec retrieve_engine(
  String.t(),
  keyword()
) :: {:ok, map()} | :error

Retrieves a model instance, providing basic information about it such as the owner and availability.

Link to this function

retrieve_file(file_id, opts \\ [])

@spec retrieve_file(
  String.t(),
  keyword()
) :: {:ok, map()} | :error

Returns information about a specific file.

Link to this function

retrieve_fine_tune(fine_tune_id, opts \\ [])

@spec retrieve_fine_tune(
  String.t(),
  keyword()
) :: {:ok, map()} | :error

Gets info about the fine-tune job.

Learn more about Fine-tuning

Link to this function

retrieve_model(model, opts \\ [])

@spec retrieve_model(
  String.t(),
  keyword()
) :: {:ok, map()} | :error

Retrieves a model instance, providing basic information about the model such as the owner and permissioning.