Hosted API (Remote Server)

Leverage your custom trained model for cloud-hosted inference.


Each model trained with Roboflow Train is deployed as a custom API you can use to make predictions from any device that has an internet connection. Inference is done on the server so you don't need to worry about the edge device's hardware capabilities.

We automatically scale this API up and down and do load balancing for you so that you can rest assured that your application will be able to handle sudden spikes in traffic without having to pay for GPU time you're not using. Our hosted prediction API has been battle-hardened to handle even the most demanding production applications (including concurrently surviving through the famous Hacker News and Reddit "hugs of death" without so much as batting an eye).

The Example Web App

The easiest way to familiarize yourself with the inference endpoint is to visit the Example Web App. To use the Web App, simply input your model , version and api_key. These will be pre-filled for you after training completes if you click through via the web UI under your versions "Training Results" section.

Then select an image via Choose File. After you have chosen the settings you want, click Run Inference.

On the left side of the screen, you will see example JavaScript code for posting a base64-encoded image to the inference endpoint. Within the form portion of the Web App, you can experiment with changing different API parameters when posting to the API.

Using the Inference API
You can POST a base64 encoded image directly to your model endpoint. Or you can pass a URL as the image parameter in the query string if your image is already hosted elsewhere.
Path Parameters
The url-safe version of the dataset name. You can find it in the web UI by looking at the URL on the main project view.
The version number identifying the version of your dataset.
Query Parameters
Your API key (obtained via your workspace API settings page)
200: OK

Code Snippets

For your convenience, we've provided code snippets for calling this endpoint in various programming languages. If you need help integrating the inference API into your project don't hesitate to reach out.

All examples upload to an example dataset with a model-endpoint of your-dataset-slug/your-version. You can easily find your dataset's identifier by looking at the curl command shown in the Roboflow web interface after your model has finished training.


Uploading a Local Image

To install dependencies, pip install requests pillow

import requests
import base64
import io
from PIL import Image
# Load Image with PIL
image ="YOUR_IMAGE.jpg").convert("RGB")
# Convert to JPEG Buffer
buffered = io.BytesIO(), quality=90, format="JPEG")
# Base 64 Encode
img_str = base64.b64encode(buffered.getvalue())
img_str = img_str.decode("ascii")
# Construct the URL
upload_url = "".join([
# POST to the API
r =, data=img_str, headers={
"Content-Type": "application/x-www-form-urlencoded"
# Output result


We're using axios to perform the POST request in this example so first run npm install axios to install the dependency.

Inferring on a Local Image

const axios = require("axios");
const fs = require("fs");
const image = fs.readFileSync("YOUR_IMAGE.jpg", {
encoding: "base64"
method: "POST",
url: "",
params: {
api_key: "YOUR_KEY"
data: image,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
.then(function(response) {
.catch(function(error) {