Skip to content

Call Vexly from Go

package main

import (
  "bytes"
  "fmt"
  "net/http"
  "os"
)

func main() {
  base := os.Getenv("VEXLY_BASE_URL")
  if base == "" {
    base = "https://api.vexly.io/api/v1/public"
  }
  token := os.Getenv("VEXLY_ACCESS_TOKEN")

  body := []byte(`{"prompt":"Reply with exactly: hello from go"}`)
  req, _ := http.NewRequest("POST", base+"/agent/runs", bytes.NewBuffer(body))
  req.Header.Set("Authorization", "Bearer "+token)
  req.Header.Set("Content-Type", "application/json")

  resp, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer resp.Body.Close()
  fmt.Println(resp.Status)
}