复制
1. claude mcp add runapi -s user -- npx -y @runapi.ai/mcp
2. 重启 Claude Code
3. 粘贴这个 prompt:生成一张图像:"{ "image_type": "high-detail food photography, AI-edited surreal composition", "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4", "main_subject": { "object": "single cube-shaped red velvet cake piece", "position": "floating in mid-air", "orientation": "slightly angled, front face visible, top frosting facing upward", "texture": { "cake": "fine, dense crumb texture with visible granules", "frosting": "smooth, creamy, thick layer with soft ridges" } }, "cake_details": { "layers": [ { "type": "red velvet sponge", "color": "deep red", "count": 2 }, { "type": "cream filling", "color": "pale off-white", "count": 1, "position": "center layer" } ], "top_frosting": { "style": "swirled frosting peak", "color": "off-white / cream", "surface_detail": "soft curved piping lines", "toppings": "small red velvet crumbs scattered on top" } }, "motion_elements": { "crumbs": { "presence": true, "distribution": "scattered around the cake in mid-air", "size_variation": "fine dust to small chunks", "motion": "frozen mid-flight" } }, "secondary_object": { "object": "metal spoon", "material": "polished stainless steel", "position": "below the cake", "orientation": "slightly tilted upward", "reflection": "subtle reflections visible on spoon surface", "interaction": "crumbs falling toward spoon" }, "lighting": { "style": "studio lighting", "direction": "soft directional light from upper side", "highlights": "gentle highlights on frosting and spoon", "shadows": "soft shadows, no harsh edges", "contrast": "moderate contrast emphasizing texture" }, "background": { "color_palette": [ "dark maroon", "deep burgundy", "muted pink gradient" ], "style": "smooth gradient backdrop", "depth": "shallow depth of field", "noise": "clean, minimal grain" }, "color_profile": { "dominant_colors": [ "deep red", "cream white", "dark maroon" ], "saturation": "rich but controlled", "tone": "luxurious and dramatic" }, "composition": { "framing": "centered subject with vertical emphasis", "visual_balance": "cake centered, spoon offset below", "negative_space": "ample empty space around subject" }, "style_tags": [ "hyper-realistic", "AI-edited look", "surreal food photography", "freeze-motion effect", "premium dessert aesthetic" ], "camera_simulation": { "focus": "sharp focus on cake", "background_blur": "smooth bokeh-like gradient", "angle": "eye-level to slightly low angle" }, "post_processing": { "clarity": "high", "sharpness": "very high", "color_grading": "cinematic dessert tones", "artifacts": "none visible" } }"
复制
1. codex plugin install runapi-mcp@agents
2. 重启 Codex
3. 粘贴这个 prompt:生成一张图像:"{ "image_type": "high-detail food photography, AI-edited surreal composition", "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4", "main_subject": { "object": "single cube-shaped red velvet cake piece", "position": "floating in mid-air", "orientation": "slightly angled, front face visible, top frosting facing upward", "texture": { "cake": "fine, dense crumb texture with visible granules", "frosting": "smooth, creamy, thick layer with soft ridges" } }, "cake_details": { "layers": [ { "type": "red velvet sponge", "color": "deep red", "count": 2 }, { "type": "cream filling", "color": "pale off-white", "count": 1, "position": "center layer" } ], "top_frosting": { "style": "swirled frosting peak", "color": "off-white / cream", "surface_detail": "soft curved piping lines", "toppings": "small red velvet crumbs scattered on top" } }, "motion_elements": { "crumbs": { "presence": true, "distribution": "scattered around the cake in mid-air", "size_variation": "fine dust to small chunks", "motion": "frozen mid-flight" } }, "secondary_object": { "object": "metal spoon", "material": "polished stainless steel", "position": "below the cake", "orientation": "slightly tilted upward", "reflection": "subtle reflections visible on spoon surface", "interaction": "crumbs falling toward spoon" }, "lighting": { "style": "studio lighting", "direction": "soft directional light from upper side", "highlights": "gentle highlights on frosting and spoon", "shadows": "soft shadows, no harsh edges", "contrast": "moderate contrast emphasizing texture" }, "background": { "color_palette": [ "dark maroon", "deep burgundy", "muted pink gradient" ], "style": "smooth gradient backdrop", "depth": "shallow depth of field", "noise": "clean, minimal grain" }, "color_profile": { "dominant_colors": [ "deep red", "cream white", "dark maroon" ], "saturation": "rich but controlled", "tone": "luxurious and dramatic" }, "composition": { "framing": "centered subject with vertical emphasis", "visual_balance": "cake centered, spoon offset below", "negative_space": "ample empty space around subject" }, "style_tags": [ "hyper-realistic", "AI-edited look", "surreal food photography", "freeze-motion effect", "premium dessert aesthetic" ], "camera_simulation": { "focus": "sharp focus on cake", "background_blur": "smooth bokeh-like gradient", "angle": "eye-level to slightly low angle" }, "post_processing": { "clarity": "high", "sharpness": "very high", "color_grading": "cinematic dessert tones", "artifacts": "none visible" } }"
复制
1. npx @runapi.ai/mcp init cursor
2. 重启 Cursor
3. 粘贴这个 prompt:生成一张图像:"{ "image_type": "high-detail food photography, AI-edited surreal composition", "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4", "main_subject": { "object": "single cube-shaped red velvet cake piece", "position": "floating in mid-air", "orientation": "slightly angled, front face visible, top frosting facing upward", "texture": { "cake": "fine, dense crumb texture with visible granules", "frosting": "smooth, creamy, thick layer with soft ridges" } }, "cake_details": { "layers": [ { "type": "red velvet sponge", "color": "deep red", "count": 2 }, { "type": "cream filling", "color": "pale off-white", "count": 1, "position": "center layer" } ], "top_frosting": { "style": "swirled frosting peak", "color": "off-white / cream", "surface_detail": "soft curved piping lines", "toppings": "small red velvet crumbs scattered on top" } }, "motion_elements": { "crumbs": { "presence": true, "distribution": "scattered around the cake in mid-air", "size_variation": "fine dust to small chunks", "motion": "frozen mid-flight" } }, "secondary_object": { "object": "metal spoon", "material": "polished stainless steel", "position": "below the cake", "orientation": "slightly tilted upward", "reflection": "subtle reflections visible on spoon surface", "interaction": "crumbs falling toward spoon" }, "lighting": { "style": "studio lighting", "direction": "soft directional light from upper side", "highlights": "gentle highlights on frosting and spoon", "shadows": "soft shadows, no harsh edges", "contrast": "moderate contrast emphasizing texture" }, "background": { "color_palette": [ "dark maroon", "deep burgundy", "muted pink gradient" ], "style": "smooth gradient backdrop", "depth": "shallow depth of field", "noise": "clean, minimal grain" }, "color_profile": { "dominant_colors": [ "deep red", "cream white", "dark maroon" ], "saturation": "rich but controlled", "tone": "luxurious and dramatic" }, "composition": { "framing": "centered subject with vertical emphasis", "visual_balance": "cake centered, spoon offset below", "negative_space": "ample empty space around subject" }, "style_tags": [ "hyper-realistic", "AI-edited look", "surreal food photography", "freeze-motion effect", "premium dessert aesthetic" ], "camera_simulation": { "focus": "sharp focus on cake", "background_blur": "smooth bokeh-like gradient", "angle": "eye-level to slightly low angle" }, "post_processing": { "clarity": "high", "sharpness": "very high", "color_grading": "cinematic dessert tones", "artifacts": "none visible" } }"
复制
1. npx @runapi.ai/mcp init windsurf
2. 重启 Windsurf
3. 粘贴这个 prompt:生成一张图像:"{ "image_type": "high-detail food photography, AI-edited surreal composition", "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4", "main_subject": { "object": "single cube-shaped red velvet cake piece", "position": "floating in mid-air", "orientation": "slightly angled, front face visible, top frosting facing upward", "texture": { "cake": "fine, dense crumb texture with visible granules", "frosting": "smooth, creamy, thick layer with soft ridges" } }, "cake_details": { "layers": [ { "type": "red velvet sponge", "color": "deep red", "count": 2 }, { "type": "cream filling", "color": "pale off-white", "count": 1, "position": "center layer" } ], "top_frosting": { "style": "swirled frosting peak", "color": "off-white / cream", "surface_detail": "soft curved piping lines", "toppings": "small red velvet crumbs scattered on top" } }, "motion_elements": { "crumbs": { "presence": true, "distribution": "scattered around the cake in mid-air", "size_variation": "fine dust to small chunks", "motion": "frozen mid-flight" } }, "secondary_object": { "object": "metal spoon", "material": "polished stainless steel", "position": "below the cake", "orientation": "slightly tilted upward", "reflection": "subtle reflections visible on spoon surface", "interaction": "crumbs falling toward spoon" }, "lighting": { "style": "studio lighting", "direction": "soft directional light from upper side", "highlights": "gentle highlights on frosting and spoon", "shadows": "soft shadows, no harsh edges", "contrast": "moderate contrast emphasizing texture" }, "background": { "color_palette": [ "dark maroon", "deep burgundy", "muted pink gradient" ], "style": "smooth gradient backdrop", "depth": "shallow depth of field", "noise": "clean, minimal grain" }, "color_profile": { "dominant_colors": [ "deep red", "cream white", "dark maroon" ], "saturation": "rich but controlled", "tone": "luxurious and dramatic" }, "composition": { "framing": "centered subject with vertical emphasis", "visual_balance": "cake centered, spoon offset below", "negative_space": "ample empty space around subject" }, "style_tags": [ "hyper-realistic", "AI-edited look", "surreal food photography", "freeze-motion effect", "premium dessert aesthetic" ], "camera_simulation": { "focus": "sharp focus on cake", "background_blur": "smooth bokeh-like gradient", "angle": "eye-level to slightly low angle" }, "post_processing": { "clarity": "high", "sharpness": "very high", "color_grading": "cinematic dessert tones", "artifacts": "none visible" } }"
curl
Node.js
Ruby
Go
复制
curl -X POST https://runapi.ai/api/v1/gpt_image_2/text_to_image \
-H "Authorization: Bearer $RUNAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"model": "gpt-image-2",
"prompt": "{ \"image_type\": \"high-detail food photography, AI-edited surreal composition\", \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4\", \"main_subject\": { \"object\": \"single cube-shaped red velvet cake piece\", \"position\": \"floating in mid-air\", \"orientation\": \"slightly angled, front face visible, top frosting facing upward\", \"texture\": { \"cake\": \"fine, dense crumb texture with visible granules\", \"frosting\": \"smooth, creamy, thick layer with soft ridges\" } }, \"cake_details\": { \"layers\": [ { \"type\": \"red velvet sponge\", \"color\": \"deep red\", \"count\": 2 }, { \"type\": \"cream filling\", \"color\": \"pale off-white\", \"count\": 1, \"position\": \"center layer\" } ], \"top_frosting\": { \"style\": \"swirled frosting peak\", \"color\": \"off-white / cream\", \"surface_detail\": \"soft curved piping lines\", \"toppings\": \"small red velvet crumbs scattered on top\" } }, \"motion_elements\": { \"crumbs\": { \"presence\": true, \"distribution\": \"scattered around the cake in mid-air\", \"size_variation\": \"fine dust to small chunks\", \"motion\": \"frozen mid-flight\" } }, \"secondary_object\": { \"object\": \"metal spoon\", \"material\": \"polished stainless steel\", \"position\": \"below the cake\", \"orientation\": \"slightly tilted upward\", \"reflection\": \"subtle reflections visible on spoon surface\", \"interaction\": \"crumbs falling toward spoon\" }, \"lighting\": { \"style\": \"studio lighting\", \"direction\": \"soft directional light from upper side\", \"highlights\": \"gentle highlights on frosting and spoon\", \"shadows\": \"soft shadows, no harsh edges\", \"contrast\": \"moderate contrast emphasizing texture\" }, \"background\": { \"color_palette\": [ \"dark maroon\", \"deep burgundy\", \"muted pink gradient\" ], \"style\": \"smooth gradient backdrop\", \"depth\": \"shallow depth of field\", \"noise\": \"clean, minimal grain\" }, \"color_profile\": { \"dominant_colors\": [ \"deep red\", \"cream white\", \"dark maroon\" ], \"saturation\": \"rich but controlled\", \"tone\": \"luxurious and dramatic\" }, \"composition\": { \"framing\": \"centered subject with vertical emphasis\", \"visual_balance\": \"cake centered, spoon offset below\", \"negative_space\": \"ample empty space around subject\" }, \"style_tags\": [ \"hyper-realistic\", \"AI-edited look\", \"surreal food photography\", \"freeze-motion effect\", \"premium dessert aesthetic\" ], \"camera_simulation\": { \"focus\": \"sharp focus on cake\", \"background_blur\": \"smooth bokeh-like gradient\", \"angle\": \"eye-level to slightly low angle\" }, \"post_processing\": { \"clarity\": \"high\", \"sharpness\": \"very high\", \"color_grading\": \"cinematic dessert tones\", \"artifacts\": \"none visible\" } }"
}
JSON
复制
import { GptImage2Client } from "@runapi.ai/gpt-image-2";
const client = new GptImage2Client({
apiKey: process.env.RUNAPI_API_KEY,
});
const result = await client.textToImage.run({
"model": "gpt-image-2",
"prompt": "{ \"image_type\": \"high-detail food photography, AI-edited surreal composition\", \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4\", \"main_subject\": { \"object\": \"single cube-shaped red velvet cake piece\", \"position\": \"floating in mid-air\", \"orientation\": \"slightly angled, front face visible, top frosting facing upward\", \"texture\": { \"cake\": \"fine, dense crumb texture with visible granules\", \"frosting\": \"smooth, creamy, thick layer with soft ridges\" } }, \"cake_details\": { \"layers\": [ { \"type\": \"red velvet sponge\", \"color\": \"deep red\", \"count\": 2 }, { \"type\": \"cream filling\", \"color\": \"pale off-white\", \"count\": 1, \"position\": \"center layer\" } ], \"top_frosting\": { \"style\": \"swirled frosting peak\", \"color\": \"off-white / cream\", \"surface_detail\": \"soft curved piping lines\", \"toppings\": \"small red velvet crumbs scattered on top\" } }, \"motion_elements\": { \"crumbs\": { \"presence\": true, \"distribution\": \"scattered around the cake in mid-air\", \"size_variation\": \"fine dust to small chunks\", \"motion\": \"frozen mid-flight\" } }, \"secondary_object\": { \"object\": \"metal spoon\", \"material\": \"polished stainless steel\", \"position\": \"below the cake\", \"orientation\": \"slightly tilted upward\", \"reflection\": \"subtle reflections visible on spoon surface\", \"interaction\": \"crumbs falling toward spoon\" }, \"lighting\": { \"style\": \"studio lighting\", \"direction\": \"soft directional light from upper side\", \"highlights\": \"gentle highlights on frosting and spoon\", \"shadows\": \"soft shadows, no harsh edges\", \"contrast\": \"moderate contrast emphasizing texture\" }, \"background\": { \"color_palette\": [ \"dark maroon\", \"deep burgundy\", \"muted pink gradient\" ], \"style\": \"smooth gradient backdrop\", \"depth\": \"shallow depth of field\", \"noise\": \"clean, minimal grain\" }, \"color_profile\": { \"dominant_colors\": [ \"deep red\", \"cream white\", \"dark maroon\" ], \"saturation\": \"rich but controlled\", \"tone\": \"luxurious and dramatic\" }, \"composition\": { \"framing\": \"centered subject with vertical emphasis\", \"visual_balance\": \"cake centered, spoon offset below\", \"negative_space\": \"ample empty space around subject\" }, \"style_tags\": [ \"hyper-realistic\", \"AI-edited look\", \"surreal food photography\", \"freeze-motion effect\", \"premium dessert aesthetic\" ], \"camera_simulation\": { \"focus\": \"sharp focus on cake\", \"background_blur\": \"smooth bokeh-like gradient\", \"angle\": \"eye-level to slightly low angle\" }, \"post_processing\": { \"clarity\": \"high\", \"sharpness\": \"very high\", \"color_grading\": \"cinematic dessert tones\", \"artifacts\": \"none visible\" } }"
});
console.log(result.id);
复制
require "runapi/gpt_image_2"
client = RunApi::GptImage2::Client.new
result = client.text_to_image.run(
model: "gpt-image-2",
prompt: "{ \"image_type\": \"high-detail food photography, AI-edited surreal composition\", \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4\", \"main_subject\": { \"object\": \"single cube-shaped red velvet cake piece\", \"position\": \"floating in mid-air\", \"orientation\": \"slightly angled, front face visible, top frosting facing upward\", \"texture\": { \"cake\": \"fine, dense crumb texture with visible granules\", \"frosting\": \"smooth, creamy, thick layer with soft ridges\" } }, \"cake_details\": { \"layers\": [ { \"type\": \"red velvet sponge\", \"color\": \"deep red\", \"count\": 2 }, { \"type\": \"cream filling\", \"color\": \"pale off-white\", \"count\": 1, \"position\": \"center layer\" } ], \"top_frosting\": { \"style\": \"swirled frosting peak\", \"color\": \"off-white / cream\", \"surface_detail\": \"soft curved piping lines\", \"toppings\": \"small red velvet crumbs scattered on top\" } }, \"motion_elements\": { \"crumbs\": { \"presence\": true, \"distribution\": \"scattered around the cake in mid-air\", \"size_variation\": \"fine dust to small chunks\", \"motion\": \"frozen mid-flight\" } }, \"secondary_object\": { \"object\": \"metal spoon\", \"material\": \"polished stainless steel\", \"position\": \"below the cake\", \"orientation\": \"slightly tilted upward\", \"reflection\": \"subtle reflections visible on spoon surface\", \"interaction\": \"crumbs falling toward spoon\" }, \"lighting\": { \"style\": \"studio lighting\", \"direction\": \"soft directional light from upper side\", \"highlights\": \"gentle highlights on frosting and spoon\", \"shadows\": \"soft shadows, no harsh edges\", \"contrast\": \"moderate contrast emphasizing texture\" }, \"background\": { \"color_palette\": [ \"dark maroon\", \"deep burgundy\", \"muted pink gradient\" ], \"style\": \"smooth gradient backdrop\", \"depth\": \"shallow depth of field\", \"noise\": \"clean, minimal grain\" }, \"color_profile\": { \"dominant_colors\": [ \"deep red\", \"cream white\", \"dark maroon\" ], \"saturation\": \"rich but controlled\", \"tone\": \"luxurious and dramatic\" }, \"composition\": { \"framing\": \"centered subject with vertical emphasis\", \"visual_balance\": \"cake centered, spoon offset below\", \"negative_space\": \"ample empty space around subject\" }, \"style_tags\": [ \"hyper-realistic\", \"AI-edited look\", \"surreal food photography\", \"freeze-motion effect\", \"premium dessert aesthetic\" ], \"camera_simulation\": { \"focus\": \"sharp focus on cake\", \"background_blur\": \"smooth bokeh-like gradient\", \"angle\": \"eye-level to slightly low angle\" }, \"post_processing\": { \"clarity\": \"high\", \"sharpness\": \"very high\", \"color_grading\": \"cinematic dessert tones\", \"artifacts\": \"none visible\" } }"
)
puts result.id
复制
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader("{\"model\":\"gpt-image-2\",\"prompt\":\"{ \\\"image_type\\\": \\\"high-detail food photography, AI-edited surreal composition\\\", \\\"resolution\\\": \\\"8K ultra-high-definition\\\", \\\"aspect_ratio\\\": \\\"3:4\\\", \\\"main_subject\\\": { \\\"object\\\": \\\"single cube-shaped red velvet cake piece\\\", \\\"position\\\": \\\"floating in mid-air\\\", \\\"orientation\\\": \\\"slightly angled, front face visible, top frosting facing upward\\\", \\\"texture\\\": { \\\"cake\\\": \\\"fine, dense crumb texture with visible granules\\\", \\\"frosting\\\": \\\"smooth, creamy, thick layer with soft ridges\\\" } }, \\\"cake_details\\\": { \\\"layers\\\": [ { \\\"type\\\": \\\"red velvet sponge\\\", \\\"color\\\": \\\"deep red\\\", \\\"count\\\": 2 }, { \\\"type\\\": \\\"cream filling\\\", \\\"color\\\": \\\"pale off-white\\\", \\\"count\\\": 1, \\\"position\\\": \\\"center layer\\\" } ], \\\"top_frosting\\\": { \\\"style\\\": \\\"swirled frosting peak\\\", \\\"color\\\": \\\"off-white / cream\\\", \\\"surface_detail\\\": \\\"soft curved piping lines\\\", \\\"toppings\\\": \\\"small red velvet crumbs scattered on top\\\" } }, \\\"motion_elements\\\": { \\\"crumbs\\\": { \\\"presence\\\": true, \\\"distribution\\\": \\\"scattered around the cake in mid-air\\\", \\\"size_variation\\\": \\\"fine dust to small chunks\\\", \\\"motion\\\": \\\"frozen mid-flight\\\" } }, \\\"secondary_object\\\": { \\\"object\\\": \\\"metal spoon\\\", \\\"material\\\": \\\"polished stainless steel\\\", \\\"position\\\": \\\"below the cake\\\", \\\"orientation\\\": \\\"slightly tilted upward\\\", \\\"reflection\\\": \\\"subtle reflections visible on spoon surface\\\", \\\"interaction\\\": \\\"crumbs falling toward spoon\\\" }, \\\"lighting\\\": { \\\"style\\\": \\\"studio lighting\\\", \\\"direction\\\": \\\"soft directional light from upper side\\\", \\\"highlights\\\": \\\"gentle highlights on frosting and spoon\\\", \\\"shadows\\\": \\\"soft shadows, no harsh edges\\\", \\\"contrast\\\": \\\"moderate contrast emphasizing texture\\\" }, \\\"background\\\": { \\\"color_palette\\\": [ \\\"dark maroon\\\", \\\"deep burgundy\\\", \\\"muted pink gradient\\\" ], \\\"style\\\": \\\"smooth gradient backdrop\\\", \\\"depth\\\": \\\"shallow depth of field\\\", \\\"noise\\\": \\\"clean, minimal grain\\\" }, \\\"color_profile\\\": { \\\"dominant_colors\\\": [ \\\"deep red\\\", \\\"cream white\\\", \\\"dark maroon\\\" ], \\\"saturation\\\": \\\"rich but controlled\\\", \\\"tone\\\": \\\"luxurious and dramatic\\\" }, \\\"composition\\\": { \\\"framing\\\": \\\"centered subject with vertical emphasis\\\", \\\"visual_balance\\\": \\\"cake centered, spoon offset below\\\", \\\"negative_space\\\": \\\"ample empty space around subject\\\" }, \\\"style_tags\\\": [ \\\"hyper-realistic\\\", \\\"AI-edited look\\\", \\\"surreal food photography\\\", \\\"freeze-motion effect\\\", \\\"premium dessert aesthetic\\\" ], \\\"camera_simulation\\\": { \\\"focus\\\": \\\"sharp focus on cake\\\", \\\"background_blur\\\": \\\"smooth bokeh-like gradient\\\", \\\"angle\\\": \\\"eye-level to slightly low angle\\\" }, \\\"post_processing\\\": { \\\"clarity\\\": \\\"high\\\", \\\"sharpness\\\": \\\"very high\\\", \\\"color_grading\\\": \\\"cinematic dessert tones\\\", \\\"artifacts\\\": \\\"none visible\\\" } }\"}")
req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, "https://runapi.ai/api/v1/gpt_image_2/text_to_image", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("RUNAPI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}