Saltar para o conteúdo principal
Versão: 20 R9 BETA

OpenAI

The OpenAI class provides a client for accessing various OpenAI API resources. It includes properties for managing API configurations and methods for performing HTTP requests to the OpenAI endpoints.

Configuration Properties

Nome da propriedadeTipoDescriçãoOpcional
apiKeyTextYour OpenAI API Key.Não para OpenAI
baseURLTextBase URL for OpenAI API requests.Sim
organizationTextYour OpenAI Organization ID.Sim
projectTextYour OpenAI Project ID.Sim

Propriedades HTTP adicionais

Nome da propriedadeTipoDescrição
timeoutRealTime in seconds before timeout occurs.
maxRetriesRealMaximum number of retry attempts in case of failure.
httpAgent4D.HTTPAgentHTTP agent used for making requests.
customHeadersRealCustom headers to be included in the HTTP requests.

Class constructor

Create an instance of the OpenAI client class.

Argument NameTipoDescrição
apiKeyTexto ou objetoapiKey if Text as first argument and the second can be an Object of parameters.

Chave API

// as text
var $client:=cs.AIKit.OpenAI.new("your api key")
// as object
var $client:=cs.AIKit.OpenAI.new({apiKey: "your api key"})

URL do Servidor

For a compatible provider API, you can configure the server URL.

var $client:=cs.AIKit.OpenAI.new({apiKey: "your api key"; baseURL: "https://server.ai"})

or after creating an instance

$client.baseURL:="https://server.ai"

Recursos API

The API provides access to multiple resources that allow seamless interaction with OpenAI's services. Each resource is encapsulated within a dedicated API class, offering a structured and intuitive way to interact with different functionalities.

Nome da propriedadeTipoDescrição
modelsOpenAIModelsAPIAcesso à API Models.
chatOpenAIChatAPIAccess to the Chat API.
imagesOpenAIImagesAPIAcesso à API Images.
moderationsOpenAIModerationsAPIAccess to the Moderations API.

Exemplo de uso

$client.chat.completions.create(...)
$client.images.generate(...)
$client.model.lists(...)