跳至内容
logo regular
logo regular

🚀 Quickstart

1
  • Get Started with 123API in 5 Minutes: Send Your First Chat Request

🗂️ Model Catalog

1
  • Best Conversation Models of 2026 Compared: GPT vs Claude vs Gemini vs DeepSeek

📖 Cookbook / Tutorials

1
  • Build an AI Chatbot from Scratch with 123API

💳 Cost & Billing

1
  • 7 Ways to Cut Your AI API Costs by Up to 70%

❓ FAQ & Troubleshooting

1
  • 401 / 403 Auth Failure: 123API Key Troubleshooting
View Categories
  • 首页
  • Doc
  • 📖 Cookbook / Tutorials
  • Build an AI Chatbot from Scratch with 123API

Build an AI Chatbot from Scratch with 123API

123api
更新 3 9 月, 2026

1 min read

This cookbook builds a minimal but production-shaped chatbot: a backend that proxies 123API’s chat endpoint with streaming, and a tiny frontend that renders tokens as they arrive. Total code is under 60 lines.

Architecture #

Browser → your backend → 123API chat endpoint → model. Keeping the key server-side is non-negotiable; never expose it to the browser.

Step 1 — Backend endpoint (Node.js) #

Step 2 — Frontend (streaming) #

Read the Server-Sent Events stream and append delta.content to the chat box. For the streaming format, see Core Capabilities.

Step 3 — Add tools with function calling #

Let the model call your API (weather, search) via function calling. This is what turns a chatbot into an agent.

Production tips #

  • Cap timeouts and add retries — see rate limits and retries.
  • Route cheap chit-chat to smaller models using the cost guide.
  • New here? Begin with the quickstart guide.

FAQ

Do I need a framework? No — the snippet above is plain Node.js. How do I keep my key safe? Call 123API from your backend only.

Suggested internal links (positions)

  1. “proxies 123API’s chat endpoint” → 123API chat endpoint (anchor: “123API chat endpoint”).
  2. “For the streaming format, see [Core Capabilities]” → Core Capabilities (anchor: “Core Capabilities”).
  3. “via [function calling]” → function calling (anchor: “function calling”).
  4. “see [rate limits and retries]” → rate limits and retries (anchor: “rate limits and retries”).
  5. “[cost guide]” → cost guide (anchor: “cost guide”).
  6. “[quickstart guide]” → quickstart guide (anchor: “quickstart guide”).
Build an AI Chatbot from Scratch with 123APIBuild an AI Chatbot from Scratch with 123API

发表回复 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

内容目录
  • Architecture
  • Step 1 — Backend endpoint (Node.js)
  • Step 2 — Frontend (streaming)
  • Step 3 — Add tools with function calling
  • Production tips

分享这篇文章 :

  • Facebook
  • X
  • LinkedIn
  • Pinterest

Was it helpful ?

  • Happy
  • 常规
  • Sad

Copyright © 2026 123API | Powered by 123API