Ask a Model API to Perform a Task via API
Inputs
Model API
We will use the Recraft API to generate images.
Example Requests and Responses
ai-labs/recraft/recraft-examples.mdPreferred Style
vector_illustrationAPI Key
ai-labs/.envTarget Files
site/src/content/lost-in-public/prompts/workflow/code-styleTarget Output
Put the response back into the YAML frontmatter of the input file, preserving all other frontmatter structure and formatting.
banner_image: <URL>Output Script in:
ai-labs/recraft/recraft-generate-banner-images.tsIncluding Custom Styles from Recraft
How to Use Your Generated Custom Style
You can include a custom style generated by the Recraft API in your model request by referencing its style ID or by loading the style JSON object. Example below uses the style you generated and saved at:
ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.jsonSample Style JSON:
json
{
"creation_time": "2025-04-15T02:24:01.574783871Z",
"credits": 40,
"id": "73a249b2-879e-4240-9973-c6fb1715a882",
"is_private": true,
"style": "digital_illustration"
} Example (Python):
python
import json
with open('ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.json') as f:
style_obj = json.load(f)
# Use style_obj['id'] as the style identifier in your API request
payload = {
'prompt': 'Your image prompt here',
'style': style_obj['id'],
# ...other parameters
} Example (JS/TS):
js
const style = require('./ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.json');
// Use style.id as the style identifier in your API request
const payload = {
prompt: 'Your image prompt here',
style: style.id,
// ...other parameters
};