| import gradio as gr |
|
|
| MODELS = [ |
| "sora-2", |
| "veo-3", |
| "runway-gen4", |
| "kling-v3-pro", |
| ] |
|
|
| MODEL_INFO = { |
| "sora-2": {"provider": "OpenAI", "resolution": "Up to 4K", "duration": "Up to 20s", "best_for": "Cinematic storytelling"}, |
| "veo-3": {"provider": "Google DeepMind", "resolution": "Up to 4K", "duration": "Up to 8s", "best_for": "Realistic motion"}, |
| "runway-gen4": {"provider": "Runway", "resolution": "Up to 4K", "duration": "Up to 16s", "best_for": "Creative/artistic"}, |
| "kling-v3-pro": {"provider": "Kling AI", "resolution": "Up to 4K", "duration": "Up to 10s", "best_for": "High quality, competitive"}, |
| } |
|
|
| def generate_video(api_key, model, prompt, duration, aspect_ratio): |
| if not api_key or api_key == 'your_nexaapi_key': |
| return None, "β οΈ Please enter your NexaAPI key. Get one free at https://nexa-api.com" |
| |
| try: |
| from nexaapi import NexaAPI |
| client = NexaAPI(api_key=api_key) |
| |
| response = client.video.generate( |
| model=model, |
| prompt=prompt, |
| duration=int(duration), |
| aspect_ratio=aspect_ratio, |
| quality='cinematic' |
| ) |
| |
| info = MODEL_INFO.get(model, {}) |
| result_text = f"""β
Video generated! |
| |
| **Model**: {model} ({info.get('provider', '')}) |
| **URL**: {response.video_url} |
| **Cost**: ~$0.05β$0.20 (vs $0.30β$2.00 direct) |
| |
| --- |
| π Get your API key: [nexa-api.com](https://nexa-api.com) |
| π RapidAPI: [rapidapi.com/user/nexaquency](https://rapidapi.com/user/nexaquency)""" |
| |
| return response.video_url, result_text |
| except Exception as e: |
| return None, f"β Error: {str(e)}\n\nGet your API key at https://nexa-api.com" |
|
|
|
|
| with gr.Blocks(title="AI Video Generation Model Comparison 2026") as demo: |
| gr.Markdown(""" |
| # π¬ AI Video Generation Model Comparison 2026 |
| ### Sora 2 vs Veo 3 vs Runway Gen-4 vs Kling AI β All via One API |
| |
| Compare all major AI video generation models through **[NexaAPI](https://nexa-api.com)** β |
| one unified endpoint, 5β10Γ cheaper than official pricing. |
| |
| | Model | Provider | Resolution | Duration | Best For | |
| |-------|---------|-----------|---------|---------| |
| | sora-2 | OpenAI | Up to 4K | Up to 20s | Cinematic storytelling | |
| | veo-3 | Google DeepMind | Up to 4K | Up to 8s | Realistic motion | |
| | runway-gen4 | Runway | Up to 4K | Up to 16s | Creative/artistic | |
| | kling-v3-pro | Kling AI | Up to 4K | Up to 10s | High quality | |
| |
| --- |
| """) |
| |
| with gr.Row(): |
| api_key = gr.Textbox(label="NexaAPI Key", placeholder="Get free at nexa-api.com", type="password") |
| |
| with gr.Row(): |
| model = gr.Dropdown(choices=MODELS, value="kling-v3-pro", label="Model") |
| aspect_ratio = gr.Dropdown(choices=["16:9", "9:16", "1:1", "4:3"], value="16:9", label="Aspect Ratio") |
| duration = gr.Slider(2, 10, value=5, step=1, label="Duration (seconds)") |
| |
| prompt = gr.Textbox( |
| label="Video Prompt", |
| value="A cinematic drone shot over a misty mountain range at golden hour", |
| lines=2 |
| ) |
| |
| btn = gr.Button("π¬ Generate Video", variant="primary") |
| |
| with gr.Row(): |
| video_out = gr.Video(label="Generated Video") |
| result_info = gr.Markdown() |
| |
| btn.click(generate_video, inputs=[api_key, model, prompt, duration, aspect_ratio], outputs=[video_out, result_info]) |
| |
| gr.Markdown(""" |
| --- |
| ## π Get Started |
| |
| - π **NexaAPI**: [nexa-api.com](https://nexa-api.com) β Free tier, no credit card |
| - π **RapidAPI**: [rapidapi.com/user/nexaquency](https://rapidapi.com/user/nexaquency) |
| - π **Python**: `pip install nexaapi` β [PyPI](https://pypi.org/project/nexaapi/) |
| - π¦ **Node**: `npm install nexaapi` β [npm](https://www.npmjs.com/package/nexaapi) |
| - π **GitHub**: [ai-video-generation-api-benchmark](https://github.com/diwushennian4955/ai-video-generation-api-benchmark) |
| - π **Tutorial**: [Dev.to Article](https://dev.to/diwushennian4955/how-to-access-sora-2-veo-3-and-runway-gen-4-with-one-api-key-5hno) |
| |
| **50+ models. 5Γ cheaper. One API key.** |
| """) |
|
|
| demo.launch() |
|
|