Skip to content

Unlock the potential of OpenAI's GPT-3 model for NLP tasks—summarization, classification, text completion, and more. This repo guides you through OpenAI API setup, offering hands-on exercises with the Completions endpoint. Gain experience integrating OpenAI API into React apps.

Notifications You must be signed in to change notification settings

saravadeo/open-ai-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

open-ai-api

Completion API

Endpoint

Endpoint URL: https://api.openai.com/v1/completions

Method: POST

Request Parameters

  • engine (String): Required. ID of the engine for the task.
  • prompt (String/Array): Optional. Text for completions generation.
  • max_tokens (Integer): Optional. Maximum tokens in the completion. Default: 16.
  • temperature (Float): Optional. Token sampling method. Default: 1.
  • top_p (Float): Optional. Nucleus sampling. Default: 1.
  • suffix (String): Optional. Text at the end for better generation.
  • n (Integer): Optional. Number of completions. Default: 1.
  • logprobs (Integer): Optional. Number of tokens with highest likelihood. Default: null.
  • best_of (Integer): Optional. Server-side generates best_of completions. Default: 1.
  • presence_penalty (Integer): Optional. Penalizes new tokens based on presence. Range: -2.0 to 2.0.
  • frequency_penalty (Integer): Optional. Penalizes new tokens based on existing frequency. Range: -2.0 to 2.0.

Response

  • choices (Array): Array of objects with logprobs and generated text.

Sample API Call

// Define endpoint URL
const endpointUrl = "https://api.openai.com/v1/completions";

// Define Header Parameters
const headerParameters = {
  "Authorization": "Bearer {{SECRET_KEY}}",
  "Content-Type": "application/json"
};

Link to Sample React Project README

About

Unlock the potential of OpenAI's GPT-3 model for NLP tasks—summarization, classification, text completion, and more. This repo guides you through OpenAI API setup, offering hands-on exercises with the Completions endpoint. Gain experience integrating OpenAI API into React apps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published