Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/openai/src/openai.ts>OpenAI

Unofficial Deno wrapper for the Open Ai api
Extremely Popular
Go to Latest
class OpenAI
import { OpenAI } from "https://deno.land/x/openai@1.4.2/src/openai.ts";

Constructors

new
OpenAI(privateKey: string, options?: { baseUrl?: string; })

Methods

cancelFineTune(fineTuneId: string): Promise<(FineTune & { events: FineTuneEvent[]; })>
createChatCompletionStream(options: ChatCompletionOptions, callback: (chunk: ChatCompletionStream) => void): Promise<void>

Creates a completion stream for the chat message

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

Creates a completion for the provided prompt and parameters

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

createCompletionStream(options: Omit<CompletionOptions, "bestOf">, callback: (chunk: CompletionStream) => void): Promise<void>

Creates a completion stream 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

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

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

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

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

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

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<FileInstance>

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: FileSpecifier, purpose: string): Promise<FileInstance>

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