Create Gateway
Create an AI Gateway for your tenant.
POST
/
ai-gateway
/
gateways
Create an AI gateway
curl --request POST \
--url https://api.knoxcall.com/v1/ai-gateway/gateways \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production AI",
"slug": "production-ai",
"budget_monthly_usd": 500
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/gateways"
payload = {
"name": "Production AI",
"slug": "production-ai",
"budget_monthly_usd": 500
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Production AI', slug: 'production-ai', budget_monthly_usd: 500})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/gateways', 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.knoxcall.com/v1/ai-gateway/gateways",
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' => 'Production AI',
'slug' => 'production-ai',
'budget_monthly_usd' => 500
]),
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.knoxcall.com/v1/ai-gateway/gateways"
payload := strings.NewReader("{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.knoxcall.com/v1/ai-gateway/gateways")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/gateways")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Production AI",
"slug": "production-ai",
"status": "active",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"budget_daily_usd": 123,
"budget_monthly_usd": 123,
"budget_overage_action": "block",
"paused_reason": "<string>",
"geo_velocity_action": "off",
"model_aliases": {},
"created_by": "<string>"
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Creates a gateway.
slug must be 2–64 lowercase alphanumerics or hyphens,
starting and ending with an alphanumeric; anything else is 422 invalid_slug,
and a slug already in use is 409 conflict.
Creating a gateway also seeds a Default prompt-firewall policy for the tenant
if one does not exist yet, and
Create an agent attaches it
when the caller names no firewall_policy_id.
That default policy’s action is warn, deliberately: a policy silently
inherited by every future agent must not be able to start refusing their traffic.
So blocking is opt-in either way — change the Default policy’s action, or attach
one of your own with action: "block". See
Prompt firewall.
The dashboard twin. The same operation exists on the admin host as
POST /admin/ai-gateway, session-authenticated with an X-Tenant-ID header and an
owner/admin role. That is what the dashboard itself calls. Prefer the /v1
operation above for anything you write: it is the surface the five SDKs, the
Postman collection and this spec cover.Authorizations
OAuth2BearerAuthApiKeyAuth
OAuth 2.1 authentication — recommended for new integrations. Access tokens
(kc_ prefix) are minted at the root-host token endpoint
https://api.knoxcall.com/oauth/token and passed as Authorization: Bearer <access_token>.
Public clients must use PKCE with the authorization_code grant; confidential
clients may use client_credentials. The first-party SDKs and the
knoxcall login CLI handle token minting, caching, refresh, and DPoP for you.
Body
application/json
Unique machine handle within the tenant.
What happens when the gateway's cap is spent (AIGW-150). Defaults to block. No fallback — that action swaps an agent's route and model, which a gateway does not have.
Available options:
block, warn Was this page helpful?
⌘I
Create an AI gateway
curl --request POST \
--url https://api.knoxcall.com/v1/ai-gateway/gateways \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production AI",
"slug": "production-ai",
"budget_monthly_usd": 500
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/gateways"
payload = {
"name": "Production AI",
"slug": "production-ai",
"budget_monthly_usd": 500
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Production AI', slug: 'production-ai', budget_monthly_usd: 500})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/gateways', 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.knoxcall.com/v1/ai-gateway/gateways",
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' => 'Production AI',
'slug' => 'production-ai',
'budget_monthly_usd' => 500
]),
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.knoxcall.com/v1/ai-gateway/gateways"
payload := strings.NewReader("{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.knoxcall.com/v1/ai-gateway/gateways")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/gateways")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Production AI\",\n \"slug\": \"production-ai\",\n \"budget_monthly_usd\": 500\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Production AI",
"slug": "production-ai",
"status": "active",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"budget_daily_usd": 123,
"budget_monthly_usd": 123,
"budget_overage_action": "block",
"paused_reason": "<string>",
"geo_velocity_action": "off",
"model_aliases": {},
"created_by": "<string>"
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}