# Recraft V4 > Recraft V4 generates design-ready images with accurate, integrated in-image text and style-reference consistency at 1K. ## Overview - **Endpoint**: `https://api.segmind.com/v1/recraft-v4` - **Model ID**: `recraft-v4` - **Category**: Text-to-Image Generation - **Type**: Synchronous (Direct response) - **Average Cost**: $0.051388888888888894 ## Pricing | has_style_reference | cost | | --- | --- | | false | 0.05 | | true | 0.05625 | ## API Information This model uses a **synchronous response pattern**: 1. Make a POST request with your parameters 2. Receive the output directly in the response (binary for images/videos/audio, JSON for text) 3. No polling required - response is immediate ### Input Schema The API accepts the following input parameters: - **`prompt`** (`string`, _required_): Prompt Text describing the image to generate (up to 10,000 characters). Text you want rendered in the image can be quoted directly. - **`style_reference_urls`** (`array`, _optional_): Style reference images Optional 1-10 images (PNG, JPG or WEBP) whose look the generation should match: rendering technique, colors, texture and composition. A one-off style-creation fee is added when references are attached. - Default: `[]` - Item type: string - **`size`** (`string`, _optional_): Size Width and height of the generated image in pixels. Auto lets Recraft pick from the prompt. The API also accepts a bare aspect ratio such as 16:9. - Default: `"auto"` - Options: "auto" (Auto (from prompt)), "1024x1024" (1024x1024 (1:1)), "1536x768" (1536x768 (2:1)), "768x1536" (768x1536 (1:2)), "1280x832" (1280x832 (3:2)), "832x1280" (832x1280 (2:3)), "1216x896" (1216x896 (4:3)), "896x1216" (896x1216 (3:4)), "1152x896" (1152x896 (5:4)), "896x1152" (896x1152 (4:5)), "832x1344" (832x1344 (6:10)), "1280x896" (1280x896 (14:10)), "896x1280" (896x1280 (10:14)), "1344x768" (1344x768 (16:9)), "768x1344" (768x1344 (9:16)) - **`style_match`** (`string`, _optional_): Style match How closely to follow the style reference images. Only used when style reference images are attached. - Default: `"flexible"` - Options: "flexible" (Flexible (match the vibe)), "precise" (Precise (hold every detail)) - **`colors`** (`array`, _optional_): Preferred colors Up to 10 preferred colors as #RRGGBB hex values, e.g. #1E90FF. - Default: `[]` - Item type: string - **`background_color`** (`string | null`, _optional_): Background color Preferred background color as a #RRGGBB hex value. - **`seed`** (`integer`, _optional_): Seed Seed for reproducible generation. -1 picks a random seed. - Default: `-1` - Range: -1 to 2147483647 **Required Parameters Example**: ```json { "prompt": "A tabletop board game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, mid-century poster illustration" } ``` **Full Example**: ```json { "prompt": "A tabletop board game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, mid-century poster illustration", "style_reference_urls": [], "size": "1024x1024", "style_match": "flexible", "colors": [], "background_color": null, "seed": -1 } ``` ### Output Schema The API returns a synchronous response based on the model type: **For Image/Video/Audio Models**: - Response contains binary data (image/png, video/mp4, audio/mp3) - Content-Type header indicates the media type - Save the response body directly to a file **For Text Models**: - Response is JSON with the generated text - Structure varies by model **HTTP Response Codes**: - **200 - OK**: Request successful, output in response body - **400 - Bad Request**: Invalid parameters - **401 - Unauthorized**: Invalid or missing API key - **404 - Not Found**: Model not found - **406 - Not Acceptable**: Insufficient credits - **429 - Too Many Requests**: Rate limit exceeded - **500 - Server Error**: Internal server error ## Usage Examples ### cURL ```bash curl -X POST "https://api.segmind.com/v1/recraft-v4" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A tabletop board game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, mid-century poster illustration", "style_reference_urls": [], "size": "1024x1024", "style_match": "flexible", "colors": [], "background_color": null, "seed": -1 }' ``` ### Python ```python import requests import json api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/recraft-v4" data = { "prompt": "A tabletop board game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, mid-century poster illustration", "style_reference_urls": [], "size": "1024x1024", "style_match": "flexible", "colors": [], "background_color": null, "seed": -1 } response = requests.post( url, json=data, headers={ 'x-api-key': api_key, 'Content-Type': 'application/json' } ) if response.status_code == 200: # For image/video/audio models, response.content contains the binary data with open('output.png', 'wb') as f: f.write(response.content) print('Generation complete, saved to output.png') else: print(f"Error: {response.status_code}") print(response.text) ``` ### JavaScript ```javascript const apiKey = 'YOUR_API_KEY'; const url = 'https://api.segmind.com/v1/recraft-v4'; const data = { "prompt": "A tabletop board game box top for a cooperative deep-sea expedition game. Title 'ABYSS PROTOCOL' in bold condensed serif letters across the top, a smaller tagline 'descend, survive, resurface' beneath it, and a bottom banner reading '2-4 PLAYERS AGES 12+ 60 MIN'. Centered flat illustration of a brass diving bell descending past a glowing bioluminescent anglerfish, teal-to-indigo palette, mid-century poster illustration", "style_reference_urls": [], "size": "1024x1024", "style_match": "flexible", "colors": [], "background_color": null, "seed": -1 }; const response = await fetch(url, { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); if (response.ok) { // For image/video/audio models, response contains binary data const blob = await response.blob(); const downloadUrl = URL.createObjectURL(blob); // Create download link const a = document.createElement('a'); a.href = downloadUrl; a.download = 'output.png'; a.click(); console.log('Generation complete'); } ``` ## Additional Resources ### Documentation - [Model Playground](https://www.segmind.com/models/recraft-v4) - [API Documentation](https://www.segmind.com/models/recraft-v4/api) - [Pricing Details](https://www.segmind.com/models/recraft-v4/pricing) - [Platform Documentation](https://docs.segmind.com/) ### Tags No tags available