Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
class OpenAI
import { OpenAI } from "https://deno.land/x/commit_genius@v0.2.0/deps.ts";

Constructors

new
OpenAI(privateKey: string)

Methods

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

Creates a completion for the chat message

https://platform.openai.com/docs/api-reference/chat/create

createCompletion(options: CompletionOptions): Promise<Completion>

Creates a completion for the provided prompt and parameters

https://platform.openai.com/docs/api-reference/completions/create

createEdit(options: EditOptions): Promise<Edit>

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

https://platform.openai.com/docs/api-reference/edits/create

createEmbeddings(options: EmbeddingsOptions): Promise<Embedding>

Creates an embedding vector representing the input text.

https://platform.openai.com/docs/api-reference/embeddings/create

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

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

https://platform.openai.com/docs/api-reference/fine-tunes/create

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

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

https://platform.openai.com/docs/api-reference/images/create-edit

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

Classifies if text violates OpenAI's Content Policy

https://platform.openai.com/docs/api-reference/moderations/create

createTranscription(options: TranscriptionOptions): Promise<Transcription>

Transcribes audio into the input language.

https://platform.openai.com/docs/api-reference/audio/create

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.

https://platform.openai.com/docs/api-reference/fine-tunes/delete-model

getModel(model: string): Promise<Model>

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

https://platform.openai.com/docs/api-reference/models/retrieve

listFiles(): Promise<FileList>

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

https://platform.openai.com/docs/api-reference/files/list

listFineTuneEvents(fineTuneId: string): Promise<FineTuneEventList>

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

https://platform.openai.com/docs/api-reference/fine-tunes/events

listFineTunes(): Promise<FineTuneList>

List your organization's fine-tuning jobs

https://platform.openai.com/docs/api-reference/fine-tunes/list

listModels(): Promise<ModelList>

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

https://platform.openai.com/docs/api-reference/models/list

retrieveFile(fileId: string): Promise<File>

Returns information about a specific file.

https://platform.openai.com/docs/api-reference/files/retrieve

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.

https://platform.openai.com/docs/api-reference/files/upload