mirror of
https://github.com/openai/openai-go.git
synced 2026-04-01 09:07:22 +09:00
27 lines
491 B
Go
27 lines
491 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/openai/openai-go/v3"
|
|
"github.com/openai/openai-go/v3/responses"
|
|
)
|
|
|
|
func main() {
|
|
client := openai.NewClient()
|
|
ctx := context.Background()
|
|
|
|
question := "Write me a haiku about computers"
|
|
|
|
resp, err := client.Responses.New(ctx, responses.ResponseNewParams{
|
|
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String(question)},
|
|
Model: openai.ChatModelGPT4,
|
|
})
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
println(resp.OutputText())
|
|
}
|