Skip to main content

Fal pass-through

The /fal_ai route forwards requests to the Fal queue API. A caller submits a model path such as /fal_ai/fal-ai/flux-pro/v1.1 with the generation parameters, then polls and fetches the result under /fal_ai/fal-ai/flux-pro/v1.1/requests/{request_id}. The gateway holds the Fal key, checks the virtual key and costs every submission from the bundled Fal prices. Only models with a price entry can be submitted, so no image is generated without a cost on the spend log.

A real-world scenario​

A design team generates product mockups with Fal models from a web app. The team lead wants one Fal account, a budget per designer and a record of what each image cost. The app submits to /fal_ai/... on the gateway with each designer's virtual key. The Fal key never reaches the browser, and the Logs page shows every submission with its price.

Before you start​

The gateway needs a Fal credential. It looks first for a model_list deployment of provider Fal AI with use_in_pass_through: true, then for the environment below.

VariablePurpose
FAL_AI_API_KEYThe Fal key the gateway sends upstream.
FAL_AI_QUEUE_API_BASEOptional. Changes the queue address from https://queue.fal.run.

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, on the Add Model tab pick Fal AI under Provider, pick a model, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or set FAL_AI_API_KEY and restart the gateway.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Submit a request through the gateway.

    curl -X POST http://localhost:4000/fal_ai/fal-ai/flux-pro/v1.1 \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"prompt": "A lighthouse at dawn, watercolour", "image_size": "landscape_4_3", "num_images": 1}'
  4. Poll GET /fal_ai/fal-ai/flux-pro/v1.1/requests/{request_id}/status and fetch the result from GET /fal_ai/fal-ai/flux-pro/v1.1/requests/{request_id} with the same key.

  5. Open /ui/logs and click the newest row to see the submission, the key and its cost.

Expected result​

Fal's own response, with its status code and headers.

{
"request_id": "7d3e3c6a-0f2b-4b6e-9c57-1a0f1b2c3d4e",
"status": "IN_QUEUE",
"status_url": "https://queue.fal.run/fal-ai/flux-pro/v1.1/requests/7d3e3c6a-0f2b-4b6e-9c57-1a0f1b2c3d4e/status"
}

The spend log row for the submission carries the key, team and user and the cost of the requested images at the requested size. Polling and result calls are free.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /fal_ai/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
401FAL_AI_API_KEY is not set and no fal_ai pass-through deployment credentials are configuredThe gateway has no Fal credential. Add a deployment with Use in pass through routes on, or set the variable.
400fal_ai/... has no pricing entry for this request; only priced Fal requests can be submitted through /fal_aiThe model or size has no price in the bundled map, so the gateway cannot cost it. Use a priced model, or add a price under custom pricing.
Any otherFal's own error bodyFal refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. The unified image generation endpoint covers Fal models with guardrails and routing, and the Fal provider page covers the unified integration.