#!/bin/bash
# Test Vertex AI Claude Opus 4.5 with correct format
PROJECT_ID="amgn-app"
LOCATION_ID="global"
MODEL_ID="claude-opus-4-5"
METHOD="rawPredict"
echo "======================================"
echo "๐งช Testing Vertex AI Claude Opus 4.5"
echo "======================================"
echo ""
# Create request JSON
cat << EOF > request.json
{
"anthropic_version": "vertex-2023-10-16",
"stream": false,
"max_tokens": 512,
"temperature": 1,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello! This is a test. Please respond with 'API test successful'."
}
]
}
]
}
EOF
echo "๐ Request JSON created:"
cat request.json
echo ""
echo ""
# Get access token
echo "๐ Getting access token..."
TOKEN=$(gcloud auth print-access-token 2>/dev/null)
if [ -z "$TOKEN" ]; then
echo "โ Not authenticated. Run: gcloud auth login"
exit 1
fi
echo "โ
Token obtained"
echo ""
# Make API call
echo "๐ค Making API call to Vertex AI..."
echo "Endpoint: https://aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/anthropic/models/${MODEL_ID}:${METHOD}"
echo ""
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/anthropic/models/${MODEL_ID}:${METHOD}")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | head -n-1)
echo "๐ฅ Response (HTTP $HTTP_CODE):"
echo ""
if [ "$HTTP_CODE" = "200" ]; then
echo "โ
SUCCESS! API is working!"
echo ""
echo "$BODY" | python -m json.tool 2>/dev/null || echo "$BODY"
else
echo "โ Error (HTTP $HTTP_CODE):"
echo "$BODY" | python -m json.tool 2>/dev/null || echo "$BODY"
fi
echo ""
echo "======================================"
echo "Test Complete!"
echo "======================================"
echo ""
# Cleanup
rm -f request.json