Skip to content

This repository will help you to integrate ChatGPT and other Openai models to your particular application

Notifications You must be signed in to change notification settings

hridesh-net/ChatGPT-Integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Using simple Requets Model

This app is to give an overview of how to access Openai Models using simple python code for any purpose.

  • This repository contains several method to do this.
  • Also in this repository you'll find integration of several different Openai Models.

you can understand the request parameters and send create your own requesrests or you can Directly copy bellow commands and run them in there particular environment.

API Reference

Endpoint: https://api.openai.com

Get all Models

  GET /v1/models
Parameter Type Description
Authorization string Required. Your API key

on Bash/shell

curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

In python

import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.list()

Model Retrival

  GET v1/models/{model}
Parameter Type Description
Authorization string Required. Your API key
model string Required. Model you want to retrive

In shell/bash

curl https://api.openai.com/v1/models/text-davinci-003 \
  -H "Authorization: Bearer $OPENAI_API_KEY"

In Python

import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.retrieve("text-davinci-003")

Chat Completeion (ChatGPT-3)

  POST v1/chat/completions

Inside Header

Parameter Type Description
Content-Type string Required. application/json
Authorization string Required. Your API key

Inside Body

Parameter Type Description
model string Required. Model you are using ("gpt-3.5-turbo")
messages string Required. Need to pass message to GPT with the role in array -> [{"role": "user", "content": "Hello!"}]

In shell/Bash

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

In python

import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")

completion = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "user", "content": "Hello!"}
  ]
)

print(completion.choices[0].message)

About

This repository will help you to integrate ChatGPT and other Openai models to your particular application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages