← Protocols
Brian AI
01Description

Intent-recognition and execution engine that turns natural-language prompts into ready-to-sign onchain transactions, smart contracts, and data answers. Ships a TypeScript SDK and a LangChain toolkit so agents can swap, bridge, deposit, borrow, and transfer across EVM chains in a single tool call.

02Best for
  • 01natural-language transaction building
  • 02intent-based DeFi agents
  • 03LangChain swap/bridge tools
  • 04consumer chat-to-onchain UX
  • 05smart contract scaffolding
03Install
  • pnpm add @brian-ai/langchain @langchain/openai
  • pnpm add @brian-ai/sdk
04Environment variables
VariableScopeDescription
BRIAN_API_KEYServerAPI key from the Brian dashboard (key.brianknows.org). Server-only.
AGENT_PRIVATE_KEYServerHex-encoded EVM private key for the agent's viem account. Server-only.
OPENAI_API_KEYServerLLM provider key used by the LangChain agent.
05Prompt snippet
Use Brian AI for natural-language onchain operations. The fastest path is `createBrianAgent({ apiKey, privateKeyOrAccount, llm: new ChatOpenAI() })` from `@brian-ai/langchain`, which returns a LangChain agent pre-loaded with swap/bridge/deposit/withdraw/borrow/transfer tools. For finer control, instantiate `BrianToolkit` and bind the resulting tools to your own agent or the Vercel AI SDK. For raw intents (no agent), use `@brian-ai/sdk`'s `BrianSDK.transact({ prompt, address, chainId })` to get back populated transaction request objects to sign with viem/ethers. Validate every returned `to`/`value`/`data` and require a user confirm step for value-transferring intents.
06Gotchas
  • Brian returns transaction request objects that must be signed and submitted by your wallet — it does not custody keys, so wallet security is your responsibility.
  • Intents that touch unsupported chains/protocols return helpful errors at runtime, not at toolkit init — wrap each tool call in try/catch.
  • API quotas apply per key; chatty agents that re-prompt on every token will hit rate limits fast — cache parsed intents.
  • Always set a maximum slippage and a per-intent USD ceiling before executing — the LLM cannot reason about MEV or sandwich risk.
  • The LangChain helper signs with whatever `AGENT_PRIVATE_KEY` you provide; never reuse a user's key, give the agent a sandboxed EOA.
  • Smart-contract generation is templated — review and audit any deployed bytecode, do not push to mainnet without independent review.
07Alternatives