By Admin on Sunday, 09 April 2023
Category: All

OpenAI Delphi API (1 / 5)

From sgcWebSockets 2023.3.0 the OpenAI API is fully supported.

The OpenAI API can be applied to virtually any task that involves understanding or generating natural language, code, or images. OpenAI offer 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.

Authentication

​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.

OpenAI Models

Once the API Key is configured, find below a list of available functions to interactuate with the OpenAI API.

Models

List and describe the various models available in the API.


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.


Chat

Given a chat conversation, the model will return a chat completion response.


Edits

Given a prompt and an instruction, the model will return an edited version of the prompt.

Images

Given a prompt and/or an input image, the model will generate a new image.


Embeddings

Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.


Audio

Turn Audio into Text.


Files

Files are used to upload documents that can be used with features like Fine-tuning.


Fine-Tunes

Manage fine-tuning jobs to tailor a model to your specific training data.


Moderations

Given a input text, outputs if the model classifies it as violating OpenAI's content policy.

OpenAI Examples

​Find below some examples of applications build in Delphi using the OpenAI API

1. ChatGPT Delphi Client

2. OpenAI Transcription Delphi Client

3. Translate OpenAI Delphi Client

4. Image Generator OpenAI Delphi Client

Find below a sample OpenAI API client built for Windows using the Delphi sgcWebSockets library which shows the main methods of the API.

Related Posts