Produces 4 high-quality 1:1 images via Meta AI's text-to-image model.
API available at /api/generate?prompt=...
Simple HTTP API to generate 1:1 square images using Meta AI's Imagine model.
Generate 4 square (1:1) images from a text prompt. Returns an array of CDN image URLs.
| Param | Type | Status | Description |
|---|---|---|---|
| prompt | string | required | Text description of image to generate. Max 500 chars. |
On success, returns success: true with array of direct image URLs from Meta's CDN (fbcdn.net).
On failure returns success: false with an error message. Common causes: expired cookies, rate limiting, invalid prompt.
HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | Success — images array populated |
| 400 | Bad request — missing prompt param |
| 500 | Server/upstream error |
JavaScript / Fetch
PHP
Request Flow
1. Your GET request hits /api/generate?prompt=...
2. PHP generates fresh UUIDs (conversationId, turnId, messageId, etc.)
3. A POST is made to https://www.meta.ai/api/graphql with doc_id: 2f707e4a86f4b01adba97e1376cbdc14
4. The imagineOperationRequest.textToImageParams.orientation is locked to SQUARE
5. Meta responds via Server-Sent Events (SSE) stream
6. SSE is parsed line-by-line; image URLs from *.fbcdn.net are extracted
7. JSON response with image URLs array is returned
GraphQL Variables (key fields)
Cookie Refresh
Cookies expire periodically. When images stop returning, update the META_ACCOUNTS constant at the top of index.php with fresh values from your browser (DevTools → Application → Cookies → meta.ai). Required cookies: datr, ecto_1_sess, rd_challenge.