Skip to content

abhayptp/go-chatgpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT client (unofficial)

Unofficial golang client for ChatGPT. Reverse Engineered from chat.openai.com

Usage

  1. Install the package.
go get github.com/abhayptp/go-chatgpt
  1. Get bearer token from the browser.

To avoid needing to refresh bearer token every hour, you can also copy "__Secure-next-auth.session-token" key from cookie and pass it in Credentials in Step 3.

  1. Pass the bearer token while initializing client.
package main

import (
	"fmt"

	"github.com/abhayptp/go-chatgpt"
)

func main() {

	// Initialize. Copy bearer-token and session-token from browser developer tools.
	c := chatgpt.NewChatGpt(chatgpt.NewClient(&chatgpt.Credentials{
		BearerToken: "Bearer <bearer-token>",
		SessionToken: "<session-token>",
		}))

	// Send message
	res, err := c.SendMessage("hello")
	if err != nil {
		// Handle err
	}

	// Handle response
	fmt.Println(res)
}

About

An unofficial ChatGPT client in Golang.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages