From request to downloadable video
Keep the creation request, task state and completed file distinct in your integration. Save enough information to recover a job after a worker restarts.
- Validate the inputs
Check the endpoint’s roles and duration limits, and verify that every reference URL is reachable by the provider.
- Submit and record the job
Send credentials from your server and keep the returned request ID. Where an SDK only exposes polling, consult the provider’s lifecycle API for explicit job control.
- Poll to a terminal state
Continue while queued or running. After a failure, examine the error and input before deciding whether to submit a new job.
- Download and inspect the result
Save the file before a signed link expires. Check duration, aspect ratio and the presence of an audio track.
Pick a model ID
Higgsfield documents sand/magi-2/text-to-video, sand/magi-2/image-to-video and sand/magi-2/reference-to-video. Read the schema for your mode before declaring inputs. Supported reference fields and limits depend on the endpoint.
The documented text and image tiers support 4–30 seconds at 1080p. Sand.ai’s native omni-reference ceiling is 20 items, with up to ten images, five videos and five audio clips. Use the provider’s mode-specific validation limits for actual requests.
Submit a text-to-video job
Install @higgsfield/client in a server-side project. Use the provider’s credentials format in HF_CREDENTIALS and keep it in the server environment. The sample sends a six-second text request and waits for the job result.
import { config, higgsfield } from "@higgsfield/client/v2";
config({ credentials: process.env.HF_CREDENTIALS });
const result = await higgsfield.subscribe("sand/magi-2/text-to-video", {
input: {
prompt: "A slow dolly toward a rain-soaked tram stop. Rain taps the shelter.",
duration: 6,
resolution: "1080p",
aspect_ratio: "16:9",
generate_audio: true,
},
withPolling: true,
});
console.log(result);
Budget and handle asynchronous jobs
The text-to-video endpoint lists US$0.08 per generated second at launch. At that rate, six seconds costs $0.48 and 30 seconds costs $2.40. Use live provider pricing for production estimates.
Higgsfield documents a single concurrent job per account across MAGI-2 modes. Queue work, persist job identifiers and check job state before retrying an ambiguous submission. Keep your own durable copy of a completed result when your workflow needs it.
Sand.ai’s own API
The Sand AI Platform documents an Ark-compatible API for organizations with the magi-2 model enabled. Send generation requests to its task endpoint and retrieve the result by ID. The Ark reference mode allows up to 10 images, three videos and three audio clips, with separate total-duration caps. Frame-controlled requests use first_frame and last_frame roles. Check the platform’s access and billing page before integrating.