curl --request PATCH \
--url https://api.ngrok.ai/gateway-config \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>",
"expectedFirewallPolicyId": "<string>"
}
'import requests
url = "https://api.ngrok.ai/gateway-config"
payload = {
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>",
"expectedFirewallPolicyId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
totalTimeout: '<string>',
perRequestTimeout: '<string>',
maxInputTokens: 123,
maxOutputTokens: 123,
metadata: '<string>',
firewallPolicyId: '<string>',
expectedFirewallPolicyId: '<string>'
})
};
fetch('https://api.ngrok.ai/gateway-config', 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://api.ngrok.ai/gateway-config",
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([
'totalTimeout' => '<string>',
'perRequestTimeout' => '<string>',
'maxInputTokens' => 123,
'maxOutputTokens' => 123,
'metadata' => '<string>',
'firewallPolicyId' => '<string>',
'expectedFirewallPolicyId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "https://api.ngrok.ai/gateway-config"
payload := strings.NewReader("{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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://api.ngrok.ai/gateway-config")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ngrok.ai/gateway-config")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accountId": "<string>",
"uri": "<string>",
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>"
}{
"statusCode": 123,
"msg": "<string>",
"details": {},
"errorCode": "<string>"
}Update AI Gateway configuration
Update the AI Gateway configuration for the authenticated account. Omitted fields preserve their existing stored value.
curl --request PATCH \
--url https://api.ngrok.ai/gateway-config \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>",
"expectedFirewallPolicyId": "<string>"
}
'import requests
url = "https://api.ngrok.ai/gateway-config"
payload = {
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>",
"expectedFirewallPolicyId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
totalTimeout: '<string>',
perRequestTimeout: '<string>',
maxInputTokens: 123,
maxOutputTokens: 123,
metadata: '<string>',
firewallPolicyId: '<string>',
expectedFirewallPolicyId: '<string>'
})
};
fetch('https://api.ngrok.ai/gateway-config', 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://api.ngrok.ai/gateway-config",
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([
'totalTimeout' => '<string>',
'perRequestTimeout' => '<string>',
'maxInputTokens' => 123,
'maxOutputTokens' => 123,
'metadata' => '<string>',
'firewallPolicyId' => '<string>',
'expectedFirewallPolicyId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "https://api.ngrok.ai/gateway-config"
payload := strings.NewReader("{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
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://api.ngrok.ai/gateway-config")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ngrok.ai/gateway-config")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"totalTimeout\": \"<string>\",\n \"perRequestTimeout\": \"<string>\",\n \"maxInputTokens\": 123,\n \"maxOutputTokens\": 123,\n \"metadata\": \"<string>\",\n \"firewallPolicyId\": \"<string>\",\n \"expectedFirewallPolicyId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accountId": "<string>",
"uri": "<string>",
"totalTimeout": "<string>",
"perRequestTimeout": "<string>",
"maxInputTokens": 123,
"maxOutputTokens": 123,
"metadata": "<string>",
"firewallPolicyId": "<string>"
}{
"statusCode": 123,
"msg": "<string>",
"details": {},
"errorCode": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Total timeout duration for a request through the AI Gateway (Go duration string, e.g. 30s, 1m). Defaults to 2m. For a streaming response, the default bounds the stream only until its first byte, after which the stream can run for up to 15 minutes. A value you set applies to the whole stream.
Per-request timeout duration for individual upstream requests (Go duration string, e.g. 30s, 1m). Defaults to 1m. Must be less than or equal to totalTimeout, checked against the configuration as it will be after the update.
Maximum number of input tokens allowed per request. Must be greater than zero.
PATCH: omit to preserve, send null to clear the cap (no
limit), or send a number to set it. Accounts that have not
written a value read back the per-account default; once
cleared with null, GET returns null until a new value is
written.
Maximum number of output tokens allowed per request. Must be greater than zero.
PATCH: omit to preserve, send null to clear the cap (no
limit), or send a number to set it. Accounts that have not
written a value read back the per-account default; once
cleared with null, GET returns null until a new value is
written.
Arbitrary user-defined metadata for the AI Gateway configuration.
PATCH: omit to preserve, send null to clear, or send a string
to set it. GET returns null when no value is stored.
4096The account's baseline Firewall policy, which applies to every key
under each access key configuration's own policy. PATCH: omit to
preserve, send null to clear, or send a policy ID to set it. The
policy must belong to the account.
The baseline policy the caller expects the account to have now. When
sent, the update applies only if the account's baseline still equals
it, and a 409 says it changed. Send null to expect no baseline.
Omit to update without the check.
Response
The updated AI Gateway configuration.
Unique identifier of the account this configuration belongs to.
URI of this AI Gateway Configuration API resource.
Total timeout duration for a request through the AI Gateway (Go duration string, e.g. 30s, 1m). Defaults to 2m. For a streaming response, the default bounds the stream only until its first byte, after which the stream can run for up to 15 minutes. A value you set applies to the whole stream.
Per-request timeout duration for individual upstream requests (Go duration string, e.g. 30s, 1m). Defaults to 1m. Must be less than or equal to totalTimeout, checked against the configuration as it will be after the update.
Maximum number of input tokens allowed per request. Must be greater than zero.
PATCH: omit to preserve, send null to clear the cap (no
limit), or send a number to set it. Accounts that have not
written a value read back the per-account default; once
cleared with null, GET returns null until a new value is
written.
Maximum number of output tokens allowed per request. Must be greater than zero.
PATCH: omit to preserve, send null to clear the cap (no
limit), or send a number to set it. Accounts that have not
written a value read back the per-account default; once
cleared with null, GET returns null until a new value is
written.
Arbitrary user-defined metadata for the AI Gateway configuration.
PATCH: omit to preserve, send null to clear, or send a string
to set it. GET returns null when no value is stored.
4096The account's baseline Firewall policy. It applies to every key,
under each access key configuration's own policy. null when the
account has none.
Was this page helpful?