#!/bin/sh
set -eu
: "${BASE_URL:?Set BASE_URL including the API version path}"
: "${API_KEY:?Set API_KEY}"
: "${MODEL_ID:?Set MODEL_ID}"
case "$BASE_URL" in https://*) ;; *) echo "Use an HTTPS BASE_URL" >&2; exit 1;; esac
# jq safely encodes model names and request text.
jq -n --arg model "$MODEL_ID" '{model:$model,messages:[{role:"user",content:"Hello, world."}]}' | curl --fail-with-body --max-time 60 "${BASE_URL%/}/chat/completions" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" --data-binary @-
