Skip to content
Recraft logo

Recraft V4

Text-to-ImageRecraftProxied

Recraft V4 generates art-directed images with strong composition, accurate text rendering, and design taste built in. Fast and cost-efficient at standard resolution.

Model Info
Terms and Licenselink
More informationlink

Usage

TypeScript
const response = await env.AI.run(
'recraft/recraftv4',
{
prompt: 'A minimalist logo of a mountain range with a sun rising behind it',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Simple Generation

Examples

With Style — Generate with a specific artistic style
TypeScript
const response = await env.AI.run(
'recraft/recraftv4',
{
prompt:
'A cozy cabin in the woods surrounded by tall pine trees, smoke rising from the chimney',
style: 'realistic_image',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 With Style
Custom Size — Specify output dimensions
TypeScript
const response = await env.AI.run(
'recraft/recraftv4',
{
prompt:
'A flat illustration of a workspace with a laptop, coffee cup, and potted plant',
size: '1024x1024',
style: 'digital_illustration',
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Custom Size
With Color Controls — Guide generation with specific brand colors
TypeScript
const response = await env.AI.run(
'recraft/recraftv4',
{
prompt:
'An abstract geometric pattern suitable for a tech company brand identity',
controls: {
colors: [
{
rgb: [255, 107, 53],
},
{
rgb: [0, 43, 91],
},
],
},
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 With Color Controls
Background Color — Set a specific background color
TypeScript
const response = await env.AI.run(
'recraft/recraftv4',
{
prompt: 'A clean icon of a lightning bolt',
size: '1024x1024',
controls: {
background_color: {
rgb: [245, 245, 245],
},
},
},
{
gateway: { id: 'default' },
}
)
console.log(response)
Response 200 Background Color

Parameters

prompt
stringrequired
size
string
style
string
substyle
string

API Schemas

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"prompt": {
"type": "string"
},
"size": {
"type": "string"
},
"style": {
"type": "string"
},
"substyle": {
"type": "string"
},
"controls": {
"type": "object",
"properties": {
"colors": {
"maxItems": 5,
"type": "array",
"items": {
"type": "object",
"properties": {
"rgb": {
"minItems": 3,
"maxItems": 3,
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
}
}
},
"required": [
"rgb"
],
"additionalProperties": false
}
},
"background_color": {
"type": "object",
"properties": {
"rgb": {
"minItems": 3,
"maxItems": 3,
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
}
}
},
"required": [
"rgb"
],
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"required": [
"prompt"
],
"additionalProperties": false
}