Skip to content

Instantly share code, notes, and snippets.

@jwmatthews
Created February 6, 2026 12:18
Show Gist options
  • Select an option

  • Save jwmatthews/b21caa835a6efd05da023b44b8bd6ac8 to your computer and use it in GitHub Desktop.

Select an option

Save jwmatthews/b21caa835a6efd05da023b44b8bd6ac8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Minimal test: Claude Opus 4.6 via Vertex AI on GCP
set -euo pipefail
PROJECT=$(gcloud config get-value project 2>/dev/null)
LOCATION="us-east5"
MODEL="claude-opus-4-6@default"
TOKEN=$(gcloud auth print-access-token)
API_URL="https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT}/locations/${LOCATION}/publishers/anthropic/models/${MODEL}:rawPredict"
response=$(curl -s -w "\n%{http_code}" -X POST "$API_URL" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"anthropic_version": "vertex-2023-10-16",
"messages": [
{ "role": "user", "content": "Say hello world." }
],
"max_tokens": 128
}')
http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | sed '$d')
if [ "$http_code" -eq 200 ]; then
echo "Success (HTTP $http_code)"
echo "$body" | jq -r '.content[0].text // "No text in response"'
else
echo "Error (HTTP $http_code)"
echo "$body" | jq . 2>/dev/null || echo "$body"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment