Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : API Atlas8# File : examples/xai/messages-compat/minimal.sh9# Module : examples10# Repository : https://git.spboucher.ai/doc-api11# Created : 2026-09-1912# Last Modified : 2026-09-1913#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: contact@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# STATUS: LIVE_VERIFIED — executed 2026-09-19 (exit 0 in 4.2s)41# Anthropic-compatible POST /v1/messages on xAI (DEPRECATED by xAI, still live). Bearer auth, no anthropic-version needed.42set -euo pipefail43cd "$(dirname "$0")/../../.."44source scripts/lib.sh45T=$(mktemp); trap 'rm -f "$T"' EXIT46xai POST /v1/messages -d '{"model":"grok-4.3","max_tokens":32,"system":"Be terse.","messages":[{"role":"user","content":"Reply with OK."}]}' > "$T"47log_request xai POST /v1/messages "$XAI_STATUS" 0.0005 "example xai/messages-compat/minimal.sh"48mask < "$T" | python3 -c 'import json,sys; r=json.load(sys.stdin); print(r["type"], r["stop_reason"], [c["type"] for c in r["content"]], r["usage"])'49[ "$XAI_STATUS" = "200" ]50