Skip to main content
Home

PixAI API client for TypeScript

This package works with Cloudflare Workers, Node.js, Deno, BunIt is unknown whether this package works with Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
70%
Published
2 months ago (0.1.0)

PixAI TypeScript API

A TypeScript library for interacting with the PixAI API, allowing you to generate images, manage tasks, and claim quotas.

Installation

Clone the repository and install dependencies:

git clone https://github.com/samirxpikachuio/pixai-art-wapper.git
cd pixai-art-wapper
npm install

Build

npm run build

Usage

Basic Example

import { PixAI, PixError } from '@samirxpikachu/pixai';

async function main() {
  try {
    const pixAIClient = new PixAI();
    
    await pixAIClient.init('your_email@example.com', 'your_password');
    
    const quota = await pixAIClient.getQuota();
    console.log(`Current quota: ${quota}`);
    
    
    const taskId = await pixAIClient.generateImage(
      "a cute cat, high quality, detailed", 
      768, 
      1024 
    );
    
    console.log(`Task created with ID: ${taskId}`);
    
    await new Promise(resolve => setTimeout(resolve, 30000));
    const mediaIds = await pixAIClient.getTaskById(taskId);
    
    if (mediaIds && mediaIds.length > 0) {
      const mediaId = mediaIds[0];
      if (mediaId) {
        const imageUrl = await pixAIClient.getMedia(mediaId);
        console.log(`Image URL: ${imageUrl}`);
      }
    }
    
  } catch (error) {
    if (error instanceof PixError) {
      console.error("PixAI Error:", error.message, error.details || "");
    } else {
      console.error("Unexpected error:", error);
    }
  }
}

main();

Using with Proxy

import { PixAI } from '@samirxpikachu/pixai';


const proxyOptions = {
  host: 'proxy.example.com',
  port: 8080,
  auth: {
    username: 'user',
    password: 'pass'
  }
};

const pixAIClient = new PixAI(proxyOptions);

Using an Existing Token

import { PixAI } from '@samirxpikachu/pixai';

const pixAIClient = new PixAI();
await pixAIClient.init(undefined, undefined, true, 'your_existing_token');

API Reference

PixAI Class

Main class for interacting with the PixAI API.

Constructor

constructor(proxy?: string | ProxyOptions | null)

Creates a new PixAI client with optional proxy configuration.

Methods

  • init(email?: string, password?: string, login: boolean = true, existingToken: string | null = null): Promise<void> Initialize the client with authentication.

  • getQuota(): Promise<number> Get the current user's quota.

  • getMedia(mediaId: string): Promise<string> Get a media URL by ID.

  • claimDailyQuota(): Promise<GraphQLResponse> Claim the daily quota.

  • claimQuestionnaireQuota(wait: number = 3): Promise<GraphQLResponse> Claim the questionnaire quota.

  • getTaskDetails(taskId: string): Promise<GraphQLResponse> Get details for a specific task.

  • getAllTasks(): Promise<(string | null)[][]> Get all tasks for the current user.

  • getLatestTask(): Promise<(string | null)[] | null> Get the latest task for the current user.

  • getTaskById(queryId: string): Promise<(string | null)[] | null> Get a specific task by ID.

  • generateImage(prompts: string, width: number = 768, height: number = 1280, x4: boolean = false): Promise<string> Generate an image with the specified parameters.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";
or

Import directly with a jsr specifier

import * as pixai from "jsr:@samirxpikachu/pixai";

Add Package

pnpm i jsr:@samirxpikachu/pixai
or (using pnpm 10.8 or older)
pnpm dlx jsr add @samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";

Add Package

yarn add jsr:@samirxpikachu/pixai
or (using Yarn 4.8 or older)
yarn dlx jsr add @samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";

Add Package

vlt install jsr:@samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";

Add Package

npx jsr add @samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";

Add Package

bunx jsr add @samirxpikachu/pixai

Import symbol

import * as pixai from "@samirxpikachu/pixai";