Strona główna / AI Writer i opisy produktów przez API

AI Writer i opisy produktów przez API

AI Writer i opisy produktów przez API. Żądania HTTP, parametry, schematy odpowiedzi i procedury Labrika.

W tym artykule

AI Writer

API umożliwia sprawdzenie salda AI Writer, obliczenie kosztu optymalizacji, jej uruchomienie oraz pobranie gotowego dokumentu. Operacje wymagają odrębnych uprawnień: ai-writer:read, ai-optimization:read i ai-optimization:write.

Optymalizacja przebiega asynchronicznie. Zapisz document_id z odpowiedzi na uruchomienie i odpytuj dokument, aż jego status przyjmie wartość success lub error. Gdy stan to pending, użyj retry_after_seconds.
GET /public-api/v1/ai-writer/balance

Zwraca aktualne saldo kredytów. Wymaga uprawnienia ai-writer:read.

Przykładowe żądanie
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/balance'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/balance", {
    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/balance"
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/balance');

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/balance", 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/balance", {
    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());
}
Odpowiedź · 200 OK
{
  "total_credits": 10000
}
Pole Typ Opis
total_credits integer Aktualne saldo AI Writer.
POST /public-api/v1/ai-writer/optimization/cost

Oblicza koszt bez uruchamiania optymalizacji. Wymaga uprawnienia ai-optimization:read. Treść JSON nie może przekraczać 3 MiB.

Przy adjust_text_length=false cena jest obliczana od razu na podstawie przesłanego tekstu. Przy true pierwsze żądanie zwraca 202 z estimate_id, expires_at i retry_after_seconds: zalecenia są przygotowywane bez pobierania kredytów. Powtarzaj to samo żądanie ceny do odpowiedzi 200. Następnie wyślij tę samą treść do /documents, dodając otrzymany estimate_id: zostanie pobrana wyświetlona cena dla zalecanej długości. Wycena jest ważna przez godzinę od rozpoczęcia przygotowania i na jedno uruchomienie; zmiana danych lub ponowne użycie zwraca 409.

Treść JSON
Pole Typ Opis i ograniczenia
keywords string[] Słowa kluczowe używane do analizy wyników wyszukiwania i optymalizacji tekstu. Wymagane: od 1 do 10 słów kluczowych.
search_engine string Wyszukiwarka, której wyniki służą do analizy: google.
region_code string Region wyszukiwania używany do analizy konkurencji. Podaj właściwy identyfikator liczbowy: dla Google — Criteria ID z wykazu kierowania geograficznego .
language string Język optymalizowanego tekstu. Na przykład użyj pl dla języka polskiego. Dopuszczalne kody znajdują się w SiteLanguage.
title string Opcjonalne. Zawartość znacznika HTML title do optymalizacji. Do 256 znaków.
description string Opcjonalne. Zawartość metaznacznika description do optymalizacji. Do 500 znaków.
h1 string Opcjonalne. Tekst nagłówka h1 do optymalizacji. Do 256 znaków.
content string Treść HTML strony do analizy i optymalizacji. Do 512 000 znaków Unicode.
adjust_text_length boolean Określa, czy długość tekstu ma zostać dostosowana do zalecanego zakresu liczby słów. Domyślnie: true.
Przykładowe żądanie
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 '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/optimization/cost'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/cost", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "keywords": [
        "seo audit"
      ],
      "search_engine": "google",
      "region_code": "2840",
      "language": "en",
      "title": "SEO Audit",
      "description": "SEO audit service",
      "h1": "SEO Audit",
      "content": "<p>Run a complete SEO audit of your website.</p>",
      "adjust_text_length": true
    }),
    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/optimization/cost"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\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/optimization/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 => '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true
}',
]);

$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/optimization/cost", strings.NewReader("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\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/optimization/cost", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    payload: "{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\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());
}
Odpowiedź · 200 OK
{
  "estimate_id": "d3k9gp386g2uo3ei6sg0",
  "expires_at": "2026-11-17T12:00:00Z",
  "cost": 120,
  "total_credits": 10000,
  "remaining_credits": 9880,
  "has_enough_credits": true
}
Pole Typ Opis
cost integer Liczba kredytów potrzebnych do uruchomienia optymalizacji.
total_credits integer Aktualne saldo AI Writer.
remaining_credits integer Przewidywane saldo kredytów po uruchomieniu optymalizacji.
has_enough_credits boolean Określa, czy bieżące saldo wystarcza do uruchomienia optymalizacji.
Po przekroczeniu limitu rozmiaru treści żądania API zwraca 413.
POST /public-api/v1/ai-writer/optimization/documents

Uruchamia optymalizację z taką samą treścią JSON jak przy obliczaniu kosztu. Wymaga uprawnienia ai-optimization:write. Opcjonalny nagłówek Idempotency-Key pozwala bezpiecznie ponowić żądanie bez ponownego uruchomienia optymalizacji lub pobrania kredytów. Klucz musi zawierać od 1 do 128 znaków z A-Z a-z 0-9 . _ : -.

Przykładowe żądanie
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: optimization-001' \
  --data '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true,
  "estimate_id": "d3k9gp386g2uo3ei6sg0"
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/optimization/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "optimization-001",
    },
    body: JSON.stringify({
      "keywords": [
        "seo audit"
      ],
      "search_engine": "google",
      "region_code": "2840",
      "language": "en",
      "title": "SEO Audit",
      "description": "SEO audit service",
      "h1": "SEO Audit",
      "content": "<p>Run a complete SEO audit of your website.</p>",
      "adjust_text_length": true,
      "estimate_id": "d3k9gp386g2uo3ei6sg0"
    }),
    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/optimization/documents"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "optimization-001",
}
payload = json.loads("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\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/optimization/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: optimization-001',
    ],
    CURLOPT_POSTFIELDS => '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true,
  "estimate_id": "d3k9gp386g2uo3ei6sg0"
}',
]);

$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/optimization/documents", strings.NewReader("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\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", "optimization-001")

	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/optimization/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "optimization-001",
    },
    payload: "{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\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());
}
Odpowiedź · 202 Accepted
{
  "cost": 120,
  "total_credits": 10000,
  "remaining_credits": 9880,
  "has_enough_credits": true,
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "pending"
}
Pole Typ Opis
cost integer Liczba kredytów pobranych za optymalizację.
total_credits integer Saldo kredytów przed pobraniem opłaty za optymalizację.
remaining_credits integer Saldo kredytów po pobraniu opłaty za optymalizację.
has_enough_credits boolean Określa, czy liczba kredytów wystarczała do uruchomienia optymalizacji.
document_id string Identyfikator uruchomionej optymalizacji. Służy do pobierania stanu i wynikowego dokumentu.
status string Stan początkowy to pending: optymalizacja została przyjęta i jest w toku.
  • 422 — za mało kredytów; odpowiedź zawiera kalkulację kosztu.
  • 409 — sprzeczne ponowne użycie Idempotency-Key.
  • 413 — treść JSON przekracza 3 MiB.
GET /public-api/v1/ai-writer/optimization/documents/{document_id}

Zwraca stan lub wynik optymalizacji. Wymaga uprawnienia ai-optimization:read. W document_id przekaż identyfikator z odpowiedzi na uruchomienie: 20 znaków z zakresu 0-9a-v.

Przykładowe żądanie
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/optimization/documents/01k3m8v7g6c5v4b3n2a1'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1", {
    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/optimization/documents/01k3m8v7g6c5v4b3n2a1"
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/optimization/documents/01k3m8v7g6c5v4b3n2a1');

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/optimization/documents/01k3m8v7g6c5v4b3n2a1", 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/optimization/documents/01k3m8v7g6c5v4b3n2a1", {
    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());
}
Pola odpowiedzi
Pole Typ Opis
document_id string Identyfikator żądanej optymalizacji.
status string Stan optymalizacji: pending — w toku, success — zakończona, error — nieudana.
retry_after_seconds integer Zalecany czas oczekiwania w sekundach przed kolejnym sprawdzeniem stanu. Zwracany dla stanu pending.
progress_percent integer Bieżący postęp optymalizacji od 0 do 100 procent. Może być zwracany dla stanu pending.
title string Zoptymalizowana zawartość elementu HTML title.
description string Zoptymalizowana zawartość metaznacznika description.
h1 string Zoptymalizowany tekst nagłówka h1.
content string Zoptymalizowana treść HTML strony.
credits_spent integer Rzeczywista liczba kredytów AI Writer pobranych po udanej optymalizacji. Zwracana tylko przy status=success.
seo_score number Ocena optymalizacji SEO od 0 do 100, zaokrąglona do dwóch miejsc po przecinku.
recommended_words_min integer Dolna granica zalecanej liczby słów.
recommended_words_max integer Górna granica zalecanej liczby słów.
actual_words integer Rzeczywista liczba słów w zoptymalizowanym tekście.
error_code string Kod błędu optymalizacji do przetwarzania maszynowego. Zwracany przy status=error.
W toku · 200 OK
{
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "pending",
  "retry_after_seconds": 10,
  "progress_percent": 50
}
Zakończona · 200 OK
{
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "success",
  "credits_spent": 120,
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Optimized content.</p>",
  "seo_score": 100,
  "recommended_words_min": 100,
  "recommended_words_max": 140,
  "actual_words": 120
}
Jeśli dokument nie należy do bieżącego użytkownika lub nie istnieje, API zwraca 404. Przy status=error odpowiedź zawiera error_code.

Przed użyciem wyniku AI sprawdź fakty, nazwę firmy lub produktu, język i zgodność z danymi wejściowymi. Przejrzyj wygenerowany HTML przed publikacją. Sukces techniczny nie zastępuje oceny treści.

Powrót do spisu treści

Dokumentacja metod API — AIWriter

Wybierz metodę ze spisu treści. Sprawdź metodę HTTP, ścieżkę, uprawnienia, wymagane parametry i treść żądania. Bloki JSON zawierające schema, properties i $ref opisują kontrakt; nie wysyłaj ich jako gotowej treści żądania. Przykłady żądań i schematy odpowiedzi są oznaczone osobno.

Metody w tej sekcji

GET /public-api/v1/ai-writer/balance

Wymaga zakresu `ai-writer:read`.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterBalance · ErrorResponse

Odpowiedzi

200

Bieżące saldo kredytów AI Writer.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterBalance"
      }
    }
  }
}
default

Bez poprawnego klucza nagłówki limitów dotyczą nieudanych prób z IP. Po uwierzytelnieniu dotyczą klucza lub konta. Mogą być pominięte przy wcześniejszej blokadzie lub niedostępnym liczniku. X-RateLimit-Reset to czas Unix w sekundach; Retry-After przy 429 to opóźnienie w sekundach.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/optimization/cost

Wymaga zakresu `ai-optimization:read`.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationCost · AIWriterOptimizationEstimate · AIWriterOptimizationEstimatePending · AIWriterOptimizationRequest · ErrorResponse

Żądanie

Treść żądania JSON nie może przekraczać 3 MiB (3145728 bajtów).

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationRequest"
      }
    }
  }
}

Odpowiedzi

200

Informacje o koszcie i bieżącym saldzie.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AIWriterOptimizationCost"
          },
          {
            "$ref": "#/components/schemas/AIWriterOptimizationEstimate"
          }
        ]
      }
    }
  }
}
202

Zalecenia są przygotowywane bez pobierania kredytów. Powtórz to samo żądanie obliczenia ceny.

{
  "headers": {
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationEstimatePending"
      }
    }
  }
}
413
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/optimization/documents

Wymaga zakresu `ai-optimization:write`.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationCost · AIWriterOptimizationRequest · AIWriterOptimizationStart · ErrorResponse

Parametry

Idempotency-Key (header)

Opcjonalny klucz do odtwarzania tego samego zakończonego żądania przez 24 godziny.

{
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Żądanie

Treść żądania JSON nie może przekraczać 3 MiB (3145728 bajtów).

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationRequest"
      }
    }
  }
}

Odpowiedzi

202

Optymalizacja przyjęta.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationStart"
      }
    }
  }
}
422

Niewystarczające kredyty AI Writer.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationCost"
      }
    }
  }
}
413
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/optimization/documents/{document_id}

Wymaga zakresu `ai-optimization:read`.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationDocument · ErrorResponse

Parametry

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-v]{20}$"
  }
}
content_view (query)
{
  "schema": {
    "type": "string",
    "enum": [
      "both",
      "plain",
      "annotated"
    ],
    "default": "both"
  }
}

Odpowiedzi

200

Bieżący stan lub wynik optymalizacji.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationDocument"
      }
    }
  }
}
400
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
404
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/expert-articles/cost

Oszacuj maksymalną liczbę kredytów AI na artykuł ekspercki. Wycena jest ważna przez 10 minut.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleEstimate · ExpertArticleInput

Uprawnienia: ai-expert-articles:read

Żądanie

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ExpertArticleInput"
      }
    }
  }
}

Odpowiedzi

200

Oszacuj maksymalną liczbę kredytów AI na artykuł ekspercki. Wycena jest ważna przez 10 minut.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleEstimate"
          }
        }
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/expert-articles/documents

Rozpocznij pisanie artykułu eksperckiego z użyciem wyceny i powiązanego klucza Idempotency-Key. Powtórz to samo żądanie, aby odzyskać pierwotny wynik uruchomienia.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleStart · ExpertArticleStartInput

Uprawnienia: ai-expert-articles:write

Parametry

Idempotency-Key (header)
{
  "required": true,
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Żądanie

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ExpertArticleStartInput"
      }
    }
  }
}

Odpowiedzi

202

Rozpocznij pisanie artykułu eksperckiego z użyciem wyceny i powiązanego klucza Idempotency-Key. Powtórz to samo żądanie, aby odzyskać pierwotny wynik uruchomienia.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleStart"
          }
        }
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
422
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/expert-articles/documents/{document_id}

Sprawdź postęp artykułu eksperckiego i pobierz wygenerowany HTML po zakończeniu.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleResult

Uprawnienia: ai-expert-articles:read

Parametry

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-v]{20}$"
  }
}

Odpowiedzi

200

Sprawdź postęp artykułu eksperckiego i pobierz wygenerowany HTML po zakończeniu.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleResult"
          }
        }
      }
    }
  }
}
404
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

Przed użyciem wyniku AI sprawdź fakty, nazwę firmy lub produktu, język i zgodność z danymi wejściowymi. Przejrzyj wygenerowany HTML przed publikacją. Sukces techniczny nie zastępuje oceny treści.

Powrót do spisu treści

Opisy produktów

Twórz opisy katalogowe na podstawie nazwy i cech produktu. API zwraca HTML, tytuł strony, metaopis i H1. Generowanie działa w tle: oszacuj koszt, utwórz dokument i pobierz wynik według identyfikatora.

Wszystkie trzy pola są wymagane w treści JSON obu żądań POST. Wyślij Content-Type: application/json. Limit to 16 KiB. Tworzenie wymaga ai-product-descriptions:write, wycena i odczyt wyniku — ai-product-descriptions:read.

Parametr Opis
title · string Nazwa i najważniejsze cechy: 1–256 znaków. Podaj model, materiał, rozmiar lub przeznaczenie, aby umożliwić rozpoznanie produktu.
language · string Kod języka z tabeli poniżej. To pole określa język wyniku.
word_count · integer Wartości parametru i docelowa długość: 400 → 400–600 słów; 600 → 600–800 słów; 800 → 800–1200 słów. Rzeczywista liczba słów jest zwracana w actual_words.

Obsługiwane języki

Użyj pl, aby wygenerować opis po polsku. Dopuszczalne kody języków znajdują się w ProductDescriptionRequest.

POST /public-api/v1/ai-writer/product-descriptions/cost

Szacuje koszt bez uruchamiania generowania i wydawania kredytów. Zwraca cost, total_credits, remaining_credits i has_enough_credits. Sprawdź has_enough_credits przed utworzeniem dokumentu; wycena nie rezerwuje salda.

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

Uruchamia generowanie. Użyj unikalnego Idempotency-Key dla nowego dokumentu. HTTP 202 zwraca document_id, status, cost i has_enough_credits. Zachowaj document_id do pobrania wyniku.

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}

Przy pending ponów GET po retry_after_seconds (zwykle 10 sekund). Przy success: content (HTML), title, description, h1, actual_words i credits_spent. Przy error odczytaj error_code; credits_spent wynosi 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());
}
Jeśli odpowiedź POST zaginie, ponów żądanie z tym samym kluczem API, Idempotency-Key i treścią. Zapisana odpowiedź jest zwracana przez 24 godziny. Inna treść lub niezakończone żądanie daje HTTP 409. Po braku kredytów doładuj saldo i użyj nowego klucza.
product_not_recognized: doprecyzuj nazwę i cechy. product_description_failed: generowanie nie powiodło się. Znany błąd rozpoznania może od razu zwrócić HTTP 422 i jest zapamiętywany na 7 dni dla tego samego produktu. Nowy klucz nie omija tej pamięci podręcznej.
Kredyty AI są rezerwowane na początku. Po sukcesie credits_spent pokazuje rzeczywiste zużycie, a niewykorzystana rezerwa jest zwracana. Błędy generowania nie zużywają kredytów.

Przed użyciem wyniku AI sprawdź fakty, nazwę firmy lub produktu, język i zgodność z danymi wejściowymi. Przejrzyj wygenerowany HTML przed publikacją. Sukces techniczny nie zastępuje oceny treści.

Powrót do spisu treści

Piaskownica API: testowanie integracji — Opisy produktów

Ta instrukcja dotyczy środowiska testowego. W każdym kroku używaj klucza TEST i /public-api-test/v1. Przykłady symulują wyniki; nie uruchamiają rzeczywistej generacji ani opłat na koncie produkcyjnym.

Twórz opisy katalogowe na podstawie nazwy i cech produktu. API zwraca HTML, tytuł strony, metaopis i H1. Generowanie działa w tle: oszacuj koszt, utwórz dokument i pobierz wynik według identyfikatora.

Wszystkie trzy pola są wymagane w treści JSON obu żądań POST. Wyślij Content-Type: application/json. Limit to 16 KiB. Tworzenie wymaga ai-product-descriptions:write, wycena i odczyt wyniku — ai-product-descriptions:read.

Parametr Opis
title · string Nazwa i najważniejsze cechy: 1–256 znaków. Podaj model, materiał, rozmiar lub przeznaczenie, aby umożliwić rozpoznanie produktu.
language · string Kod języka z tabeli poniżej. To pole określa język wyniku.
word_count · integer Wartości parametru i docelowa długość: 400 → 400–600 słów; 600 → 600–800 słów; 800 → 800–1200 słów. Rzeczywista liczba słów jest zwracana w actual_words.

Obsługiwane języki

Użyj pl, aby wygenerować opis po polsku. Dopuszczalne kody języków znajdują się w ProductDescriptionRequest.

POST /public-api-test/v1/ai-writer/product-descriptions/cost

Szacuje koszt bez uruchamiania generowania i wydawania kredytów. Zwraca cost, total_credits, remaining_credits i has_enough_credits. Sprawdź has_enough_credits przed utworzeniem dokumentu; wycena nie rezerwuje salda.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/cost'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/cost"
headers = {
    "Authorization": "Bearer YOUR_TEST_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-test/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_TEST_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-test/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_TEST_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-test/v1/ai-writer/product-descriptions/cost", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents

Uruchamia generowanie. Użyj unikalnego Idempotency-Key dla nowego dokumentu. HTTP 202 zwraca document_id, status, cost i has_enough_credits. Zachowaj document_id do pobrania wyniku.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents"
headers = {
    "Authorization": "Bearer YOUR_TEST_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-test/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_TEST_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-test/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_TEST_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-test/v1/ai-writer/product-descriptions/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents/{document_id}

Przy pending ponów GET po retry_after_seconds (zwykle 10 sekund). Przy success: content (HTML), title, description, h1, actual_words i credits_spent. Przy error odczytaj error_code; credits_spent wynosi 0.

curl
curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID"
headers = {
    "Authorization": "Bearer YOUR_TEST_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-test/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_TEST_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-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_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-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_TEST_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());
}
Jeśli odpowiedź POST zaginie, ponów żądanie z tym samym kluczem API, Idempotency-Key i treścią. Zapisana odpowiedź jest zwracana przez 24 godziny. Inna treść lub niezakończone żądanie daje HTTP 409. Po braku kredytów doładuj saldo i użyj nowego klucza.
product_not_recognized: doprecyzuj nazwę i cechy. product_description_failed: generowanie nie powiodło się. Znany błąd rozpoznania może od razu zwrócić HTTP 422 i jest zapamiętywany na 7 dni dla tego samego produktu. Nowy klucz nie omija tej pamięci podręcznej.
Kredyty AI są rezerwowane na początku. Po sukcesie credits_spent pokazuje rzeczywiste zużycie, a niewykorzystana rezerwa jest zwracana. Błędy generowania nie zużywają kredytów.

W trybie testowym użyj tych wartości title, aby odtworzyć błędy. Dla każdego scenariusza użyj nowego Idempotency-Key.

title Wynik
sandbox:product_not_recognized Natychmiast HTTP 422
sandbox:async_product_not_recognized pending, następnie error product_not_recognized
sandbox:product_description_failed pending, następnie error product_description_failed
curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: sandbox-product-not-recognized-v1' \
  --data '{
  "title": "sandbox:product_not_recognized",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "sandbox-product-not-recognized-v1",
    },
    body: JSON.stringify({
      "title": "sandbox:product_not_recognized",
      "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-test/v1/ai-writer/product-descriptions/documents"
headers = {
    "Authorization": "Bearer YOUR_TEST_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "sandbox-product-not-recognized-v1",
}
payload = json.loads("{\n  \"title\": \"sandbox:product_not_recognized\",\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-test/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_TEST_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: sandbox-product-not-recognized-v1',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "sandbox:product_not_recognized",
  "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-test/v1/ai-writer/product-descriptions/documents", strings.NewReader("{\n  \"title\": \"sandbox:product_not_recognized\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Idempotency-Key", "sandbox-product-not-recognized-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-test/v1/ai-writer/product-descriptions/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "sandbox-product-not-recognized-v1",
    },
    payload: "{\n  \"title\": \"sandbox:product_not_recognized\",\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());
}

Przed użyciem wyniku AI sprawdź fakty, nazwę firmy lub produktu, język i zgodność z danymi wejściowymi. Przejrzyj wygenerowany HTML przed publikacją. Sukces techniczny nie zastępuje oceny treści.

Powrót do spisu treści

Dokumentacja metod API — ProductDescriptions

Wybierz metodę ze spisu treści. Sprawdź metodę HTTP, ścieżkę, uprawnienia, wymagane parametry i treść żądania. Bloki JSON zawierające schema, properties i $ref opisują kontrakt; nie wysyłaj ich jako gotowej treści żądania. Przykłady żądań i schematy odpowiedzi są oznaczone osobno.

Metody w tej sekcji

POST /public-api/v1/ai-writer/product-descriptions/cost

Wymaga zakresu ai-product-descriptions:read klucza i uprawnienia konta public-api-product-descriptions.show. Wariant testowy jest dostępny z kluczem test pod /public-api-test/v1 z takim samym sufiksem ścieżki. Sandbox korzysta z danych testowych, bez AI i rzeczywistych opłat. Zwykła nazwa produktu zwraca sukces; sandbox:product_not_recognized zwraca 422; sandbox:async_product_not_recognized i sandbox:product_description_failed zwracają odpowiedni błąd po pending. Dokumenty testowe są dostępne przez 7 dni lub do zresetowania sandboxa, zależnie od tego, co nastąpi wcześniej.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionCost · ProductDescriptionRequest

Żądanie

Treść JSON o rozmiarze do 16384 bajtów.

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionRequest"
      }
    }
  }
}

Odpowiedzi

200

Bieżący wynik; oszacowanie kosztu nie rezerwuje ani nie zużywa kredytów.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionCost"
      }
    }
  }
}
default

Bez poprawnego klucza nagłówki limitów dotyczą nieudanych prób z IP. Po uwierzytelnieniu dotyczą klucza lub konta. Mogą być pominięte przy wcześniejszej blokadzie lub niedostępnym liczniku. X-RateLimit-Reset to czas Unix w sekundach; Retry-After przy 429 to opóźnienie w sekundach.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/product-descriptions/documents

Wymaga zakresu ai-product-descriptions:write klucza i uprawnienia konta public-api-product-descriptions.show. Wariant testowy jest dostępny z kluczem test pod /public-api-test/v1 z takim samym sufiksem ścieżki. Sandbox korzysta z danych testowych, bez AI i rzeczywistych opłat. Zwykła nazwa produktu zwraca sukces; sandbox:product_not_recognized zwraca 422; sandbox:async_product_not_recognized i sandbox:product_description_failed zwracają odpowiedni błąd po pending. Dokumenty testowe są dostępne przez 7 dni lub do zresetowania sandboxa, zależnie od tego, co nastąpi wcześniej.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionCost · ProductDescriptionRejected · ProductDescriptionRequest · ProductDescriptionStart

Parametry

Idempotency-Key (header)

Wymagany do płatnego generowania. Przez 24 godziny odtwarza odpowiedź dla tego samego klucza, trasy i identycznej treści żądania. Inna treść zwraca 409. Równoczesne żądania i uruchomienia o niepewnym wyniku pozostają zablokowane z 409; nie ponawiaj żądania z nowym kluczem.

{
  "required": true,
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Żądanie

Treść JSON o rozmiarze do 16384 bajtów.

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionRequest"
      }
    }
  }
}

Odpowiedzi

202

Generowanie przyjęte; koszt jest zarezerwowaną górną granicą.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionStart"
      }
    }
  }
}
422

Niewystarczające kredyty lub nieudane rozpoznanie produktu zapisane w pamięci podręcznej w ciągu ostatnich 7 dni (error.code=product_not_recognized, credits_spent=0). Generowanie nie rozpoczyna się. Po zmianie parametrów lub doładowaniu salda użyj nowego Idempotency-Key.

{
  "content": {
    "application/json": {
      "schema": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ProductDescriptionCost"
          },
          {
            "$ref": "#/components/schemas/ProductDescriptionRejected"
          }
        ]
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/product-descriptions/documents/{document_id}

Wymaga zakresu ai-product-descriptions:read klucza i uprawnienia konta public-api-product-descriptions.show. Wariant testowy jest dostępny z kluczem test pod /public-api-test/v1 z takim samym sufiksem ścieżki. Sandbox korzysta z danych testowych, bez AI i rzeczywistych opłat. Zwykła nazwa produktu zwraca sukces; sandbox:product_not_recognized zwraca 422; sandbox:async_product_not_recognized i sandbox:product_description_failed zwracają odpowiedni błąd po pending. Dokumenty testowe są dostępne przez 7 dni lub do zresetowania sandboxa, zależnie od tego, co nastąpi wcześniej.

Powiązane modele danych: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionDocument

Parametry

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string"
  }
}

Odpowiedzi

200

Stan opisu produktu właściciela. Wyniki pending sprawdź ponownie po 10 sekundach.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionDocument"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

Przed użyciem wyniku AI sprawdź fakty, nazwę firmy lub produktu, język i zgodność z danymi wejściowymi. Przejrzyj wygenerowany HTML przed publikacją. Sukces techniczny nie zastępuje oceny treści.

Powrót do spisu treści