# Sora 2 > Sora 2 transforms detailed text descriptions into stunning, dynamic videos within seconds. ## Overview - **Endpoint**: `https://api.segmind.com/v1/sora-2` - **Model ID**: `sora-2` - **Category**: Image-to-Video Generation - **Type**: Synchronous (Direct response) - **Average Cost**: $1.6686153846153846 ## Pricing | duration | cost | | --- | --- | | 4 | 0.572 | | 8 | 1.144 | | 12 | 1.716 | ## API Information This model uses a **synchronous response pattern**: 1. Make a POST request with your parameters 2. Receive the output directly in the response (binary for images/videos/audio, JSON for text) 3. No polling required - response is immediate ### Input Schema The API accepts the following input parameters: - **`prompt`** (`string`, _required_): Prompt Define the video content with detailed or abstract descriptions. Use detailed action scenes or serene landscapes to enhance creativity. - Default: `"A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power."` - **`input_reference`** (`File (URL)`, _optional_): Input reference Provide an URL to an image for reference. - **`duration`** (`integer | null`, _optional_): Duration Set the animation duration in seconds. Use shorter durations for quick previews and longer for detailed animations. - Default: `8` - Options: "4" (4), "8" (8), "12" (12) - **`size`** (`string | null`, _optional_): Size Select the video's aspect ratio. Choose portrait for social media stories or landscape for traditional videos. - Default: `"720x1280"` - Options: "720x1280" (Portrait), "1280x720" (Landscape) **Required Parameters Example**: ```json { "prompt": "A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power." } ``` **Full Example**: ```json { "prompt": "A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power.", "input_reference": "https://example.com/image.jpg", "duration": "8", "size": "720x1280" } ``` ### Output Schema The API returns a synchronous response based on the model type: **For Image/Video/Audio Models**: - Response contains binary data (image/png, video/mp4, audio/mp3) - Content-Type header indicates the media type - Save the response body directly to a file **For Text Models**: - Response is JSON with the generated text - Structure varies by model **HTTP Response Codes**: - **200 - OK**: Request successful, output in response body - **400 - Bad Request**: Invalid parameters - **401 - Unauthorized**: Invalid or missing API key - **404 - Not Found**: Model not found - **406 - Not Acceptable**: Insufficient credits - **429 - Too Many Requests**: Rate limit exceeded - **500 - Server Error**: Internal server error ## Usage Examples ### cURL ```bash curl -X POST "https://api.segmind.com/v1/sora-2" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power.", "input_reference": "https://example.com/image.jpg", "duration": "8", "size": "720x1280" }' ``` ### Python ```python import requests import json api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/sora-2" data = { "prompt": "A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power.", "input_reference": "https://example.com/image.jpg", "duration": "8", "size": "720x1280" } response = requests.post( url, json=data, headers={ 'x-api-key': api_key, 'Content-Type': 'application/json' } ) if response.status_code == 200: # For image/video/audio models, response.content contains the binary data with open('output.png', 'wb') as f: f.write(response.content) print('Generation complete, saved to output.png') else: print(f"Error: {response.status_code}") print(response.text) ``` ### JavaScript ```javascript const apiKey = 'YOUR_API_KEY'; const url = 'https://api.segmind.com/v1/sora-2'; const data = { "prompt": "A monk meditating under a waterfall, droplets misting around, capturing tranquility amidst nature's power.", "input_reference": "https://example.com/image.jpg", "duration": "8", "size": "720x1280" }; const response = await fetch(url, { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); if (response.ok) { // For image/video/audio models, response contains binary data const blob = await response.blob(); const downloadUrl = URL.createObjectURL(blob); // Create download link const a = document.createElement('a'); a.href = downloadUrl; a.download = 'output.png'; a.click(); console.log('Generation complete'); } ``` ## Additional Resources ### Documentation - [Model Playground](https://www.segmind.com/models/sora-2) - [API Documentation](https://www.segmind.com/models/sora-2/api) - [Pricing Details](https://www.segmind.com/models/sora-2/pricing) - [Platform Documentation](https://docs.segmind.com/) ### Tags No tags available