class OpenAI::Client

Overview

OpenAI client

Defined in:

openai/client.cr
openai/config.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(api_key : String | Nil = nil, proxy : ProxyConfig | Nil = nil) #

[View source]
def self.new(config : OpenAI::Client::Config) #

[View source]

Class Method Detail

def self.azure(api_key : String | Nil, api_endpoint : String, proxy : ProxyConfig | Nil = nil) #

[View source]

Instance Method Detail

def cancel_fine_tuning_job(job_id : String) : FineTuningJob #

Immediately cancel a fine-tune job.


[View source]
def chat_completion(req : ChatCompletionRequest) : ChatCompletionResponse #

API call to Create a completion for the chat message.


[View source]
def chat_completion_stream(req : ChatCompletionRequest) : ChatCompletionStream #

API call to create a chat completion w/ streaming support. It sets whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.


[View source]
def completion(req : CompletionRequest) : CompletionResponse #

API call to create a completion. This is the main endpoint of the API. Returns new text as well as, if requested, the probabilities over each alternative token at each position.

If using a fine-tuned model, simply provide the model's ID in the CompletionRequest object, and the server will use the model's parameters to generate the completion.


[View source]
def completion_stream(req : CompletionRequest) : CompletionStream #

API call to create a completion w/ streaming support. It sets whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.


[View source]
def config : Config #

[View source]
def create_fine_tuning_job(job : FineTuningJobRequest) : FineTuningJob #

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.


[View source]
def create_image(req : ImageRequest) : ImageResponse #

API call to create an image. This is the main endpoint of the DALL-E API.


[View source]
def create_image_edit(req : ImageEditRequest) : ImageResponse #

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


[View source]
def create_image_variation(req : ImageVariationRequest) : ImageResponse #

Creates a variation of a given image.


[View source]
def delete_file(file_id : String) : FileDeletionStatus #

Delete a file


[View source]
def embeddings(req : EmbeddingRequest) : EmbeddingResponse #

Creates an embedding vector representing the input text.


[View source]
def engine(id : String) : Engine #

Retrieves an engine instance, providing basic information about such as the owner and availability.


[View source]
def engines : Array(Engine) #

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


[View source]
def get_file(file_id : String) : FileResponse #

Retrieve a file


[View source]
def get_file_contents(file_id : String) : IO #

Returns the contents of the specified file.


[View source]
def get_fine_tuning_job(job_id : String) : FineTuningJob #

Get info about a fine-tuning job.


[View source]
def list_files : Array(FileResponse) #

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


[View source]
def list_fine_tuning_events(job_id : String, after : String | Nil = nil, limit : Int32 = 20) : FineTuningJobEventList #

Get status updates for a fine-tuning job. after : Identifier for the last job from the previous pagination request. limit : Number of fine-tuning jobs to retrieve.


[View source]
def list_fine_tuning_jobs(after : String | Nil = nil, limit : Int32 = 20) : FineTuningJobEventList #

List your organization's fine-tuning jobs after : Identifier for the last job from the previous pagination request. limit : Number of fine-tuning jobs to retrieve.


[View source]
def model(id : String) : Model #

Retrieves a model instance, providing basic information about the model


[View source]
def models : Array(Model) #

Lists currently available models, and provide basic information about each model


[View source]
def moderation(req : ModerationRequest) : ModerationResponse #

Performs a moderation api call


[View source]
def transcription(req : TranscriptionRequest) : TranscriptionResponse #

API call to transcribe audio into the input language.


[View source]
def translation(req : TranscriptionRequest) : TranscriptionResponse #

API call to translate audio into English.


[View source]
def upload_file(req : FileRequest) : FileResponse #

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 OpenAI if you need to increase the storage limit.


[View source]