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:
| Capability | Meaning |
|---|---|
artifactSources | Where weights can come from: huggingFace, registry (an Ollama tag) or upload |
huggingFaceFormats | The Hugging Face weight formats it loads, such as base (safetensors) and awq |
uploadFormats | The formats it accepts as an upload, such as gguf. Empty when it accepts none |
gpu | Whether deployments can have GPUs |
maxReplicas | The most replicas a deployment can have |
scaleToZero | Whether an idle deployment releases its hardware |
scalesOnDemand | Whether the platform starts and releases replicas by itself |
deployParameters | A 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.
| Field | Notes |
|---|---|
discriminator | rationalAI for a model Rational AI deploys. thirdParty is for a model a provider serves through a connector |
name | The name people see. Must be unique. Defaults to modelIdentifier |
modelIdentifier | What API callers send as model. Must be unique. Defaults to name, then to the repository |
purpose | textGeneration, embedding, reranking, imageGeneration or decision. Inferred from the repository when omitted |
artifact | source with repository (and optionally revision and file) for huggingFace, reference for registry, or format for upload |
type | The weight format: base, awq, ggml or gguf. Inferred from the repository when omitted |
deployParameters | contextLength, 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:
| Scale | Behavior |
|---|---|
min = max = n | Always n replicas. 0 and 0 is a stopped deployment |
min = 0, max ≥ 1 | On demand: releases its hardware after idleTimeout without requests, and starts again on the next one |
min ≥ 1 | Always 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:
| Field | Meaning |
|---|---|
phase | Where it is in its lifecycle (see the next table) |
readyReplicas, desiredReplicas | How many replicas answer, out of how many it should run |
reason, message | Why it waits or failed, such as WaitingForCapacity, SlowStart, OutOfMemory or Crashed |
progress | What the platform is doing now, such as pulling an image |
lastTransitionAt, lastUsedAt | When it entered its phase, and when it last served a request |
| Phase | Meaning |
|---|---|
provisioning | First start of these settings: downloading weights and images |
starting | A deployment that was ready before is starting again |
ready | At least one replica answers requests |
idle | No replica runs. The next request starts one |
stopping | Going down to zero replicas |
stopped | No replica runs, and requests don't start one |
failed | The settings can't run. reason and message say why. It stays failed until you deploy again |
deleting | The 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.
| Action | Endpoint |
|---|---|
| List models | GET /models (filters: query, purpose, usable, hosting, phase) |
| Read a model | GET /models/{id} |
| Create a model | POST /models |
| Upload weights | PUT /models/{id}/artifact |
| Edit a model (never deploys) | PATCH /models/{id} |
| Preview the default of each deploy parameter | POST /models/{id}/deploy-defaults |
| Set the approval | POST /models/{id}/approval |
| Hosting and its capabilities | GET /models/hosting |
| Read the deployment | GET /models/{id}/deployment |
| Deploy, roll out, or restart | POST /models/{id}/deployment |
| Change the scale, stop, or resume | PATCH /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 model | POST /models/{id}/replace |
| Delete a model | DELETE /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
| Symptom | What to check |
|---|---|
404 on every call | The address. Calls go to /api/management/v0/... on the Control Room's host. |
409 on create | Another model has that name. List the models and reuse it, or choose another name. |
409 on deploy | The revision you sent is stale. Read the model and deploy its current deployRevision. |
Stuck in provisioning with WaitingForCapacity | No GPU has room for the model. Stop another deployment, or lower gpuCount. |
failed with OutOfMemory or Crashed | message carries the runner's error. Lower contextLength, or pick a smaller or quantized model, then deploy again. |
Next steps
- Deploy and run self-hosted models: the same tasks in the Control Room.
- Access Rational AI via API: call the deployed model through the OpenAI-compatible API.