examples(typescript): add langchain-krewe-inference-chatbot#1222
Open
harrydev44 wants to merge 1 commit into
Open
examples(typescript): add langchain-krewe-inference-chatbot#1222harrydev44 wants to merge 1 commit into
harrydev44 wants to merge 1 commit into
Conversation
A LangChain chatbot that uses AgentKit's built-in x402ActionProvider to call krewe (https://www.krewe.world) — a decentralized AI inference network on Base mainnet. The agent's CDP wallet pays in USDC per call (0.005 USD for text.structure up to 0.05 USD for text.complete) and gets 2-of-3 byte-equal miner consensus output for four job kinds: text.structure, text.embed, web.scrape, text.complete. The example demonstrates the canonical "x402-paywalled inference as a first-class agent tool" pattern: no API key, no provisioning step, the wallet IS the API key. Pricing, max-payment cap, and orchestrator URL are all env-configurable. The chatbot exposes both chat mode and an autonomous mode that picks creative krewe jobs on a 30s loop, useful for cost/perf testing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🟡 Heimdall Review Status
|
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new LangChain chatbot example to
typescript/examples/that uses AgentKit's built-inx402ActionProviderto call krewe — a decentralized AI inference network on Base mainnet — for four job kinds (text.structure,text.embed,web.scrape,text.complete).This is the canonical "x402-paywalled inference as a first-class agent tool" pattern: no API key, no provisioning step, the agent's CDP wallet IS the API key. Each call settles per-request in USDC via EIP-3009
transferWithAuthorization(handled transparently byx402ActionProvider+@x402/fetch), and the agent gets back 2-of-3 byte-equal miner consensus output.Pricing surfaced in the system prompt so the agent makes cost-aware tool choices:
kindtext.structuretext.embedweb.scrapetext.completeThe orchestrator at
https://krewe-orchestrator-production.up.railway.app/v2/predictis already live in production and returns the documentedWWW-Authenticate: x402 scheme=\"x402-eip3009-usdc\"header on the 402 challenge — verified with the existingx402ActionProvider.What's in this PR
typescript/examples/langchain-krewe-inference-chatbot/chatbot.ts— entrypoint, mirrors the structure oflangchain-cdp-chatbot/chatbot.ts(chat mode + autonomous mode + identical CDP wallet wiring) so it's easy to diff and reason about.package.json,tsconfig.json,.eslintrc.json,.prettierrc,.prettierignore— copied verbatim from the canonicallangchain-cdp-chatbotexample, with only the package name + description changed.README.md— prompts to try, prerequisites, env vars, run instructions, and a walkthrough of what's happening during the x402 handshake..env-local— addsNETWORK_ID,KREWE_PREDICT_URL,KREWE_MAX_PAYMENT_USDC(all with sensible defaults).README.md— adds the new example to the directory tree.Why this is worth merging
x402ActionProvideragainst a real, production x402 service. Today the canonical example registershttps://www.x402.org/protected(a demo endpoint); this PR shows what a real production integration looks like, including a maximum-payment cap, a deterministic price table, and a system prompt that teaches the agent when to reach for the tool.Test plan
chatbot.tsmirrors the provenlangchain-cdp-chatbottemplate structure — wallet config, agent setup, chat/auto loops are identical patterns.curl -X POST .../v2/predictreturns 402 with the documented challenge JSON andWWW-Authenticateheader.tsconfig, eslint, prettier) copied verbatim fromlangchain-cdp-chatbotto match repo conventions.README.mdexamples tree updated alphabetically.Happy to address any feedback on naming, system prompt wording, or which AgentKit providers to bundle alongside x402 in the default config.
Links: