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

# AI Content Generation

> Generate, enhance, and refine product content using brand-aware AI.

## Setting up AI specs

Before generating content, configure your brand's AI specifications. This ensures all AI output matches your brand voice.

Navigate to **Brands > \[Your Brand] > AI Specs** in the dashboard, or use the API:

```bash theme={null}
curl -X PATCH ".../brands/{brandId}/ai-specs" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tone_of_voice": "Professional yet approachable. Use active voice.",
    "target_audience": "Fashion-conscious millennials, 25-40",
    "keywords_always": ["sustainable", "premium", "crafted"],
    "keywords_never": ["cheap", "basic", "generic"],
    "content_policies": "Never mention competitor brands. Always highlight sustainability.",
    "custom_instructions": "Include care instructions when describing fabrics."
  }'
```

## Generating content

### New product descriptions

```bash theme={null}
curl -X POST "https://app.alana.shopping/api/ai/generate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "brandId": "BRAND_ID",
    "type": "description",
    "context": {
      "productTitle": "Organic Linen Blazer",
      "category": "Apparel > Outerwear > Blazers",
      "attributes": {"material": "100% organic linen", "color": "Navy"}
    }
  }'
```

### Enhancing existing content

```bash theme={null}
curl -X POST "https://app.alana.shopping/api/ai/enhance" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "brandId": "BRAND_ID",
    "text": "Navy blazer made from linen. Good for office.",
    "type": "description",
    "instructions": "Make it more compelling and add sustainability messaging"
  }'
```

### Interactive chat (Canvas)

The Canvas AI chat provides a conversational interface for content operations:

```bash theme={null}
curl -X POST "https://app.alana.shopping/api/ai/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "brandId": "BRAND_ID",
    "messages": [
      {"role": "user", "content": "Write 3 title variations for our organic linen blazer"}
    ]
  }'
```

### Generating high-confidence FAQs

The dedicated `faq` action (Phase 185) produces 5–10 product-specific Q\&As with category labels and a confidence score per question. The API post-filters to keep only `confidence >= 0.7` items; the prompt explicitly forbids questions about color/size/availability/price (those are structured fields).

```bash theme={null}
curl -X POST "https://app.alana.shopping/api/ai/generate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "faq",
    "workspaceId": "WORKSPACE_ID",
    "model": "balanced",
    "productContext": {
      "id": "PROD_123",
      "name": "Organic Linen Blazer",
      "brand": "Alana",
      "description": "Tailored blazer in 100% organic linen, navy color, single-breasted.",
      "price": 489
    }
  }'
```

The `model` parameter accepts `"economic"`, `"balanced"`, or `"high"` and maps to the LiteLLM tier alias (`canvas-faq-eco` / `canvas-faq-bal` / `canvas-faq-hi`). Higher tiers use stronger models — useful when the response returns 400 with fewer than 5 high-confidence FAQs.

Response shape:

```json theme={null}
{
  "success": true,
  "action": "faq",
  "data": {
    "faqs": [
      {
        "question": "Posso lavar este blazer na máquina?",
        "answer": "Não recomendamos. Linho é um tecido delicado — prefira lavagem a seco ou à mão com água fria.",
        "category": "cuidado",
        "confidence": 0.94
      },
      {
        "question": "Como é o caimento?",
        "answer": "Modelagem alfaiataria com leve estrutura nos ombros, caimento solto no torso. Veste no tamanho usual.",
        "category": "tamanho",
        "confidence": 0.88
      }
    ]
  }
}
```

Categories: `uso`, `cuidado`, `tamanho`, `envio`, `trocas`, `material`, `estilo`, `outro`. The route returns 400 if fewer than 5 high-confidence FAQs survive the filter — set `"model": "high"` in the request body or include more product detail in `productContext`.

## AI credit usage

AI operations consume credits based on your workspace plan. Monitor usage via the billing dashboard or API.

<Warning>
  AI credits reset monthly. If you exceed your plan's limit, AI operations will be rate-limited until the next billing cycle.
</Warning>
