Create Service
curl --request POST \
--url http://127.0.0.1:9321/api/services \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"image": "<string>",
"port": 8000,
"gpus": 0,
"restart_policy": "always",
"command": "<string>",
"script_path": "<string>",
"env": {},
"health_check": {
"path": "/",
"type": "http",
"timeout_s": 2,
"unhealthy_threshold": 3,
"start_period_s": 0
}
}
'import requests
url = "http://127.0.0.1:9321/api/services"
payload = {
"name": "<string>",
"image": "<string>",
"port": 8000,
"gpus": 0,
"restart_policy": "always",
"command": "<string>",
"script_path": "<string>",
"env": {},
"health_check": {
"path": "/",
"type": "http",
"timeout_s": 2,
"unhealthy_threshold": 3,
"start_period_s": 0
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
image: '<string>',
port: 8000,
gpus: 0,
restart_policy: 'always',
command: '<string>',
script_path: '<string>',
env: {},
health_check: {
path: '/',
type: 'http',
timeout_s: 2,
unhealthy_threshold: 3,
start_period_s: 0
}
})
};
fetch('http://127.0.0.1:9321/api/services', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "9321",
CURLOPT_URL => "http://127.0.0.1:9321/api/services",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'image' => '<string>',
'port' => 8000,
'gpus' => 0,
'restart_policy' => 'always',
'command' => '<string>',
'script_path' => '<string>',
'env' => [
],
'health_check' => [
'path' => '/',
'type' => 'http',
'timeout_s' => 2,
'unhealthy_threshold' => 3,
'start_period_s' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:9321/api/services"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://127.0.0.1:9321/api/services")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:9321/api/services")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"status": "pending",
"gpu_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"manageable": true,
"desired_state": "<string>",
"kind": "service",
"image": "<string>",
"gpu_ids": [
"<string>"
],
"restart_policy": "<string>",
"restart_count": 0,
"health_check": {},
"container_id": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"error_class": "OOM",
"error_message": "<string>",
"submitted_via": "cli",
"endpoint": {
"container_port": 123,
"host_port": 123,
"effective_host_port": 123,
"protocol": "tcp",
"route": "<string>",
"url": "<string>",
"public_url": "<string>",
"public_urls": [
{
"url": "<string>",
"kind": "default",
"state": "ready",
"access": "private",
"domain": "<string>",
"cert_state": "internal"
}
]
},
"rollback_available": false,
"build_version": 123,
"last_deploy": {},
"data_dir_bytes": 123,
"source": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Services
Create Service
Reference for merged 0.6.0 source. The latest verified binary release is 0.5.5; use your Engine’s /api/openapi.json for its installed contract.
Create Service
curl --request POST \
--url http://127.0.0.1:9321/api/services \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"image": "<string>",
"port": 8000,
"gpus": 0,
"restart_policy": "always",
"command": "<string>",
"script_path": "<string>",
"env": {},
"health_check": {
"path": "/",
"type": "http",
"timeout_s": 2,
"unhealthy_threshold": 3,
"start_period_s": 0
}
}
'import requests
url = "http://127.0.0.1:9321/api/services"
payload = {
"name": "<string>",
"image": "<string>",
"port": 8000,
"gpus": 0,
"restart_policy": "always",
"command": "<string>",
"script_path": "<string>",
"env": {},
"health_check": {
"path": "/",
"type": "http",
"timeout_s": 2,
"unhealthy_threshold": 3,
"start_period_s": 0
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
image: '<string>',
port: 8000,
gpus: 0,
restart_policy: 'always',
command: '<string>',
script_path: '<string>',
env: {},
health_check: {
path: '/',
type: 'http',
timeout_s: 2,
unhealthy_threshold: 3,
start_period_s: 0
}
})
};
fetch('http://127.0.0.1:9321/api/services', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "9321",
CURLOPT_URL => "http://127.0.0.1:9321/api/services",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'image' => '<string>',
'port' => 8000,
'gpus' => 0,
'restart_policy' => 'always',
'command' => '<string>',
'script_path' => '<string>',
'env' => [
],
'health_check' => [
'path' => '/',
'type' => 'http',
'timeout_s' => 2,
'unhealthy_threshold' => 3,
'start_period_s' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:9321/api/services"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://127.0.0.1:9321/api/services")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:9321/api/services")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"image\": \"<string>\",\n \"port\": 8000,\n \"gpus\": 0,\n \"restart_policy\": \"always\",\n \"command\": \"<string>\",\n \"script_path\": \"<string>\",\n \"env\": {},\n \"health_check\": {\n \"path\": \"/\",\n \"type\": \"http\",\n \"timeout_s\": 2,\n \"unhealthy_threshold\": 3,\n \"start_period_s\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"status": "pending",
"gpu_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"manageable": true,
"desired_state": "<string>",
"kind": "service",
"image": "<string>",
"gpu_ids": [
"<string>"
],
"restart_policy": "<string>",
"restart_count": 0,
"health_check": {},
"container_id": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"finished_at": "2023-11-07T05:31:56Z",
"exit_code": 123,
"error_class": "OOM",
"error_message": "<string>",
"submitted_via": "cli",
"endpoint": {
"container_port": 123,
"host_port": 123,
"effective_host_port": 123,
"protocol": "tcp",
"route": "<string>",
"url": "<string>",
"public_url": "<string>",
"public_urls": [
{
"url": "<string>",
"kind": "default",
"state": "ready",
"access": "private",
"domain": "<string>",
"cert_state": "internal"
}
]
},
"rollback_available": false,
"build_version": 123,
"last_deploy": {},
"data_dir_bytes": 123,
"source": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
application/json
Pattern:
^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$Required range:
1 <= x <= 65535Required range:
x >= 0Available options:
no, on-failure, always Show child attributes
Show child attributes
Available options:
nvidia, amd Show child attributes
Show child attributes
Response
HTTP 201 response
Available options:
pending, scheduled, running, paused, completed, failed, cancelled, retrying, building, degraded, restarting, stopped Available options:
batch, service, model, database Available options:
OOM, GPU_FAIL, IMAGE_PULL_FAIL, USER_ERROR, TIMEOUT, CONTAINER_FAIL, MOUNT_MISSING, GPU_OOM, PLATFORM_ERROR, UNKNOWN Show child attributes
Show child attributes