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%
1.3 KB · 19 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# Extended (manual) thinking on Haiku 4.5: thinking.type enabled + budget_tokens 1024, max_tokens 1200.3# Prints the thinking block (summary + signature prefix) and usage.output_tokens_details.thinking_tokens.4# STATUS: LIVE_VERIFIED 2026-09-18 — 200, [thinking, text "4"], thinking_tokens 30 (~$0.0003).5# Run: bash examples/anthropic/thinking/extended_thinking.sh6set -eo pipefail7cd "$(dirname "$0")/../../.." && source scripts/lib.sh8OUTF="$(mktemp)"; trap 'rm -f "$OUTF"' EXIT9# `ant` sets ANT_STATUS; calling it inside $(...) would lose it, so write the body to a file instead.10call() { ant "$@" > "$OUTF"; OUT="$(cat "$OUTF")"; }11MODEL="${ANTHROPIC_MODEL:-claude-haiku-4-5-20251001}"12call POST /v1/messages -d "$(jq -n --arg m "$MODEL" '{model:$m, max_tokens:1200,13  thinking:{type:"enabled", budget_tokens:1024},14  messages:[{role:"user", content:"What is 2+2? Reply with the number."}]}')"15echo "HTTP $ANT_STATUS"16echo "$OUT" | jq -c '.content[] | {type, thinking: (.thinking // null | if . then .[0:80] else null end), signature: (.signature // null | if . then .[0:24] else null end), text}'17echo "$OUT" | jq -c '.usage | {output_tokens, output_tokens_details}'18log_request anthropic POST /v1/messages "$ANT_STATUS" 0.0003 "example thinking/extended_thinking.sh $MODEL"19