Strona główna / Testowanie opisów produktów

Testowanie opisów produktów

Sprawdź generowanie opisów z kluczem TEST i adresem testowym. Odpowiedzi są symulowane i nie powodują opłat na koncie produkcyjnym.

Na tej stronie

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.