Go client for interacting with OpenAI API endpoints.
23
stars
55
commits
Go
primary language
Jul 30, 2026
updated
Zero dependency (Unofficial) Go Client for OpenAI API endpoints. Built upon the great work done here.
Why did we bother to refactor the original library? We have 5 main goals:
We hope that by doing the above, future maintenance should also be trivial. Read more on the original refactoring PR here.
go get github.com/fabiustech/openai
package main
import (
"context"
"fmt"
"os"
"github.com/fabiustech/openai"
"github.com/fabiustech/openai/models"
"github.com/fabiustech/openai/params"
)
func main() {
var key, ok = os.LookupEnv("OPENAI_API_KEY")
if !ok {
panic("env variable OPENAI_API_KEY not set")
}
var c = openai.NewClient(key)
var resp, err = c.CreateCompletion(context.Background(), &openai.CompletionRequest[models.Completion]{
Model: models.TextDavinci003,
MaxTokens: 100,
Prompt: "Lorem ipsum",
Temperature: params.Optional(0.0),
})
if err != nil {
return
}
fmt.Println(resp.Choices[0].Text)
}
Contributions are welcome and encouraged! Feel free to report any bugs / feature requests as issues.
Go
98.6%
Makefile
1.4%
Go client for interacting with OpenAI API endpoints.
23
stars
55
commits
Go
primary language
Jul 30, 2026
updated
Zero dependency (Unofficial) Go Client for OpenAI API endpoints. Built upon the great work done here.
Why did we bother to refactor the original library? We have 5 main goals:
We hope that by doing the above, future maintenance should also be trivial. Read more on the original refactoring PR here.
go get github.com/fabiustech/openai
package main
import (
"context"
"fmt"
"os"
"github.com/fabiustech/openai"
"github.com/fabiustech/openai/models"
"github.com/fabiustech/openai/params"
)
func main() {
var key, ok = os.LookupEnv("OPENAI_API_KEY")
if !ok {
panic("env variable OPENAI_API_KEY not set")
}
var c = openai.NewClient(key)
var resp, err = c.CreateCompletion(context.Background(), &openai.CompletionRequest[models.Completion]{
Model: models.TextDavinci003,
MaxTokens: 100,
Prompt: "Lorem ipsum",
Temperature: params.Optional(0.0),
})
if err != nil {
return
}
fmt.Println(resp.Choices[0].Text)
}
Contributions are welcome and encouraged! Feel free to report any bugs / feature requests as issues.
Go
98.6%
Makefile
1.4%