midjourney-sdk
TypeScript icon, indicating that this package has built-in type declarations

3.1.2 • Public • Published

MidJourney-SDK npm version

MidJourney in Discord API for Node.js.

Demo

Live demo

Support

  • Command
    • [x] /imagine
    • [x] /info
    • [x] /settings
    • [x] /fast
    • [x] /relax
  • Button Action
    • [x] upscale
    • [x] variation
    • [x] reroll
    • [x] zoomout
    • [x] vary(Region)
  • Remix Mode

Install

pnpm i midjourney-sdk

Usage

import { MidJourney } from 'midjourney-sdk'
const ins = new MidJourney({
  token: process.env.NEXT_PUBLIC_TOKEN,
  guild_id: process.env.NEXT_PUBLIC_GUILD_ID,
  channel_id: process.env.NEXT_PUBLIC_CHANNEL_ID,
  skipHeartbeat: true
})
;(async () => {
  await ins.init()
  // trigger image job
  const msg1 = await ins.api.imagine('apple --q 5', ({ url, progress }) => {
    console(url, progress)
  })
  // trigger button job
  const msg2 = await ins.api.action(
    'msgId',
    'customId',
    'msgFlags',
    ({ url, progress }) => {
      console(url, progress)
    }
  )
  // trigger remix job
  const msg3 = await ins.api.remixSubmit(
    'modalMsgId',
    'customId',
    'components',
    ({ url, progress }) => {
      console(url, progress)
    }
  )
  // trigger vary(region) job
  const msg4 = await ins.api.varyRegion(
    'customId',
    'prompt',
    'mask',
    ({ url, progress }) => {
      console(url, progress)
    }
  )
})()

Development

  • edit environment .env file
# playground/.env
NEXT_PUBLIC_TOKEN=
NEXT_PUBLIC_GUILD_ID=
NEXT_PUBLIC_CHANNEL_ID=
# discord api proxy url
NEXT_PUBLIC_API_BASE_URL=
# discord websocket proxy url
NEXT_PUBLIC_IMG_BASE_URL=
# discord websocket proxy url
NEXT_PUBLIC_WS_BASE_URL=
  • run play script
pnpm play
  • open http://localhost:3000

License

MIT License © 2023-PRESENT BaoBao

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.1.23latest

Version History

VersionDownloads (Last 7 Days)Published
3.1.23
3.1.10
3.1.00
3.0.30
3.0.20
3.0.10
3.0.00
2.3.00
2.2.50
2.2.40
2.2.30
2.2.20
2.2.10
2.2.00
2.1.40
2.1.30
2.1.20
2.1.10
2.1.00
2.0.20
2.0.10
2.0.00
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.41
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i midjourney-sdk

Weekly Downloads

3

Version

3.1.2

License

MIT

Unpacked Size

57 kB

Total Files

7

Last publish

Collaborators

  • lby20010429