Registry / http-client / sashabaranov-go-openai

sashabaranov-go-openai

JSON →
library1.41.2gogounverified

Go OpenAI is an unofficial Go client library for the OpenAI API.

go get github.com/sashabaranov/go-openai
INSTALL
IMPORT
SIG · SASHABARANOV-GO-OP
S
sashabaranov-go-openai
http-clientgov1.41.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

openai
github.com/sashabaranov/go-openai

Sends a chat completion request to OpenAI's GPT-3.5 Turbo model.

package main import ( "context" "github.com/sashabaranov/go-openai" ) func main() { client := openai.NewClient("your-api-key") resp, err := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{ Model: openai.GPT3Dot5Turbo, Messages: []openai.ChatCompletionMessage{ {Role: "user", Content: "Hello!"}, }, }) if err != nil { panic(err) } println(resp.Choices[0].Message.Content) }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.41.2latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
sashabaranov-go-openai — go get sashabaranov-go-openai · libregistry