Python 88.3%
TypeScript 7.6%
Shell 4.1%
1#!/usr/bin/env bash2# STATUS: LIVE_VERIFIED — executed 2026-09-19 (exit 0 in 1.9s)3# Create a batch, add one request (responses body accepted), list, cancel.4set -euo pipefail5cd "$(dirname "$0")/../../.."6source scripts/lib.sh7T=$(mktemp); trap 'rm -f "$T"' EXIT8xai POST /v1/batches -d '{"name":"atlas-example-sh"}' > "$T"; log_request xai POST /v1/batches "$XAI_STATUS" 0 "example xai/batches/create.sh"; [ "$XAI_STATUS" = "200" ]9BID=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["batch_id"])' "$T"); echo "batch $BID"10xai POST "/v1/batches/$BID/requests" -d '{"batch_requests":[{"batch_request_id":"r1","batch_request":{"responses":{"model":"grok-4.3","input":"Reply with OK.","max_output_tokens":2000}}}]}' > "$T"11log_request xai POST "/v1/batches/{id}/requests" "$XAI_STATUS" 0.0004 "example xai/batches/create.sh add"; [ "$XAI_STATUS" = "200" ]; echo "add → $XAI_STATUS (empty body)"12xai GET "/v1/batches?limit=3" > "$T"; log_request xai GET /v1/batches "$XAI_STATUS" 0 "example xai/batches/create.sh list"; mask < "$T" | python3 -c 'import json,sys; print(len(json.load(sys.stdin)["batches"]), "batches listed")'13curl -sS -o "$T" -w '%{http_code}' -X POST "https://api.x.ai/v1/batches/$BID:cancel" -H "Authorization: Bearer $XAI_API_KEY" > "$T.c"; ST=$(cat "$T.c"); rm -f "$T.c"14log_request xai POST "/v1/batches/{id}:cancel" "$ST" 0 "example xai/batches/create.sh cancel"; mask < "$T" | python3 -c 'import json,sys; r=json.load(sys.stdin); print("cancel_time", r["cancel_time"], r["state"])'15[ "$ST" = "200" ]16