Skip to main content
class OpenAI
import { OpenAI } from "";


OpenAI(privateKey: string)


cancelFineTune(fineTuneId: string): Promise<(FineTune & { events: FineTuneEvent[]; })>
createChatCompletion(options: ChatCompletionOptions): Promise<ChatCompletion>

Creates a completion for the chat message

createCompletion(options: CompletionOptions): Promise<Completion>

Creates a completion for the provided prompt and parameters

createEdit(options: EditOptions): Promise<Edit>

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

createEmbeddings(options: EmbeddingsOptions): Promise<Embedding>

Creates an embedding vector representing the input text.

createFineTune(options: FineTuneOptions): Promise<(FineTune & { events: FineTuneEvent[]; })>

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

createImage(options: ImageOptions): Promise<Image>
createImageEdit(options: ImageEditOptions): Promise<Image>

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

createImageVariation(options: ImageVariationOptions): Promise<Image>
createModeration(input: string | string[], model?: string): Promise<Moderation>

Classifies if text violates OpenAI's Content Policy

createTranscription(options: TranscriptionOptions): Promise<Transcription>

Transcribes audio into the input language.

createTranslation(options: TranslationOptions): Promise<Translation>
deleteFile(fileId: string): Promise<DeletedFile>
deleteFineTuneModel(model: string): Promise<DeletedFineTune>

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

getModel(model: string): Promise<Model>

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

listFiles(): Promise<FileList>

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

listFineTuneEvents(fineTuneId: string): Promise<FineTuneEventList>

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

listFineTunes(): Promise<FineTuneList>

List your organization's fine-tuning jobs

listModels(): Promise<ModelList>

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

retrieveFile(fileId: string): Promise<File>

Returns information about a specific file.

retrieveFileContent(fileId: string)
retrieveFineTune(fineTuneId: string): Promise<(FineTune & { events: FineTuneEvent[]; })>
uploadFile(file: string, purpose: string): Promise<File>

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.