Skip to main content

Deploy open-source models via API

Register an open-source model from Hugging Face, deploy it, wait until it's ready, and change its scale or stop it, all with the Management API. Use it to script what Deploy and run self-hosted models does in the Control Room, for example to set up several workspaces the same way.

A self-hosted model has two parts. The model is the registry record: its name, the weights it runs (its artifact) and its deploy parameters. The deployment is the running copy of those weights, with its replicas and its phase. A model has at most one deployment, at /models/{id}/deployment.

POST  /management/v0/models                    -> creates the model, returns its id and deployRevision
POST /management/v0/models/{id}/deployment -> deploys that revision
GET /management/v0/models/{id}/deployment -> phase, replicas, reason
PATCH /management/v0/models/{id}/deployment -> changes the scale, or stops it

The Management API is served under /api on your Control Room's address, such as https://control-room.example.com/api. Browse it in the Swagger UI at /api/swagger/index.html (group backend-management-v0).

Before you begin​

  • An API key or a signed-in session. A workspace key from Settings → API Keys acts as an administrator. A user needs Create on the AI Model Registry row of their role to create and deploy models, and Update to change the scale. The examples send the key as Authorization: Bearer $TOKEN. See Access Rational AI via API.
  • The model's Hugging Face repository, such as Qwen/Qwen3-8B. The API stores the name as you send it, so check that it exists on huggingface.co.
  • A plan that includes self-hosted models, on Rational AI's cloud. Without it, a deploy is refused with "This workspace's plan does not include hosting your own models on our GPUs."

Check what your hosting can deploy​

Each installation has one hosting platform for its models. Ask it what it accepts before you create anything:

curl -s "https://control-room.example.com/api/management/v0/models/hosting" \
-H "Authorization: Bearer $TOKEN"

The answer lists the hosting targets (one today), each with its provider, capabilities and defaultIdleTimeoutSeconds:

CapabilityMeaning
artifactSourcesWhere weights can come from: huggingFace, registry (an Ollama tag) or upload
huggingFaceFormatsThe Hugging Face weight formats it loads, such as base (safetensors) and awq
uploadFormatsThe formats it accepts as an upload, such as gguf. Empty when it accepts none
gpuWhether deployments can have GPUs
maxReplicasThe most replicas a deployment can have
scaleToZeroWhether an idle deployment releases its hardware
scalesOnDemandWhether the platform starts and releases replicas by itself
deployParametersA JSON Schema of the provider parameters it accepts, with their defaults

defaultIdleTimeoutSeconds is how long an on-demand deployment waits without requests before it releases its hardware, when the deployment sets no timeout of its own.

Create the model​

Send POST /management/v0/models with the rationalAI discriminator and the weights in artifact:

curl -s -X POST "https://control-room.example.com/api/management/v0/models" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"discriminator": "rationalAI",
"name": "Qwen3 8B",
"purpose": "textGeneration",
"publisher": "Qwen",
"artifact": { "source": "huggingFace", "repository": "Qwen/Qwen3-8B" },
"deployParameters": { "contextLength": 32768 }
}'

The response is 201 Created with the model. Save its id and deployRevision.

FieldNotes
discriminatorrationalAI for a model Rational AI deploys. thirdParty is for a model a provider serves through a connector
nameThe name people see. Must be unique. Defaults to modelIdentifier
modelIdentifierWhat API callers send as model. Must be unique. Defaults to name, then to the repository
purposetextGeneration, embedding, reranking, imageGeneration or decision. Inferred from the repository when omitted
artifactsource with repository (and optionally revision and file) for huggingFace, reference for registry, or format for upload
typeThe weight format: base, awq, ggml or gguf. Inferred from the repository when omitted
deployParameterscontextLength, gpuCount (0 runs on the CPU) and providerParameters, the keys the hosting's schema declares

Creating a model never deploys it, and neither does editing it with PATCH /models/{id}. Nothing reaches the hosting platform until you deploy.

If your workspace requires model approval, the model answers only after it is approved. See Require approval before a model answers.

Upload the weights instead​

If uploadFormats isn't empty, create the model with "artifact": { "source": "upload", "format": "gguf" } and a name, then stream the file:

curl -s -X PUT "https://control-room.example.com/api/management/v0/models/<MODEL_ID>/artifact" \
-H "Content-Type: application/octet-stream" \
-H "Authorization: Bearer $TOKEN" \
--data-binary @my-model.gguf

A model accepts one upload only. It can't be deployed until the upload completes.

Deploy the model​

Send POST /management/v0/models/{id}/deployment with the revision you're confirming, which must equal the model's deployRevision, and optionally a scale:

curl -s -X POST "https://control-room.example.com/api/management/v0/models/<MODEL_ID>/deployment" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{ "revision": 1, "scale": { "min": 0, "max": 1 } }'

The response is 201 Created. The same call rolls out new deploy parameters to an existing deployment, or restarts it when nothing changed.

If someone edited the model after you read it, its deployRevision has moved on and the deploy is refused with 409 Conflict. Read the model again and deploy the new revision. This way a deployment always runs settings someone confirmed.

The scale object sets how many replicas the deployment may run:

ScaleBehavior
min = max = nAlways n replicas. 0 and 0 is a stopped deployment
min = 0, max ≥ 1On demand: releases its hardware after idleTimeout without requests, and starts again on the next one
min ≥ 1Always keeps min replicas running

idleTimeout is a duration such as "00:15:00". Leave it out to use defaultIdleTimeoutSeconds (600 seconds unless your installation changed it). The platform clamps the range to its maxReplicas.

Follow the deployment​

curl -s "https://control-room.example.com/api/management/v0/models/<MODEL_ID>/deployment" \
-H "Authorization: Bearer $TOKEN"

The answer has the deployment, plus outOfDate and changedFields, which say whether the model's deploy parameters changed since it was deployed. The deployment carries:

FieldMeaning
phaseWhere it is in its lifecycle (see the next table)
readyReplicas, desiredReplicasHow many replicas answer, out of how many it should run
reason, messageWhy it waits or failed, such as WaitingForCapacity, SlowStart, OutOfMemory or Crashed
progressWhat the platform is doing now, such as pulling an image
lastTransitionAt, lastUsedAtWhen it entered its phase, and when it last served a request
PhaseMeaning
provisioningFirst start of these settings: downloading weights and images
startingA deployment that was ready before is starting again
readyAt least one replica answers requests
idleNo replica runs. The next request starts one
stoppingGoing down to zero replicas
stoppedNo replica runs, and requests don't start one
failedThe settings can't run. reason and message say why. It stays failed until you deploy again
deletingThe deployment is being removed

A first deployment can take several minutes while the weights download. Temporary problems, such as waiting for a free GPU, show in reason without changing the phase.

Change the scale or stop the deployment​

PATCH /management/v0/models/{id}/deployment changes the scale at once, without restarting running replicas. The optional replicas sets how many to run now, within the new range:

# Stop: no replicas, and requests don't start one
curl -s -X PATCH "https://control-room.example.com/api/management/v0/models/<MODEL_ID>/deployment" \
-H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
-d '{ "scale": { "min": 0, "max": 0 } }'

# Resume on demand, and start one replica now so the first request doesn't wait
curl -s -X PATCH "https://control-room.example.com/api/management/v0/models/<MODEL_ID>/deployment" \
-H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
-d '{ "scale": { "min": 0, "max": 1 }, "replicas": 1 }'

"replicas": 0 releases the hardware of an on-demand deployment until the next request. A platform that scales on demand by itself (scalesOnDemand) refuses replicas.

Endpoint reference​

All paths are relative to /api/management/v0.

ActionEndpoint
List modelsGET /models (filters: query, purpose, usable, hosting, phase)
Read a modelGET /models/{id}
Create a modelPOST /models
Upload weightsPUT /models/{id}/artifact
Edit a model (never deploys)PATCH /models/{id}
Preview the default of each deploy parameterPOST /models/{id}/deploy-defaults
Set the approvalPOST /models/{id}/approval
Hosting and its capabilitiesGET /models/hosting
Read the deploymentGET /models/{id}/deployment
Deploy, roll out, or restartPOST /models/{id}/deployment
Change the scale, stop, or resumePATCH /models/{id}/deployment
Delete the deployment (keeps the model)DELETE /models/{id}/deployment
Send a test request to a ready model (never deploys)POST /models/{id}/test
Move a model's uses to another modelPOST /models/{id}/replace
Delete a modelDELETE /models/{id}
Search installable models (administrators only)GET /supported

PATCH /models/{id} with "enabled": false disables a model: its requests are refused at once and model pickers stop offering it, while its deployment stays as it is.

Troubleshooting​

SymptomWhat to check
404 on every callThe address. Calls go to /api/management/v0/... on the Control Room's host.
409 on createAnother model has that name. List the models and reuse it, or choose another name.
409 on deployThe revision you sent is stale. Read the model and deploy its current deployRevision.
Stuck in provisioning with WaitingForCapacityNo GPU has room for the model. Stop another deployment, or lower gpuCount.
failed with OutOfMemory or Crashedmessage carries the runner's error. Lower contextLength, or pick a smaller or quantized model, then deploy again.

Next steps​