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.1 KB · 10 lines typescript
Raw Blame History
1// web_fetch_20250910 with citations. STATUS: UNVERIFIED as a script (raw request LIVE_VERIFIED 2026-09-18, d1).2// Run: node --env-file=.env --experimental-strip-types examples/anthropic/web-fetch/web_fetch.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-haiku-4-5-20251001", max_tokens: 200, tools: [{ type: "web_fetch_20250910", name: "web_fetch", max_uses: 1, citations: { enabled: true }, max_content_tokens: 2000 }], messages: [{ role: "user", content: "Fetch https://example.com and tell me the page title in 3 words." }] } as any);7logRequest("anthropic", "POST", "/v1/messages", 200, 0.004, "web_fetch.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