npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nexusapi-sdk

v0.2.0

Published

Node.js / TypeScript SDK for NexusAPI — video and image generation through a single API (Veo, Kling, Seedance, Nano-Banana). OpenAI-compatible. Auto-retries, auto idempotency.

Downloads

313

Readme

NexusAPI Node.js SDK

Официальный Node.js / TypeScript SDK для NexusAPI — единый API для генерации видео и изображений через Veo, Kling, Seedance, Nano-Banana и др.

Установка

npm install nexusapi-sdk

Требует Node.js 18+ (используем встроенный fetch). Без внешних зависимостей.

Пакет на npm называется nexusapi-sdk (имя nexusapi зарезервировано другим проектом). Mirror Python SDK: pip install nexusapi-sdk.

Quickstart

import { NexusClient } from "nexusapi-sdk";

const client = new NexusClient({
  apiKey: process.env.NEXUS_KEY!,  // создать в panel.nexusapi.dev
});

// Изображение (sync — SDK сам опрашивает статус)
const img = await client.images.generate({
  model: "nano-banana",
  prompt: "Минималистичный логотип кофейни",
  aspect_ratio: "1:1",
});
console.log(img.imageUrl);
// → https://nexusapi-s3.../result.png

// Видео (async — получаем Task, ждём отдельно)
const task = await client.videos.create({
  model: "veo-3-fast",
  prompt: "Кот играет на пианино",
  duration: 8,
  aspect_ratio: "16:9",
});
console.log(`Task ${task.id}, status=${task.status}`);

// Polling до завершения (до 10 минут)
await task.wait();
console.log(task.videoUrl);

Возможности

  • Auto-retries — на 5xx, 429 и сетевые ошибки. По умолчанию до 3 попыток с экспоненциальным backoff (0.5s, 1s, 2s + jitter). Учитывает Retry-After header. Настраивается через maxRetries: N в опциях клиента.
  • Auto Idempotency-Key — для каждого POST автоматически генерируется UUID v4 если не передан свой. Retry безопасен — двойного списания не будет.
  • Все native-параметрыwebhook_url, negative_prompt, image_url, cfg_scale, video_urls для seedance, source_video_url для veo-extend передаются прямо в create() / generate() как обычные поля объекта.
  • Auto-polling для image-моделей (sync UX). Для видео — task.wait().
  • Типизированные ошибкиNexusError (база), BillingError, RateLimitError, ValidationError, NotFoundError, AuthenticationError, PermissionError, TaskTimeoutError (client-side wait), TaskFailedError (провайдер не справился), NetworkError (retries исчерпаны).
  • TypeScript-first — полные типы для всех методов.
  • Zero dependencies — только native fetch Node 18+.

Примеры

Webhook вместо polling

const task = await client.videos.create({
  model: "veo-3-fast",
  prompt: "...",
  duration: 8,
  webhook_url: "https://your-app.com/nexus-callback",
});
// Не вызываем .wait() — NexusAPI POST'нет на webhook_url когда видео готово
return task.id;  // сохраняем в БД, ждём колбэка

Image-to-video (Kling motion)

const video = await client.videos.create({
  model: "kling-v2.6-motion-1080p",
  prompt: "Камера медленно отъезжает, раскрывая пейзаж",
  duration: 8,
  image_url: "https://your-bucket.s3.../start-frame.jpg",
});
await video.wait();
console.log(video.videoUrl);

Image edit (nano-banana)

const edited = await client.images.generate({
  model: "nano-banana-pro",
  prompt: "Сделай небо более драматичным",
  image_url: "https://your-bucket.s3.../photo.jpg",
});
console.log(edited.imageUrl);

Извлечение результата

const task = await client.videos.create({ ... });
await task.wait();
console.log(task.videoUrl);       // для видео-моделей
console.log(task.imageUrl);       // для image-моделей (берёт первое из imageUrls)
console.log(task.imageUrls);      // для image-моделей с несколькими изображениями
console.log(task.result);         // сырой объект с провайдер-специфичным контентом

Обработка ошибок

import {
  NexusClient,
  BillingError,
  RateLimitError,
  ValidationError,
} from "nexusapi-sdk";

try {
  const task = await client.videos.create({ ... });
  await task.wait();
} catch (e) {
  if (e instanceof BillingError) {
    console.error("Недостаточно средств");
  } else if (e instanceof RateLimitError) {
    console.error("Превышен rate-limit");
  } else if (e instanceof ValidationError) {
    console.error("Невалидные параметры:", e.message);
  } else {
    throw e;
  }
}

Каталог моделей

const models = await client.models.list();
for (const m of models) {
  console.log(`${m.id}: ${m.priceRub}₽ за ${m.unit}`);
}

Документация

Лицензия

MIT