aliyun-use

Aliyun Bailian AI tools for Node.js - chat, translation. Use when you need LLM capabilities with Qwen or other Aliyun models.

Aliyun Use - Node.js AI Tools

Aliyun Bailian 百炼 AI 工具集,提供对话、翻译等功能。Node.js 实现。

统一接口(与其他 provider 接口一致)

import { chat, translate, understandImage, webSearch } from 'aliyun-use/scripts/index.js';

// 对话
await chat('你好');                              // 简单对话
await chat('写代码', { model: 'qwen3.5-plus' });  // 指定模型
await chat('继续', { history: [{role:'user',content:'你好'}] }); // 带历史

// 翻译
await translate('hello', { to: 'Chinese' });
await translate('你好', { to: 'English', from: 'zh' });

// 搜索(基于模型知识库)
await webSearch('今日新闻');

返回格式

// 成功
{ success: true, result: { content: '...' } }

// 失败
{ success: false, error: 'error message' }

CLI 用法

# 对话
node scripts/index.js chat "你好"

# 翻译
node scripts/index.js translate "hello" --to Chinese

# 搜索
node scripts/index.js search "news"

环境变量

变量默认值说明
ALIYUN_BAILIAN_API_KEY-必填,API Key
ALIYUN_BAILIAN_API_HOSThttps://coding.dashscope.aliyuncs.com/apps/anthropicAPI 端点
ALIYUN_MODELqwen3.5-plus对话模型

获取 API Key: https://bailian.console.aliyun.com/

函数签名

chat(message, opts)

参数类型默认值说明
messagestring-用户消息
opts.systemstringnull系统提示
opts.modelstringqwen3.5-plus模型名
opts.temperaturenumber0.7温度 0-1
opts.max_tokensnumber2048最大 token
opts.streambooleanfalse流式输出
opts.historyarraynull历史记录

translate(text, opts)

参数类型默认值说明
textstring-待翻译文本
opts.tostringEnglish目标语言
opts.fromstringauto源语言
opts.modelstringqwen3.5-plus模型名

understandImage(prompt, imagePath, opts)

注意: Aliyun 暂不支持此接口,建议使用 kimi-useminimax-use

webSearch(query, opts)

参数类型默认值说明
querystring-搜索查询
opts.modelstringqwen3.5-plus模型名

可用模型

  • qwen3.5-plus - 旗舰模型
  • qwen3-max - 最大模型
  • qwen3-coder-next - 编码模型
  • qwen3-coder-plus - 编码增强

安装依赖

cd ~/workspace/skills/aliyun-use
npm install