Polyweave

@polyweave/moonshot (1.0.3)

Published 2026-07-11 00:13:19 +00:00 by Dvorak

Installation

@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/
npm install @polyweave/moonshot@1.0.3
"@polyweave/moonshot": "1.0.3"

About this package

Moonshot (Kimi)

Moonshot AI / Kimi adapter for Polyweave. Thinking mode, web search, 256K context.

Published as @polyweave/moonshot.

Synopsis

import { createMoonshotAdapter } from '@polyweave/moonshot';
import { createTextFrame, createParamFrame, createFrameSink } from '@polyweave/core';

var adapter = createMoonshotAdapter({ apiKey: process.env.MOONSHOT_API_KEY, model: 'kimi-k2.6' });

adapter.source.pipe(createFrameSink(function(frame) {
  if (frame.type === 'TEXT') console.log(frame.content.text);
}));

adapter.sink.write(createTextFrame('Solve this complex math problem'));

Install

npm install @polyweave/moonshot

Description

Moonshot AI adapter for the Kimi model series. OpenAI-compatible chat completions with streaming SSE, tool/function calling, vision input, and thinking/reasoning mode.

Models: kimi-k2.6, kimi-k2.5, kimi-k2-thinking, moonshot-v1-8k, moonshot-v1-32k, moonshot-v1-128k.

API

createMoonshotAdapter(config)

Parameter Type Default Description
config.apiKey string process.env.MOONSHOT_API_KEY API key
config.baseURL string https://api.moonshot.cn/v1 Base URL
config.model string kimi-k2.6 Default model
config.budget number 0 Budget cap
config.name string null Node name for PARAM targeting
config.timeout number 120000 Request timeout in ms

Returns an IFrameDuplex with source and sink.

Frame Protocol

Inbound Outbound
TEXT, IMAGE TEXT, TOOL_CALL, RECEIPT, ERROR, END
PARAM
COST_CHECK COST

PARAM Keys

model, max_tokens, temperature, top_p, stream, thinking, system, tools, tool_choice, response_format, budget, apiKey

Tests

npm test

Covers adapter construction and PARAM accumulation.

Requirements

Node.js 18 or later. ESM only.

Caveats

Thinking mode produces reasoning_content before content in SSE streams. The adapter currently handles standard content streaming; reasoning_content is available in metadata. Kimi k2 models use fixed temperature=1.0 for thinking and 0.6 for non-thinking modes.

See Also

License

MIT

Dependencies

Development Dependencies

ID Version
@rigor/core *

Peer Dependencies

ID Version
@polyweave/core *
@polyweave/costs *

Keywords

polyweave moonshot kimi llm chinese thinking adapter
Details
npm
2026-07-11 00:13:19 +00:00
4
John Dvorak
SEE LICENSE IN LICENSE
latest
5.8 KiB
Assets (1)
Versions (4) View all
1.0.3 2026-07-11
1.0.2 2026-07-10
1.0.1 2026-07-10
1.0.0 2026-07-10