Go
Use the openai-go SDK with 000 Labs.
Install
go get github.com/openai/openai-gomain.go
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithBaseURL("https://api.000labs.xyz/v1/"),
option.WithAPIKey(os.Getenv("000_LABS_API_KEY")),
)
resp, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
Model: "openai/gpt-4o-mini",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("What is the meaning of life?"),
},
})
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}