Giter VIP home page Giter VIP logo

freegpt35-homi's Introduction

Contributors Forks Stargazers Issues License

freegpt35

Unlimited free GPT-3.5 turbo API service.
About author »

Features · Examples · Reference · License

Features

  • Streaming API. freegpt35 allow the response sent back incrementally in chunks.
  • Easy Deploy. Containerized, starts in seconds using docker compose.
  • Login free. Do not need to worry about the details of authorization, use in a glance.

Examples

Usage at a glance

mkdir freegpt35 && cd freegpt35
curl -O https://raw.githubusercontent.com/hominsu/freegpt35/main/deploy/docker-compose.yml

Then add the environment if you need, for more details check the following Customize part.

docker compose up -d

Once deployed, use following command to confirm that everything working.

curl -X POST "http://localhost:3000/v1/chat/completions" \
     -H "Authorization: Bearer anything_or_your_key" \
     -H "Content-Type: application/json" \
     -d '{
           "model": "gpt-3.5-turbo",
           "messages": [{"role": "user", "content": "Hello"}],
         }'
{"id":"chatcmpl-*********","created":9999999999,"model":"gpt-3.5-turbo","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"Hi there! How can I assist you today?","role":"assistant"}}],"usage":{"prompt_tokens":1,"completion_tokens":10,"total_tokens":11}}

Nginx Template

Here is an nginx conf template that you can refer to. More info about NGINX Docker setup you can check this post: 优雅地在 Docker 中使用 NGINX

upstream freegpt35 {
    server 127.0.0.1:3000
}

server {
    listen 80;
    listen [::]:80;
    server_name your.domain.name;

    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name your.domain.name;

    ssl_certificate /etc/nginx/ssl/your.domain.name/full.pem;
    ssl_certificate_key /etc/nginx/ssl/your.domain.name/key.pem;

    ssl_session_timeout 5m;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers TLS13_AES_128_GCM_SHA256:TLS13_AES_256_GCM_SHA384:TLS13_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305;
    ssl_prefer_server_ciphers on;

    location /v1/chat/completions {
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto "https";
       proxy_pass http://freegpt35;

       proxy_buffering  off;
       proxy_cache      off;

       send_timeout               600;
       proxy_connect_timeout      600;
       proxy_send_timeout         600;
       proxy_read_timeout         600;
       chunked_transfer_encoding  on;
    }
    error_page   500 502 503 504  /50x.html;
}

Vercel

If you subscribe to Vercel, you can try this deploy method, otherwise do not waste your time, since with Hobby plan your serverless API routes can only be processed for 5 seconds, the route responds with a FUNCTION_INVOCATION_TIMEOUT error.

Deploy with Vercel

Once deployed, you can test with curl again

curl -X POST "https://freegpt35.vercel.app/v1/chat/completions" \
     -H "Authorization: Bearer anything_or_your_key" \
     -H "Content-Type: application/json" \
     -d '{
           "model": "gpt-3.5-turbo",
           "messages": [{"role": "user", "content": "Hello"}]
         }'
{"id":"chatcmpl-**********","created":9999999999,"model":"gpt-3.5-turbo","object":"chat.completion","choices":[{"finish_reason":"stop","index":0,"message":{"content":"Hey there! How's it going?","role":"assistant"}}],"usage":{"prompt_tokens":1,"completion_tokens":8,"total_tokens":9}}

Customize

You can also define your Environment Variables to for some specific cases.

Environment Variable Description
NEXT_BASE_URL Base URL for the ChatGPT, modified it if you using an mirror site
NEXT_API_URL DO NOT MODIFIED IT, unless you really know what you're doing
NEXT_API_KEY API key used for authentication to access the API.
NEXT_MAX_RETRIES Maximum number of retries for API requests in case of failure.
NEXT_USER_AGENT User agent string used in the headers of requests sent from the server.
NEXT_PROXY_ENABLE Enable or disable proxy usage (true or false).
NEXT_PROXY_PROTOCOL Protocol used by the proxy (e.g., http, https).
NEXT_PROXY_HOST Hostname or IP address of the proxy server.
NEXT_PROXY_PORT Port number on which the proxy server is listening.
NEXT_PROXY_AUTH Enable or disable proxy authentication (true or false).
NEXT_PROXY_USERNAME Username for proxy authentication, if authentication is enabled.
NEXT_PROXY_PASSWORD Password for proxy authentication, if authentication is enabled.

Reference

License

Distributed under the AGPL 3.0 license. See LICENSE for more information.

freegpt35-homi's People

Contributors

hominsu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.