Python (SDK)
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.compute_services.update_service_scaling(id="<id>", idempotency_key="<value>", idle_timeout_seconds=800181, max_replicas=693036, min_replicas=178601)
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.computeServices.updateServiceScaling({
id: "<id>",
idempotencyKey: "<value>",
computeScalingInput: {
idleTimeoutSeconds: 800181,
maxReplicas: 693036,
minReplicas: 178601,
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
UpdateServiceScalingRequest req = new UpdateServiceScalingRequest() {
Id = "<id>",
IdempotencyKey = "<value>",
Body = new ComputeScalingInput() {
IdleTimeoutSeconds = 800181,
MaxReplicas = 693036,
MinReplicas = 178601,
},
};
var res = await sdk.ComputeServices.UpdateServiceScalingAsync(req);
// handle responsecurl --request PATCH \
--url https://apigw.mka1.com/api/v1/compute/services/{id}/scaling \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
}
'const options = {
method: 'PATCH',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
idle_timeout_seconds: 2,
max_replicas: 2,
min_replicas: 1,
target_concurrency_per_replica: 5000
})
};
fetch('https://apigw.mka1.com/api/v1/compute/services/{id}/scaling', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/compute/services/{id}/scaling",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'idle_timeout_seconds' => 2,
'max_replicas' => 2,
'min_replicas' => 1,
'target_concurrency_per_replica' => 5000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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 := "https://apigw.mka1.com/api/v1/compute/services/{id}/scaling"
payload := strings.NewReader("{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://apigw.mka1.com/api/v1/compute/services/{id}/scaling")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/compute/services/{id}/scaling")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}"
response = http.request(request)
puts response.read_body{
"accrued_usd": 123,
"compute": {
"accelerator": "<string>",
"ephemeral_disk_gb": 2,
"gpu_count": 4,
"instance_count": 2,
"interconnect": "<string>",
"vcpu_count": 2
},
"created_at": "2023-11-07T05:31:56Z",
"endpoints": [
{
"host": "<string>",
"name": "<string>",
"port": 123,
"protocol": "<string>",
"url": "<string>"
}
],
"id": "<string>",
"limits": {
"max_cost_usd": 123,
"max_runtime_hours": 123
},
"reason": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"started_at": "2023-11-07T05:31:56Z",
"state": "requested",
"terminal_at": "2023-11-07T05:31:56Z",
"ready": true,
"allocated_at": "2023-11-07T05:31:56Z",
"current_price_usd_hr": 123,
"hardware": {
"accelerator": "<string>",
"gpu_count": 123,
"gpu_memory_gb": 123,
"interconnect": "<string>"
},
"instance_price_usd_hr": 123,
"name": "<string>",
"price_usd_hr": 123,
"pricing_model": "instance_minutes",
"provider": "<string>",
"ssh": {
"command": "<string>",
"host": "<string>",
"port": 123,
"user": "<string>"
},
"volumes": [
{
"mount_path": "<string>",
"volume_id": "<string>"
}
],
"health": "healthy",
"scaling": {
"applied": {
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
},
"applied_at": "2023-11-07T05:31:56Z",
"applied_generation": 1,
"autoscaler": {
"blocked_reason": "<string>",
"drain_timeout_seconds": 2,
"evaluation_interval_seconds": 2,
"last_scale_at": "2023-11-07T05:31:56Z",
"observed_at": "2023-11-07T05:31:56Z",
"observed_concurrency": 1,
"recommended_replicas": 2,
"status": "disabled"
},
"desired": {
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
},
"desired_generation": 2,
"desired_updated_at": "2023-11-07T05:31:56Z",
"replicas": {
"allocated": 1,
"applied": 64,
"applied_generation": 1,
"decision": "create",
"desired": 64,
"desired_generation": 2,
"draining": 1,
"ready": 1,
"updated_at": "2023-11-07T05:31:56Z"
}
},
"volume": {
"accrued_cost_usd": 123,
"data": [
{
"path": "<string>",
"resolved_revision": "<string>",
"revision": "<string>",
"type": "huggingface",
"url": "<string>"
}
],
"mount_path": "<string>",
"price_usd_hr": 123,
"size_gb": 123,
"status": "provisioning"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"details": {}
}
}Compute Services
Replace a service scaling policy
PATCH
/
api
/
v1
/
compute
/
services
/
{id}
/
scaling
Python (SDK)
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.compute_services.update_service_scaling(id="<id>", idempotency_key="<value>", idle_timeout_seconds=800181, max_replicas=693036, min_replicas=178601)
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.computeServices.updateServiceScaling({
id: "<id>",
idempotencyKey: "<value>",
computeScalingInput: {
idleTimeoutSeconds: 800181,
maxReplicas: 693036,
minReplicas: 178601,
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
UpdateServiceScalingRequest req = new UpdateServiceScalingRequest() {
Id = "<id>",
IdempotencyKey = "<value>",
Body = new ComputeScalingInput() {
IdleTimeoutSeconds = 800181,
MaxReplicas = 693036,
MinReplicas = 178601,
},
};
var res = await sdk.ComputeServices.UpdateServiceScalingAsync(req);
// handle responsecurl --request PATCH \
--url https://apigw.mka1.com/api/v1/compute/services/{id}/scaling \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
}
'const options = {
method: 'PATCH',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
idle_timeout_seconds: 2,
max_replicas: 2,
min_replicas: 1,
target_concurrency_per_replica: 5000
})
};
fetch('https://apigw.mka1.com/api/v1/compute/services/{id}/scaling', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/compute/services/{id}/scaling",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'idle_timeout_seconds' => 2,
'max_replicas' => 2,
'min_replicas' => 1,
'target_concurrency_per_replica' => 5000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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 := "https://apigw.mka1.com/api/v1/compute/services/{id}/scaling"
payload := strings.NewReader("{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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.patch("https://apigw.mka1.com/api/v1/compute/services/{id}/scaling")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/compute/services/{id}/scaling")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"idle_timeout_seconds\": 2,\n \"max_replicas\": 2,\n \"min_replicas\": 1,\n \"target_concurrency_per_replica\": 5000\n}"
response = http.request(request)
puts response.read_body{
"accrued_usd": 123,
"compute": {
"accelerator": "<string>",
"ephemeral_disk_gb": 2,
"gpu_count": 4,
"instance_count": 2,
"interconnect": "<string>",
"vcpu_count": 2
},
"created_at": "2023-11-07T05:31:56Z",
"endpoints": [
{
"host": "<string>",
"name": "<string>",
"port": 123,
"protocol": "<string>",
"url": "<string>"
}
],
"id": "<string>",
"limits": {
"max_cost_usd": 123,
"max_runtime_hours": 123
},
"reason": {
"code": "<string>",
"message": "<string>",
"details": {}
},
"started_at": "2023-11-07T05:31:56Z",
"state": "requested",
"terminal_at": "2023-11-07T05:31:56Z",
"ready": true,
"allocated_at": "2023-11-07T05:31:56Z",
"current_price_usd_hr": 123,
"hardware": {
"accelerator": "<string>",
"gpu_count": 123,
"gpu_memory_gb": 123,
"interconnect": "<string>"
},
"instance_price_usd_hr": 123,
"name": "<string>",
"price_usd_hr": 123,
"pricing_model": "instance_minutes",
"provider": "<string>",
"ssh": {
"command": "<string>",
"host": "<string>",
"port": 123,
"user": "<string>"
},
"volumes": [
{
"mount_path": "<string>",
"volume_id": "<string>"
}
],
"health": "healthy",
"scaling": {
"applied": {
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
},
"applied_at": "2023-11-07T05:31:56Z",
"applied_generation": 1,
"autoscaler": {
"blocked_reason": "<string>",
"drain_timeout_seconds": 2,
"evaluation_interval_seconds": 2,
"last_scale_at": "2023-11-07T05:31:56Z",
"observed_at": "2023-11-07T05:31:56Z",
"observed_concurrency": 1,
"recommended_replicas": 2,
"status": "disabled"
},
"desired": {
"idle_timeout_seconds": 2,
"max_replicas": 2,
"min_replicas": 1,
"target_concurrency_per_replica": 5000
},
"desired_generation": 2,
"desired_updated_at": "2023-11-07T05:31:56Z",
"replicas": {
"allocated": 1,
"applied": 64,
"applied_generation": 1,
"decision": "create",
"desired": 64,
"desired_generation": 2,
"draining": 1,
"ready": 1,
"updated_at": "2023-11-07T05:31:56Z"
}
},
"volume": {
"accrued_cost_usd": 123,
"data": [
{
"path": "<string>",
"resolved_revision": "<string>",
"revision": "<string>",
"type": "huggingface",
"url": "<string>"
}
],
"mount_path": "<string>",
"price_usd_hr": 123,
"size_gb": 123,
"status": "provisioning"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"details": {}
}
}Authorizations
Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.
Headers
Minimum string length:
1Optional strong entity tag containing the current desired scaling-policy generation.
Minimum string length:
1Optional external end-user identifier forwarded by the API gateway.
Path Parameters
Body
application/json
Response
Scaling policy accepted for asynchronous reconciliation
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Available options:
requested, allocating, provisioning, running, ready, finalizing, terminating, succeeded, failed, terminated Show child attributes
Show child attributes
Available options:
instance_minutes, instance_seconds Opaque compute-provider identifier. Supported values are deployment-specific.
Minimum string length:
1Show child attributes
Show child attributes
Show child attributes
Show child attributes
Available options:
healthy, warming, degraded Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I