Skip to content

OpenAI GPT3/3.5 ChatGPT API Client for Go, go libra simple, less dependencies, and well-tested

License

Notifications You must be signed in to change notification settings

AndreiRegiani/openaigo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openaigo

Go CodeQL App Test over API License FOSSA Status
Maintainability Go Report Card codecov
Reference GoDoc

Yet another API client for api.openai.com.

This library is community-maintained, NOT officially supported by OpenAI.

Usage Example

package main

import (
  "fmt"
  "github.com/otiai10/openaigo"
)

func main() {
  client := openaigo.NewClient(os.Getenv("OPENAI_API_KEY"))
  request := openaigo.ChatCompletionRequestBody{
    Model: "gpt-3.5-turbo",
    Messages: []openaigo.ChatMessage{
      {Role: "user", Content: "Hello!"},
    },
  }
  ctx := context.Background()
  response, err := client.Chat(ctx, request)
  fmt.Println(response, err)
}

if you just want to try, hit commands below.

git clone https://github.com/otiai10/openaigo.git
cd openaigo
OPENAI_API_KEY=YourAPIKey go run ./testapp/main.go

API Keys?

Visit https://beta.openai.com/account/api-keys and you can create your own API key to get started for free.

Endpoint Support

Issues

Report any issue here or any feedback is welcomed.

About

OpenAI GPT3/3.5 ChatGPT API Client for Go, go libra simple, less dependencies, and well-tested

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%