Skip to content

Commit be2b4dc

Browse files
Trinity Agentclaude
andcommitted
feat(cloud): add API key validation before spawning agent container (#147)
Add a CI step that validates the Anthropic API key before spawning Railway containers. This prevents wasted resources if the API key is invalid or the model routing is misconfigured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c16ed8f commit be2b4dc

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/agent-spawn.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ jobs:
1414
contents: read
1515
issues: write
1616
steps:
17+
- name: Validate API key
18+
env:
19+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
20+
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
21+
run: |
22+
RESPONSE=$(curl -s "${ANTHROPIC_BASE_URL}/v1/messages" \
23+
-H "x-api-key: ${ANTHROPIC_API_KEY}" \
24+
-H "anthropic-version: 2023-06-01" \
25+
-H "Content-Type: application/json" \
26+
-d '{"model":"glm-5","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}')
27+
MODEL=$(echo "$RESPONSE" | jq -r '.model // "error"')
28+
echo "API returned model: $MODEL"
29+
if [ "$MODEL" = "error" ]; then
30+
echo "::error::API key validation failed"
31+
exit 1
32+
fi
33+
1734
- name: Spawn container via Railway API
1835
env:
1936
RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }}

0 commit comments

Comments
 (0)