File size: 3,656 Bytes
08450ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 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()
|