npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xuejike/llm-text2image

v1.0.0

Published

基于大语言模型的文生图命令行工具

Readme

@xuejike/llm-text2image

基于大语言模型的文生图命令行工具,支持阿里云百炼(DashScope)和腾讯云混元(Hunyuan)两个平台。

功能特性

  • 支持多 Provider:阿里云百炼(通义万相)、腾讯云混元
  • 四级配置优先级:命令行参数 > 环境变量 > 配置文件 > 默认值
  • 支持 PNG / JPG / WEBP 输出格式
  • 支持反向提示词、自定义尺寸、批量生成
  • 统一的错误处理和中文提示

安装

npm install -g @xuejike/llm-text2image

或本地开发安装:

npm install
npm run build
npm link

快速开始

1. 配置 API Key

阿里云百炼(DashScope):

# 方式一:命令行配置(持久化到 ~/.text2img/config.yaml)
text2img config set dashscope.api-key <your-api-key>

# 方式二:环境变量
export TEXT2IMG_DASHSCOPE_API_KEY=<your-api-key>

腾讯云混元(Hunyuan):

# 方式一:命令行配置
text2img config set hunyuan.secret-id <your-secret-id>
text2img config set hunyuan.secret-key <your-secret-key>

# 方式二:环境变量
export TEXT2IMG_HUNYUAN_SECRET_ID=<your-secret-id>
export TEXT2IMG_HUNYUAN_SECRET_KEY=<your-secret-key>

2. 生成图片

# 使用默认 Provider(百炼)生成图片
text2img generate "一只可爱的猫咪在花园里玩耍"

# 指定 Provider
text2img generate "赛博朋克风格的城市夜景" -p hunyuan

# 指定模型和尺寸
text2img generate "山水画" -m wanx-v2 -s 1280x720

# 使用反向提示词
text2img generate "高清风景照" --negative-prompt "模糊,低质量"

# 指定输出目录和格式
text2img generate "星空" -o ./images -f jpg

# 批量生成
text2img generate "抽象艺术" -n 3

# 临时使用其他 API Key(优先级最高)
text2img generate "测试" -k sk-your-temp-key

命令参考

generate(别名:gen)

根据提示词生成图片。

text2img generate <prompt> [选项]

| 选项 | 说明 | 默认值 | |------|------|--------| | -p, --provider <name> | 指定 Provider(dashscope / hunyuan) | dashscope | | -m, --model <model> | 指定模型 | Provider 默认模型 | | -s, --size <WxH> | 图片尺寸,如 1024x1024 | 1024x1024 | | -n, --count <number> | 生成数量 | 1 | | --negative-prompt <text> | 反向提示词 | - | | -o, --output <dir> | 输出目录 | ./output | | -f, --format <fmt> | 输出格式(png/jpg/webp) | png | | -k, --api-key <key> | API Key(优先级最高) | - |

providers

列出所有可用的 Provider。

text2img providers

config set

设置配置项,持久化到 ~/.text2img/config.yaml

text2img config set <key> <value>

支持的配置项:

| Key | 说明 | |-----|------| | dashscope.api-key | 百炼 API Key | | hunyuan.secret-id | 混元 SecretId | | hunyuan.secret-key | 混元 SecretKey | | default-provider | 默认 Provider |

支持的模型

阿里云百炼(DashScope)

| 模型 ID | 名称 | 支持尺寸 | |---------|------|---------| | wanx-v1 | 通义万相-文生图 V1 | 512x512, 768x768, 1024x1024 | | wanx-v2 | 通义万相-文生图 V2 | 512x512, 768x768, 1024x1024, 1280x720 |

腾讯云混元(Hunyuan)

| 模型 ID | 名称 | 支持尺寸 | |---------|------|---------| | hunyuan-image | 混元文生图 | 768x768, 1024x1024, 1280x720, 720x1280, 1920x1080, 1080x1920 |

配置文件

配置文件位于 ~/.text2img/config.yaml,示例:

defaultProvider: dashscope
outputDir: ./output
defaultSize:
  width: 1024
  height: 1024
defaultFormat: png
providers:
  dashscope:
    apiKey: sk-your-dashscope-key
  hunyuan:
    extra:
      secretId: AKIDxxxxxxxx
      secretKey: xxxxxxxx

开发

# 安装依赖
npm install

# 编译
npm run build

# 运行测试
npm test

# 本地链接(全局可用)
npm link

License

MIT