This is a library implemented in Go for OpenAI API. It supports:
go get github.com/mengbin92/openai
package main
import (
"context"
"fmt"
"os"
"github.com/mengbin92/openai"
)
func main() {
client := openai.NewClient("your token", "your org", "proxy")
resp, err := client.CreateChatCompletion(
context.Background(),
&openai.ChatCompletionRequset{
Model: openai.GPT3Dot5Turbo,
Messages: []openai.Message{
{Role: openai.ChatMessageRoleUser, Content: "hi!"},
},
},
)
if err != nil {
fmt.Printf("CreateChatCompletion error: %s\n", err.Error())
os.Exit(-1)
}
fmt.Println(resp.Choices[0].Message.Content)
}