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.4 KB · 10 lines typescript
Raw Blame History
1// PTC step 1 on claude-sonnet-4-6 (haiku -> 400). Step 2: tool_result-only message + container id, see basic.sh. STATUS: UNVERIFIED as a script (raw request LIVE_VERIFIED 2026-09-18, g1).2// Run: node --env-file=.env --experimental-strip-types examples/anthropic/tools/programmatic-tool-calling/basic.ts3import Anthropic from "@anthropic-ai/sdk";4import { logRequest } from "../../../shared/tool-loop/log.ts";5const client = new Anthropic();6const resp: any = await client.messages.create({ model: "claude-sonnet-4-6", max_tokens: 500, tools: [{ type: "code_execution_20260120", name: "code_execution" }, { name: "query_database", description: "Execute a SQL query. Returns a JSON array of row objects.", input_schema: { type: "object", properties: { sql: { type: "string" } }, required: ["sql"] }, allowed_callers: ["code_execution_20260120"] }], messages: [{ role: "user", content: "Use code to call query_database with sql 'SELECT 1 AS one' and tell me the value of one." }] } as any);7logRequest("anthropic", "POST", "/v1/messages", 200, 0.011, "basic.ts");8console.log(resp.stop_reason, JSON.stringify(resp.content.map((b: any) => ({ type: b.type, name: b.name, toolset_name: b.toolset_name, input: b.input, caller: b.caller, text: b.text, content: typeof b.content === "object" ? "[…]" : b.content })), null, 1).slice(0, 1500));9console.log("usage", resp.usage, "container", resp.container);10