Add a virtual key
curl --request POST \
--url https://gateway.your-domain.com/key/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"key_alias": "acme-corp",
"models": [
"smart-router"
],
"max_budget": 25,
"budget_duration": "30d",
"rpm_limit": 120,
"tpm_limit": 200000,
"duration": "90d"
}
'import requests
url = "https://gateway.your-domain.com/key/generate"
payload = {
"key_alias": "acme-corp",
"models": ["smart-router"],
"max_budget": 25,
"budget_duration": "30d",
"rpm_limit": 120,
"tpm_limit": 200000,
"duration": "90d"
}
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({
key_alias: 'acme-corp',
models: ['smart-router'],
max_budget: 25,
budget_duration: '30d',
rpm_limit: 120,
tpm_limit: 200000,
duration: '90d'
})
};
fetch('https://gateway.your-domain.com/key/generate', 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://gateway.your-domain.com/key/generate",
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([
'key_alias' => 'acme-corp',
'models' => [
'smart-router'
],
'max_budget' => 25,
'budget_duration' => '30d',
'rpm_limit' => 120,
'tpm_limit' => 200000,
'duration' => '90d'
]),
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://gateway.your-domain.com/key/generate"
payload := strings.NewReader("{\n \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\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://gateway.your-domain.com/key/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.your-domain.com/key/generate")
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 \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\n}"
response = http.request(request)
puts response.read_body{
"key": "sk-5AKAW_A...",
"key_alias": "acme-corp",
"models": [
"smart-router"
],
"max_budget": 25,
"rpm_limit": 120,
"expires": "2026-10-06T14:44:35Z"
}{
"error": {
"message": "Authentication Error, No api key passed in."
}
}Keys
Add a virtual key
Mint a virtual key scoped to models, with a budget, rate limits, and expiry.
POST
/
key
/
generate
Add a virtual key
curl --request POST \
--url https://gateway.your-domain.com/key/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"key_alias": "acme-corp",
"models": [
"smart-router"
],
"max_budget": 25,
"budget_duration": "30d",
"rpm_limit": 120,
"tpm_limit": 200000,
"duration": "90d"
}
'import requests
url = "https://gateway.your-domain.com/key/generate"
payload = {
"key_alias": "acme-corp",
"models": ["smart-router"],
"max_budget": 25,
"budget_duration": "30d",
"rpm_limit": 120,
"tpm_limit": 200000,
"duration": "90d"
}
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({
key_alias: 'acme-corp',
models: ['smart-router'],
max_budget: 25,
budget_duration: '30d',
rpm_limit: 120,
tpm_limit: 200000,
duration: '90d'
})
};
fetch('https://gateway.your-domain.com/key/generate', 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://gateway.your-domain.com/key/generate",
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([
'key_alias' => 'acme-corp',
'models' => [
'smart-router'
],
'max_budget' => 25,
'budget_duration' => '30d',
'rpm_limit' => 120,
'tpm_limit' => 200000,
'duration' => '90d'
]),
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://gateway.your-domain.com/key/generate"
payload := strings.NewReader("{\n \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\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://gateway.your-domain.com/key/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.your-domain.com/key/generate")
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 \"key_alias\": \"acme-corp\",\n \"models\": [\n \"smart-router\"\n ],\n \"max_budget\": 25,\n \"budget_duration\": \"30d\",\n \"rpm_limit\": 120,\n \"tpm_limit\": 200000,\n \"duration\": \"90d\"\n}"
response = http.request(request)
puts response.read_body{
"key": "sk-5AKAW_A...",
"key_alias": "acme-corp",
"models": [
"smart-router"
],
"max_budget": 25,
"rpm_limit": 120,
"expires": "2026-10-06T14:44:35Z"
}{
"error": {
"message": "Authentication Error, No api key passed in."
}
}Authorizations
A ForceAI virtual key or the master key, sent as Authorization: Bearer <key>.
Body
application/json