JSPM

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

1.0.66
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 57
  • Score
    100M100P100Q83585F
  • License MIT

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

Package Exports

  • @umituz/react-native-ai-fal-provider
  • @umituz/react-native-ai-fal-provider/src/index.ts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@umituz/react-native-ai-fal-provider) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

FAL AI provider service for React Native applications. Provides client wrapper, error handling, and React hooks.

Installation

npm install @umituz/react-native-ai-fal-provider @fal-ai/client

Usage

Initialize the Provider

import { falProvider } from "@umituz/react-native-ai-fal-provider";

falProvider.initialize({
  apiKey: "YOUR_FAL_API_KEY",
  maxRetries: 3,
  defaultTimeoutMs: 300000,
});

Using the Hook

import { useFalGeneration } from "@umituz/react-native-ai-fal-provider";

function MyComponent() {
  const { data, error, isLoading, generate, retry } = useFalGeneration({
    timeoutMs: 120000,
    onProgress: (status) => console.log("Progress:", status),
    onError: (error) => console.log("Error:", error),
  });

  const handleGenerate = async () => {
    await generate("fal-ai/flux/dev", {
      prompt: "A beautiful sunset",
      image_size: "landscape_16_9",
    });
  };

  return (
    // Your UI
  );
}

Direct Provider Usage

import { falProvider } from "@umituz/react-native-ai-fal-provider";

const result = await falProvider.subscribe("fal-ai/flux/dev", {
  prompt: "A beautiful sunset",
});

Error Handling

import { mapFalError, isFalErrorRetryable, falProvider } from "@umituz/react-native-ai-fal-provider";

try {
  await falProvider.run("fal-ai/flux/dev", { prompt: "test" });
} catch (error) {
  const errorInfo = mapFalError(error);
  console.log("Error type:", errorInfo.type);
  console.log("Message key:", errorInfo.messageKey);
  console.log("Retryable:", errorInfo.retryable);
}

API

falProvider

  • initialize(config) - Initialize the provider with API key
  • subscribe(model, input, options) - Subscribe to generation job
  • run(model, input, options) - Run a generation job
  • submitJob(model, input) - Submit a job to queue
  • getJobStatus(model, requestId) - Get job status
  • getJobResult(model, requestId) - Get job result
  • isInitialized() - Check if provider is initialized
  • reset() - Reset the provider
  • getCapabilities() - Get provider capabilities
  • isFeatureSupported(feature) - Check if feature is supported

useFalGeneration Hook

  • data - Generation result
  • error - Error info if failed
  • isLoading - Loading state
  • isRetryable - Whether error is retryable
  • generate(endpoint, input) - Start generation
  • retry() - Retry last generation
  • reset() - Reset state

Error Utilities

  • mapFalError(error) - Map error to FalErrorInfo
  • isFalErrorRetryable(error) - Check if error is retryable
  • categorizeFalError(error) - Get error category

License

MIT