Run the example
Extract the archive and run these commands inside its directory. The example lists public models by default. To submit a job, set BEATO_API_KEY and BEATO_IDEMPOTENCY_KEY in your environment.
go run ./cmd/example
Example source
package main
import (
"context"
"encoding/json"
"log"
"os"
"time"
beato "beato.dev/sdk"
)
func main() {
ctx := context.Background()
client := beato.New(os.Getenv("BEATO_API_KEY"), os.Getenv("BEATO_API_BASE_URL"))
key := os.Getenv("BEATO_IDEMPOTENCY_KEY")
if key == "" {
models, err := client.Models(ctx)
if err != nil {
log.Fatal(err)
}
if err := json.NewEncoder(os.Stdout).Encode(models); err != nil {
log.Fatal(err)
}
return
}
job, err := client.CreateJob(ctx, beato.JobInput{Model: "nano-banana", Prompt: "A watercolor of a rainy street"}, key)
if err != nil {
log.Fatal(err)
}
for i := 0; i < 60 && job.Status != "succeeded" && job.Status != "failed"; i++ {
time.Sleep(5 * time.Second)
job, err = client.GetJob(ctx, job.ID)
if err != nil {
log.Fatal(err)
}
}
if err := json.NewEncoder(os.Stdout).Encode(job); err != nil {
log.Fatal(err)
}
}