Skip to content

Instantly share code, notes, and snippets.

@PawanOsman
Created February 2, 2023 21:31
Show Gist options
  • Save PawanOsman/be803be44caed2449927860956b240ad to your computer and use it in GitHub Desktop.
Save PawanOsman/be803be44caed2449927860956b240ad to your computer and use it in GitHub Desktop.

I created a dedicated HTTP API for official ChatGPT API, its using POST so it can handle long prompts and it supports setting all OpenAI properties

Example in NodeJS: (Its same for other languages you need to create a post request like below)

Ask ChatGPT a question

axios({
    method: 'post',
    url: 'https://chatgpt.pawan.krd/ask',
    headers: {
        'Content-Type': 'application/json'
    },
    data: JSON.stringify({
        "key": "sk-BBCnjlwWeCNlvyFk5hxxxxxxxxxxxxxxxxxxxxxxx",
        "prompt": "who are you?",
        "id": "default"
    })
})

// response 
{
  "status": true,
  "response": "Hello, how can i help you?"
}

// or 

{
  "status": false,
  "error" "Something went wrong"
}

Reset conversation by id

axios({
    method: 'post',
    url: 'https://chatgpt.pawan.krd/reset',
    headers: {
        'Content-Type': 'application/json'
    },
    data: JSON.stringify({
        "key": "sk-BBCnjlwWeCNlvyFk5hxxxxxxxxxxxxxxxxxxxxxxx",
        "id": "default"
    })
})

Init the API with all Options (Optional you can directly request ask if you don't want to modify the options)

await axios({
    method: 'post',
    url: 'https://chatgpt.pawan.krd/init',
    headers: {
        'Content-Type': 'application/json'
    },
    data: JSON.stringify({
        "key": "sk-BBCnjlwWeCNlvyFk5hxxxxxxxxxxxxxxxxxxxxxxx",
        "options": {
            "instructions": "You are ChatGPT, your name Is ChatGPT!"
        }
    })
});

// response
{
  "status": true
}

Options

options =  {
    temperature?: number;
    max_tokens?: number;
    top_p?: number;
    frequency_penalty?: number;
    presence_penalty?: number;
    instructions?: string;
    stop?: string;
}
@0xdevalias
Copy link

I created a dedicated HTTP API for official ChatGPT API

And how do we know this service won't just log/steal our API tokens?

@PawanOsman
Copy link
Author

I created a dedicated HTTP API for official ChatGPT API

And how do we know this service won't just log/steal our API tokens?

Its up to you, i don't force anyone use my services, i have many free services and its 2 - 3 months i launched a bypass server for ChatGPT which many peoples using it and puting thier tokens on it

You can ask them, they all know that i don't need any key or token

Its not something i can prove for you you can join the discord server and ask them,

or you can just use my other API which uses my own API Key and you dont need to put your key
I shared as a repository named "ChatGPT"

@PawanOsman
Copy link
Author

Also if you dont trust you can use a new OpenAI account API Key

Or contact me i will give you my key to use it
What more you want?

@alimaqsood
Copy link

hi, can you please write code for PHP to use it?

@optionsx
Copy link

optionsx commented Feb 4, 2023

I created a dedicated HTTP API for official ChatGPT API

And how do we know this service won't just log/steal our API tokens?

you should know better atleast...
it's an apiKey which has a scope of openai models only, meaning it can't access any private data, use an empty openai key since it's free of charge
bruh.

@imbytecat
Copy link

What's the difference bewteen this and PawanOsman/ChatGPT? Why does this require an API Key and will I spend the credits?

@PawanOsman
Copy link
Author

PawanOsman commented Feb 6, 2023

What's the difference bewteen this and PawanOsman/ChatGPT? Why does this require an API Key and will I spend the credits?

PawanOsman/ChatGPT doesn't support options and runs on a single API Key which maybe gets rate limited sometimes because many peoples use it, no it doesn't charge you, even you can use a new account with 0 credit it will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment