SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
14 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
880 B · 11 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# POST /v1/messages/count_tokens with system + a client tool (free endpoint)3# STATUS: LIVE_VERIFIED 2026-09-18 (curl via scripts/lib.sh `ant` wrapper; key injected from .env, never printed)4# Run: bash examples/anthropic/messages/count_tokens.sh5set -eo pipefail6source "$(dirname "$0")/../../../scripts/lib.sh"; out="$(mktemp)"; trap 'rm -f "$out"' EXIT7ant POST /v1/messages/count_tokens -d '{"model":"claude-haiku-4-5-20251001","system":"You are a helpful assistant.",8  "tools":[{"name":"get_weather","description":"Get current weather for a city.","input_schema":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}],9  "messages":[{"role":"user","content":"Reply with OK."}]}' > "$out"; mask < "$out"10echo; echo "HTTP $ANT_STATUS"; log_request anthropic POST /v1/messages/count_tokens "$ANT_STATUS" 0 "example count_tokens.sh"11