### Install Synexa Node.js Client Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Install the Synexa Node.js client package using npm. This is the first step before using the client in your project. ```bash npm install synexa ``` -------------------------------- ### Run AI Model (Simple Usage) Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Execute an AI model with simple input and await the result. This is the most straightforward way to get a model's output. ```typescript // Simple usage const model = "black-forest-labs/flux-schnell"; const input = { "prompt": "a futuristic robot looking into the distance" }; const [output] = await synexa.run(model, { input }); console.log(output); ``` -------------------------------- ### Create Prediction with Webhook Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Create a prediction and configure a webhook to receive notifications on prediction events like 'start' or 'completed'. ```typescript // Create a prediction with webhook const prediction = await synexa.createPrediction({ model: "black-forest-labs/flux-schnell", input: { prompt: "An astronaut riding a rainbow unicorn, cinematic, dramatic" }, webhook: "https://your-webhook-url.com", webhook_events_filter: ["start", "completed"] }); // Get prediction status const status = await synexa.getPrediction(prediction.id); // Wait for the prediction with options const result = await synexa.wait(prediction, { type: "block", // "block" or "poll" interval: 1000, // polling interval in ms timeout: 60 // timeout in seconds for blocking mode }); console.log(result.output); ``` -------------------------------- ### Instantiate Synexa Client Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Create an instance of the Synexa client. Requires your Synexa API token for authentication, typically provided via an environment variable. ```typescript const synexa = new Synexa.default({ auth: process.env.SYNEXA_API_TOKEN // Your Synexa API token }); ``` -------------------------------- ### Run AI Model with File Output Handling Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Run an AI model and handle potential file outputs. If the output is a URL, you can retrieve the URL string or the file data as a Blob. ```typescript // Advanced usage with file output handling const model = "black-forest-labs/flux-schnell"; const input = { prompt: "An astronaut riding a rainbow unicorn, cinematic, dramatic" }; const [output] = await synexa.run(model, { input }); // If the output is a URL, you get a FileOutput object if (output instanceof FileOutput) { console.log(output.url()); // Get the URL string const blob = await output.blob(); // Get the file data as a Blob } ``` -------------------------------- ### Run AI Model with Advanced Options Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Execute an AI model with advanced options including wait strategy, webhook configuration, cancellation via AbortSignal, and progress callbacks. ```typescript const controller = new AbortController(); const [output] = await synexa.run("black-forest-labs/flux-schnell", { input: { prompt: "An astronaut riding a rainbow unicorn, cinematic, dramatic" }, wait: { type: "block", // or "poll" interval: 1000, // polling interval in ms timeout: 60 // timeout in seconds for blocking mode }, webhook: "https://your-webhook-url.com", webhook_events_filter: ["start", "output", "logs", "completed"], signal: controller.signal, // AbortSignal for cancellation progress: (prediction) => { console.log(`Status: ${prediction.status}`); } }); ``` -------------------------------- ### Import Synexa Node.js Client Source: https://github.com/synexa-ai/synexa-javascript/blob/main/README.md Import the Synexa package into your Node.js project. Supports both ECMAScript Modules (ESM) and CommonJS module formats. ```typescript // ESM import Synexa from 'synexa'; // CommonJS const Synexa = require('synexa').default; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.