> ## Documentation Index
> Fetch the complete documentation index at: https://docs.searchcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Product LLMs.txt

Generate `/llms/{product-slug}.txt` files for products and deploy to Vercel.

<Warning>
  **Standalone endpoint for manual use only.** The cron job does NOT call this endpoint directly.
  Instead, `discover-products` calls `generate_product_llms_txt` internally for new products.
</Warning>

## Use Cases

* Regenerate product llms after content updates (manual)
* Backfill llms files for products that were created without them
* Manual trigger to refresh product llms content
* Debugging and testing llms generation

## Request Body

| Field         | Type   | Required | Description                                                                   |
| ------------- | ------ | -------- | ----------------------------------------------------------------------------- |
| `business_id` | string | Yes      | Clerk org ID                                                                  |
| `product_ids` | array  | No       | Specific product IDs to generate for. If omitted, generates for ALL products. |

## Response

```json theme={null}
{
  "status": "success",
  "products_processed": 5,
  "files_generated": 5,
  "files_deployed": 5,
  "products": ["Product A", "Product B", "Product C", "Product D", "Product E"]
}
```

## How It Works

```
1. Fetch business entity and AI site project_name
2. Fetch products (all or filtered by product_ids)
3. For each product:
   - Get source_urls from entities.product_source_urls
   - Generate /llms/{slug}.txt content using Gemini
4. Deploy all generated files to Vercel (single deployment)
5. Return summary
```

## Shared Service

This endpoint uses the shared `generate_product_llms_txt` service:

```
src/app/shared/products/generate_llms_txt.py
```

The same service is used by:

* **Onboarding** (GROUP 3b)
* **Cron** (`discover-products`)

## Product LLMs Architecture

| File          | Location                   | Purpose                                  |
| ------------- | -------------------------- | ---------------------------------------- |
| Root llms.txt | `/llms.txt`                | Business overview, key details, FAQs     |
| Product llms  | `/llms/{product-slug}.txt` | Detailed product info, features, pricing |

This architecture scales to thousands of products:

* Root `llms.txt` stays small (\~3KB)
* Each product gets its own file (\~1-2KB)
* Product files are fetched on-demand for AI article generation

## Example Request

```bash theme={null}
# Generate for all products
curl -X POST https://searchcompany-main.up.railway.app/api/cron/generate-product-llms-txt \
  -H "Content-Type: application/json" \
  -H "X-API-Key: search-company" \
  -d '{"business_id": "my-business-123"}'

# Generate for specific products
curl -X POST https://searchcompany-main.up.railway.app/api/cron/generate-product-llms-txt \
  -H "Content-Type: application/json" \
  -H "X-API-Key: search-company" \
  -d '{"business_id": "my-business-123", "product_ids": ["uuid-1", "uuid-2"]}'
```

## Code Location

```
src/app/apis/cron/generate_product_llms_txt/
├── __init__.py
└── routes.py
```
