@framers/agentos-ext-image-generation

中文文档
2.1.3发布于 2026/11/02Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 2.2万

Image generation extension for AgentOS — OpenAI, OpenRouter, Stability AI, and Replicate

原始使用文档
文档目录8 节
  1. Installation
  2. Usage
  3. Configuration
  4. Tools
  5. generate_image
  6. Notes
  7. Releases
  8. License

Image generation

This pack gives an agent a text-to-image tool through the AgentOS SDK, using OpenAI, OpenRouter, Stability AI or Replicate.

Installation

npm install @framers/agentos-ext-image-generation

Peer dependency: @framers/agentos with range >=0.10.40.

Usage

import { AgentOS } from '@framers/agentos';

const agentos = await AgentOS.create({
  extensionManifest: {
    packs: [
      {
        package: '@framers/agentos-ext-image-generation',
        options: {
          openaiApiKey: process.env.OPENAI_API_KEY,
          openrouterApiKey: process.env.OPENROUTER_API_KEY,
          stabilityApiKey: process.env.STABILITY_API_KEY,
          replicateApiToken: process.env.REPLICATE_API_TOKEN,
          imageDir: process.env.AGENTOS_IMAGE_DIR,
        },
      },
    ],
  },
});

Configuration

OptionSecret idEnvironment variableRequiredDefault
openaiApiKeyopenai.apiKeyOPENAI_API_KEYYes for selected OpenAI providerNone
openrouterApiKeyopenrouter.apiKeyOPENROUTER_API_KEYYes for selected OpenRouter providerNone
stabilityApiKeystability.apiKeySTABILITY_API_KEYYes for selected Stability providerNone
replicateApiTokenreplicate.apiTokenREPLICATE_API_TOKENYes for selected Replicate providerNone
defaultProviderNoneNoneNoFirst configured provider: openai, openrouter, stability, replicate; otherwise openai
defaultModelNoneNoneNogpt-image-2.5-flare for OpenAI; google/gemini-2.5-flash-image for OpenRouter; stable-image-core for Stability; black-forest-labs/flux-schnell for Replicate
defaultSizeNoneNoneNo1024x1024
defaultQualityNoneNoneNomedium for OpenAI GPT Image models; otherwise unset
imageDirNoneAGENTOS_IMAGE_DIRNoPOSIX: os.tmpdir()/agentos-images-${process.getuid()}; Windows: os.homedir()/AppData/Local/Temp/agentos-images
saveImageNoneNoneNoSave image data locally and return a file: URL
priorityNoneNoneNo50

Keys resolve from the option, then getSecret, then the environment variable. The manifest marks each provider secret optional, but generation requires the selected provider's key. A tool call's provider overrides defaultProvider; its model, size and quality override their pack defaults.

Tools

ToolWhat it does
generate_imageGenerates an image from a text prompt using the configured providers and returns its URL.

generate_image

ParameterTypeRequiredDescription
promptstringYesDetailed text description of the image to generate. Be specific about style, subject, composition, lighting, and mood.
sizestringNoImage dimensions: 1024x1024 (square, default), 1536x1024 or 1792x1024 (landscape), 1024x1536 or 1024x1792 (portrait).
aspectRatiostringNoOptional aspect ratio hint for providers that support it.
qualitystringNoImage quality: low, medium (default), high, or auto. standard and hd are read as medium and high. Higher quality costs more.
stylestringNoOptional style: vivid for hyper-real and dramatic, natural for more realistic.
providerstringNoWhich AI provider to use: openai, openrouter, stability or replicate. If omitted, the extension uses its configured default provider.
modelstringNoOptional: the provider's own model id.
seednumberNoOptional seed for providers that support reproducible image generation.
negativePromptstringNoOptional negative prompt for providers that support excluding specific traits or artifacts.

Notes

The package requires Node.js >=22. Generation calls can incur image charges. Missing credentials produce a failed tool result naming the selected provider's environment variable and key page. Empty prompts, invalid schema values, provider errors and storage failures also return failed results.

For OpenAI GPT Image models, the service maps standard quality to medium and hd to high. It adds the selected style as text in the prompt instead of sending a style parameter. Other model routes receive quality without this conversion.

The result uses the first image returned by the provider. Provider HTTP(S) URLs pass through unchanged. Image data is saved as PNG, JPEG or WebP and returned as a URL rather than base64. The tool ignores fields outside its schema, including n and providerOptions.

The default saver checks storage before calling a provider. On POSIX, the images directory belongs to the service user and forbids writes by other users. Its parents belong to that user or root and forbid other users' writes unless sticky. Saved images are scoped by context.userContext.userId, or stored under shared when absent. The pack does not delete saved images.

A custom saveImage receives bytes, mimeType, tool and context, and must return an HTTP(S) URL that passes the saver's length check. A file: URL refers to the machine running the tool; hosts with remote clients supply saveImage.

Releases

New versions are published from framerslab/agentos-extensions by GitHub Actions through npm trusted publishing, with a provenance statement.

License

Apache-2.0

版本与发布记录

@framers/agentos-ext-image-generation 共发布 10 个版本,首次发布于 2026/03/16;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.3latest2026/11/0214 天前
2.1.22026/11/0114 天前
2.1.12026/11/0115 天前
2.1.02026/10/121 个月前
2.0.12026/10/121 个月前
2.0.02026/10/111 个月前

关于 @framers/agentos-ext-image-generation 的常见问题

@framers/agentos-ext-image-generation 是什么?

Image generation extension for AgentOS — OpenAI, OpenRouter, Stability AI, and Replicate

如何安装 @framers/agentos-ext-image-generation?

在项目目录运行 npm install @framers/agentos-ext-image-generation,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.10.40)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-image-generation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@framers/agentos-ext-image-generation 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@framers/agentos-ext-image-generation 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@framers/agentos-ext-image-generation 可以商用吗?

@framers/agentos-ext-image-generation 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@framers/agentos-ext-image-generation 的下载量有多少?

根据 npm 官方下载统计,@framers/agentos-ext-image-generation 在 2026/10/16 – 2026/11/14 这 30 天内被下载 21,570 次,日均约 719 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@framers/agentos-ext-image-generation 还在维护吗?

最新版本 2.1.3 发布于 2026/11/02(14 天前);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/03/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。