# Node Kimi K3 streaming chat

A Kimi K3 chat page streams long answers, renders readable Markdown, and carries the complete thread into every follow up. Tokay runs the Express app as one Web Service and keeps your Moonshot API key encrypted.

Use this example when you want to see how a reasoning model's conversation state and usage data move through a small hosted chat. Your Moonshot account needs Kimi K3 access before the Service can answer.

## Facts

- Runtime: Node.js
- Framework: Express
- Service types: Web Service
- Resources: None
- Required secrets: `MOONSHOT_API_KEY`

## What it does

The opening prompt asks Kimi to plan a trip, but you can replace it with any question.

The answer arrives piece by piece and supports lists, tables, links, and code. Ask another question and Kimi receives the earlier messages, including the reasoning payload its API requires you to return.

Below each response, the page shows elapsed time and token counts. **New chat** clears the visible conversation and begins a fresh session.

## Deploy it

Bring this folder to Tokay any way you like. Paste or upload it in the dashboard, push it with git, or hand it to your AI agent along with [our agent instructions](https://app.tokay.io/llms.txt). Tokay figures out the rest.

Working in Claude, ChatGPT, VS Code, or another MCP client? Connect the [Tokay MCP server](https://tokay.io/docs/platform-mcp) and ask your agent to deploy this example. It signs in through your browser, so there is no token to paste.

New to Tokay? The [getting started guide](https://tokay.io/getting-started) walks you through your first deploy.

## Add your Kimi API key

Create a key in the [Kimi API Platform](https://platform.kimi.ai/console/api-keys). On the Service page, open **Environment** and find `MOONSHOT_API_KEY` under **From your code**. Choose **Set shared value**, keep the value secret, and save your Kimi key.

Once the Kimi key is **Good to go**, finish the deployment tracker and use **Go Live** if offered. Open the chat from the live URL at the top of the Service.

## Try it

1. Send the trip question and wait for the streamed answer to finish.
2. Ask Kimi to revise one detail from that answer without restating the plan.
3. Press **New chat** and ask the same follow up. The missing context proves you started a separate thread.

## How it works

You keep context in the page because the Kimi API is stateless. The browser sends the thread to the server on every turn, and the server forwards visible answer deltas over SSE.

Kimi's reasoning deltas stay out of the interface, but the server retains their complete payload and returns it unchanged on the next request. The demo selects low reasoning effort and lets Moonshot AI enforce the model's context limit.

Marked and DOMPurify turn model Markdown into safe page content. Your API key and conversation are never written to application storage.

## Secrets

| Name | Visibility | Required | Purpose |
| --- | --- | --- | --- |
| `MOONSHOT_API_KEY` | Secret | Yes | Authenticates requests to Moonshot AI. |

## Grow from here

Try the [AI research queue](/examples/python-fastapi-postgres-ai-research-queue) when Kimi should work from saved evidence in a recoverable job.

## Source files

- [package.json](https://tokay.io/examples/src/node-kimi-k3-streaming-tool-chat/package.json)
- [src/server.ts](https://tokay.io/examples/src/node-kimi-k3-streaming-tool-chat/src/server.ts)
- [tsconfig.json](https://tokay.io/examples/src/node-kimi-k3-streaming-tool-chat/tsconfig.json)

## Download and source

- [Download the complete project](https://tokay.io/examples/downloads/node-kimi-k3-streaming-tool-chat.zip)
- Last updated: 2026-07-31
- Example revision: `52c7b7f`
- [View this revision on GitHub](https://github.com/tokayio/tokay-examples/tree/52c7b7ffd52e157375b08f1f11ff4fbe6c498642/node-kimi-k3-streaming-tool-chat)
