Back to Templates

Node Starter Agent

A minimal Node.js LLM agent starter on EdgeOne Makers with streaming responses, conversation memory, interruption, and platform tool calling.

View Demo
FrameworkReact.js
Use CaseAgents,AI
A minimal Node.js LLM agent starter on EdgeOne Makers with streaming responses, conversation memory, interruption, and platform tool calling.

Node.js Starter Agent

A minimal Node.js / TypeScript LLM Agent template on EdgeOne Makers — built on raw fetch against an OpenAI-compatible Chat Completions endpoint, with EdgeOne sandbox tool calling and context.store-backed conversation memory. No agent framework.

Framework: None (raw Node) · Category: Quick Start · Language: TypeScript

Deploy to EdgeOne Makers

Overview

The smallest reasonable starting point if you want a chat Agent without committing to a framework. The whole loop — prompt → stream LLM → execute tool calls → loop → final answer — is plain fetch and a small toolRegistry. Read the source top-to-bottom and you've seen everything.

  • SSE streaming chat — token-by-token push of text_delta, plus tool_called events.
  • EdgeOne sandbox toolscommands, files, code_interpreter, browser are pulled from context.tools and exposed as OpenAI function calling tools.
  • Tool-calling loop — up to 10 rounds: model returns tool_calls → execute via toolRegistry.execute() → append results → re-request, until a final answer.
  • Conversation memoryChatSession(context.store) reads/writes per-conversation history via the EdgeOne store.
  • Honest cancellation — frontend AbortController plus backend context.request.signal actually release the upstream LLM connection.

Environment Variables

VariableRequiredDescription
AI_GATEWAY_API_KEYYesModel gateway API key. Use your Makers Models API Key, or any OpenAI-compatible provider key.
AI_GATEWAY_BASE_URLYesGateway base URL. For Makers Models, use https://ai-gateway.edgeone.link/v1.
AI_GATEWAY_MODELNoModel ID. Defaults to @makers/deepseek-v4-flash (a free built-in model).
WSA_API_KEYNoTencent Cloud Web Search API key. Required only if you use the web-search tool.

This template follows the OpenAI-compatible standard — point these at Makers Models or any compatible provider.

How to get AI_GATEWAY_API_KEY

  1. Open the Makers Console.
  2. Sign in and enable Makers.
  3. Go to Makers → Models → API Key and create a key.
  4. Copy it into AI_GATEWAY_API_KEY.

The built-in @makers/deepseek-v4-flash model is free with a usage cap and is suitable for prototyping. For production, bind your own paid provider (BYOK).

How to get WSA_API_KEY

WSA_API_KEY is only needed when calling the web-search tool. See the documentation.

Local Development

Prerequisites: Node.js ≥ 18 and the EdgeOne CLI (npm i -g edgeone).

npm install
cp .env.example .env       # then fill in AI_GATEWAY_API_KEY / AI_GATEWAY_BASE_URL
edgeone makers dev

Local agent metrics & traces are exposed at http://localhost:8080/agent-metrics.

Project Structure

node-starter/
├── agents/                          # Node/TS backend (EdgeOne Makers Agent Functions, stateful)
│   ├── chat/index.ts               # POST /chat — SSE streaming chat with tool loop
│   ├── chat/stop.ts                # POST /chat/stop — abort active agent run
│   ├── _model.ts                   # LLM model config (private)
│   ├── _logger.ts                  # Logger utility (private)
│   ├── _session.ts                 # Session adapter over context.store (private)
│   └── _tools.ts                   # EdgeOne tool registry (private)
├── cloud-functions/                 # Node/TS backend (EdgeOne Makers Node Functions, stateless)
│   ├── history/index.ts            # POST /history — conversation history
│   └── _logger.ts                  # Logger utility (private)
├── src/                             # React + Vite + TypeScript frontend
│   ├── App.tsx                     # Main app + SSE stream lifecycle
│   ├── api.ts                      # /chat, /chat/stop, /history wrappers
│   └── components/                 # ChatWindow, ChatInput, CodeViewer, ToolIndicators, ...
├── package.json
├── vite.config.ts
├── tsconfig.json
└── index.html

Files prefixed with _ are private modules — not exposed as public routes.

Resources

License

MIT.