OpenAI
OpenAI is a private research laboratory that aims to develop and direct artificial intelligence (AI) in ways that benefit humanity as a whole. OpenAI has developed the following projects:
- GPT-3: This powerful language model serves as the basis for other OpenAI products. It analyzes human-generated text to learn to generate similar text on its own.
- DALL-E and DALL-E 2: These generative AI platforms can analyze text-based descriptions of images that users want them to produce and then generate those images exactly as described.
- CLIP: CLIP is a neural network that synthesizes visuals and text pertaining to them to predict the best possible captions that most accurately describe those visuals. Because of its ability to learn from more than one type of data (both images and text), it can be categorized as multimodal AI.
- ChatGPT: ChatGPT is currently the most advanced AI chatbot designed for generating humanlike text and producing answers to users' questions. Having been trained on large data sets, it can generate answers and responses the way a human would.
- Codex: Codex was trained on billions of lines of code in various programming languages to help software developers simplify coding processes. It's founded on GPT-3 technology, but instead of generating text, it generates code.
- Whisper: Whisper is an automatic speech recognition (ASR) tool. It has been trained on a multitude of audio data to recognize, transcribe, and translate speech in about 100 different languages, including technical language and different accents.
OpenAI API
The OpenAI API can be applied to virtually any task that involves understanding or generating natural language, code, or images. OpenAI offers a spectrum of models with different levels of power suitable for different tasks, as well as the ability to fine-tune your own custom models. These models can be used for everything from content generation to semantic search and classification.
Most common uses
Configuration
OpenAI
The OpenAI API uses API keys for authentication. Visit your API Keys page to retrieve the API key you'll use in your requests.
Remember that your API key is a secret! Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.
This API Key must be configured in the OpenAIOptions.ApiKey property of the component. Optionally, for users who belong to multiple organizations, you can set your Organization in the property OpenAIOptions.Organization if your account belongs to an organization.
Once the API Key is configured, find below a list of available functions to interact with the OpenAI API.
Azure
The client supports Microsoft Azure OpenAI Services, so you can use your Azure account to interact with the Azure OpenAI API too. To configure the client to work with Azure, follow the steps below:
- Configure the property OpenAIOptions.Provider = oapvAzure
- Set the values of ResourceName and DeploymentId (these values can be located in your Azure Account)
- OpenAIOptions.AzureOptions.ResourceName = <your resource name>.
- OpenAIOptions.AzureOptions.DeploymentId = <your deployment id>.
- Set the API Key of your Azure Account
- OpenAIOptions.ApiKey = <azure api key>.
Keep in mind that not all the OpenAI methods are supported by Azure, currently only the following methods are supported:
- Completion
- Chat Completion
Properties
OpenAIOptions
- ApiKey: The API key for authenticating with the OpenAI API.
- Organization: Optional organization ID for users belonging to multiple organizations.
- Provider: Select the provider: oapvOpenAI (default) or oapvAzure for Microsoft Azure OpenAI Services.
- AzureOptions: Configuration for Azure OpenAI Services.
- ResourceName: The Azure resource name.
- DeploymentId: The Azure deployment ID.
- APIVersion: The Azure API version.
- HttpOptions: HTTP connection settings.
- ReadTimeout: Timeout in milliseconds for reading HTTP responses. Default is 0 (no timeout).
- LogOptions: Logging configuration.
- Enabled: When True, HTTP requests and responses are logged to a file.
- FileName: The file path where log output is written.
- RetryOptions: Automatic retry configuration for failed API requests.
- Enabled: When True, failed requests are automatically retried.
- Retries: Maximum number of retry attempts.
- Wait: Wait time in milliseconds between retry attempts.
Models
List and describe the various models available in the API.
- GetModels: Lists the currently available models, and provides basic information about each one such as the owner and availability.
- GetModel: Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
- Model: The ID of the model to use for this request
Completions
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
- CreateCompletion: Creates a completion for the provided prompt and parameters
- Model: ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
- Prompt: The prompt to generate completions.
Chat
Given a chat conversation, the model will return a chat completion response.
- Model: ID of the model to use. Call GetModels to get a list of all models supported by the Chat API.
- Message: The message to generate chat completions for.
- Role: by default user, other options are: system, assistant.
Edits
Given a prompt and an instruction, the model will return an edited version of the prompt.
- CreateEdit: Creates a new edit for the provided input, instruction, and parameters.
- Model: ID of the model to use. You can use the text-davinci-edit-001 or code-davinci-edit-001 model with this endpoint.
- Instruction: The instruction that tells the model how to edit the prompt.
- Input: (optional) The input text to use as a starting point for the edit.
Images
Given a prompt and/or an input image, the model will generate a new image.
- CreateImage: Creates an image given a prompt.
- Prompt: A text description of the desired image(s). The maximum length is 1000 characters.
- CreateImageEdit: Creates an edited or extended image given an original image and a prompt.
- Image: The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
- Prompt: A text description of the desired image(s). The maximum length is 1000 characters.
- CreateImageVariations: Creates a variation of a given image.
- Image: The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
Embeddings
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
- CreateEmbeddings: Creates an embedding vector representing the input text.
- Model: ID of the model to use.
- Input: Input text to get embeddings for.
Audio
Turn Audio into Text.
- CreateTranscriptionFromFile: Transcribes audio into the input language from a filename
- Model: ID of the model to use. Only whisper-1 is currently available.
- Filename: The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
- CreateTranscription: Records audio for X seconds and transcribes it.
- Model: ID of the model to use. Only whisper-1 is currently available.
- Time: time in milliseconds, by default 10 seconds.
- CreateTranslationFromFile: Translates audio into English.
- Model: ID of the model to use. Only whisper-1 is currently available.
- Filename: The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
- CreateTranslation: Records audio for X seconds and translates it.
- Model: ID of the model to use. Only whisper-1 is currently available.
- Time: time in milliseconds, by default 10 seconds.
Files
Files are used to upload documents that can be used with features like Fine-tuning.
- ListFiles: Returns a list of files that belong to the user's organization.
- UploadFile: 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.
- Filename: Name of the JSON Lines file to be uploaded. If the purpose is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your training examples.
- Purpose: The intended purpose of the uploaded documents. Use "fine-tune" for Fine-tuning.
- DeleteFile: Delete a file.
- FileId: The ID of the file to use for this request
- RetrieveFile: Returns information about a specific file.
- FileId: The ID of the file to use for this request
- RetrieveFileContent: Returns the contents of the specified file
- FileId: The ID of the file to use for this request.
Fine-Tunes
Manage fine-tuning jobs to tailor a model to your specific training data.
- CreateFineTune: 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.
- TrainingFile: The ID of an uploaded file that contains training data.
- ListFineTunes: List your organization's fine-tuning jobs
- RetrieveFineTune: Gets info about the fine-tune job.
- FineTuneId: The ID of the fine-tune job
- CancelFineTune: Immediately cancel a fine-tune job.
- FineTuneId: The ID of the fine-tune job
- ListFineTuneEvents: Get fine-grained status updates for a fine-tune job.
- FineTuneId: The ID of the fine-tune job
- DeleteFineTuneModel: Delete a fine-tuned model. You must have the Owner role in your organization.
- Model: The model to delete.
Moderations
Given an input text, outputs if the model classifies it as violating OpenAI's content policy.
- CreateModeration: Classifies if text violates OpenAI's Content Policy
- Input: The input text to classify
RealTime
The OpenAI Realtime API enables low-latency, multimodal interactions including speech-to-speech conversational experiences and real-time transcription.
- Transcription: You can use the Realtime API for transcription-only use cases, either with input from a microphone or from a file. For example, you can use it to generate subtitles or transcripts in real-time. With the transcription-only mode, the model will not generate responses.
Assistants
Build AI assistants that can call models and use tools to perform tasks.
- CreateAssistant: Creates an assistant with a model and instructions.
- ListAssistants: Returns a list of assistants.
- RetrieveAssistant: Retrieves an assistant by ID.
- ModifyAssistant: Modifies an existing assistant.
- DeleteAssistant: Deletes an assistant.
Threads
Threads represent a conversation session. Messages are added to threads, which are then processed by runs.
- CreateThread: Creates a new thread.
- RetrieveThread: Retrieves a thread by ID.
- ModifyThread: Modifies a thread.
- DeleteThread: Deletes a thread.
Thread Messages
Messages are added to threads and contain the content of a conversation.
- CreateMessage: Creates a message within a thread.
- ThreadId: The ID of the thread.
- ListMessages: Returns a list of messages for a given thread.
- RetrieveMessage: Retrieves a message by thread and message ID.
- ModifyMessage: Modifies a message.
- DeleteMessage: Deletes a message from a thread.
Runs
Runs represent an execution on a thread with an assistant. The assistant uses its configuration and the thread messages to perform tasks by calling models and tools.
- CreateRun: Creates a run for a thread with a specified assistant.
- ListRuns: Returns a list of runs belonging to a thread.
- RetrieveRun: Retrieves a run by thread and run ID.
- ModifyRun: Modifies a run.
- SubmitToolOutputsToRun: Submits tool outputs for a run that requires action.
- CancelRun: Cancels an in-progress run.
Run Steps
Run steps represent the individual steps taken during a run execution.
- ListRunSteps: Returns a list of run steps belonging to a run.
- RetrieveRunSteps: Retrieves a run step by thread, run, and step ID.
Vector Stores
Vector stores are used to store and search over files using embeddings for retrieval-augmented generation (RAG).
- CreateVectorStore: Creates a vector store.
- ListVectorStores: Returns a list of vector stores.
- RetrieveVectorStore: Retrieves a vector store by ID.
- ModifyVectorStore: Modifies a vector store.
- DeleteVectorStore: Deletes a vector store.
Vector Store Files
Manage files within vector stores.
- CreateVectorStoreFile: Attaches a file to a vector store.
- ListVectorStoreFiles: Returns a list of files in a vector store.
- RetrieveVectorStoreFile: Retrieves a vector store file.
- DeleteVectorStoreFile: Removes a file from a vector store.
Vector Store File Batches
Batch operations for adding files to vector stores.
- CreateVectorStoreFileBatch: Creates a batch to add multiple files to a vector store.
- RetrieveVectorStoreFileBatch: Retrieves a file batch by ID.
- CancelVectorStoreFileBatch: Cancels an in-progress file batch.
- ListVectorStoreFilesBatch: Lists files in a batch.
Speech
Generate spoken audio from text using text-to-speech models.
- CreateSpeech: Generates audio from the input text. Returns audio data as a string or writes to a response stream.
- Model: The TTS model to use (e.g. tts-1, tts-1-hd).
- Input: The text to generate audio for.
- Voice: The voice to use (alloy, echo, fable, onyx, nova, shimmer).
Fine-Tuning Jobs
Manage fine-tuning jobs to create customized models. This is the newer fine-tuning API that replaces the legacy Fine-Tunes endpoint.
- CreateFineTuningJob: Creates a fine-tuning job from a training file.
- ListFineTuningJobs: Lists your organization's fine-tuning jobs.
- RetrieveFineTuningJob: Retrieves info about a fine-tuning job.
- CancelFineTuningJob: Cancels a fine-tuning job.
- ListFineTuningJobEvents: Lists status updates for a fine-tuning job.
- ListFineTuningJobCheckpoints: Lists checkpoints for a fine-tuning job.
Responses
Create and manage model responses. The Responses API supports multi-turn conversations, tool use, and structured outputs.
- CreateResponse: Creates a model response.
- RetrieveResponse: Retrieves a response by ID.
- DeleteResponse: Deletes a response.
- CancelResponse: Cancels an in-progress response.
- ListInputItems: Lists input items for a response.
Batches
Create and manage batch API requests for asynchronous processing at lower cost.
- CreateBatch: Creates a batch job.
- RetrieveBatch: Retrieves a batch by ID.
- ListBatches: Lists all batches.
- CancelBatch: Cancels an in-progress batch.
Uploads
Upload large files in parts. Useful for files that exceed the standard upload size limit.
- CreateUpload: Creates an upload session.
- AddUploadPart: Adds a part to an upload.
- CompleteUpload: Completes a multi-part upload and creates a file.
- CancelUpload: Cancels an in-progress upload.