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

@umituz/react-native-ai-pruna-provider

v1.0.48

Published

Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation

Downloads

3,756

Readme

@umituz/react-native-ai-pruna-provider

Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation.

Supported Models

  • p-image: Text-to-image generation ($0.005/run)
  • p-image-edit: Image-to-image editing ($0.010/run)
  • p-video: Image-to-video generation with draft mode support

Installation

npm install @umituz/react-native-ai-pruna-provider

Quick Start

import { initializePrunaProvider } from '@umituz/react-native-ai-pruna-provider';

// Initialize at app startup
initializePrunaProvider({
  apiKey: process.env.PRUNA_API_KEY,
  setAsActive: true,
});

Usage

Text-to-Image (p-image)

import { prunaProvider } from '@umituz/react-native-ai-pruna-provider';

const result = await prunaProvider.subscribe('p-image', {
  prompt: 'A sunset over the ocean',
  aspect_ratio: '16:9',
});
console.log(result.url);

Image Editing (p-image-edit)

const result = await prunaProvider.subscribe('p-image-edit', {
  images: ['data:image/jpeg;base64,...'],
  prompt: 'Make it look like a painting',
  aspect_ratio: '1:1',
});

Image-to-Video (p-video)

const result = await prunaProvider.subscribe('p-video', {
  image: 'data:image/jpeg;base64,...',
  prompt: 'The camera pans slowly from left to right',
  duration: 10,
  resolution: '1080p',
  fps: 24,
  draft: true, // Enable draft mode
});

Draft Mode (p-video)

Draft mode is a faster, more cost-effective way to generate videos for testing and iteration.

What is Draft Mode?

  • 50% cheaper than normal mode
  • 4x faster generation time
  • Lower quality output (suitable for previews)
  • Same resolution options (720p, 1080p)

Pricing

| Resolution | Normal Mode | Draft Mode | Savings | |------------|-------------|------------|---------| | 720p | $0.05/sec | $0.025/sec | 50% | | 1080p | $0.08/sec | $0.04/sec | 50% |

When to Use Draft Mode

Recommended for:

  • Testing prompts and concepts
  • Iterating on video generation
  • Previewing before final generation
  • Longer videos (8+ seconds)
  • High resolution (1080p)

Not recommended for:

  • Final production videos
  • Social media sharing
  • Client deliverables

Draft Mode Example

// Test with draft mode (fast & cheap)
const draftResult = await prunaProvider.subscribe('p-video', {
  image: base64Image,
  prompt: 'Person walking on beach',
  duration: 10,
  resolution: '1080p',
  draft: true, // Enable draft mode
});
// Cost: 10 × $0.04 = $0.40

// Generate final version with normal mode
const finalResult = await prunaProvider.subscribe('p-video', {
  image: base64Image,
  prompt: 'Person walking on beach',
  duration: 10,
  resolution: '1080p',
  draft: false, // Normal mode (default)
});
// Cost: 10 × $0.08 = $0.80

API Reference

PrunaProvider

Implements IAIProvider interface.

Methods

  • initialize(config: AIProviderConfig): void - Initialize provider with API key
  • isInitialized(): boolean - Check if provider is initialized
  • getCapabilities(): ProviderCapabilities - Get provider capabilities
  • subscribe<T>(model, input, options?): Promise<T> - Subscribe to generation result
  • run<T>(model, input, options?): Promise<T> - Run generation once
  • submitJob(model, input): Promise<JobSubmission> - Submit async job
  • getJobStatus(model, requestId): Promise<JobStatus> - Get job status
  • getJobResult<T>(model, requestId): Promise<T> - Get job result
  • reset(): void - Reset provider state
  • cancelCurrentRequest(): void - Cancel current request
  • hasRunningRequest(): boolean - Check if request is running
  • getSessionLogs(sessionId): LogEntry[] - Get session logs
  • endLogSession(sessionId): LogEntry[] - End log session

usePrunaGeneration Hook

React hook for Pruna AI generation operations.

import { usePrunaGeneration } from '@umituz/react-native-ai-pruna-provider';

const {
  data,
  error,
  isLoading,
  isRetryable,
  requestId,
  generate,
  retry,
  cancel,
  reset,
} = usePrunaGeneration<{
  url: string;
  generation_url: string;
}>({
  timeoutMs: 120000,
  onProgress: (status) => console.log(status),
  onError: (error) => console.error(error),
});

// Generate video
await generate('p-video', {
  image: base64Image,
  prompt: 'Camera pans from left to right',
  duration: 10,
  resolution: '1080p',
  draft: true,
});

Type Exports

// Core types
export type { PrunaModelId, PrunaResolution, PrunaAspectRatio };
export type { PrunaPredictionInput, PrunaPredictionResponse };
export type { PrunaConfig, PrunaErrorType, PrunaErrorInfo };

// Draft mode utilities
export {
  validateDraftModeParams,
  calculateDraftModeDiscount,
  getDraftModeDescription,
  recommendDraftMode,
  calculateDraftModeSavings,
  getPricingPerSecond,
  formatPriceUSD,
  compareDraftModePricing,
};

// Constants
export {
  P_VIDEO_PRICING,
  DRAFT_MODE_CONFIG,
  P_VIDEO_DEFAULTS,
  PRUNA_CAPABILITIES,
};

Error Handling

The provider provides typed error information:

try {
  await prunaProvider.subscribe('p-video', input);
} catch (error) {
  if (error.retryable) {
    // Retry the request
  } else {
    // Handle error
    console.error(error.message);
  }
}

Error Types

  • AUTHENTICATION - Invalid API key
  • RATE_LIMIT - Too many requests
  • NETWORK - Network error
  • TIMEOUT - Request timeout
  • VALIDATION - Invalid input parameters
  • QUOTA - Credit/quota exceeded
  • SERVER - Server error (5xx)
  • UNKNOWN - Unknown error

Initialization

Direct Initialization

import { initializePrunaProvider } from '@umituz/react-native-ai-pruna-provider';

export const configureAIServices = (): void => {
  initializePrunaProvider({
    apiKey: getPrunaApiKey(),
    setAsActive: true,
  });
};

Init Module Factory

import { createAiProviderInitModule } from '@umituz/react-native-ai-pruna-provider';

const prunaInitModule = createAiProviderInitModule({
  apiKey: getPrunaApiKey(),
  setAsActive: true,
});

// Register with app initialization
appRegistry.registerModule('pruna-ai', prunaInitModule);

Best Practices

  1. Use Draft Mode for Testing: Always test prompts with draft mode before generating final videos
  2. Handle Errors Gracefully: Check error.retryable before retrying requests
  3. Monitor Progress: Use onProgress callback to track generation status
  4. Clean Up Resources: Call reset() when done to clean up request store
  5. Set Timeouts: Use appropriate timeout values (120s for images, 300s for videos)

Example: Complete Workflow

import { prunaProvider, usePrunaGeneration } from '@umituz/react-native-ai-pruna-provider';

function VideoGenerator() {
  const { generate, data, isLoading, error } = usePrunaGeneration<{ url: string }>();

  const handleGenerate = async () => {
    // Step 1: Test with draft mode
    const draftResult = await generate('p-video', {
      image: base64Image,
      prompt: 'Person walking on beach',
      duration: 10,
      resolution: '1080p',
      draft: true,
    });

    if (draftResult) {
      console.log('Draft preview:', draftResult.url);
    }

    // Step 2: Generate final version
    const finalResult = await generate('p-video', {
      image: base64Image,
      prompt: 'Person walking on beach',
      duration: 10,
      resolution: '1080p',
      draft: false,
    });

    console.log('Final video:', finalResult.url);
  };

  return (
    <View>
      <Button onPress={handleGenerate} disabled={isLoading}>
        Generate Video
      </Button>
      {error && <Text>Error: {error.message}</Text>}
      {data && <Video source={{ uri: data.url }} />}
    </View>
  );
}

License

MIT

Author

Umit UZ [email protected]

Repository

https://github.com/umituz/react-native-ai-pruna-provider

See Also