Node Starter Agent
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
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, plustool_calledevents. - EdgeOne sandbox tools —
commands,files,code_interpreter,browserare pulled fromcontext.toolsand exposed as OpenAI function calling tools. - Tool-calling loop — up to 10 rounds: model returns
tool_calls→ execute viatoolRegistry.execute()→ append results → re-request, until a final answer. - Conversation memory —
ChatSession(context.store)reads/writes per-conversation history via the EdgeOne store. - Honest cancellation — frontend
AbortControllerplus backendcontext.request.signalactually release the upstream LLM connection.
Environment Variables
| Variable | Required | Description |
|---|---|---|
AI_GATEWAY_API_KEY | Yes | Model gateway API key. Use your Makers Models API Key, or any OpenAI-compatible provider key. |
AI_GATEWAY_BASE_URL | Yes | Gateway base URL. For Makers Models, use https://ai-gateway.edgeone.link/v1. |
AI_GATEWAY_MODEL | No | Model ID. Defaults to @makers/deepseek-v4-flash (a free built-in model). |
WSA_API_KEY | No | Tencent 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
- Open the Makers Console.
- Sign in and enable Makers.
- Go to Makers → Models → API Key and create a key.
- 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.