Generate Script from Prompt
curl --request POST \
--url https://v1.api.altostrat.io/scripts/gen-ai \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "Create a firewall rule to block all incoming traffic on port 22 from the internet."
}
'import requests
url = "https://v1.api.altostrat.io/scripts/gen-ai"
payload = { "prompt": "Create a firewall rule to block all incoming traffic on port 22 from the internet." }
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({
prompt: 'Create a firewall rule to block all incoming traffic on port 22 from the internet.'
})
};
fetch('https://v1.api.altostrat.io/scripts/gen-ai', 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://v1.api.altostrat.io/scripts/gen-ai",
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([
'prompt' => 'Create a firewall rule to block all incoming traffic on port 22 from the internet.'
]),
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://v1.api.altostrat.io/scripts/gen-ai"
payload := strings.NewReader("{\n \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\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://v1.api.altostrat.io/scripts/gen-ai")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v1.api.altostrat.io/scripts/gen-ai")
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 \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\n}"
response = http.request(request)
puts response.read_body{
"response": [
{
"content": "/ip firewall filter add action=drop chain=input in-interface=ether1 protocol=tcp dst-port=22;",
"error": null,
"destructive": true
}
],
"tokenUsage": {
"prompt": 75,
"completion": 30,
"total": 105
},
"response_id": "cmpl-8fV3x5m7y6z4w3v2u1t0s"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}AI Script Generation
Generate Script from Prompt
Submits a natural language prompt to the AI engine to generate a MikroTik RouterOS script. The response includes the generated script content, a flag indicating if the script is potentially destructive, and any errors or warnings from the AI.
POST
/
scripts
/
gen-ai
Generate Script from Prompt
curl --request POST \
--url https://v1.api.altostrat.io/scripts/gen-ai \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "Create a firewall rule to block all incoming traffic on port 22 from the internet."
}
'import requests
url = "https://v1.api.altostrat.io/scripts/gen-ai"
payload = { "prompt": "Create a firewall rule to block all incoming traffic on port 22 from the internet." }
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({
prompt: 'Create a firewall rule to block all incoming traffic on port 22 from the internet.'
})
};
fetch('https://v1.api.altostrat.io/scripts/gen-ai', 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://v1.api.altostrat.io/scripts/gen-ai",
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([
'prompt' => 'Create a firewall rule to block all incoming traffic on port 22 from the internet.'
]),
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://v1.api.altostrat.io/scripts/gen-ai"
payload := strings.NewReader("{\n \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\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://v1.api.altostrat.io/scripts/gen-ai")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v1.api.altostrat.io/scripts/gen-ai")
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 \"prompt\": \"Create a firewall rule to block all incoming traffic on port 22 from the internet.\"\n}"
response = http.request(request)
puts response.read_body{
"response": [
{
"content": "/ip firewall filter add action=drop chain=input in-interface=ether1 protocol=tcp dst-port=22;",
"error": null,
"destructive": true
}
],
"tokenUsage": {
"prompt": 75,
"completion": 30,
"total": 105
},
"response_id": "cmpl-8fV3x5m7y6z4w3v2u1t0s"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}{
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "The 'name' parameter is required for this request.",
"doc_url": "https://docs.altostrat.io/errors/parameter_missing"
}Authorizations
Altostrat SDX API uses JWT Bearer tokens for authentication. Obtain a token via the Authentication API and include it in the Authorization header as 'Bearer {token}'.
Body
application/json
The natural language prompt describing the desired script.
Maximum string length:
200Example:
"Create a firewall rule to block all incoming traffic on port 22 from the internet."
Was this page helpful?
⌘I