File size: 1,987 Bytes
92d8b0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# API Documentation

Base path: `/api/v1`

## Auth

- `POST /auth/login`
  - Admin username/password login.
  - Returns `access_token`, `refresh_token`, and expiry metadata.
- `POST /auth/refresh`
  - Exchanges a refresh token for a fresh token pair.
- `GET /auth/me`
  - Returns the authenticated user profile.

## Users

- `GET /users/me/profile`
- `GET /users/me/credits`
- `PATCH /users/me/settings`
- `GET /users/me/history`
- `GET /users/{user_id}` (admin only)

## Images

- `POST /images/upload`
  - Accepts `multipart/form-data` with a photo file.
  - Validates file type, size, and integrity.
- `GET /images/me`

## Jobs

- `POST /jobs/`
  - Creates and dispatches a queued job.
  - Supports:
    - `text_to_image`
    - `anime_style`
    - `ghibli_style`
    - `cartoon_style`
    - `realistic_enhancement`
    - `face_enhancement`
    - `background_removal`
    - `background_replacement`
    - `object_removal`
    - `object_replacement`
    - `ai_repaint`
    - `inpainting`
    - `outpainting`
    - `upscale`
    - `colorization`
    - `old_photo_restoration`
- `GET /jobs/me`
- `GET /jobs/{job_id}`
- `POST /jobs/{job_id}/cancel`

## Models

- `GET /models/`
  - Lists configured model descriptors and capabilities.

## Admin

- `GET /admin/stats`
- `GET /admin/users`
- `GET /admin/jobs`
- `POST /admin/credits/grant`
- `POST /admin/broadcasts`

## Payments

- `POST /payments/checkout`
  - Creates a provider-specific checkout session or deep link.
- `GET /payments/me/transactions`

## Auth Model

- Bearer JWT for API routes.
- HTTP-only JWT cookie for the server-rendered admin dashboard.
- Role enforcement on admin endpoints using the `roles` claim and Mongo user record validation.

## Error Behavior

- `400`: invalid prompt, blocked prompt, invalid file.
- `401`: missing or invalid token.
- `402`: insufficient credits.
- `403`: role violation.
- `404`: missing resource.
- `429`: rate limit or daily quota exceeded.
- `500`: worker or infrastructure error.