Saltar al contenido principal

Use ChatGPT

Totalum allows you to use OpenAI's ChatGPT API without the need to register for an OpenAI account. You can use it directly through the Totalum SDK or API.

What happens if you are not programming in javascript?​

If you are not programming in javascript, you can use the api directly, see TOTALUM API DOCUMENTATION

If you are programming in javascript, you can use the totalumSdk​

Note: If you use totalumSdk inside a totalum plugin, you don't need to authenticate, you can start using totalum sdk functions like this: modules.totalumSdk.ocr.ocrOfImage(fileName); etc...

If you have questions about how to install and use TotalumSdk, check the documentation: Totalum SDK Installation, and Using the SDK

No hace falta que te registres en openai

Functions for call OpenAI API without need to have an OpenAI account​

Create a chat completion​


//body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
const bodyExample={
// see the openai api docs for more info
messages: [
{content: 'You are a math specialist assistant', role: 'system'},
{content: 'how I can resolve a matrix', role: 'user'}
//etc...
],
model: 'gpt-3.5-turbo',
max_tokens: 30,
}

const result = await totalumClient.openai.createChatCompletion(bodyExample);
const chatCompletion = result.data.data;
// returns the completion provided by openai api

Create a completion (deprecated, use createChatCompletion instead)​


//body the openai completion body, more info here: https://platform.openai.com/docs/api-reference/completions/create
const body={
// see the openai api docs for more info
}

const result = await totalumClient.openai.createCompletion(body);
const gptCompletion = result.data.data;

// returns the completion provided by openai api

Generate an image​


//body the openai chat completion body, more info here: https://platform.openai.com/docs/api-reference/chat/create
const bodyExample={
prompt:'your prompt',
size: '256x256' | '512x512' | '1024x1024',
fileName: 'file-name-of-file-saved.png' // CAUTION: if you use the same name for multiple images, the images will be overwritten
}

const result = await totalumClient.openai.generateImage(bodyExample);
const imageCompletion = result.data.data;
// returns the file name with the file generated by openai, if is not an url, you can download it using files.getDownloadUrl(imageCompletion);