API Reference

The BetterWaifu API allows you to integrate AI image generation into your applications programmatically.

Base URL

https://betterwaifu.com/api/v1

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer bw_your_api_key_here

Getting Your API Key

  1. Log in to your BetterWaifu account
  2. Click your profile avatar → Settings
  3. Navigate to the API Key tab
  4. Click Generate API Key
  5. Copy and securely store your API key (it's only shown once)

⚠️ Requirements: An active BetterWaifu subscription is required to use the API.

⚠️ Security: Never share your API key or commit it to version control. Use environment variables instead.

Rate Limits

  • One active generation at a time
  • 60 second timeout between generations

Quick Start

1. Check Your Account

curl https://betterwaifu.com/api/v1/account \
  -H "Authorization: Bearer bw_your_api_key_here"

2. List Available Models

curl https://betterwaifu.com/api/v1/models \
  -H "Authorization: Bearer bw_your_api_key_here"

3. Generate an Image

curl -X POST https://betterwaifu.com/api/v1/generate \
  -H "Authorization: Bearer bw_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "1girl, solo, long hair, blue eyes, masterpiece, best quality",
    "negative_prompt": "lowres, bad anatomy, bad hands",
    "model_version_id": 814910,
    "width": 832,
    "height": 1216,
    "steps": 30,
    "cfg_scale": 7,
    "sampler": "euler_a"
  }'

4. Poll for Results

curl https://betterwaifu.com/api/v1/generate/job_abc123 \
  -H "Authorization: Bearer bw_your_api_key_here"

Response Format

Success Response

{
  "id": "job_abc123",
  "status": "succeeded",
  "output": {
    "images": [
      {
        "url": "https://cdn.betterwaifu.com/xxx/yyy.webp",
        "id": "abc123xyz"
      }
    ],
    "seed": 1234567890
  }
}

Error Response

{
  "error": "Your prompt was flagged by moderation. Please revise and try again."
}

Common HTTP Status Codes

CodeDescription
200Success
201Created (generation queued)
400Bad Request (invalid parameters or moderation flag)
401Unauthorized (invalid or missing API key)
402Payment Required (insufficient credits)
403Forbidden (model not available or subscription inactive)
404Not Found (generation or model not found)
429Too Many Requests (active generation in progress)
500Server Error

Endpoints

MethodEndpointDescription
GET/accountGet account info and credit balance
GET/modelsList available generation models
POST/generateSubmit a new generation
GET/generate/{id}Get generation status and results

Next Steps