Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt

Use this file to discover all available pages before exploring further.

Methods: client.CreateBatch(...), client.RetrieveBatch(...), client.CancelBatch(...), client.GetAsyncJobWebSocketURL(...), client.GetBatchWebSocketURL(...), client.AsyncJobs.WebSocketURL(...).
import (
  "context"
  "fmt"
  aistats "github.com/AI-Stats/AI-Stats/packages/sdk/sdk-go"
)

client := aistats.New(apiKey, "https://api.phaseo.app/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"]),
  &aistats.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 May 6, 2026