Producks AI - API Endpoint Documentation


Generate Product Description

Endpoint

POST https://producks.ai/api/generate

Description

This API endpoint generates a product description based on the photo provided along with additional details and tone preferences.

Request Parameters

  • token (string, required): Authentication token for accessing the API.
  • details (string, optional): Any additional details for the product in the photo.
  • tone (string, optional): Tone preference for the generated description. Valid values are:
    • 0: neutral
    • 1: focused on brand building
    • 2: persuasive sales technique
    • 3: focused on need-satisfaction
    • 4: focused on hard-sell techniques

Request Body

file (file, required): The photo file of the product for which the description needs to be generated. (Supported formats: JPEG, PNG)


Example Request (Python)


    import requests

    url = "https://producks.ai/api/generate"

    payload = {
        'token': 'Your token goes here',
        'details': 'Any additional detail for the product in the photo',
        'tone': '0'
    }

    # file abc.jpg in the current folder
    files = [
        ('file', ('abc.jpg', open('abc.jpg', 'rb'), 'image/jpeg'))
    ]

    response = requests.request("POST", url, data=payload, files=files)

    print(response.text)

Example Request (PHP)

    
    $url = 'https://producks.ai/api/generate';

    $payload = array(
        'token' => 'Your token goes here',
        'details' => 'Any additional detail for the product in the photo',
        'tone' => '0'
    );

    // Assuming abc.jpg is in the current folder
    $files = array(
        'file' => curl_file_create('abc.jpg', 'image/jpeg', 'abc.jpg')
    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array_merge($payload, $files));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));

    $response = curl_exec($ch);

    curl_close($ch);

    echo $response;

    
    

Response

Upon successful request, the API responds with a JSON object containing the following fields:

  • title (string): Generated product title.
  • description (string): Generated product description.
  • image_url (string): URL of the product photo used for generating the description.

Example Response

{
    "title": "Product Title Generated",
    "description": "Product Description generated",
    "image_url": "Product photo URL"
}

Error Responses

  • HTTP Status Code 401: Unauthorized - Invalid or missing authentication token.
  • HTTP Status Code 400: Bad Request - Invalid parameters or missing required fields.

Notes

  • Ensure that the photo file is provided in the request and is of supported format (JPEG, PNG).
  • Tone preference is optional. If not provided, the default tone (neutral) will be used for generating the description.