mj-imagine: Calling Midjourney Text-to-Image in an Agent

Preface

Generating images directly in a conversation typically involves switching to the Midjourney web page or Discord, copying the prompt over, and waiting for the result. If you want Agents with Skills capabilities like Cursor or Claude Code to complete “write prompt → call model → get back image URL” within the task flow, you need a reusable skill wrapper instead of hand-writing HTTP requests every time.

Below is an introduction to mj-imagine on SkillHub (coordinate @user_f95f21b8/dlazy-mj-imagine, current version 1.0.9). It connects the Midjourney inference capability hosted by dLazy to the Agent side, executing dlazy mj.imagine via @dlazy/cli, and supports pure text-to-image generation.

What Is This

mj-imagine is a community-sourced (community) Skill, categorized under design-media, published by user_f95f21b8. The official description is:

Generate artistic images using Midjourney (MJ) model. Supports text-to-image.

The skill package is identified as dlazy-mj.imagine, essentially a thin wrapper over the dLazy API: prompts and parameters are sent to api.dlazy.com, and the generated result URL is returned from files.dlazy.com. The CLI is maintained by dlazyai, with source code available at github.com/dlazyai/cli.

SkillHub page statistics (based on the store display): rating 100000, approximately 1200 downloads; the tag includes requires_api_key=true, so you need to configure a dLazy API Key before use.

Core Functionality

Based on the skill package’s SKILL.md and the SkillHub description, the verified capabilities are as follows:

  1. Text-to-Image: Generate artistic images through the Midjourney model (modelId: mj_imagine).
  2. Aspect Ratio and Model: --aspect_ratio supports auto, 1:1, 4:3, 16:9, etc.; --botType can be MID_JOURNEY or NIJI_JOURNEY.
  3. Output Format: --output defaults to a four-panel grid (grid), and you can also specify U1–U4 for single upscaled results.
  4. Debugging and Async: --dry-run lets you view the request payload and cost estimate; --no-wait returns a generateId, and you can poll with dlazy status <generateId> --wait.
  5. Trigger Words: The skill description lists midjourney, mj, and text-to-image related phrases, facilitating Agent routing to this Skill.

The dependency environment requires npm / npx; the CLI version is pinned to @dlazy/cli@1.0.9.

Installation and Activation

1. Install the SkillHub CLI (if not already installed)

command -v skillhub && skillhub --version

If not installed, you can follow the SkillHub documentation to perform a complete installation:

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

See skillhub.cn/install/skillhub.md for instructions.

2. Install mj-imagine into the current Agent’s skills directory

When installing, you must use --dir to point to the skills path actually recognized by the Agent; otherwise, it defaults to ./skills/ and may not be loaded. Common path examples:

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ in the project

Search and installation commands (consistent with the skillhub search output):

skillhub search mj-imagine

skillhub install dlazy-mj-imagine --namespace user_f95f21b8 --dir ~/.cursor/skills/

You can also let the Agent install it according to the official prompt:

Please install `@user_f95f21b8/dlazy-mj-imagine` according to https://skillhub.cn/install/skillhub.md.

Restart or refresh the Agent after installation to enable the Skills.

3. Install and configure the dLazy CLI

Global installation (consistent with the declaration in the skill metadata):

npm install -g @dlazy/cli@1.0.9

Or call it on-demand without installing a global package:

npx @dlazy/cli@1.0.9 <command>

Configure the API Key (written to ~/.dlazy/config.json, and %USERPROFILE%\.dlazy\config.json on Windows):

dlazy auth set YOUR_API_KEY

You can also pass it via an environment variable for a single run:

export DLAZY_API_KEY=YOUR_API_KEY

The Key can be obtained at dlazy.com/dashboard/organization/api-key; you need to register or log in at dlazy.com first.

Typical Usage

On the Agent side, you should execute dlazy mj.imagine according to the skill description. First, view the help:

dlazy mj.imagine -h

Basic text-to-image (--prompt is required):

dlazy mj.imagine --prompt 'a watercolor cityscape at dusk, soft lighting'

Specify aspect ratio and Niji style:

dlazy mj.imagine \
  --prompt 'anime character portrait, detailed eyes' \
  --aspect_ratio 9:16 \
  --botType NIJI_JOURNEY \
  --output grid

Image-with-prompt examples from the skill documentation (local or remote reference images):

dlazy mj.imagine --prompt '提示词内容' --image '/path/to/image.png'

dlazy mj.imagine --prompt '提示词内容' --image 'https://files.dlazy.com/image.png'

On success, the CLI returns JSON, where outputs contains a url pointing to a PNG on files.dlazy.com. If using --no-wait, you need to then execute dlazy status <generateId> --wait to wait for completion.

In a conversation, you can describe the image in natural language and specify the aspect ratio or MID_JOURNEY / NIJI_JOURNEY, and the Agent will assemble the above parameters and execute the command.

Applicable Scenarios and Notes

Who it’s for

  • Designers, operators, or front-end developers already using Skills capabilities like Cursor and Claude Code, who want to generate Midjourney-style illustrations within the same context.
  • Teams willing to use the dLazy-hosted API (pay-as-you-go, requires a self-provided Key) rather than self-hosting an MJ proxy.

Limitations and Notes

  1. Requires internet connection and API Key: If not configured or the Key is invalid, it returns unauthorized; when the balance is insufficient, the code will be insufficient_balance, and you need to top up at dlazy.com credit settings.
  2. Data export path: Prompts and uploaded local files will be transferred to dLazy’s API and media storage; please check against your organization’s compliance requirements before use.
  3. CLI version lock: The skill pins @dlazy/cli@1.0.9; before upgrading the CLI, it is recommended to check whether the skill version on SkillHub has been updated accordingly.
  4. Security and content policy: The backend may reject violation prompts (e.g., returning safety policy-related errors); you need to control this on the prompt side.

Conclusion

mj-imagine condenses Midjourney text-to-image into the dlazy mj.imagine command that Agents can call: SkillHub handles skill package distribution, and the dLazy CLI handles authentication and API calls. If your pain point is “conveniently generating images during coding or writing conversations,” you can follow the above steps to complete the Skill and CLI installation, then configure the API Key to try it out.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye