Giter Club home page Giter Club logo

chatgpt-free-api's Introduction

ChatGPT Free API

CI Docker Pulls

Provide free GPT-3.5 API service by reverse engineering the login-free ChatGPT website.

Note: This service requires the IP to be able to use the login-free Chatgpt normally.

Install

Docker

docker run -d -p 3040:3040 --name chatgpt-free-api xsigoking/chatgpt-free-api

Binaries for macOS, Linux, and Windows

Download it from GitHub Releases, unzip, and add chatgpt-free-api to your $PATH.

Usage

Run server

chatgpt-api-server                                  # Listening on 0.0.0.0:3040, no proxy
PORT=8080 chatgpt-api-server                        # Listening on port 8080
ALL_PROXY=http://localhost:18080 chatgpt-api-server # Use a proxy

Request Example

curl http://127.0.0.1:3040/v1/chat/completions \
  -i -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

License

The project is under the MIT License, Refer to the LICENSE file for detailed information.

chatgpt-free-api's People

Contributors

bfeitknecht avatar xsigoking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

chatgpt-free-api's Issues

What is the reason for the error message?

What is the reason for the error message
{ "status": false, "error":{ "message": "Failed to meet chat requirements, error decoding response body", "type": "invalid_request_error" } }

error

{"status":false,"error":{"message":"Failed to meet chat requirements, error decoding response body","type":"invalid_request_error"}}

started in docker by your command, sending curl with your command.

Failed to check the chat requirements, `{"details":"Unauthorized"}`

Login-free ChatGPT is being gradually launched. It may not be available in your current region.

OpenAI, April 1, 2024

Starting today, you can use ChatGPT instantly, without needing to sign-up. We're rolling this out gradually, with the aim to make AI accessible to anyone curious about its capabilities.

Run the following command to check if it is available

curl 'https://chat.openai.com/backend-anon/sentinel/chat-requirements' \
  -H 'accept: */*' \
  -H 'accept-language: en' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'oai-device-id: 31d07b2e-40ae-4af8-9501-573ed853e39b' \
  -H 'oai-language: en-US' \
  -H 'origin: https://chat.openai.com' \
  -H 'pragma: no-cache' \
  -H 'referer: https://chat.openai.com/' \
  -H 'sec-ch-ua: "Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36' \
  --data-raw '{}'

If curl returns {"details":"Unauthorized"}, then login-free ChatGPT is not available in your current region.

Error Decoding Response Body

chatgpt-free-api service running on a proxy in the USA

curl http://127.0.0.1:3040/v1/chat/completions   -i -X POST   -H "Content-Type: application/json"   -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": false
  }'

returns:

HTTP/1.1 200 OK
content-type: application/json
access-control-allow-origin: *
access-control-allow-methods: GET,POST,PUT,PATCH,DELETE
access-control-allow-headers: Content-Type,Authorization
content-length: 98
date: Thu, 18 Apr 2024 09:05:57 GMT

{"status":false,"error":{"message":"error decoding response body","type":"invalid_request_error"}}

log of the service:

Access the API server at: http://0.0.0.0:3040/v1/chat/completions

Environment Variables:
  - PORT: change the listening port, defaulting to 3040
  - ALL_PROXY: configure the proxy server, supporting HTTP, HTTPS, and SOCKS5 protocols
  - AUTHORIZATION: only for internal use to protect the API and will not be sent to OpenAI

Please contact us at https://github.com/xsigoking/chatgpt-free-api if you encounter any issues.

[2024-04-17T10:56:13Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T10:58:57Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:00:57Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:01:10Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:13:07Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:44:44Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:47:40Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:48:11Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:48:37Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:50:04Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:50:46Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:51:10Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:52:01Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T11:52:19Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T12:01:21Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-17T12:07:59Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T07:48:47Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T08:57:13Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:00:32Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:00:44Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:01:01Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:02:21Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:02:42Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:04:54Z ERROR] POST /v1/chat/completions 200 error decoding response body
[2024-04-18T09:05:57Z ERROR] POST /v1/chat/completions 200 error decoding response body

Failed to get answer caused by: Invalid header value: "application/json"

I tried:

  • running the server from the released binary
  • docker: docker run -d --name chatgpt-free-api xsigoking/chatgpt-free-api
  • docker-compose:
version: '3'
services:
  chatgpt-free-api:
    image: xsigoking/chatgpt-free-api:latest
    restart: always
    ports:
      - "3040:3040"

Everything led to the same error:

Screenshot 2024-04-10 at 12 07 41 Screenshot 2024-04-10 at 12 09 53

System Software Overview:

  System Version: macOS 14.4.1 (23E224)
  Kernel Version: Darwin 23.4.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: echo
  User Name: Basil (bf)
  Secure Virtual Memory: Enabled
  System Integrity Protection: Enabled
  Time since boot: 12 days, 20 hours, 11 minutes

Hardware Overview:

  Model Name: MacBook Pro
  Model Identifier: Mac14,9
  Model Number: MPHE3SM/A
  Chip: Apple M2 Pro
  Total Number of Cores: 10 (6 performance and 4 efficiency)
  Memory: 16 GB
  System Firmware Version: 10151.101.3
  OS Loader Version: 10151.101.3
  Serial Number (system): M77K97QL9N
  Activation Lock Status: Disabled

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.