
Deploy RF-DETR | (Just Updated) Object Detection API, YOLO Alternative, 4 Models, API Key Pre-Set
RF-DETR object detection API: YOLO alternative, COCO boxes, CPU, Apache-2.0
Just deployed
Deploy and Host RF-DETR (Object Detection API) on Railway
An object detection API finds the things in a picture and tells you where they are: send an image, get back a box, a label and a confidence score for every person, car, dog, chair or cup it sees. This template serves Roboflow's RF-DETR, a real-time detection transformer and the usual Apache-2.0 alternative to YOLO models, on CPU behind one authenticated HTTP API. The Nano, Small, Medium and Large weights are already inside the image, an API key is generated for you at deploy, and no GPU is needed.
About Hosting RF-DETR
The service runs the rfdetr 1.12.1 package with PyTorch 2.15.0 behind a small FastAPI server. All four COCO detection models are baked into the image: Nano (48.4 COCO AP50:95, 384 px input), Small (53.0, 512 px), Medium (54.7, 576 px) and Large (56.5, 704 px), figures from the upstream README. POST /detect takes up to 8 images per request, as multipart file parts or one raw image/* body, and returns for each image its width and height and a list of detections, each with a COCO label (80 classes, from person to toothbrush), a class_id, a score and a box of [x1, y1, x2, y2] pixels in the image you sent, highest score first. Three optional fields tune a call, as query parameters or form fields: model (nano, small, medium or large, default medium), threshold (0 to 1, default 0.5) and classes (comma-separated COCO names to keep, for example person,car; an unknown name is a 422). GET /v1/models lists the four models, the 80 class names and the limits in force.
The weights are verified by sha256 at build time, so nothing downloads at boot and the default model is ready about 8 seconds after the container starts; the other three load on their first request, about 1 to 3 seconds each. The service sizes its thread pool from the container's own CPU quota, handles one request at a time so memory stays bounded, accepts JPEG, PNG, WebP, GIF, BMP and TIFF checked by their magic bytes, refuses an image over 10 MiB or 50 million pixels (413), and answers 415 for any other content type. Images are held in memory for the length of one request and are never logged or written to disk. Only the Apache-2.0 detection checkpoints are shipped: the optional rfdetr[plus] models (PML 1.0 licence) and Ultralytics YOLO (AGPL-3.0) are not part of this image.
Measured on Railway, 8 vCPU (the X-Processing-Seconds header, one 810x1080 photo resized to three sizes, second call onward): model time was 0.10 to 0.31 s for Nano, 0.15 to 0.43 s for Small, 0.20 to 0.78 s for Medium and 0.23 to 1.01 s for Large, from a 640x480 up to a 4000x3000 JPEG (1.9 MB); the first call after a restart or the first call to a model is slower (Nano 1.6 s, Large 2.3 s) while it warms up. A whole request over the public URL, upload included, took 0.3 to 1.3 s. Twenty concurrent 1920x1080 uploads to the Medium model finished in 5.1 s, about 4 images per second. Resident memory was 634 MB after boot with only the default model loaded and peaked at 1.34 GB with all four loaded.
What it does not do. Detection accuracy was not benchmarked here: the checks were that the weights load, that a street photo of a bus and four people returns one bus (0.95) and four people (0.89 to 0.95) from the Medium and Large models, and that bad input and bad keys are refused. It finds the 80 COCO classes and nothing else; it cannot be fine-tuned from this API. The boxes are the model's raw output at a fixed square input size (the image is resized to it), so small objects in a very large photo are lost. There is no segmentation, tracking or video endpoint, only still images. COCO labels carry the biases of the dataset; check them before using detections of people for anything that affects a person.
Agent contract
- Public URL:
https://RAILWAY_PUBLIC_DOMAIN(the generated domain of therfdetrservice) - Private URL:
http://rfdetr.railway.internal:8080 - Credentials: the
API_KEYvariable of therfdetrservice - Auth: send
Authorization: Bearer $API_KEYon every route exceptGET /health; a call without the key or with a wrong one answers401 - Health:
GET /healthreturns 200 once the default model is loaded (503 while it loads)
# needs: RAILWAY_PUBLIC_DOMAIN, API_KEY (a variable of the rfdetr service); also curl and base64.
# signup: none - the API has no user accounts, only the API_KEY bearer
R="https://$RAILWAY_PUBLIC_DOMAIN"
echo iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg== | base64 -d | tee /tmp/px.png | wc -c
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/health")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/health"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST "$R/detect" -F file=@/tmp/px.png
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -X POST "$R/detect" -H "Authorization: Bearer not-the-key" -F file=@/tmp/px.png
curl -s -X POST "$R/detect" -H "Authorization: Bearer $API_KEY" -F model=nano -F threshold=0.5 -F file=@/tmp/px.png
curl -s "$R/v1/models" -H "Authorization: Bearer $API_KEY" | head -c 200; echo
A fresh deploy prints health: 200, write without key: 401, write wrong key: 401, a JSON result {"model":"nano","threshold":0.5,"results":[{"filename":"px.png","width":1,"height":1,"count":0,"detections":[]}]} (the test image is one blank pixel, so nothing is found) and the start of the model list. To see real detections, send a photo instead of /tmp/px.png: each entry of detections is {"label":"person","class_id":1,"score":0.94,"box":[x1,y1,x2,y2]}. A file that is not an image answers 422, an image over the size or pixel limit answers 413, a content type that is neither multipart nor image/* answers 415, an unknown model or classes name answers 422, and a 503 means the default model is still loading. The API only reads the images you send and never fetches a URL, so it cannot be pointed at an address inside your network.
Why Deploy RF-DETR on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying RF-DETR on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
- Your images stay in your container — detection runs in your own service, not in a hosted vision API that sees every upload.
- Four models behind one endpoint — pick Nano for speed or Large for accuracy per request with
model=, no redeploy. - No GPU bill and no per-image fee — you pay for the container, not for each detection.
- Open weights, commercial use — the upstream README states the Nano, Small, Medium and Large detection models are released under Apache-2.0, unlike AGPL-3.0 YOLO packages.
- Private by default — a generated bearer key guards every route but the health check, and the container refuses to start without one.
- Nothing to configure — no volume, no model download and no variables to fill in: submit the deploy form empty.
Common Use Cases
- Counting and filtering uploads — count people or cars in a photo, or keep only pictures that contain a
dogwithclasses=dog. - Pre-processing for other models — crop the boxes this API returns and send them to an OCR, embedding or classification service.
- Visual checks in an automation — let an n8n or agent workflow ask "is there a person in this camera snapshot" with one HTTP call.
Dependencies for RF-DETR Hosting
- A service with at least 2 GB of RAM (resident memory measured at 634 MB after boot and 1.34 GB with all four models loaded) and 8 vCPU for the speeds above; fewer vCPU run proportionally slower.
- No volume: the service keeps no state and the weights are in the image.
Deployment Dependencies
- roboflow/rf-detr — the model and package, Apache-2.0 for the Nano, Small, Medium and Large detection models per its README
- RF-DETR paper — Robinson et al., ICLR 2026
- bon5co/rfdetr-railway — the Railway wrapper image this template deploys, Apache-2.0
- Licences: the upstream README states: "The
rfdetrpackage, RF-DETR Nano, Small, Medium and Large detection ... are released under the Apache 2.0 license". PyTorch is BSD-3-Clause and transformers is Apache-2.0. The notices travel with the image at/app/NOTICE.
Template Content

