> ## Documentation Index
> Fetch the complete documentation index at: https://lava.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# fal.ai

> Generative-media gateway for fal.ai — run image, video, audio, and speech models (FLUX, Kling, Veo, and hundreds more) with your own fal API key.

Generative-media gateway for fal.ai — run image, video, audio, and speech models (FLUX, Kling, Veo, and hundreds more) with your own fal API key. Best when an agent needs to generate or transform media from a prompt or an input file and then retrieve a hosted output URL. Unlike a single-model image API, fal exposes a large catalog behind one async queue, so slow jobs like video generation submit instantly and are polled to completion.

5 example endpoints available through Lava's AI Gateway. See the [fal.ai API docs](https://docs.fal.ai/) for full documentation.

<Warning>This provider requires your own credentials — connect your API key or OAuth account before use.</Warning>

<Info>This is a **catch-all provider** — any valid URL under `https://queue.fal.run` is supported. fal.ai generative media (image, video, audio, speech). Default to the ASYNC QUEUE at [https://queue.fal.run](https://queue.fal.run) — the Lava gateway has a \~25s edge timeout, so long jobs must never block a single request. Model ids look like fal-ai/\{model} (e.g. fal-ai/flux/dev, fal-ai/flux/schnell). Queue flow: (1) submit POST [https://queue.fal.run/\&#123;model\_id\&#125](https://queue.fal.run/\&#123;model_id\&#125); with the model input as body\_json — returns immediately with request\_id, status\_url, and response\_url; (2) poll GET [https://queue.fal.run/\&#123;model\_id\&#125;/requests/\&#123;request\_id\&#125;/status](https://queue.fal.run/\&#123;model_id\&#125;/requests/\&#123;request_id\&#125;/status) until status is COMPLETED (do NOT use the /status/stream SSE endpoint — it holds the connection open and can 504); (3) fetch the output with GET [https://queue.fal.run/\&#123;model\_id\&#125;/requests/\&#123;request\_id\&#125](https://queue.fal.run/\&#123;model_id\&#125;/requests/\&#123;request_id\&#125);, which returns the media URLs. Cancel with PUT [https://queue.fal.run/\&#123;model\_id\&#125;/requests/\&#123;request\_id\&#125;/cancel](https://queue.fal.run/\&#123;model_id\&#125;/requests/\&#123;request_id\&#125;/cancel). The SYNCHRONOUS host [https://fal.run/\&#123;model\_id\&#125](https://fal.run/\&#123;model_id\&#125); blocks until generation finishes — use it ONLY for fast, sub-25s image models; video and other slow models WILL time out, always queue them. Models take file inputs as URLs — pass any public or presigned URL, or an inline data URI (data:image/png;base64,...) for smaller files. To host a local file on fal's CDN instead: POST [https://rest.fal.ai/storage/upload/initiate](https://rest.fal.ai/storage/upload/initiate) with body\_json \{"content\_type": ..., "file\_name": ...} returns upload\_url and file\_url; PUT the raw file bytes directly to upload\_url with a plain HTTP client (presigned — no fal key, not routed through Lava), then pass file\_url in the model input. Authenticate by connecting your own fal key — Lava attaches the Authorization: Key header for you. See [https://docs.fal.ai](https://docs.fal.ai) for each model input schema. The endpoints below are curated examples.</Info>

## Endpoints

### Submit a generation job to the async queue. Returns immediately with request\_id, status\_url, and response\_url while the job runs on fal. Use this for every model — required for video and other slow models that would exceed the gateway timeout synchronously.

**POST** `https://queue.fal.run/fal-ai/flux/dev` — Free

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://queue.fal.run/fal-ai/flux/dev', {
      body: {
    "prompt": "a red panda coding at a desk, cinematic lighting"
    },
    });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.lava.so/v1/forward?u=https%3A%2F%2Fqueue.fal.run%2Ffal-ai%2Fflux%2Fdev" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{"prompt":"a red panda coding at a desk, cinematic lighting"}'
    ```
  </Tab>
</Tabs>

### Run a model synchronously — blocks until generation finishes and returns the output directly. Only for fast, sub-25s models (e.g. FLUX schnell); video and slow models will 504, use the queue instead.

**POST** `https://fal.run/fal-ai/flux/schnell` — Free

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://fal.run/fal-ai/flux/schnell', {
      body: {
    "prompt": "a red panda coding at a desk, cinematic lighting"
    },
    });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.lava.so/v1/forward?u=https%3A%2F%2Ffal.run%2Ffal-ai%2Fflux%2Fschnell" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY" \
      -H "Content-Type: application/json" \
      -d '{"prompt":"a red panda coding at a desk, cinematic lighting"}'
    ```
  </Tab>
</Tabs>

### Poll the status of a queued request (IN\_QUEUE, IN\_PROGRESS, COMPLETED). Poll this endpoint; do not use /status/stream, which holds the connection open and can time out.

**GET** `https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}/status` — Free

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}/status', { method: 'GET' });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.lava.so/v1/forward?u=https%3A%2F%2Fqueue.fal.run%2Ffal-ai%2Fflux%2Fdev%2Frequests%2F%7Brequest_id%7D%2Fstatus" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY"
    ```
  </Tab>
</Tabs>

### Fetch the result of a completed queued request. Returns the model output, including hosted URLs for generated images, video, or audio.

**GET** `https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}` — Free

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}', { method: 'GET' });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "https://api.lava.so/v1/forward?u=https%3A%2F%2Fqueue.fal.run%2Ffal-ai%2Fflux%2Fdev%2Frequests%2F%7Brequest_id%7D" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY"
    ```
  </Tab>
</Tabs>

### Cancel a queued request that has not started running yet. Returns 202 Accepted, or 400 if the job already completed.

**PUT** `https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}/cancel` — Free

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    const data = await lava.gateway('https://queue.fal.run/fal-ai/flux/dev/requests/{request_id}/cancel', { method: 'PUT' });
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X PUT "https://api.lava.so/v1/forward?u=https%3A%2F%2Fqueue.fal.run%2Ffal-ai%2Fflux%2Fdev%2Frequests%2F%7Brequest_id%7D%2Fcancel" \
      -H "Authorization: Bearer $LAVA_SECRET_KEY" \
      -H "Content-Type: application/json"
    ```
  </Tab>
</Tabs>

## Next Steps

<CardGroup cols={2}>
  <Card title="All Providers" icon="grid" href="/gateway/supported-providers">
    Browse all supported AI providers
  </Card>

  <Card title="Forward Proxy" icon="route" href="/gateway/forward-proxy">
    Learn how to construct proxy URLs and authenticate requests
  </Card>
</CardGroup>
