/ai/token/update
POST https://api.sitehost.nz/1.5/ai/token/update.json
Updates an AI token. Only the params supplied are changed.
Form Parameters
| Parameter | Type | Required | Description |
| client_id | integer | Yes | The ID for the client.Example: 1 |
| key_id | string | Yes | The ID of the token to update.Example: 3f6c2a9e-8b14-4d7a-9c5e-1a2b3c4d5e6f |
| params[label] | string | A new label for the token, up to 255 characters.Example: Production app | |
| params[allowed_ips][0] | string | The IPv4 or IPv6 addresses or CIDR ranges allowed to use the token, up to 255 entries. This replaces the existing list. To remove the restriction, send params[allowed_ips][0] with an empty value. This parameter accepts one or more values in the format of params[allowed_ips][0]=x, params[allowed_ips][1]=y.Example: 203.0.113.0/24 | |
| params[capabilities][0] | string | The capabilities the token can use. Valid options are inference, embedding and rerank. This replaces the existing list and must contain at least one value. This parameter accepts one or more values in the format of params[capabilities][0]=x, params[capabilities][1]=y.Example: embedding | |
| params[requests_per_minute] | integer | The maximum number of requests per minute. Use 0 to remove the limit.Example: 120 | |
| params[cost_limit_hourly] | number | The maximum spend per hour in NZD (excl. GST), to at most 2 decimal places. Use 0 to remove the limit.Example: 10.00 | |
| params[cost_limit_daily] | number | The maximum spend per day in NZD (excl. GST), to at most 2 decimal places. Use 0 to remove the limit.Example: 100.00 | |
| params[cost_limit_monthly] | number | The maximum spend per month in NZD (excl. GST), to at most 2 decimal places. Use 0 to remove the limit.Example: 1000.00 |
Code Samples
JavaScript PHP Rails Pythonvar xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.5/ai/token/update.json", false);
var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", 1);
data.append("key_id", "3f6c2a9e-8b14-4d7a-9c5e-1a2b3c4d5e6f");
data.append("params[label]", "Production app");
data.append("params[allowed_ips][0]", "203.0.113.0\/24");
data.append("params[capabilities][0]", "embedding");
data.append("params[requests_per_minute]", 120);
data.append("params[cost_limit_hourly]", "10.00");
data.append("params[cost_limit_daily]", "100.00");
data.append("params[cost_limit_monthly]", "1000.00");
xmlHttp.send(data);
var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.5/ai/token/update.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'key_id' => '3f6c2a9e-8b14-4d7a-9c5e-1a2b3c4d5e6f',
'params[label]' => 'Production app',
'params[allowed_ips][0]' => '203.0.113.0/24',
'params[capabilities][0]' => 'embedding',
'params[requests_per_minute]' => 120,
'params[cost_limit_hourly]' => '10.00',
'params[cost_limit_daily]' => '100.00',
'params[cost_limit_monthly]' => '1000.00',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'
uri = URI.parse("https://api.sitehost.nz/1.5/ai/token/update.json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
body = {"apikey" => "your_key_here",
"client_id" => 1,
"key_id" => "3f6c2a9e-8b14-4d7a-9c5e-1a2b3c4d5e6f",
"params[label]" => "Production app",
"params[allowed_ips][0]" => "203.0.113.0/24",
"params[capabilities][0]" => "embedding",
"params[requests_per_minute]" => 120,
"params[cost_limit_hourly]" => "10.00",
"params[cost_limit_daily]" => "100.00",
"params[cost_limit_monthly]" => "1000.00",
}
request.set_form_data(body)
response = http.request(request)
import requests
from collections import OrderedDict
uri = 'https://api.sitehost.nz/1.5/ai/token/update.json'
# We need ordered dictionary because parameters have to be in the right order.
# Refer to Developer Notes for more information.
body = OrderedDict()
body['apikey'] = 'your_key_here'
body['client_id'] = 1
body['key_id'] = '3f6c2a9e-8b14-4d7a-9c5e-1a2b3c4d5e6f'
body['params[label]'] = 'Production app'
body['params[allowed_ips][0]'] = '203.0.113.0/24'
body['params[capabilities][0]'] = 'embedding'
body['params[requests_per_minute]'] = 120
body['params[cost_limit_hourly]'] = '10.00'
body['params[cost_limit_daily]'] = '100.00'
body['params[cost_limit_monthly]'] = '1000.00'
response = requests.post(uri, data=body)
Response
200:application/json
{
"return": {
"updated": true
},
"msg": "Successful",
"status": true
}
"return": {
"updated": true
},
"msg": "Successful",
"status": true
}