Tutorials, comparisons and design patterns for building autonomous agents that self-fund, call 345+ models and orchestrate MCP Tools.
A plain-prompt eval stops measuring your agent at the exact moment the agent starts doing its job: the first tool call. This tutorial wraps the LLM4Agents conversation loop in a Promptfoo custom provider — about forty lines of TypeScript — so the eval exercises the real thing: system prompt, MCP allowlist, tool rounds, and settled cost. It covers the three asserts that catch real agent regressions (did it use the tool, did it stay within its round budget, did it repeat itself), wires the suite into GitHub Actions so a prompt edit that breaks retrieval fails the PR, and addresses the elephant in the runner: Promptfoo is now owned by OpenAI, and why that is acceptable for this stack.
The whole retrieval pipeline — file storage, PDF parsing, embedding, vector search, and the conversation loop — lives behind one endpoint and one balance. This tutorial builds a working RAG agent over your own PDFs in under 50 lines of TypeScript and about 30 of Python: ingest with workspace_upload, pdf_parse, and vector_upsert, then hand the model a one-tool allowlist and let it call vector_query for itself. Plus a three-query golden eval, a Workers Cron deploy while Agent Cron is still in development, an honest cost breakdown (about 65 cents to ingest a 120-page handbook), and a component-by-component comparison with the LangChain RAG stack.
Every paid call on the gateway accepts two payment modes: Bearer against a prepaid balance, or x402 walk-up with a signed stablecoin authorization, priced 10 percent lower. The discount is not the decision. Bearer settles actual usage and refunds the delta; walk-up settles the worst-case quote, final, no refund path — which means max_tokens discipline decides which mode is actually cheaper for inference. This post works through the real decision tree: who funds the call, what billing model you sell, when mixed mode wins, how AP2 mandates fit when the agent spends someone else's money, and why the new x402 upto scheme changes the trade.
An LLM call is metered output: you only know what it cost after the last token. This is the internals tour of the billing pattern that makes a prepaid balance work anyway — reserve the worst case before the request leaves, proxy the stream untouched, settle the actual cost from the final usage chunk, refund the delta. Plus the reason max_tokens is your reserve knob, why streaming responses report cost in the last SSE event instead of a header, how the same reserve becomes the x402 walk-up quote, and the three edge cases that decide whether a billing design is honest: dropped streams, mid-chain fallbacks, and upstream rate limits.
Most users of the LLM4Agents API never learn that the MCP server at mcp.llm4agents.com exposes 67 documented tools across twelve families: headless scraping with proxy tiers and persistent sessions, Google search in batches of 100, image generation and analysis, eight Workers AI primitives, an R2-backed file workspace with single-use download tokens, a 768-dim vector store, key-value memory, notifications with an SSRF-guarded webhook, eleven data utilities, read-only web3 lookups on four chains, and document parsing. Every paid tool answers to a Bearer key against your balance, and almost every one also answers to an x402 signed payment at a 10 percent discount — we curl the endpoint with no credentials and decode the live HTTP 402 quote to show exactly how. Plus the pricing anchors, the three balance-only exceptions, when to upgrade from one-shot scrapes to sessions, and the allowlist discipline that keeps 67 tools from becoming 67 attack surfaces.
Most agent memory systems pay an LLM to read the transcript and extract beliefs on every interaction. FERNme — Fuzzy-Edged Recall Network — does the opposite: deterministic Hebbian updates on a graph of fuzzy 0–9 edges, zero LLM calls on the write path, and a prompt-facing card that stays around 25 tokens whether it is your first visit or your fifth year. It ships a FastAPI REST surface, an MCP server, a glass-box editor, and a supernode design that lets a user assemble one cross-site profile they own, default-deny. We walk through the mechanism, the reported benchmarks (drift detection 0.72 vs 0.13, cards 77× smaller, writes 122× cheaper than Mem0 in pure mode), the honest caveats of a v0.3 research preview on synthetic data, and what a deterministic, injection-resistant, user-owned memory layer means for an agent-payments gateway billing per call.
The week the agent economy stopped being a demo. Mastercard launched Agent Pay for Machines on June 10 with 30+ partners and USDC/RLUSD as the core settlement rail. Coinbase and AWS pushed x402 into CloudFront and WAF on June 16, putting HTTP 402 at the infrastructure edge. The MCP working group locked a stateless release candidate ahead of the July 28 final. And the frontier shelf churned again: Fable 5 was pulled from general availability, GPT-5.6 leaked, and Gemini 3.5 Pro neared GA. We read each through one lens: what it means for an OpenAI-compatible gateway where agents pay per call in stablecoins.
OpenAI's Agent Builder and Evals go read-only on October 31, 2026, and shut down November 30. Every operator built on those products has a six-month migration window. This post is the runbook: a six-piece mapping from OpenAI Agent Builder to the LLM4Agents stack, with real code on both ends. We cover the system prompt and conversation loop using the @llm4agents/sdk client.chat.conversation API, the tool catalog using the unified MCP server at mcp.llm4agents.com (70+ tools across scraper, search, image, AI, notify, data, vector, workspace, web3, document categories), the knowledge base using workspace_upload plus vector_upsert and vector_query, the eval suite using Promptfoo pointed at the OpenAI-compatible /v1/chat/completions endpoint, the conversation memory using memory_set and memory_get for cross-session state plus the conversation history field for within-session state, and the deployment shell using the agent-playground or the agent-helper CLI while the LLM4Agents Agent Builder UI is still in development. We also explain what model fallback chains, the reserve-proxy-settle billing model, and X-Cost-Usd-Cents response headers give you that OpenAI did not. The piece is paired with the Friday roundup that reported the sunset; the operator who reads both has the why and the how.