复制
1. claude mcp add runapi -s user -- npx -y @runapi.ai/mcp
2. 重启 Claude Code
3. 粘贴这个 prompt:生成一张图像:"{ "global_settings": { "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4 vertical", "render_style": "hyper-realistic commercial food photography", "quality": "premium advertising grade", "sharpness": "extreme micro-detail, crisp edges", "noise": "none", "artifacts": "none", "depth_of_field": "shallow, subject-focused", "motion": "frozen mid-air ingredients", "background_style": "solid single-color studio backdrop" }, "subject": { "main_food": "chocolate chip cookies", "quantity": 3, "appearance": [ "golden-brown freshly baked cookies", "soft cracked surface", "visible melted chocolate chips", "slightly crisp edges", "natural handmade texture" ], "branding_rules": [ "no text", "no logo", "no embossing", "no patterns", "no symbols" ] }, "secondary_elements": { "ingredients_flying": [ "dark chocolate chunks", "cookie crumbs", "fine sugar crystals" ], "motion_style": "dynamic floating explosion", "distribution": "balanced around the cookies, natural randomness", "particle_detail": "sharp, frozen motion with depth separation" }, "composition": { "camera_angle": "slightly low angle", "framing": "center-weighted hero composition", "spacing": "clean negative space around subject", "focus_priority": "front cookie in razor-sharp focus" }, "lighting": { "type": "professional studio lighting", "key_light": "soft directional key light", "fill_light": "gentle fill for texture clarity", "rim_light": "subtle rim highlight for separation", "shadows": "soft and natural, no harsh contrast" }, "color_palette": { "background_color": "pastel blue", "cookie_tones": "warm golden browns", "accent_colors": "rich chocolate browns, crystal sugar whites", "contrast": "high subject-background separation" }, "photography_style": { "genre": "luxury food advertising", "mood": "fresh, indulgent, premium", "cleanliness": "spotless studio look", "post_processing": "minimal, natural, high-end retouching" }, "exclusions": [ "text", "logos", "watermarks", "hands", "plates", "props", "packaging", "background objects", "cartoon style", "illustration style" ] }"
复制
1. codex plugin install runapi-mcp@agents
2. 重启 Codex
3. 粘贴这个 prompt:生成一张图像:"{ "global_settings": { "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4 vertical", "render_style": "hyper-realistic commercial food photography", "quality": "premium advertising grade", "sharpness": "extreme micro-detail, crisp edges", "noise": "none", "artifacts": "none", "depth_of_field": "shallow, subject-focused", "motion": "frozen mid-air ingredients", "background_style": "solid single-color studio backdrop" }, "subject": { "main_food": "chocolate chip cookies", "quantity": 3, "appearance": [ "golden-brown freshly baked cookies", "soft cracked surface", "visible melted chocolate chips", "slightly crisp edges", "natural handmade texture" ], "branding_rules": [ "no text", "no logo", "no embossing", "no patterns", "no symbols" ] }, "secondary_elements": { "ingredients_flying": [ "dark chocolate chunks", "cookie crumbs", "fine sugar crystals" ], "motion_style": "dynamic floating explosion", "distribution": "balanced around the cookies, natural randomness", "particle_detail": "sharp, frozen motion with depth separation" }, "composition": { "camera_angle": "slightly low angle", "framing": "center-weighted hero composition", "spacing": "clean negative space around subject", "focus_priority": "front cookie in razor-sharp focus" }, "lighting": { "type": "professional studio lighting", "key_light": "soft directional key light", "fill_light": "gentle fill for texture clarity", "rim_light": "subtle rim highlight for separation", "shadows": "soft and natural, no harsh contrast" }, "color_palette": { "background_color": "pastel blue", "cookie_tones": "warm golden browns", "accent_colors": "rich chocolate browns, crystal sugar whites", "contrast": "high subject-background separation" }, "photography_style": { "genre": "luxury food advertising", "mood": "fresh, indulgent, premium", "cleanliness": "spotless studio look", "post_processing": "minimal, natural, high-end retouching" }, "exclusions": [ "text", "logos", "watermarks", "hands", "plates", "props", "packaging", "background objects", "cartoon style", "illustration style" ] }"
复制
1. npx @runapi.ai/mcp init cursor
2. 重启 Cursor
3. 粘贴这个 prompt:生成一张图像:"{ "global_settings": { "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4 vertical", "render_style": "hyper-realistic commercial food photography", "quality": "premium advertising grade", "sharpness": "extreme micro-detail, crisp edges", "noise": "none", "artifacts": "none", "depth_of_field": "shallow, subject-focused", "motion": "frozen mid-air ingredients", "background_style": "solid single-color studio backdrop" }, "subject": { "main_food": "chocolate chip cookies", "quantity": 3, "appearance": [ "golden-brown freshly baked cookies", "soft cracked surface", "visible melted chocolate chips", "slightly crisp edges", "natural handmade texture" ], "branding_rules": [ "no text", "no logo", "no embossing", "no patterns", "no symbols" ] }, "secondary_elements": { "ingredients_flying": [ "dark chocolate chunks", "cookie crumbs", "fine sugar crystals" ], "motion_style": "dynamic floating explosion", "distribution": "balanced around the cookies, natural randomness", "particle_detail": "sharp, frozen motion with depth separation" }, "composition": { "camera_angle": "slightly low angle", "framing": "center-weighted hero composition", "spacing": "clean negative space around subject", "focus_priority": "front cookie in razor-sharp focus" }, "lighting": { "type": "professional studio lighting", "key_light": "soft directional key light", "fill_light": "gentle fill for texture clarity", "rim_light": "subtle rim highlight for separation", "shadows": "soft and natural, no harsh contrast" }, "color_palette": { "background_color": "pastel blue", "cookie_tones": "warm golden browns", "accent_colors": "rich chocolate browns, crystal sugar whites", "contrast": "high subject-background separation" }, "photography_style": { "genre": "luxury food advertising", "mood": "fresh, indulgent, premium", "cleanliness": "spotless studio look", "post_processing": "minimal, natural, high-end retouching" }, "exclusions": [ "text", "logos", "watermarks", "hands", "plates", "props", "packaging", "background objects", "cartoon style", "illustration style" ] }"
复制
1. npx @runapi.ai/mcp init windsurf
2. 重启 Windsurf
3. 粘贴这个 prompt:生成一张图像:"{ "global_settings": { "resolution": "8K ultra-high-definition", "aspect_ratio": "3:4 vertical", "render_style": "hyper-realistic commercial food photography", "quality": "premium advertising grade", "sharpness": "extreme micro-detail, crisp edges", "noise": "none", "artifacts": "none", "depth_of_field": "shallow, subject-focused", "motion": "frozen mid-air ingredients", "background_style": "solid single-color studio backdrop" }, "subject": { "main_food": "chocolate chip cookies", "quantity": 3, "appearance": [ "golden-brown freshly baked cookies", "soft cracked surface", "visible melted chocolate chips", "slightly crisp edges", "natural handmade texture" ], "branding_rules": [ "no text", "no logo", "no embossing", "no patterns", "no symbols" ] }, "secondary_elements": { "ingredients_flying": [ "dark chocolate chunks", "cookie crumbs", "fine sugar crystals" ], "motion_style": "dynamic floating explosion", "distribution": "balanced around the cookies, natural randomness", "particle_detail": "sharp, frozen motion with depth separation" }, "composition": { "camera_angle": "slightly low angle", "framing": "center-weighted hero composition", "spacing": "clean negative space around subject", "focus_priority": "front cookie in razor-sharp focus" }, "lighting": { "type": "professional studio lighting", "key_light": "soft directional key light", "fill_light": "gentle fill for texture clarity", "rim_light": "subtle rim highlight for separation", "shadows": "soft and natural, no harsh contrast" }, "color_palette": { "background_color": "pastel blue", "cookie_tones": "warm golden browns", "accent_colors": "rich chocolate browns, crystal sugar whites", "contrast": "high subject-background separation" }, "photography_style": { "genre": "luxury food advertising", "mood": "fresh, indulgent, premium", "cleanliness": "spotless studio look", "post_processing": "minimal, natural, high-end retouching" }, "exclusions": [ "text", "logos", "watermarks", "hands", "plates", "props", "packaging", "background objects", "cartoon style", "illustration style" ] }"
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": "{ \"global_settings\": { \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4 vertical\", \"render_style\": \"hyper-realistic commercial food photography\", \"quality\": \"premium advertising grade\", \"sharpness\": \"extreme micro-detail, crisp edges\", \"noise\": \"none\", \"artifacts\": \"none\", \"depth_of_field\": \"shallow, subject-focused\", \"motion\": \"frozen mid-air ingredients\", \"background_style\": \"solid single-color studio backdrop\" }, \"subject\": { \"main_food\": \"chocolate chip cookies\", \"quantity\": 3, \"appearance\": [ \"golden-brown freshly baked cookies\", \"soft cracked surface\", \"visible melted chocolate chips\", \"slightly crisp edges\", \"natural handmade texture\" ], \"branding_rules\": [ \"no text\", \"no logo\", \"no embossing\", \"no patterns\", \"no symbols\" ] }, \"secondary_elements\": { \"ingredients_flying\": [ \"dark chocolate chunks\", \"cookie crumbs\", \"fine sugar crystals\" ], \"motion_style\": \"dynamic floating explosion\", \"distribution\": \"balanced around the cookies, natural randomness\", \"particle_detail\": \"sharp, frozen motion with depth separation\" }, \"composition\": { \"camera_angle\": \"slightly low angle\", \"framing\": \"center-weighted hero composition\", \"spacing\": \"clean negative space around subject\", \"focus_priority\": \"front cookie in razor-sharp focus\" }, \"lighting\": { \"type\": \"professional studio lighting\", \"key_light\": \"soft directional key light\", \"fill_light\": \"gentle fill for texture clarity\", \"rim_light\": \"subtle rim highlight for separation\", \"shadows\": \"soft and natural, no harsh contrast\" }, \"color_palette\": { \"background_color\": \"pastel blue\", \"cookie_tones\": \"warm golden browns\", \"accent_colors\": \"rich chocolate browns, crystal sugar whites\", \"contrast\": \"high subject-background separation\" }, \"photography_style\": { \"genre\": \"luxury food advertising\", \"mood\": \"fresh, indulgent, premium\", \"cleanliness\": \"spotless studio look\", \"post_processing\": \"minimal, natural, high-end retouching\" }, \"exclusions\": [ \"text\", \"logos\", \"watermarks\", \"hands\", \"plates\", \"props\", \"packaging\", \"background objects\", \"cartoon style\", \"illustration style\" ] }"
}
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": "{ \"global_settings\": { \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4 vertical\", \"render_style\": \"hyper-realistic commercial food photography\", \"quality\": \"premium advertising grade\", \"sharpness\": \"extreme micro-detail, crisp edges\", \"noise\": \"none\", \"artifacts\": \"none\", \"depth_of_field\": \"shallow, subject-focused\", \"motion\": \"frozen mid-air ingredients\", \"background_style\": \"solid single-color studio backdrop\" }, \"subject\": { \"main_food\": \"chocolate chip cookies\", \"quantity\": 3, \"appearance\": [ \"golden-brown freshly baked cookies\", \"soft cracked surface\", \"visible melted chocolate chips\", \"slightly crisp edges\", \"natural handmade texture\" ], \"branding_rules\": [ \"no text\", \"no logo\", \"no embossing\", \"no patterns\", \"no symbols\" ] }, \"secondary_elements\": { \"ingredients_flying\": [ \"dark chocolate chunks\", \"cookie crumbs\", \"fine sugar crystals\" ], \"motion_style\": \"dynamic floating explosion\", \"distribution\": \"balanced around the cookies, natural randomness\", \"particle_detail\": \"sharp, frozen motion with depth separation\" }, \"composition\": { \"camera_angle\": \"slightly low angle\", \"framing\": \"center-weighted hero composition\", \"spacing\": \"clean negative space around subject\", \"focus_priority\": \"front cookie in razor-sharp focus\" }, \"lighting\": { \"type\": \"professional studio lighting\", \"key_light\": \"soft directional key light\", \"fill_light\": \"gentle fill for texture clarity\", \"rim_light\": \"subtle rim highlight for separation\", \"shadows\": \"soft and natural, no harsh contrast\" }, \"color_palette\": { \"background_color\": \"pastel blue\", \"cookie_tones\": \"warm golden browns\", \"accent_colors\": \"rich chocolate browns, crystal sugar whites\", \"contrast\": \"high subject-background separation\" }, \"photography_style\": { \"genre\": \"luxury food advertising\", \"mood\": \"fresh, indulgent, premium\", \"cleanliness\": \"spotless studio look\", \"post_processing\": \"minimal, natural, high-end retouching\" }, \"exclusions\": [ \"text\", \"logos\", \"watermarks\", \"hands\", \"plates\", \"props\", \"packaging\", \"background objects\", \"cartoon style\", \"illustration style\" ] }"
});
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: "{ \"global_settings\": { \"resolution\": \"8K ultra-high-definition\", \"aspect_ratio\": \"3:4 vertical\", \"render_style\": \"hyper-realistic commercial food photography\", \"quality\": \"premium advertising grade\", \"sharpness\": \"extreme micro-detail, crisp edges\", \"noise\": \"none\", \"artifacts\": \"none\", \"depth_of_field\": \"shallow, subject-focused\", \"motion\": \"frozen mid-air ingredients\", \"background_style\": \"solid single-color studio backdrop\" }, \"subject\": { \"main_food\": \"chocolate chip cookies\", \"quantity\": 3, \"appearance\": [ \"golden-brown freshly baked cookies\", \"soft cracked surface\", \"visible melted chocolate chips\", \"slightly crisp edges\", \"natural handmade texture\" ], \"branding_rules\": [ \"no text\", \"no logo\", \"no embossing\", \"no patterns\", \"no symbols\" ] }, \"secondary_elements\": { \"ingredients_flying\": [ \"dark chocolate chunks\", \"cookie crumbs\", \"fine sugar crystals\" ], \"motion_style\": \"dynamic floating explosion\", \"distribution\": \"balanced around the cookies, natural randomness\", \"particle_detail\": \"sharp, frozen motion with depth separation\" }, \"composition\": { \"camera_angle\": \"slightly low angle\", \"framing\": \"center-weighted hero composition\", \"spacing\": \"clean negative space around subject\", \"focus_priority\": \"front cookie in razor-sharp focus\" }, \"lighting\": { \"type\": \"professional studio lighting\", \"key_light\": \"soft directional key light\", \"fill_light\": \"gentle fill for texture clarity\", \"rim_light\": \"subtle rim highlight for separation\", \"shadows\": \"soft and natural, no harsh contrast\" }, \"color_palette\": { \"background_color\": \"pastel blue\", \"cookie_tones\": \"warm golden browns\", \"accent_colors\": \"rich chocolate browns, crystal sugar whites\", \"contrast\": \"high subject-background separation\" }, \"photography_style\": { \"genre\": \"luxury food advertising\", \"mood\": \"fresh, indulgent, premium\", \"cleanliness\": \"spotless studio look\", \"post_processing\": \"minimal, natural, high-end retouching\" }, \"exclusions\": [ \"text\", \"logos\", \"watermarks\", \"hands\", \"plates\", \"props\", \"packaging\", \"background objects\", \"cartoon style\", \"illustration style\" ] }"
)
puts result.id
复制
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader("{\"model\":\"gpt-image-2\",\"prompt\":\"{ \\\"global_settings\\\": { \\\"resolution\\\": \\\"8K ultra-high-definition\\\", \\\"aspect_ratio\\\": \\\"3:4 vertical\\\", \\\"render_style\\\": \\\"hyper-realistic commercial food photography\\\", \\\"quality\\\": \\\"premium advertising grade\\\", \\\"sharpness\\\": \\\"extreme micro-detail, crisp edges\\\", \\\"noise\\\": \\\"none\\\", \\\"artifacts\\\": \\\"none\\\", \\\"depth_of_field\\\": \\\"shallow, subject-focused\\\", \\\"motion\\\": \\\"frozen mid-air ingredients\\\", \\\"background_style\\\": \\\"solid single-color studio backdrop\\\" }, \\\"subject\\\": { \\\"main_food\\\": \\\"chocolate chip cookies\\\", \\\"quantity\\\": 3, \\\"appearance\\\": [ \\\"golden-brown freshly baked cookies\\\", \\\"soft cracked surface\\\", \\\"visible melted chocolate chips\\\", \\\"slightly crisp edges\\\", \\\"natural handmade texture\\\" ], \\\"branding_rules\\\": [ \\\"no text\\\", \\\"no logo\\\", \\\"no embossing\\\", \\\"no patterns\\\", \\\"no symbols\\\" ] }, \\\"secondary_elements\\\": { \\\"ingredients_flying\\\": [ \\\"dark chocolate chunks\\\", \\\"cookie crumbs\\\", \\\"fine sugar crystals\\\" ], \\\"motion_style\\\": \\\"dynamic floating explosion\\\", \\\"distribution\\\": \\\"balanced around the cookies, natural randomness\\\", \\\"particle_detail\\\": \\\"sharp, frozen motion with depth separation\\\" }, \\\"composition\\\": { \\\"camera_angle\\\": \\\"slightly low angle\\\", \\\"framing\\\": \\\"center-weighted hero composition\\\", \\\"spacing\\\": \\\"clean negative space around subject\\\", \\\"focus_priority\\\": \\\"front cookie in razor-sharp focus\\\" }, \\\"lighting\\\": { \\\"type\\\": \\\"professional studio lighting\\\", \\\"key_light\\\": \\\"soft directional key light\\\", \\\"fill_light\\\": \\\"gentle fill for texture clarity\\\", \\\"rim_light\\\": \\\"subtle rim highlight for separation\\\", \\\"shadows\\\": \\\"soft and natural, no harsh contrast\\\" }, \\\"color_palette\\\": { \\\"background_color\\\": \\\"pastel blue\\\", \\\"cookie_tones\\\": \\\"warm golden browns\\\", \\\"accent_colors\\\": \\\"rich chocolate browns, crystal sugar whites\\\", \\\"contrast\\\": \\\"high subject-background separation\\\" }, \\\"photography_style\\\": { \\\"genre\\\": \\\"luxury food advertising\\\", \\\"mood\\\": \\\"fresh, indulgent, premium\\\", \\\"cleanliness\\\": \\\"spotless studio look\\\", \\\"post_processing\\\": \\\"minimal, natural, high-end retouching\\\" }, \\\"exclusions\\\": [ \\\"text\\\", \\\"logos\\\", \\\"watermarks\\\", \\\"hands\\\", \\\"plates\\\", \\\"props\\\", \\\"packaging\\\", \\\"background objects\\\", \\\"cartoon style\\\", \\\"illustration style\\\" ] }\"}")
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)
}