Shorten Prompt
curl --request POST \
--url https://api.legnext.ai/api/v1/shorten \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"prompt": "<string>",
"callback": "<string>"
}
'import requests
url = "https://api.legnext.ai/api/v1/shorten"
payload = {
"prompt": "<string>",
"callback": "<string>"
}
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({prompt: '<string>', callback: '<string>'})
};
fetch('https://api.legnext.ai/api/v1/shorten', 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.legnext.ai/api/v1/shorten",
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' => '<string>',
'callback' => '<string>'
]),
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.legnext.ai/api/v1/shorten"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\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.legnext.ai/api/v1/shorten")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.legnext.ai/api/v1/shorten")
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 \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 400,
"message": "Invalid request parameters",
"raw_message": "Invalid request parameters",
"detail": null
}{
"code": 401,
"message": "Failed to verify api key",
"raw_message": "",
"detail": null
}{
"code": 402,
"message": "insufficient quota",
"raw_message": "insufficient quota",
"detail": null
}{
"code": 403,
"message": "Forbidden - Sensitive content detected",
"raw_message": "Forbidden - Sensitive content detected",
"detail": null
}{
"code": 413,
"message": "File size exceeds maximum limit",
"raw_message": "file too large",
"detail": null
}{
"code": 422,
"message": "Invalid parameter values",
"raw_message": "Invalid parameter values",
"detail": null
}{
"code": 429,
"message": "rate limit exceeded, please retry later",
"raw_message": "rate limit exceeded, please retry later",
"detail": null
}{
"code": 500,
"message": "Internal server error",
"raw_message": "Internal server error",
"detail": null
}Image Generation
Shorten
Simplify prompts to essential elements
POST
/
v1
/
shorten
Shorten Prompt
curl --request POST \
--url https://api.legnext.ai/api/v1/shorten \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"prompt": "<string>",
"callback": "<string>"
}
'import requests
url = "https://api.legnext.ai/api/v1/shorten"
payload = {
"prompt": "<string>",
"callback": "<string>"
}
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({prompt: '<string>', callback: '<string>'})
};
fetch('https://api.legnext.ai/api/v1/shorten', 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.legnext.ai/api/v1/shorten",
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' => '<string>',
'callback' => '<string>'
]),
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.legnext.ai/api/v1/shorten"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\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.legnext.ai/api/v1/shorten")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.legnext.ai/api/v1/shorten")
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 \"prompt\": \"<string>\",\n \"callback\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 400,
"message": "Invalid request parameters",
"raw_message": "Invalid request parameters",
"detail": null
}{
"code": 401,
"message": "Failed to verify api key",
"raw_message": "",
"detail": null
}{
"code": 402,
"message": "insufficient quota",
"raw_message": "insufficient quota",
"detail": null
}{
"code": 403,
"message": "Forbidden - Sensitive content detected",
"raw_message": "Forbidden - Sensitive content detected",
"detail": null
}{
"code": 413,
"message": "File size exceeds maximum limit",
"raw_message": "file too large",
"detail": null
}{
"code": 422,
"message": "Invalid parameter values",
"raw_message": "Invalid parameter values",
"detail": null
}{
"code": 429,
"message": "rate limit exceeded, please retry later",
"raw_message": "rate limit exceeded, please retry later",
"detail": null
}{
"code": 500,
"message": "Internal server error",
"raw_message": "Internal server error",
"detail": null
}Headers
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key | string | Yes | Your API key |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The prompt to analyze and shorten (1-8192 characters) |
callback | string | No | Callback URL for task completion notifications |
Example Request
curl -X POST "https://api.legnext.ai/api/v1/shorten" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cyberpunk hacker workspace filled with holographic screens, glowing code streams, mechanical keyboards, neon reflections, cables and circuit boards everywhere, volumetric lighting, ultra-detailed sci-fi aesthetic, cinematic atmosphere, inspired by Ghost in the Shell and Blade Runner, rendered in octane, 8k resolution --ar 21:9 --v 7 --style raw --q 2",
"callback": "https://webhook.site/your-webhook-id"
}'
import requests
url = "https://api.legnext.ai/api/v1/shorten"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"prompt": "A cyberpunk hacker workspace filled with holographic screens, glowing code streams, mechanical keyboards, neon reflections, cables and circuit boards everywhere, volumetric lighting, ultra-detailed sci-fi aesthetic, cinematic atmosphere, inspired by Ghost in the Shell and Blade Runner, rendered in octane, 8k resolution --ar 21:9 --v 7 --style raw --q 2",
"callback": "https://webhook.site/your-webhook-id"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result)
# Query result
job_id = result["job_id"]
query_url = f"https://api.legnext.ai/api/v1/job/{job_id}"
result = requests.get(query_url, headers={"x-api-key": "YOUR_API_KEY"})
output = result.json()["output"]
print("Shortened prompts:", output["prompts"])
const response = await fetch('https://api.legnext.ai/api/v1/shorten', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'A cyberpunk hacker workspace filled with holographic screens, glowing code streams, mechanical keyboards, neon reflections, cables and circuit boards everywhere, volumetric lighting, ultra-detailed sci-fi aesthetic, cinematic atmosphere, inspired by Ghost in the Shell and Blade Runner, rendered in octane, 8k resolution --ar 21:9 --v 7 --style raw --q 2',
callback: 'https://webhook.site/your-webhook-id'
})
});
const result = await response.json();
console.log(result);
// Poll for result
const jobId = result.job_id;
let output;
while (true) {
const queryResponse = await fetch(
`https://api.legnext.ai/api/v1/job/${jobId}`,
{
headers: { 'x-api-key': 'YOUR_API_KEY' }
}
);
const data = await queryResponse.json();
if (data.status === 'completed') {
output = data.output;
break;
}
await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 5 seconds
}
console.log('Shortened prompts:', output.prompts);
Response
Returns a task object containing the task information.{
"job_id": "48833d7a-d588-4ad9-897b-25e1ea9edff7",
"model": "midjourney",
"task_type": "shorten",
"status": "pending",
"config": {
"service_mode": "public",
"webhook_config": {
"endpoint": "",
"secret": ""
}
},
"input": null,
"output": {
"promptEn": "",
"description": "",
"finalPrompt": "",
"prompts": []
},
"meta": {
"created_at": "",
"started_at": "",
"ended_at": "",
"usage": {
"type": "point",
"frozen": 20,
"consume": 0
}
},
"detail": null,
"logs": [],
"error": {
"code": 0,
"raw_message": "",
"message": "",
"detail": null
}
}
This is the initial success response. Use the
job_id to check the task status via the Get Task endpoint to retrieve the completed result with shortened prompts.⌘I