The official Forge-generated Go SDK requires Go 1.23+ and uses only the standard library.
Install
Run this inside your Go module.
go get github.com/vectali/vectali-go@v0.4.1Convert and download
Set VECTALI_API_KEY. Convert returns a typed result with result.Svg and result.ConversionID. Download returns the bytes for your chosen format.
package main
import (
"context"
"log"
"os"
"github.com/vectali/vectali-go"
)
func main() {
ctx := context.Background()
client := vectali.NewClient(os.Getenv("VECTALI_API_KEY"))
result, err := client.Convert(ctx, "logo.png")
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("logo.svg", []byte(result.Svg), 0644); err != nil {
log.Fatal(err)
}
pdf, err := client.Download(ctx, result.ConversionID, "pdf")
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("logo.pdf", pdf, 0644); err != nil {
log.Fatal(err)
}
}Choose an input type
Convert accepts a path string, []byte or io.Reader. The SDK streams the multipart upload and keeps borrowed readers open. Set Filename when sending raw bytes or a reader. For a retry, provide a fresh reader over the same original data and reuse IdempotencyKey.
result, err := client.Convert(ctx, image, vectali.ConvertOptions{
Filename: "logo.png",
IdempotencyKey: jobID,
})
Configure the client
Use vectali.WithBaseURL(origin) for a custom API origin and vectali.WithTimeout(duration) to override the 260-second default. Pass a context.Context to calls to support cancellation.
GetAllowance(ctx) reads billing and remaining conversions. vectali.NewClient("").Health(ctx) checks public health without a key.
Handle errors and retries
Use errors.As to find a *vectali.ResponseError. Its Response preserves the HTTP status, headers and body. Other errors can come from transport, context cancellation or local file handling.
var failure *vectali.ResponseError
if errors.As(err, &failure) {
log.Println(failure.Response.StatusCode, failure.Response.Header.Get("X-Vectali-Request-Id"))
log.Println("Retry-After:", failure.Response.Header.Get("Retry-After"))
}
Apply the rate limit guidance before rescheduling. A new Convert call without an explicit key generates a new UUID.