/go-chatgpt-api

Unofficial API in Go (bypass Cloudflare 403).

Primary LanguageGoMIT LicenseMIT

go-chatgpt-api

Unofficial ChatGPT API.

Available APIs:


  • get conversation list

GET /conversations?offset=0&limit=20

offset defaults to 0, limit defaults to 20 (max 100).


  • get conversation content

GET /conversation/{conversationID}


  • create conversation

POST /conversation

{
  "action": "next",
  "messages": [
    {
      "id": "message id",
      "author": {
        "role": "user"
      },
      "content": {
        "content_type": "text",
        "parts": [
          "Hello World"
        ]
      }
    }
  ],
  "parent_message_id": "parent message id",
  "conversation_id": "conversation id",
  "model": "text-davinci-002-render-sha",
  "timezone_offset_min": -480,
  "history_and_training_disabled": false
}

  • generate conversation title

POST /conversation/gen_title/{conversationID}

{
  "message_id": "response message id"
}

  • rename conversation

PATCH /conversation/{conversationID}

{
  "title": "new title"
}

  • delete conversation

PATCH /conversation/{conversationID}

{
  "is_visible": false
}

  • delete all conversations

PATCH /conversations

{
  "is_visible": false
}

  • feedback message

POST /conversation/message_feedback

{
  "message_id": "message id",
  "conversation_id": "conversation id",
  "rating": "thumbsUp/thumbsDown"
}

  • login (currently only support ChatGPT accounts)

POST /auth/login

{
  "username": "email",
  "password": "password"
}

  • chat completion (apiKey)

POST /v1/chat/completions

{
  "messages": [
    {
      "role": "user",
      "content": "Hello World"
    }
  ],
  "model": "gpt-3.5-turbo",
  "stream": true
}

No need to run chatgpt-proxy-server anymore.


If you need to setup a proxy, set GO_CHATGPT_API_PROXY, for example: GO_CHATGPT_API_PROXY=http://127.0.0.1:20171 or GO_CHATGPT_API_PROXY=socks5://127.0.0.1:20170.

services:
  go-chatgpt-api:
    container_name: go-chatgpt-api
    image: linweiyuan/go-chatgpt-api
    ports:
      - 8080:8080
    environment:
      - GIN_MODE=release
      - GO_CHATGPT_API_PROXY=
    restart: unless-stopped

If you get Access denied, but the server is in support countries, have a try with this:

services:
  go-chatgpt-api:
    container_name: go-chatgpt-api
    image: linweiyuan/go-chatgpt-api
    environment:
      - GIN_MODE=release
      - GO_CHATGPT_API_PROXY=socks5://chatgpt-proxy-server-warp:65535
    depends_on:
      - chatgpt-proxy-server-warp
    restart: unless-stopped

  chatgpt-proxy-server-warp:
    container_name: chatgpt-proxy-server-warp
    image: linweiyuan/chatgpt-proxy-server-warp
    environment:
      - LOG_LEVEL=OFF
    restart: unless-stopped