needle.js
Load the official .cact archive, define JSON Schema tools, and run the
complete execution loop without a framework.
needle.js
Load the official .cact archive, define JSON Schema tools, and run the
complete execution loop without a framework.
Vercel AI SDK
Use a standard LanguageModelV4 with generateText(), streamText(), AI
SDK tools, and structured output.
pi-ai + Agent
Register a native, zero-cost pi-ai provider or install it directly into pi as a local model extension.
Build the engine
Follow a token through the model, decode Cactus Quants, and implement a reference inference loop and byte grammar from scratch.
Needle 2 is purpose-built for selecting tools and extracting their arguments. The model combines grouped-query attention, four-lane hyper-connections, a fixed Hadamard MLP, and hashed n-gram memory. Cactus Quants keeps 45 million parameters in a compact archive that can be read without expanding every matrix.
needle.js implements that stack in TypeScript and keeps the deployment contract simple:
On Apple WebKit with WebGPU, greedy generation measures about 45 tok/s in pure TypeScript and 55 tok/s with resident TypeGPU execution. Small projections stay on CPU because a WebGPU round trip costs more than their compute. See the numbers.