BlogGradio

How to deploy a Gradio app.

Gradio deploys with one sentence. Your code must launch on 0.0.0.0 and the PORT variable, and the app has 1 GB of memory.

How the Agent API works
  • Entry file foundapp.py, main.py and more
  • python app.pyAntideploy runs your file
  • Launch on PORTSet server_name and server_port
  • 1 GB of memoryUse hosted models where you can

The short answer

To deploy a Gradio app, give your coding agent the sentence below. Antideploy finds Gradio in your requirements, finds the file that imports it, and runs it with python. Unlike Streamlit, Gradio is not started with extra flags, so your code must launch on 0.0.0.0 and on the port in the PORT variable. Each app has 1 GB of memory.

Say this to your coding agent

Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.

What Antideploy detects

  • Gradio. Detected from gradio in requirements.txt or pyproject.toml.
  • The entry file. It looks for streamlit_app.py, app.py, dashboard.py, main.py and home.py, in that order, in the folder of your requirements. The first one that contains import gradio wins. Otherwise it uses any .py file that imports Gradio.
  • The start command. python <entry file>. Nothing is added, so the launch settings are yours.
  • The port. Antideploy sets PORT and sends traffic to it.

The launch line

By default Gradio listens on 127.0.0.1, which only your own computer can reach. On a server it must listen on 0.0.0.0 and on the port Antideploy gives it.

app.py
import os
import gradio as gr

def greet(name):
    return "Hello " + name

demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch(
    server_name="0.0.0.0",
    server_port=int(os.environ.get("PORT", 7860)),
)

If your app uses gr.Blocks, the same launch call applies. Without these two arguments the deploy builds but never starts listening, and fails with a message that names the port.

Memory

An app that loads a large model into memory when it starts can run out of 1 GB and be stopped before it listens. Two ways help.

  • Call a hosted model instead of loading weights, for example through an AI key that your agent creates
  • If you must load a model, load it the first time it is needed, not at import time
  • Pin Python to 3.12 in a .python-version file if a package such as torch has no build for a newer version

Step by step

  1. Add the launch arguments

    Set server_name="0.0.0.0" and read the port from PORT.

  2. Paste the sentence and approve one link

    Your agent creates the app and deploys it. Keys you need, such as a model key, are saved as write-only variables.

  3. Open your link

    Antideploy installs your requirements, runs your file, and checks that the app answers. Your agent tells you the address.

01Before you commit

Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

  1. Apps sleep when idle

    On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

  2. One instance, no previews

    Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

  3. The disk forgets

    Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

02Questions

Gradio questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Is Gradio free to host here?

It runs on the Free plan, which includes 1 live app with a server. Failed deploys are free.

Why does my Gradio app build but not start?

Usually it listens on 127.0.0.1 or on a fixed port. Set server_name and server_port as shown above. See never started listening.

Can I run a local machine learning model?

Only if it fits in 1 GB together with the rest of the app. Large models usually do not. Use a hosted model instead.

Does Gradio work with WebSockets and streaming?

Yes. Each app is one long-running process, and Antideploy sets no time limit of its own on a connection.

Where do I put my API keys?

In environment variables. Values you save on Antideploy are encrypted and write-only.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.