Skip to main content
Methods: client.CreateBatch(...), client.RetrieveBatch(...), client.CancelBatch(...), client.GetAsyncJobWebSocketURL(...), client.GetBatchWebSocketURL(...), client.AsyncJobs.WebSocketURL(...).
import (
  "context"
  "fmt"
  phaseo "github.com/phaseoteam/Phaseo/packages/sdk/sdk-go"
)

client := phaseo.New(apiKey, "https://api.phaseo.ai/v1")
ctx := context.Background()

created, err := client.CreateBatch(ctx, map[string]interface{}{
  "endpoint": "responses",
  "input_file_id": "file_123",
  "session_id": "agent-run-42",
})
if err != nil {
  panic(err)
}

status, err := client.RetrieveBatch(ctx, fmt.Sprint(created.(map[string]interface{})["id"]))
if err != nil {
  panic(err)
}

cancelling, err := client.CancelBatch(ctx, fmt.Sprint(created.(map[string]interface{})["id"]))
if err != nil {
  panic(err)
}

websocketURL, err := client.GetBatchWebSocketURL(
  fmt.Sprint(created.(map[string]interface{})["id"]),
  &phaseo.AsyncJobWebSocketOptions{IntervalMS: 1500},
)
if err != nil {
  panic(err)
}

fmt.Println(status)
fmt.Println(cancelling)
fmt.Println(websocketURL)
Batch responses also surface gateway observability fields such as request_id, provider, echoed session_id / webhook, and terminal billing / pricing_lines when available. Use client.GetBatchWebSocketURL(...) when you want to subscribe to the documented /v1/async/batch/{id}/ws lifecycle stream instead of polling only. Use client.AsyncJobs.WebSocketURL("batch", batchID, options) when you want the generic async-jobs resource helper. Use client.GetAsyncJobWebSocketURL("batch", batchID, options) when you want the same generic helper without going through the resource object.
Last modified on July 9, 2026