Fal AI
Fal AI ↗ provides access to 600+ production-ready generative media models through a single, unified API. The service offers the world's largest collection of open image, video, voice, and audio generation models, all accessible with one line of code.
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/fal
When making requests to Fal AI, replace https://fal.run
in the URL you're currently using with https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/fal
.
When making requests to Fal AI, ensure you have the following:
- Your AI Gateway Account ID.
- Your AI Gateway gateway name.
- An active Fal AI API token.
- The name of the Fal AI model you want to use.
By default, requests to the Fal AI endpoint will hit the synchronous API at https://fal.run/<path>
.
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/fal/fal-ai/fast-sdxl \ --header 'Authorization: Key {fal_ai_token}' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "Make an image of a cat flying an aeroplane" }'
If you need to hit a different target URL, you can supply the entire Fal target URL in the x-fal-target-url
header.
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/fal \ --header 'Authorization: Bearer {fal_ai_token}' \ --header 'x-fal-target-url: https://queue.fal.run/fal-ai/bytedance/seedream/v4/edit' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "Dress the model in the clothes and hat. Add a cat to the scene and change the background to a Victorian era building.", "image_urls": [ "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_1.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_2.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_3.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_4.png" ] }'
Fal AI also supports real-time interactions through WebSockets. For WebSocket connections and examples, see the Realtime WebSockets API documentation.
The x-fal-target-url
format is compliant with the Fal SDKs, so AI Gateway can be easily passed as a proxyUrl
in the SDKs.
import { fal } from "@fal-ai/client";
fal.config({ credentials: "{fal_ai_token}", // OR pass a cloudflare api token if using BYOK on AI Gateway proxyUrl: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/fal"});
const result = await fal.subscribe("fal-ai/bytedance/seedream/v4/edit", { "input": { "prompt": "Dress the model in the clothes and hat. Add a cat to the scene and change the background to a Victorian era building.", "image_urls": [ "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_1.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_2.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_3.png", "https://storage.googleapis.com/falserverless/example_inputs/seedream4_edit_input_4.png" ] }});
console.log(result.data.images[0]);
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark