Skip to content

Instantly share code, notes, and snippets.

@PawanOsman
Created March 7, 2023 22:57
Show Gist options
  • Save PawanOsman/72dddd0a12e5829da664a43fc9b9cf9a to your computer and use it in GitHub Desktop.
Save PawanOsman/72dddd0a12e5829da664a43fc9b9cf9a to your computer and use it in GitHub Desktop.
OAI Reverse Proxy - FREE

Introduction:

Reverse proxy to use OpenAI API Join Our Discord Server 😁

Features

  1. Works same as OpenAI API
  2. Supports Streaming!
  3. It's FREE!

Support Our Work

You can support our work by donating

We realy appreciate your Support

Patreon: https://patreon.com/pawanosman

PayPal: paypal@kurdlabs.com

Requirements

A free private API key (required to reduce abuse use) To get a free API key for this reverse proxy you can follow the below steps.

  1. First join our Discord server and go to #Bot channel
  2. Do /key command and it will give you a Free API key for this reverse proxy endpoint.

Note:

  1. First time you join may be you need to wat for 10 mins to be able to send message.
  2. Each API key is tied to a single IP address, so if you use an API key with a particular IP address, you cannot use it from any other IP address.
  3. You can reset your Key IP address by using /resetip command from our Discord Server.

Usage:

To use this API, you need to send a POST request to the following endpoint:

https://gpt.pawan.krd/api/completions

The body object parameters are the same body object of the official API . Example:

Key Value Description
prompt your prompt
temperature 0.7 Controls the "creativity" of the generated text. Higher values result in more creative responses.
max_tokens 256 Maximum number of tokens (words) in the generated response.
top_p 0.9 Controls the "diversity" of the generated text. Higher values result in more diverse responses.
frequency_penalty 0 Penalizes the model for repeating words/phrases in the generated response.
presence_penalty 0 Penalizes the model for omitting words/phrases from the input prompt in the generated response.
model text-davinci-003 Specifies the GPT model to use for generating the response.
stop <|im_end|> Specifies the sequence of characters to use as the end of the generated response.
stream true/false If set to true, the response will be streamed.

Example using cURL:

curl -X POST \
  https://gpt.pawan.krd/api/completions \
  -H 'Authorization: Bearer <YOUR_KEY_FROM_DISCORD>' \
  -H 'Content-Type: application/json' \
  -d '{
  "prompt": "Hello?",
  "temperature": 0.7,
  "max_tokens": 256,
  "top_p": 0.9,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "model": "text-davinci-003",
  "stop": "<|im_end|>"
}'

Example using Node.js:

import axios from 'axios';

const data = JSON.stringify({
  "prompt": "Hello?",
  "temperature": 0.7,
  "max_tokens": 256,
  "top_p": 0.9,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "model": "text-davinci-003",
  "stop": "<|im_end|>"
});

const config = {
  method: 'post',
  url: 'https://gpt.pawan.krd/api/completions',
  headers: { 
    'Authorization': 'Bearer <YOUR_KEY_FROM_DISCORD>', 
    'Content-Type': 'application/json'
  },
  data : data
};

let response = await axios(config);
console.log(response.data);

Example using C#:

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        var request = new HttpRequestMessage
        {
            Method = HttpMethod.Post,
            RequestUri = new Uri("https://gpt.pawan.krd/api/completions"),
            Headers =
            {
                { "Authorization", "Bearer <YOUR_KEY_FROM_DISCORD>" },
                { "Content-Type", "application/json" },
            },
            Content = new StringContent(@"{
  ""prompt"": ""Hello?"",
  ""temperature"": 0.7,
  ""max_tokens"": 256,
  ""top_p"": 0.9,
  ""frequency_penalty"": 0,
  ""presence_penalty"": 0,
  ""model"": ""text-davinci-003"",
  ""stop"": ""<|im_end|>""
}"),
        };

        HttpResponseMessage response = await client.SendAsync(request);
        response.EnsureSuccessStatusCode();

        string responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseBody);
    }
}

Example using Python:

import requests
import json

url = "https://gpt.pawan.krd/api/completions"

payload = {
  "prompt": "Hello?",
  "temperature": 0.7,
  "max_tokens": 256,
  "top_p": 0.9,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "model": "text-davinci-003",
  "stop": "<|im_end|>"
}
headers = {
    'Authorization': 'Bearer <YOUR_KEY_FROM_DISCORD>',
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)
@riarhey
Copy link

riarhey commented Aug 14, 2023

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