ai-coding-minesIndexGitHub

Calling a Gradio Space directly over REST

Deploy and infrastructure

Call it with a two-step REST flow without the gradio_client package (no runtime dependency to add).

POST {base}/gradio_api/call/{fn}   body: {"data":[...]}   → event_id
GET  {base}/gradio_api/call/{fn}/{event_id}               → parse the result URL from SSE

base is https://{owner}-{space}.hf.space (lowercase, /-).

1. Don't guess parameters; check info

GET {base}/gradio_api/infonamed_endpoints lists every function name with parameter order, types, and defaults.

Guessing predict with [prompt, '', w, h, 5] spun uselessly. The real endpoint was /generate_video with [prompt, aspect_ratio (a Literal string), steps, negative_prompt, ...].

2. Send a float and you get error; it has to be int

0.0 (float) for rate / pitchevent: error and nothing else. 0 (int) works. The error body is null, so the cause is invisible. You only catch it by sending the same request with only the type changed.

3. No token, error

Anonymous calls get event: error. A free account's Read token is enough.

4. The result URL is a temporary path

Shaped like {base}/gradio_api/file=/tmp/gradio/.../x.mp4. Accessible but volatile; download and push to storage immediately.