翻篇收录说明
翻篇网页快照

Recraft API Examples: Generate, Edit, Vectorize - Recraft

https://www.recraft.ai/docs/api-reference/examples

最近抓取:2026-12-04 13:54:30(北京时间)

最近内容变化:2026-12-01 21:31:06(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Ready-to-run Recraft API examples for generation, styles, editing, vectorizing, upscaling, and prompt enhancement.

正文摘录

Generate AI images using cURL or Python and create your own styles programmatically. Generate image Fast, low-cost generation with Recraft V4.1 Flash V2 generate_recraftv4_1_flash_v2.shgenerate_recraftv4_1_flash_v2.pycurl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "portrait of a street musician at golden hour", "model": "recraftv4_1_flash_v2", "response_format": "multipart" }' \ --output response.multipart Raster generation with Recraft V4.1 generate_recraftv4_1.shgenerate_recraftv4_1.pygenerate_recraftv4_1_openai.pycurl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "two race cars on a track", "model": "recraftv4_1" }' Vector generation with Recraft V4.1 Vector generate_recraftv4_1_vector.shgenerate_recraftv4_1_vector.pygenerate_recraftv4_1_vector_openai.pycurl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "cat on a mat", "model": "recraftv4_1_vector" }' Custom image size with Recraft V4.1 Pro generate_recraftv4_1_pro_with_size.shgenerate_recraftv4_1_pro_with_size.pygenerate_recraftv4_1_pro_with_size_openai.pycurl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "red point siamese cat", "model": "recraftv4_1_pro", "size": "2560x1664" }' Generation with style references (Recraft V4 Styles) generate_with_style_references.shgenerate_with_style_references_json.shgenerate_with_style_references.pygenerate_with_style_references_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "prompt=product hero shot, bottle on a table" \ -F "model=recraftv4_styles" \ -F "style_references=@reference.png" Generation with a curated style (Recraft V3) generate_digital_illustration.shgenerate_digital_illustration.pygenerate_digital_illustration_openai.pycurl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "a monster with lots of hands", "style": "Hand-drawn" }' Create style Style creation and generation with Recraft V4 Styles create_v4_style_and_generate.shcreate_v4_style_and_generate_json.shcreate_v4_style_and_generate.pycreate_v4_style_and_generate_openai.pycurl -X POST https://external.api.recraft.ai/v1/styles \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "model=recraftv4_styles" \ -F "file1=@reference-1.png" # response: {"id":"229b2a75-05e4-4580-85f9-b47ee521a00d"} curl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "product hero shot, bottle on a table", "model": "recraftv4_styles", "style_id": "229b2a75-05e4-4580-85f9-b47ee521a00d" }' Style creation and generation with Recraft V3 create_style_and_generate.shcreate_style_and_generate_json.shcreate_style_and_generate.pycreate_style_and_generate_openai.pycurl -X POST https://external.api.recraft.ai/v1/styles \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "style=digital_illustration" \ -F "model=recraftv3" \ -F "file=@image.png" # response: {"id":"095b9f9d-f06f-4b4e-9bb2-d4f823203427"} curl https://external.api.recraft.ai/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "wood potato masher", "model": "recraftv3", "style_id": "095b9f9d-f06f-4b4e-9bb2-d4f823203427" }' Image to image Image to image with a curated style (Recraft V3) image_to_image.shimage_to_image_json.shimage_to_image.pyimage_to_image_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/imageToImage \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "image=@image.png" \ -F "prompt=winter" \ -F "strength=0.2" \ -F "style=Illustration" Image inpainting Inpainting with a curated style (Recraft V3) inpaint.shinpaint_json.shinpaint.pyinpaint_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/inpaint \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "prompt=moon" \ -F "style=Enterprise" \ -F "image=@image.png" -F "mask=@mask.png" Image outpainting Outpainting to a target aspect ratio outpaint.shoutpaint_json.shoutpaint.pyoutpaint_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/outpaint \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "prompt=a mountain landscape" \ -F "size=16:9" \ -F "zoom_out_percentage=25.0" \ -F "image=@image.png" Outpainting with per-side margins outpaint_expand.shoutpaint_expand_json.shoutpaint_expand.pyoutpaint_expand_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/outpaint \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "prompt=a mountain landscape" \ -F "expand_left=256" \ -F "expand_right=256" \ -F "expand_top=128" \ -F "expand_bottom=128" \ -F "image=@image.png" Vectorize image Vectorization of a PNG image vectorize.shvectorize_json.shvectorize.pyvectorize_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/vectorize \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "file=@image.png" Remove background Background removal with a Base64 JSON response remove_background_b64.shremove_background_b64_json.shremove_background_b64.pyremove_background_b64_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/removeBackground \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "response_format=b64_json" \ -F "file=@image.png" Crisp upscale Crisp upscale with a Base64 JSON response crisp_upscale_b64.shcrisp_upscale_b64_json.shcrisp_upscale_b64.pycrisp_upscale_b64_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/crispUpscale \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "response_format=b64_json" \ -F "file=@image.png" Creative upscale Creative upscale of a PNG image creative_upscale.shcreative_upscale_json.shcreative_upscale.pycreative_upscale_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/creativeUpscale \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "file=@image.png" Enhance details Subtle enhancement of a PNG image enhance_details.shenhance_details_json.shenhance_details.pyenhance_details_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/enhance \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "file=@image.png" \ -F "refinement=subtle" Remix image Image variation with WEBP output variate_image.shvariate_image_json.shvariate_image.pyvariate_image_openai.pycurl -X POST https://external.api.recraft.ai/v1/images/variateImage \ -H "Content-Type: multipart/form-data" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -F "response_format=url" \ -F "size=1024x1024" \ -F "n=1" \ -F "random_seed=13191922" \ -F "image_format=webp" \ -F "image=@image.png" Enhance prompt Enhance a prompt enhance_prompt.shenhance_prompt.pyenhance_prompt_openai.pycurl https://external.api.recraft.ai/v1/prompts/enhance \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RECRAFT_API_TOKEN" \ -d '{ "prompt": "race car on a track" }'