import gradio as gr import pandas as pd # Leaderboard data LEADERBOARD = pd.DataFrame([ {"Model": "sora-2", "Provider": "OpenAI", "Quality Score": 9.5, "Speed (s)": 45, "Cost/Video ($)": 0.15, "Resolution": "4K", "Max Duration": "20s"}, {"Model": "veo-3", "Provider": "Google", "Quality Score": 9.3, "Speed (s)": 35, "Cost/Video ($)": 0.12, "Resolution": "4K", "Max Duration": "8s"}, {"Model": "runway-gen4", "Provider": "Runway", "Quality Score": 8.8, "Speed (s)": 25, "Cost/Video ($)": 0.10, "Resolution": "4K", "Max Duration": "16s"}, {"Model": "kling-v3-pro", "Provider": "Kling AI", "Quality Score": 8.7, "Speed (s)": 30, "Cost/Video ($)": 0.10, "Resolution": "4K", "Max Duration": "10s"}, {"Model": "wan-2.1", "Provider": "Wan", "Quality Score": 7.5, "Speed (s)": 15, "Cost/Video ($)": 0.05, "Resolution": "1080p", "Max Duration": "8s"}, ]).sort_values("Quality Score", ascending=False) def generate_video(api_key, model, prompt, duration, aspect_ratio): if not api_key or api_key == 'your_nexaapi_key': return None, "āš ļø Enter your NexaAPI key. Get 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 ) info = LEADERBOARD[LEADERBOARD['Model'] == model].iloc[0] if model in LEADERBOARD['Model'].values else {} result = f"āœ… **{model}** — Video generated!\n\n**URL**: {response.video_url}\n\n**Cost**: ~${info.get('Cost/Video ($)', 0.10):.2f}\n\nšŸ”— [nexa-api.com](https://nexa-api.com) | [RapidAPI](https://rapidapi.com/user/nexaquency)" return response.video_url, result except Exception as e: return None, f"āŒ Error: {e}\n\nGet key at https://nexa-api.com" with gr.Blocks(title="AI Video Generation Model Comparator") as demo: gr.Markdown(""" # šŸ† AI Video Generation Model Comparator ### Powered by [NexaAPI](https://nexa-api.com) — One API Key, All Models Compare Sora 2, Veo 3, Runway Gen-4, Kling AI, and more — all via one unified endpoint. 5–10Ɨ cheaper than official pricing. """) with gr.Tab("šŸ† Leaderboard"): gr.Markdown("### Model Rankings (Quality Ɨ Cost Ɨ Speed)") gr.Dataframe(value=LEADERBOARD, interactive=False) gr.Markdown(""" **All models accessible via [NexaAPI](https://nexa-api.com)** - šŸ”Œ [RapidAPI](https://rapidapi.com/user/nexaquency) — Subscribe in seconds - šŸ `pip install nexaapi` → [PyPI](https://pypi.org/project/nexaapi/) - šŸ“¦ `npm install nexaapi` → [npm](https://www.npmjs.com/package/nexaapi) """) with gr.Tab("šŸŽ¬ Generate"): api_key = gr.Textbox(label="NexaAPI Key", placeholder="Get free at nexa-api.com", type="password") with gr.Row(): model = gr.Dropdown(choices=list(LEADERBOARD['Model']), value="kling-v3-pro", label="Model") aspect = gr.Dropdown(choices=["16:9", "9:16", "1:1"], value="16:9", label="Aspect Ratio") duration = gr.Slider(2, 10, value=5, step=1, label="Duration (s)") prompt = gr.Textbox(label="Prompt", value="A serene Japanese garden with cherry blossoms falling, cinematic 4K", lines=2) btn = gr.Button("šŸŽ¬ Generate", variant="primary") with gr.Row(): video_out = gr.Video(label="Output") result_md = gr.Markdown() btn.click(generate_video, inputs=[api_key, model, prompt, duration, aspect], outputs=[video_out, result_md]) demo.launch()