Product descriptions: workflow
Create descriptions from a product name and its attributes. Follow the steps from a cost estimate to HTML, page title, meta description and H1.
On this page
- Supported languages
- POST /public-api/v1/ai-writer/product-descriptions/cost
- POST /public-api/v1/ai-writer/product-descriptions/documents
- GET /public-api/v1/ai-writer/product-descriptions/documents/{document_id}
Generate catalog product descriptions from a product name and its features. The API returns HTML content, a page title, a meta description, and H1. Generation runs in the background: estimate the cost, create a document, then retrieve the result by its identifier.
All three fields are required in the JSON body of both POST requests. Send Content-Type: application/json. The body limit is 16 KiB. Creation requires ai-product-descriptions:write; estimation and reading the result require ai-product-descriptions:read.
| Parameter | Description |
|---|---|
title · string | Product name and key features: 1–256 characters. Include the model, material, size, or intended use to help identify the product. |
language · string | A language code from the reference below. This field determines the output language. |
word_count · integer |
Parameter values and target lengths: 400 → 400–600 words; 600 → 600–800 words; 800 → 800–1200 words. The actual word count is returned in actual_words.
|
Supported languages
Use en to generate an English description. The accepted language codes are listed in ProductDescriptionRequest.
POST /public-api/v1/ai-writer/product-descriptions/cost
Estimates the cost without starting generation or spending credits. The response contains cost, total_credits, remaining_credits, and has_enough_credits. Check has_enough_credits before creating the document; an estimate does not reserve the balance.
curl
curl --fail-with-body --silent --show-error --location \
--request POST \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}' \
'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost'
JavaScript
async function main () {
const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}),
signal: AbortSignal.timeout(30_000),
})
if (!response.ok) {
const responseText = await response.text()
throw new Error(`HTTP ${response.status}: ${responseText}`)
}
const responseText = await response.text()
const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText
console.log(data)
}
main().catch(error => {
console.error(error)
process.exitCode = 1
})
Python
import json
import requests
url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
}
payload = json.loads("{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}")
response = requests.request(
"POST",
url,
headers=headers,
json=payload,
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php
$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost');
if ($curl === false) {
throw new RuntimeException('Unable to initialize cURL');
}
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => '{
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}',
]);
$response = curl_exec($curl);
if ($response === false) {
$message = curl_error($curl);
curl_close($curl);
throw new RuntimeException('Network error: ' . $message);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $response");
}
if ($response !== '' && str_contains($contentType, 'application/json')) {
print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
echo $response;
}
Go
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
defer cancel()
request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", strings.NewReader("{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}"))
if err != nil {
panic(err)
}
request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
request.Header.Set("Accept", "application/json")
request.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
errorBody, readErr := io.ReadAll(response.Body)
if readErr != nil {
panic(readErr)
}
panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
}
if _, err := io.Copy(os.Stdout, response.Body); err != nil {
panic(err)
}
}
Google Apps Script
function callLabrikaPublicAPI() {
const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", {
method: "post",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
},
payload: "{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}",
followRedirects: false,
muteHttpExceptions: true,
});
const status = response.getResponseCode();
if (status < 200 || status >= 300) {
throw new Error('HTTP ' + status + ': ' + response.getContentText());
}
Logger.log(response.getContentText());
}
POST /public-api/v1/ai-writer/product-descriptions/documents
Starts generation. Send a unique Idempotency-Key for each new document. HTTP 202 returns document_id, status, cost, and has_enough_credits. Save document_id to retrieve the result.
curl
curl --fail-with-body --silent --show-error --location \
--request POST \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: product-123-description-v1' \
--data '{
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}' \
'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "product-123-description-v1",
},
body: JSON.stringify({
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}),
signal: AbortSignal.timeout(30_000),
})
if (!response.ok) {
const responseText = await response.text()
throw new Error(`HTTP ${response.status}: ${responseText}`)
}
const responseText = await response.text()
const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText
console.log(data)
}
main().catch(error => {
console.error(error)
process.exitCode = 1
})
Python
import json
import requests
url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "product-123-description-v1",
}
payload = json.loads("{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}")
response = requests.request(
"POST",
url,
headers=headers,
json=payload,
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php
$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents');
if ($curl === false) {
throw new RuntimeException('Unable to initialize cURL');
}
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Accept: application/json',
'Content-Type: application/json',
'Idempotency-Key: product-123-description-v1',
],
CURLOPT_POSTFIELDS => '{
"title": "Ceramic coffee mug, 350 ml, dishwasher safe",
"language": "en",
"word_count": 400
}',
]);
$response = curl_exec($curl);
if ($response === false) {
$message = curl_error($curl);
curl_close($curl);
throw new RuntimeException('Network error: ' . $message);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $response");
}
if ($response !== '' && str_contains($contentType, 'application/json')) {
print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
echo $response;
}
Go
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
defer cancel()
request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", strings.NewReader("{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}"))
if err != nil {
panic(err)
}
request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
request.Header.Set("Accept", "application/json")
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Idempotency-Key", "product-123-description-v1")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
errorBody, readErr := io.ReadAll(response.Body)
if readErr != nil {
panic(readErr)
}
panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
}
if _, err := io.Copy(os.Stdout, response.Body); err != nil {
panic(err)
}
}
Google Apps Script
function callLabrikaPublicAPI() {
const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", {
method: "post",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "product-123-description-v1",
},
payload: "{\n \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n \"language\": \"en\",\n \"word_count\": 400\n}",
followRedirects: false,
muteHttpExceptions: true,
});
const status = response.getResponseCode();
if (status < 200 || status >= 300) {
throw new Error('HTTP ' + status + ': ' + response.getContentText());
}
Logger.log(response.getContentText());
}
GET /public-api/v1/ai-writer/product-descriptions/documents/{document_id}
For pending, repeat GET after retry_after_seconds (normally 10 seconds). For success, the response includes content (HTML), title, description, h1, actual_words, and credits_spent. For error, read error_code; credits_spent is 0.
curl
curl --fail-with-body --silent --show-error --location \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Accept: application/json' \ 'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID'
JavaScript
async function main () {
const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
})
if (!response.ok) {
const responseText = await response.text()
throw new Error(`HTTP ${response.status}: ${responseText}`)
}
const responseText = await response.text()
const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText
console.log(data)
}
main().catch(error => {
console.error(error)
process.exitCode = 1
})
Python
import json
import requests
url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
}
response = requests.request(
"GET",
url,
headers=headers,
timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php
$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID');
if ($curl === false) {
throw new RuntimeException('Unable to initialize cURL');
}
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Accept: application/json',
],
]);
$response = curl_exec($curl);
if ($response === false) {
$message = curl_error($curl);
curl_close($curl);
throw new RuntimeException('Network error: ' . $message);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $response");
}
if ($response !== '' && str_contains($contentType, 'application/json')) {
print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
echo $response;
}
Go
package main
import (
"context"
"fmt"
"io"
"net/http"
"os"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
defer cancel()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", nil)
if err != nil {
panic(err)
}
request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil {
panic(err)
}
defer response.Body.Close()
if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
errorBody, readErr := io.ReadAll(response.Body)
if readErr != nil {
panic(readErr)
}
panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
}
if _, err := io.Copy(os.Stdout, response.Body); err != nil {
panic(err)
}
}
Google Apps Script
function callLabrikaPublicAPI() {
const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
method: "get",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Accept": "application/json",
},
followRedirects: false,
muteHttpExceptions: true,
});
const status = response.getResponseCode();
if (status < 200 || status >= 300) {
throw new Error('HTTP ' + status + ': ' + response.getContentText());
}
Logger.log(response.getContentText());
}
If the POST response is lost, retry with the same API key, Idempotency-Key, and unchanged body. The saved response is returned for 24 hours. A different body or an unfinished request returns HTTP 409. After an insufficient-credit response, add credits and use a new key.
product_not_recognized: clarify the product name and features. product_description_failed: generation failed. A known recognition failure may return HTTP 422 immediately; identical unrecognized products are cached for 7 days. A new key does not bypass this cache.
AI credits are reserved when generation starts. On success, credits_spent reports actual usage and unused reserved credits are returned. Failed generation does not spend credits.
Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.
