Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abhayptp/go-chatgpt
An unofficial ChatGPT client in Golang.
https://github.com/abhayptp/go-chatgpt
chatgpt
Last synced: 6 days ago
JSON representation
An unofficial ChatGPT client in Golang.
- Host: GitHub
- URL: https://github.com/abhayptp/go-chatgpt
- Owner: abhayptp
- Created: 2022-12-03T23:36:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-10T20:07:59.000Z (almost 2 years ago)
- Last Synced: 2024-08-02T20:47:22.805Z (3 months ago)
- Topics: chatgpt
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 64
- Watchers: 1
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-ChatGPT - ChatGPT client (unofficial)
- awesome-chatgpt - go-chatgpt
- awesome-chatgpt - ChatGPT client (unofficial)
README
# ChatGPT client (unofficial)
Unofficial golang client for ChatGPT. Reverse Engineered from [chat.openai.com](https://chat.openai.com)
## Usage
1. Install the package.
```bash
go get github.com/abhayptp/go-chatgpt
```2. 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.
3. Pass the bearer token while initializing client.
```go
package mainimport (
"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 ",
SessionToken: "",
}))// Send message
res, err := c.SendMessage("hello")
if err != nil {
// Handle err
}// Handle response
fmt.Println(res)
}
```