New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixai-art/client

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixai-art/client

### Installation

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
205
increased by318.37%
Maintainers
0
Weekly downloads
 
Created
Source

PixAI Client

Installation

Our package name is @pixai-art/client and you can use any of your preferred package managers to install it.

@pixai-art/client

Usage

Following is a simple example of how you can use the client to generate an image.

For more examples, please refer to the example directory.

For more information on the API, please refer to the documentation.

[!NOTE] By design, this library can be used in both Node.js and browser environments. However, since the Node.js environment does not come with a WebSocket implementation, you'll need to install the ws or any other similar libraries additionally if you need to use WebSocket to listen for changes in real-time tasks.

import assert from 'node:assert'
import fs from 'node:fs/promises'
import { createInterface } from 'node:readline/promises'
import PixAIClient from '@pixai-art/client'

const rl = createInterface({
  input: process.stdin,
  output: process.stdout,
})

const client = new PixAIClient({
  apiKey: 'YOUR_API_KEY',
  webSocketImpl: require('ws'),
})

const main = async () => {
  const prompts = await rl.question(
    'What do you want to generate an image of? ',
  )
  const task = await client.generateImage(
    {
      prompts,
      modelId: '1648918127446573124',
      width: 512,
      height: 512,
    },
    {
      onUpdate: task => {
        console.log(new Date(), 'Task update:', task)
      },
    },
  )
  console.log('Task completed: ', task)

  const media = await client.getMediaFromTask(task)

  assert(media && !Array.isArray(media))

  console.log('downloading generated image...')
  const buffer = await client.downloadMedia(media)

  await fs.writeFile('output.png', Buffer.from(buffer))

  console.log('done! check image named output.png')

  process.exit(0)
}

main()

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc