🏁/v1/batch/generate-query

Available at https://api.theproductllm.com/v1/batch/filter-search-results

Processes batch query generation for product searches.

This endpoint generates optimized search queries for products. It supports both initial query generation (just product data) and refined query generation (product data with past queries and result sets). Files should contain either all initial OR all refined queries, not mixed.

Required Parameters

  • file: JSONL file upload. Each line must be a valid JSON object with one of the following structures:

Initial Query Format

{
  "product": {
    "title": "string (required)",
    "brand": "string (optional)",
    "code": "string (optional)",
    "description": "string or dict (optional)",
    "id": "string (optional)",
    "price": "string or float (optional)"
  }
}

Refined Query Format (2nd round after initial query generation + search)

{
  "product": {
    "title": "string (required)",
    "brand": "string (optional)",
    "code": "string (optional)",
    "description": "string or dict (optional)",
    "id": "string (optional)",
    "price": "string or float (optional)"
  },
  "past_queries": ["query1", "query2"],
  "result_sets": [
    [
      {"title": "string", "brand": "string"},
      {"title": "string", "brand": "string"}
    ],
    [
      {"title": "string", "brand": "string"}
    ]
  ]
}

Request

import requests

# For initial queries
with open('initial_queries.jsonl', 'rb') as f:
    response = requests.post(
        "https://api.theproductllm.com/v1/batch/generate-query",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        files={"file": f}
    )
print(response.json())

Example JSONL Content (Initial Queries)

{"product": {"title": "Sony WH-1000XM5 Headphones", "brand": "Sony", "description": "Premium wireless noise canceling headphones"}}
{"product": {"title": "Apple MacBook Pro 16-inch", "brand": "Apple", "code": "MK1E3LL/A"}}

Example JSONL Content (Refined Queries)

{"product": {"title": "Sony WH-1000XM5 Headphones", "brand": "Sony"}, "past_queries": ["Sony WH-1000XM5"], "result_sets": [[{"title": "Sony WH-1000XM4", "brand": "Sony"}]]}

Response

{
  "job_id": "550e8400-e29b-41d4-a716-446655440002",
  "total_rows": 2,
  "tokens": 5000,
  "message": "Batch inference job submitted successfully. Processing 2 initial queries.",
}

Last updated