- Run the existing Cog image without code changes.
- Build from a Dockerfile, such as the Dockerfile that Cog generates.
- Convert the Cog
Predictorclass to afal.App.
fal CLI and gives you autoscaling, logs, and app analytics. For other Docker servers that do not use Cog, see Migrate an External Docker Server.
Choose a Migration Path
The time includes the first image build and a test deployment. Large model weights add download time to the first build and the first runner start.
Before You Start
- Install the
falCLI and log in. See Installation. - Make sure your account has Serverless access. Request access on the Serverless get-started page.
- Choose a GPU. See Machine Types for the list, for example
GPU-H100orGPU-B200.
Path 1: Run the Existing Cog Image
A Cog image contains its own HTTP server. On fal, an image-only app starts the container and sends requests to the port that you expose. You do not write afal.App class.
Build and Push the Image
Build the image with Cog and push it to a registry that fal can pull from:Configure the App
Add the app topyproject.toml. Do not set ref or python_entry_point. Without them, fal treats the container as an image-only app and does not load the fal Python runtime.
cmd. To override it, add cmd under [tool.fal.apps.my-cog-model.image]. See the pyproject.toml reference.
Test and Deploy
Run an ephemeral deployment to test the image:Call the App
fal forwards each request to the container without changes. The Cog API stays the same, so send the Cog request body to the/predictions path under your endpoint ID:
status_url and a response_url. Poll the status URL, then fetch the result from the response URL. See Calling Your Endpoints for queue, webhook, and streaming flows.
The Cog server returns files in the format that Cog uses, such as data URIs or paths. They do not go to the fal CDN. To return CDN URLs, use path 3.
Path 2: Build From a Dockerfile
Use this path when the model needs system packages, a specific CUDA version, or build steps that arequirements list cannot express. fal builds the image from your Dockerfile and caches the result.
Get a Dockerfile
If you already have a Dockerfile, use it. If you only have acog.yaml, print the Dockerfile that Cog generates:
- Remove the
COPY . /src,EXPOSE, andCMDlines at the end. fal starts the app. - Remove the Cog wheel installation (
cog-*.whl). fal does not use the Cog runtime. - Replace the Cog requirements step with your pip packages.
- Make sure that
curlis installed. fal uses it when a runner starts. - Install
falas the last step. This gives compatible versions ofpydantic,protobuf, andboto3.
cog debug is a hidden debugging command, and Cog does not guarantee its output format. The generated Dockerfile can change between Cog versions.Reference the Dockerfile From a fal.App
ContainerImage.from_dockerfile() reads a file from disk. To keep the Dockerfile in your Python file, use ContainerImage.from_dockerfile_str(). Both accept build_args, secrets, registries, and a build context_dir for COPY. See Use a Custom Container Image for all options and the build cache rules.
You can also keep the Dockerfile and its settings in pyproject.toml. Set dockerfile = "Dockerfile" under [tool.fal.apps.<app-name>.image]. See the pyproject.toml reference.
Path 3: Convert the Predictor to a fal.App
The Cog Predictor class maps directly to a fal.App. The setup() method stays the same. The predict() method becomes an @fal.endpoint method with Pydantic input and output models.
- Cog
- fal
cog.yaml. fal.toolkit.Image replaces cog.Path and uploads the image to the fal CDN, so the response contains a URL. The imports are inside setup() so that they run on the runner, not on your machine. See Serialization and Build for the reason.
Test the app on a temporary runner, then deploy it:
fal run executes setup() and your endpoints as production does. Import errors and model-load failures show in your terminal, not as a failed production deployment.
Call the deployed app:
What Changes After the Migration
How Billing Works on fal
fal bills Serverless apps per second of runner time, at the rate for the machine type. A runner is a container on a GPU. You pay while a runner is alive, not per prediction.
fal does not charge for requests that fail with an HTTP 5xx status. fal bills a multi-GPU runner as the GPU count multiplied by the duration. See Serverless Pricing for the full rules, and fal.ai/pricing for the hourly rate of each GPU.
Three settings decide most of the cost:
keep_alivekeeps an idle runner warm for a number of seconds after the last request. A longer value reduces cold starts and adds IDLE time.min_concurrencykeeps a minimum number of runners alive at all times. Set it to0to scale to zero, so that an app with no traffic has no compute charge.machine_typesets the per-second rate. Use the smallest GPU that fits the model.
Test Your Deployment
Open your app from the Apps dashboard. Follow Testing Your Own Apps to test an endpoint. Use the app’s Logs and Requests pages to inspect recorded requests.Next Steps
- App Lifecycle explains each stage, from code serialization to runner shutdown.
- Use a Custom Container Image covers every Dockerfile option.
- Optimize Container Images reduces build and start times.
- Scale Your Application explains the scaling settings.