Train Policy Adapter
curl --request POST \
--url https://api.zerodrift.ai/api/policies/import/{import_id}/train \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"cost_cap_usd": 123,
"examples_per_rule": 123
}
'import requests
url = "https://api.zerodrift.ai/api/policies/import/{import_id}/train"
payload = {
"cost_cap_usd": 123,
"examples_per_rule": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({cost_cap_usd: 123, examples_per_rule: 123})
};
fetch('https://api.zerodrift.ai/api/policies/import/{import_id}/train', 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.zerodrift.ai/api/policies/import/{import_id}/train",
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([
'cost_cap_usd' => 123,
'examples_per_rule' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-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://api.zerodrift.ai/api/policies/import/{import_id}/train"
payload := strings.NewReader("{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.zerodrift.ai/api/policies/import/{import_id}/train")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zerodrift.ai/api/policies/import/{import_id}/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}"
response = http.request(request)
puts response.read_body{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"training_run_id": "run-808961af",
"status": "queued",
"message": "Training started. Poll the training status endpoint for progress.",
"poll": {
"method": "GET",
"url": "/api/policies/import/550e8400-e29b-41d4-a716-446655440000/train"
}
}
Training Studio
Train Policy Adapter
Start a Training Studio adapter run from an activated policy import
POST
/
api
/
policies
/
import
/
{import_id}
/
train
Train Policy Adapter
curl --request POST \
--url https://api.zerodrift.ai/api/policies/import/{import_id}/train \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"cost_cap_usd": 123,
"examples_per_rule": 123
}
'import requests
url = "https://api.zerodrift.ai/api/policies/import/{import_id}/train"
payload = {
"cost_cap_usd": 123,
"examples_per_rule": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({cost_cap_usd: 123, examples_per_rule: 123})
};
fetch('https://api.zerodrift.ai/api/policies/import/{import_id}/train', 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.zerodrift.ai/api/policies/import/{import_id}/train",
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([
'cost_cap_usd' => 123,
'examples_per_rule' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-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://api.zerodrift.ai/api/policies/import/{import_id}/train"
payload := strings.NewReader("{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.zerodrift.ai/api/policies/import/{import_id}/train")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zerodrift.ai/api/policies/import/{import_id}/train")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cost_cap_usd\": 123,\n \"examples_per_rule\": 123\n}"
response = http.request(request)
puts response.read_body{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"training_run_id": "run-808961af",
"status": "queued",
"message": "Training started. Poll the training status endpoint for progress.",
"poll": {
"method": "GET",
"url": "/api/policies/import/550e8400-e29b-41d4-a716-446655440000/train"
}
}
Start asynchronous training for an activated policy import. Training Studio
re-reads the import’s original document, generates and judges examples, and
trains a policy-specific LoRA adapter.
Call this after Import Policy
and Activate Rules. Import
extracts candidate rules; training is only accepted once those rules are
activated (
409 if the import is still pending review). Then poll
Get Training Status
until training succeeds or fails.
Training uses the original imported document, not only the extracted rule
definitions. If that document has expired under your retention policy,
re-import and activate the policy before training.
Path Parameters
string
required
The activated policy import to train.
Request Body
The body is optional. Omit it to use Training Studio defaults.number
Optional maximum generation spend in US dollars for this run.
integer
Optional number of generated training examples per extracted rule.
Response
Returns202 Accepted after the training run has been created.
string
Policy import being trained.
string
Training Studio run identifier.
string
Initial status reported for the training run.
string
Human-readable next step, when present.
object
{
"import_id": "550e8400-e29b-41d4-a716-446655440000",
"training_run_id": "run-808961af",
"status": "queued",
"message": "Training started. Poll the training status endpoint for progress.",
"poll": {
"method": "GET",
"url": "/api/policies/import/550e8400-e29b-41d4-a716-446655440000/train"
}
}
Error Responses
| Status | Description |
|---|---|
| 400 | Invalid training options |
| 403 | A full-access API key is required, or the import belongs to another customer |
| 404 | Import not found |
| 409 | Import is not activated, or another training run is already in progress |
| 410 | Original document expired; re-import the policy |
| 422 | Document is too short to train, or Training Studio rejected it |
| 500 | Import state could not be read or updated |
| 502 | Training Studio request failed |
| 503 | Training is not configured in this environment |
Example
cURL
curl -X POST \
"https://api.zerodrift.ai/api/policies/import/550e8400-e29b-41d4-a716-446655440000/train" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'

