The Mochi 1 API enables the seamless transformation of text prompts into engaging video content. This comprehensive documentation provides all the essential details to integrate, authenticate, and utilize the API effectively for text-to-video functionality, empowering developers to create visually compelling videos with ease.
To access the Mochi 1 API, subscribe to the service and acquire a Subscription Key. Include this key in the request header to authenticate and gain access.
Content-Type | Set to application/json |
---|---|
Cache-Control | Recommended to set to no-cache |
Ocp-Apim-Subscription-Key | YOUR_SUBSCRIPTION_KEY |
Base URL: https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate
API Parameters: The API POST- https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate takes the following parameters:
Parameters | Type | Required | Description |
prompt | string | Yes | The instruction or description for generating the video scene. |
seed | integer | Optional | A random seed to ensure consistent results. Must be a value between 1 and 9,999,999,999. |
JSON
{ "prompt": "Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.", "seed": 445 }
POST https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate HTTP/1.1 Content-Type: application/json Cache-Control: no-cache { "prompt": "Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.", "seed": 445 }
import urllib.request, json try: url = "https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate" hdr ={ # Request headers 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', } # Request body data = data = json.dumps(data) req = urllib.request.Request(url, headers=hdr, data = bytes(data.encode("utf-8"))) req.get_method = lambda: 'POST' response = urllib.request.urlopen(req) print(response.getcode()) print(response.read()) except Exception as e: print(e)
// Request body const body = { "prompt": "Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.", "seed": 445 }; fetch('https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate', { method: 'POST', body: JSON.stringify(body), // Request headers headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache',} }) .then(response => { console.log(response.status); console.log(response.text()); }) .catch(err => console.error(err));
curl -v -X POST "https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{ \"prompt\": \"Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.\", \"seed\": 445 }"
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import java.io.UnsupportedEncodingException; import java.io.DataInputStream; import java.io.InputStream; import java.io.FileInputStream; public class HelloWorld { public static void main(String[] args) { try { String urlString = "https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate"; URL url = new URL(urlString); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Request headers connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Cache-Control", "no-cache"); connection.setRequestMethod("POST"); // Request body connection.setDoOutput(true); connection .getOutputStream() .write( "{ \"prompt\": \"Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.\", \"seed\": 445 }".getBytes() ); int status = connection.getResponseCode(); System.out.println(status); BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream()) ); String inputLine; StringBuffer content = new StringBuffer(); while ((inputLine = in.readLine()) != null) { content.append(inputLine); } in.close(); System.out.println(content); connection.disconnect(); } catch (Exception ex) { System.out.print("exception:" + ex.getMessage()); } } }
$url = "https://gateway.appypie.com/fal-ai-mochi-v1/v1/generate"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); # Request headers $headers = array( 'Content-Type: application/json', 'Cache-Control: no-cache',); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); # Request body $request_body = '{ "prompt": "Create a serene video scene of a sparrow bird flying through a lush green forest under a bright blue sky. Capture the bird’s graceful movements as it flits between branches and foliage, showcasing the vibrant colors of nature. Include gentle sounds of rustling leaves and cheerful birdsong to enhance the atmosphere. The lighting should reflect a sunny day, with dappled sunlight filtering through the trees, creating a peaceful and lively ambiance.", "seed": 445 }'; curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body); $resp = curl_exec($curl); curl_close($curl); var_dump($resp);
JSON
HTTP/1.1 200 OK { "requestId": "REQUEST_ID" }
To check the completion status of your video request and retrieve the video URL, you need to make a subsequent API call using the request_id obtained from the initial response.
https://gateway.appypie.com/fal-ai-mochi-v1/v1/getStatus
Content-Type | Set to application/json |
---|---|
Cache-Control | Recommended to set to no-cache |
Ocp-Apim-Subscription-Key | YOUR_SUBSCRIPTION_KEY |
Base URL: https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus
API Parameters: The API POST- https://gateway.appypie.com/fal-ai-mochi-v1/v1/getStatus takes the following parameters:
Parameters | Type | Required | Description |
requestId | string | Yes | A unique identifier received from the initial video generation request, used to check the status and retrieve the final video |
JSON
{ "requestId": "REQUEST_ID" }
POST https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus HTTP/1.1 Content-Type: application/json Cache-Control: no-cache { "requestId": "REQUEST_ID" }
import urllib.request, json try: url = "https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus" hdr ={ # Request headers 'Content-Type': 'application/json', 'Cache-Control': 'no-cache', } # Request body data = data = json.dumps(data) req = urllib.request.Request(url, headers=hdr, data = bytes(data.encode("utf-8"))) req.get_method = lambda: 'POST' response = urllib.request.urlopen(req) print(response.getcode()) print(response.read()) except Exception as e: print(e)
// Request body const body = { "requestId": "REQUEST_ID" }; fetch('https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus', { method: 'POST', body: JSON.stringify(body), // Request headers headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-cache',} }) .then(response => { console.log(response.status); console.log(response.text()); }) .catch(err => console.error(err));
curl -v -X POST "https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus" -H "Content-Type: application/json" -H "Cache-Control: no-cache" --data-raw "{ \"requestId\": \"REQUEST_ID\" }"
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import java.io.UnsupportedEncodingException; import java.io.DataInputStream; import java.io.InputStream; import java.io.FileInputStream; public class HelloWorld { public static void main(String[] args) { try { String urlString = "https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus"; URL url = new URL(urlString); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //Request headers connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Cache-Control", "no-cache"); connection.setRequestMethod("POST"); // Request body connection.setDoOutput(true); connection .getOutputStream() .write( "{ \"requestId\": \"REQUEST_ID\" }".getBytes() ); int status = connection.getResponseCode(); System.out.println(status); BufferedReader in = new BufferedReader( new InputStreamReader(connection.getInputStream()) ); String inputLine; StringBuffer content = new StringBuffer(); while ((inputLine = in.readLine()) != null) { content.append(inputLine); } in.close(); System.out.println(content); connection.disconnect(); } catch (Exception ex) { System.out.print("exception:" + ex.getMessage()); } } }
$url = "https://gateway.appypie.com/fal-ai-mochi-v1-polling/v1/getStatus"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); # Request headers $headers = array( 'Content-Type: application/json', 'Cache-Control: no-cache',); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); # Request body $request_body = '{ "requestId": "" }'; curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body); $resp = curl_exec($curl); curl_close($curl); var_dump($resp);
JSON
HTTP/1.1 200 OK { "status": "completed", "video_url": "https://fal.media/files/tiger/mk010nqBWTqH0N8J4DLXM_output_1730717535.mp4" }
The Mochi 1 API returns specific HTTP status codes and response bodies to indicate the success or failure of a request. Developers should implement appropriate error handling in their applications to manage these responses effectively.
Status Code | Description | Response Body |
200 | Success - The request was successfully processed, and the image generation is in progress or completed. | { "msg": "Image Getting Created", ... } |
400 | Bad Request - The request contains invalid parameters or missing fields. | { "error": "Invalid request parameters" } |
401 | Unauthorized - The provided subscription key is missing or invalid. | { "error": "Invalid or missing authentication" } |
403 | Forbidden - The subscription does not have access to this API or action. | { "error": "Access denied for this operation" } |
404 | Not Found - The requested resource or endpoint could not be found. | { "error": "Endpoint not found" } |
429 | Too Many Requests - The request rate limit has been exceeded. | { "error": "Rate limit exceeded, please retry later" } |
500 | Internal Server Error - An unexpected error occurred on the server. | { "error": "An unexpected error occurred, please try again later" } |
{ "status": "NOT_FOUND" }
This documentation provides all the essential information for using Mochi 1 API effectively. Be sure to replace YOUR_SUBSCRIPTION_KEY with the actual key you received when subscribing to the service.