复制
1. claude mcp add runapi -s user -- npx -y @runapi.ai/mcp
2. 重启 Claude Code
3. 粘贴这个 prompt:生成一张图像:"{ "style": "Minimalist modern recipe infographic", "visual_aesthetic": { "photography_style": "Top-down / 3-quarter angle food photography", "design_language": "Scandinavian, editorial cookbook layout", "background": "Soft neutral beige / cream", "lighting": "Soft diffused light with gentle shadows", "detail_level": "Ultra-realistic, ultra-sharp, 8K resolution" }, "layout": { "composition": "Finished dish centered on a white ceramic plate or bowl", "elements": [ "Floating ingredient icons in soft circular frames", "Clean vector-style ingredient illustrations", "Clear ingredient labels with quantities", "Curved step-by-step flow with numbered cooking icons" ], "typography": "High readability, modern sans-serif", "spacing": "Balanced, airy, uncluttered" }, "recipes": [ { "dish_name": "Traditional Polish Pierogi", "dish_presentation": "Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives", "ingredients": [ { "name": "All-purpose flour", "quantity": "2.5 cups" }, { "name": "Potatoes", "quantity": "3 medium" }, { "name": "Farmer cheese", "quantity": "200g" }, { "name": "Onion", "quantity": "1 medium" }, { "name": "Butter", "quantity": "40g" }, { "name": "Salt", "quantity": "1 tsp" }, { "name": "Water", "quantity": "0.75 cups" } ], "steps": [ "Prepare dough", "Cook and mash filling", "Fill and shape pierogi", "Boil until tender", "Serve with butter" ], "meta": { "calories": "270 kcal / serving", "time": "70 min", "servings": 4 } }, { "dish_name": "Vinaigrette Salad", "dish_presentation": "Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs", "ingredients": [ { "name": "Beetroot", "quantity": "2 medium" }, { "name": "Potatoes", "quantity": "2 medium" }, { "name": "Carrots", "quantity": "1 medium" }, { "name": "Pickled cucumbers", "quantity": "2 pcs" }, { "name": "Green peas", "quantity": "1 cup" }, { "name": "Sunflower oil", "quantity": "2 tbsp" }, { "name": "Fresh dill", "quantity": "1 bunch" } ], "steps": [ "Boil vegetables", "Cool and dice", "Mix ingredients", "Dress salad", "Chill and serve" ], "meta": { "calories": "180 kcal / serving", "time": "30 min + chill", "servings": 4 } }, { "dish_name": "Solyanka Soup", "dish_presentation": "Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl", "ingredients": [ { "name": "Mixed meats", "quantity": "400g" }, { "name": "Onion", "quantity": "1 large" }, { "name": "Pickles", "quantity": "3 pcs" }, { "name": "Tomato paste", "quantity": "2 tbsp" }, { "name": "Olives", "quantity": "1/2 cup" }, { "name": "Garlic", "quantity": "2 cloves" }, { "name": "Bay leaf", "quantity": "1 pc" }, { "name": "Lemon", "quantity": "For serving" } ], "steps": [ "Simmer broth", "Sauté aromatics", "Add meats and pickles", "Season and simmer", "Serve with lemon" ], "meta": { "calories": "320 kcal / serving", "time": "90 min", "servings": 5 } } ] }"
复制
1. codex plugin install runapi-mcp@agents
2. 重启 Codex
3. 粘贴这个 prompt:生成一张图像:"{ "style": "Minimalist modern recipe infographic", "visual_aesthetic": { "photography_style": "Top-down / 3-quarter angle food photography", "design_language": "Scandinavian, editorial cookbook layout", "background": "Soft neutral beige / cream", "lighting": "Soft diffused light with gentle shadows", "detail_level": "Ultra-realistic, ultra-sharp, 8K resolution" }, "layout": { "composition": "Finished dish centered on a white ceramic plate or bowl", "elements": [ "Floating ingredient icons in soft circular frames", "Clean vector-style ingredient illustrations", "Clear ingredient labels with quantities", "Curved step-by-step flow with numbered cooking icons" ], "typography": "High readability, modern sans-serif", "spacing": "Balanced, airy, uncluttered" }, "recipes": [ { "dish_name": "Traditional Polish Pierogi", "dish_presentation": "Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives", "ingredients": [ { "name": "All-purpose flour", "quantity": "2.5 cups" }, { "name": "Potatoes", "quantity": "3 medium" }, { "name": "Farmer cheese", "quantity": "200g" }, { "name": "Onion", "quantity": "1 medium" }, { "name": "Butter", "quantity": "40g" }, { "name": "Salt", "quantity": "1 tsp" }, { "name": "Water", "quantity": "0.75 cups" } ], "steps": [ "Prepare dough", "Cook and mash filling", "Fill and shape pierogi", "Boil until tender", "Serve with butter" ], "meta": { "calories": "270 kcal / serving", "time": "70 min", "servings": 4 } }, { "dish_name": "Vinaigrette Salad", "dish_presentation": "Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs", "ingredients": [ { "name": "Beetroot", "quantity": "2 medium" }, { "name": "Potatoes", "quantity": "2 medium" }, { "name": "Carrots", "quantity": "1 medium" }, { "name": "Pickled cucumbers", "quantity": "2 pcs" }, { "name": "Green peas", "quantity": "1 cup" }, { "name": "Sunflower oil", "quantity": "2 tbsp" }, { "name": "Fresh dill", "quantity": "1 bunch" } ], "steps": [ "Boil vegetables", "Cool and dice", "Mix ingredients", "Dress salad", "Chill and serve" ], "meta": { "calories": "180 kcal / serving", "time": "30 min + chill", "servings": 4 } }, { "dish_name": "Solyanka Soup", "dish_presentation": "Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl", "ingredients": [ { "name": "Mixed meats", "quantity": "400g" }, { "name": "Onion", "quantity": "1 large" }, { "name": "Pickles", "quantity": "3 pcs" }, { "name": "Tomato paste", "quantity": "2 tbsp" }, { "name": "Olives", "quantity": "1/2 cup" }, { "name": "Garlic", "quantity": "2 cloves" }, { "name": "Bay leaf", "quantity": "1 pc" }, { "name": "Lemon", "quantity": "For serving" } ], "steps": [ "Simmer broth", "Sauté aromatics", "Add meats and pickles", "Season and simmer", "Serve with lemon" ], "meta": { "calories": "320 kcal / serving", "time": "90 min", "servings": 5 } } ] }"
复制
1. npx @runapi.ai/mcp init cursor
2. 重启 Cursor
3. 粘贴这个 prompt:生成一张图像:"{ "style": "Minimalist modern recipe infographic", "visual_aesthetic": { "photography_style": "Top-down / 3-quarter angle food photography", "design_language": "Scandinavian, editorial cookbook layout", "background": "Soft neutral beige / cream", "lighting": "Soft diffused light with gentle shadows", "detail_level": "Ultra-realistic, ultra-sharp, 8K resolution" }, "layout": { "composition": "Finished dish centered on a white ceramic plate or bowl", "elements": [ "Floating ingredient icons in soft circular frames", "Clean vector-style ingredient illustrations", "Clear ingredient labels with quantities", "Curved step-by-step flow with numbered cooking icons" ], "typography": "High readability, modern sans-serif", "spacing": "Balanced, airy, uncluttered" }, "recipes": [ { "dish_name": "Traditional Polish Pierogi", "dish_presentation": "Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives", "ingredients": [ { "name": "All-purpose flour", "quantity": "2.5 cups" }, { "name": "Potatoes", "quantity": "3 medium" }, { "name": "Farmer cheese", "quantity": "200g" }, { "name": "Onion", "quantity": "1 medium" }, { "name": "Butter", "quantity": "40g" }, { "name": "Salt", "quantity": "1 tsp" }, { "name": "Water", "quantity": "0.75 cups" } ], "steps": [ "Prepare dough", "Cook and mash filling", "Fill and shape pierogi", "Boil until tender", "Serve with butter" ], "meta": { "calories": "270 kcal / serving", "time": "70 min", "servings": 4 } }, { "dish_name": "Vinaigrette Salad", "dish_presentation": "Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs", "ingredients": [ { "name": "Beetroot", "quantity": "2 medium" }, { "name": "Potatoes", "quantity": "2 medium" }, { "name": "Carrots", "quantity": "1 medium" }, { "name": "Pickled cucumbers", "quantity": "2 pcs" }, { "name": "Green peas", "quantity": "1 cup" }, { "name": "Sunflower oil", "quantity": "2 tbsp" }, { "name": "Fresh dill", "quantity": "1 bunch" } ], "steps": [ "Boil vegetables", "Cool and dice", "Mix ingredients", "Dress salad", "Chill and serve" ], "meta": { "calories": "180 kcal / serving", "time": "30 min + chill", "servings": 4 } }, { "dish_name": "Solyanka Soup", "dish_presentation": "Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl", "ingredients": [ { "name": "Mixed meats", "quantity": "400g" }, { "name": "Onion", "quantity": "1 large" }, { "name": "Pickles", "quantity": "3 pcs" }, { "name": "Tomato paste", "quantity": "2 tbsp" }, { "name": "Olives", "quantity": "1/2 cup" }, { "name": "Garlic", "quantity": "2 cloves" }, { "name": "Bay leaf", "quantity": "1 pc" }, { "name": "Lemon", "quantity": "For serving" } ], "steps": [ "Simmer broth", "Sauté aromatics", "Add meats and pickles", "Season and simmer", "Serve with lemon" ], "meta": { "calories": "320 kcal / serving", "time": "90 min", "servings": 5 } } ] }"
复制
1. npx @runapi.ai/mcp init windsurf
2. 重启 Windsurf
3. 粘贴这个 prompt:生成一张图像:"{ "style": "Minimalist modern recipe infographic", "visual_aesthetic": { "photography_style": "Top-down / 3-quarter angle food photography", "design_language": "Scandinavian, editorial cookbook layout", "background": "Soft neutral beige / cream", "lighting": "Soft diffused light with gentle shadows", "detail_level": "Ultra-realistic, ultra-sharp, 8K resolution" }, "layout": { "composition": "Finished dish centered on a white ceramic plate or bowl", "elements": [ "Floating ingredient icons in soft circular frames", "Clean vector-style ingredient illustrations", "Clear ingredient labels with quantities", "Curved step-by-step flow with numbered cooking icons" ], "typography": "High readability, modern sans-serif", "spacing": "Balanced, airy, uncluttered" }, "recipes": [ { "dish_name": "Traditional Polish Pierogi", "dish_presentation": "Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives", "ingredients": [ { "name": "All-purpose flour", "quantity": "2.5 cups" }, { "name": "Potatoes", "quantity": "3 medium" }, { "name": "Farmer cheese", "quantity": "200g" }, { "name": "Onion", "quantity": "1 medium" }, { "name": "Butter", "quantity": "40g" }, { "name": "Salt", "quantity": "1 tsp" }, { "name": "Water", "quantity": "0.75 cups" } ], "steps": [ "Prepare dough", "Cook and mash filling", "Fill and shape pierogi", "Boil until tender", "Serve with butter" ], "meta": { "calories": "270 kcal / serving", "time": "70 min", "servings": 4 } }, { "dish_name": "Vinaigrette Salad", "dish_presentation": "Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs", "ingredients": [ { "name": "Beetroot", "quantity": "2 medium" }, { "name": "Potatoes", "quantity": "2 medium" }, { "name": "Carrots", "quantity": "1 medium" }, { "name": "Pickled cucumbers", "quantity": "2 pcs" }, { "name": "Green peas", "quantity": "1 cup" }, { "name": "Sunflower oil", "quantity": "2 tbsp" }, { "name": "Fresh dill", "quantity": "1 bunch" } ], "steps": [ "Boil vegetables", "Cool and dice", "Mix ingredients", "Dress salad", "Chill and serve" ], "meta": { "calories": "180 kcal / serving", "time": "30 min + chill", "servings": 4 } }, { "dish_name": "Solyanka Soup", "dish_presentation": "Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl", "ingredients": [ { "name": "Mixed meats", "quantity": "400g" }, { "name": "Onion", "quantity": "1 large" }, { "name": "Pickles", "quantity": "3 pcs" }, { "name": "Tomato paste", "quantity": "2 tbsp" }, { "name": "Olives", "quantity": "1/2 cup" }, { "name": "Garlic", "quantity": "2 cloves" }, { "name": "Bay leaf", "quantity": "1 pc" }, { "name": "Lemon", "quantity": "For serving" } ], "steps": [ "Simmer broth", "Sauté aromatics", "Add meats and pickles", "Season and simmer", "Serve with lemon" ], "meta": { "calories": "320 kcal / serving", "time": "90 min", "servings": 5 } } ] }"
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": "{ \"style\": \"Minimalist modern recipe infographic\", \"visual_aesthetic\": { \"photography_style\": \"Top-down / 3-quarter angle food photography\", \"design_language\": \"Scandinavian, editorial cookbook layout\", \"background\": \"Soft neutral beige / cream\", \"lighting\": \"Soft diffused light with gentle shadows\", \"detail_level\": \"Ultra-realistic, ultra-sharp, 8K resolution\" }, \"layout\": { \"composition\": \"Finished dish centered on a white ceramic plate or bowl\", \"elements\": [ \"Floating ingredient icons in soft circular frames\", \"Clean vector-style ingredient illustrations\", \"Clear ingredient labels with quantities\", \"Curved step-by-step flow with numbered cooking icons\" ], \"typography\": \"High readability, modern sans-serif\", \"spacing\": \"Balanced, airy, uncluttered\" }, \"recipes\": [ { \"dish_name\": \"Traditional Polish Pierogi\", \"dish_presentation\": \"Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives\", \"ingredients\": [ { \"name\": \"All-purpose flour\", \"quantity\": \"2.5 cups\" }, { \"name\": \"Potatoes\", \"quantity\": \"3 medium\" }, { \"name\": \"Farmer cheese\", \"quantity\": \"200g\" }, { \"name\": \"Onion\", \"quantity\": \"1 medium\" }, { \"name\": \"Butter\", \"quantity\": \"40g\" }, { \"name\": \"Salt\", \"quantity\": \"1 tsp\" }, { \"name\": \"Water\", \"quantity\": \"0.75 cups\" } ], \"steps\": [ \"Prepare dough\", \"Cook and mash filling\", \"Fill and shape pierogi\", \"Boil until tender\", \"Serve with butter\" ], \"meta\": { \"calories\": \"270 kcal / serving\", \"time\": \"70 min\", \"servings\": 4 } }, { \"dish_name\": \"Vinaigrette Salad\", \"dish_presentation\": \"Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs\", \"ingredients\": [ { \"name\": \"Beetroot\", \"quantity\": \"2 medium\" }, { \"name\": \"Potatoes\", \"quantity\": \"2 medium\" }, { \"name\": \"Carrots\", \"quantity\": \"1 medium\" }, { \"name\": \"Pickled cucumbers\", \"quantity\": \"2 pcs\" }, { \"name\": \"Green peas\", \"quantity\": \"1 cup\" }, { \"name\": \"Sunflower oil\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Fresh dill\", \"quantity\": \"1 bunch\" } ], \"steps\": [ \"Boil vegetables\", \"Cool and dice\", \"Mix ingredients\", \"Dress salad\", \"Chill and serve\" ], \"meta\": { \"calories\": \"180 kcal / serving\", \"time\": \"30 min + chill\", \"servings\": 4 } }, { \"dish_name\": \"Solyanka Soup\", \"dish_presentation\": \"Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl\", \"ingredients\": [ { \"name\": \"Mixed meats\", \"quantity\": \"400g\" }, { \"name\": \"Onion\", \"quantity\": \"1 large\" }, { \"name\": \"Pickles\", \"quantity\": \"3 pcs\" }, { \"name\": \"Tomato paste\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Olives\", \"quantity\": \"1/2 cup\" }, { \"name\": \"Garlic\", \"quantity\": \"2 cloves\" }, { \"name\": \"Bay leaf\", \"quantity\": \"1 pc\" }, { \"name\": \"Lemon\", \"quantity\": \"For serving\" } ], \"steps\": [ \"Simmer broth\", \"Sauté aromatics\", \"Add meats and pickles\", \"Season and simmer\", \"Serve with lemon\" ], \"meta\": { \"calories\": \"320 kcal / serving\", \"time\": \"90 min\", \"servings\": 5 } } ] }"
}
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": "{ \"style\": \"Minimalist modern recipe infographic\", \"visual_aesthetic\": { \"photography_style\": \"Top-down / 3-quarter angle food photography\", \"design_language\": \"Scandinavian, editorial cookbook layout\", \"background\": \"Soft neutral beige / cream\", \"lighting\": \"Soft diffused light with gentle shadows\", \"detail_level\": \"Ultra-realistic, ultra-sharp, 8K resolution\" }, \"layout\": { \"composition\": \"Finished dish centered on a white ceramic plate or bowl\", \"elements\": [ \"Floating ingredient icons in soft circular frames\", \"Clean vector-style ingredient illustrations\", \"Clear ingredient labels with quantities\", \"Curved step-by-step flow with numbered cooking icons\" ], \"typography\": \"High readability, modern sans-serif\", \"spacing\": \"Balanced, airy, uncluttered\" }, \"recipes\": [ { \"dish_name\": \"Traditional Polish Pierogi\", \"dish_presentation\": \"Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives\", \"ingredients\": [ { \"name\": \"All-purpose flour\", \"quantity\": \"2.5 cups\" }, { \"name\": \"Potatoes\", \"quantity\": \"3 medium\" }, { \"name\": \"Farmer cheese\", \"quantity\": \"200g\" }, { \"name\": \"Onion\", \"quantity\": \"1 medium\" }, { \"name\": \"Butter\", \"quantity\": \"40g\" }, { \"name\": \"Salt\", \"quantity\": \"1 tsp\" }, { \"name\": \"Water\", \"quantity\": \"0.75 cups\" } ], \"steps\": [ \"Prepare dough\", \"Cook and mash filling\", \"Fill and shape pierogi\", \"Boil until tender\", \"Serve with butter\" ], \"meta\": { \"calories\": \"270 kcal / serving\", \"time\": \"70 min\", \"servings\": 4 } }, { \"dish_name\": \"Vinaigrette Salad\", \"dish_presentation\": \"Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs\", \"ingredients\": [ { \"name\": \"Beetroot\", \"quantity\": \"2 medium\" }, { \"name\": \"Potatoes\", \"quantity\": \"2 medium\" }, { \"name\": \"Carrots\", \"quantity\": \"1 medium\" }, { \"name\": \"Pickled cucumbers\", \"quantity\": \"2 pcs\" }, { \"name\": \"Green peas\", \"quantity\": \"1 cup\" }, { \"name\": \"Sunflower oil\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Fresh dill\", \"quantity\": \"1 bunch\" } ], \"steps\": [ \"Boil vegetables\", \"Cool and dice\", \"Mix ingredients\", \"Dress salad\", \"Chill and serve\" ], \"meta\": { \"calories\": \"180 kcal / serving\", \"time\": \"30 min + chill\", \"servings\": 4 } }, { \"dish_name\": \"Solyanka Soup\", \"dish_presentation\": \"Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl\", \"ingredients\": [ { \"name\": \"Mixed meats\", \"quantity\": \"400g\" }, { \"name\": \"Onion\", \"quantity\": \"1 large\" }, { \"name\": \"Pickles\", \"quantity\": \"3 pcs\" }, { \"name\": \"Tomato paste\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Olives\", \"quantity\": \"1/2 cup\" }, { \"name\": \"Garlic\", \"quantity\": \"2 cloves\" }, { \"name\": \"Bay leaf\", \"quantity\": \"1 pc\" }, { \"name\": \"Lemon\", \"quantity\": \"For serving\" } ], \"steps\": [ \"Simmer broth\", \"Sauté aromatics\", \"Add meats and pickles\", \"Season and simmer\", \"Serve with lemon\" ], \"meta\": { \"calories\": \"320 kcal / serving\", \"time\": \"90 min\", \"servings\": 5 } } ] }"
});
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: "{ \"style\": \"Minimalist modern recipe infographic\", \"visual_aesthetic\": { \"photography_style\": \"Top-down / 3-quarter angle food photography\", \"design_language\": \"Scandinavian, editorial cookbook layout\", \"background\": \"Soft neutral beige / cream\", \"lighting\": \"Soft diffused light with gentle shadows\", \"detail_level\": \"Ultra-realistic, ultra-sharp, 8K resolution\" }, \"layout\": { \"composition\": \"Finished dish centered on a white ceramic plate or bowl\", \"elements\": [ \"Floating ingredient icons in soft circular frames\", \"Clean vector-style ingredient illustrations\", \"Clear ingredient labels with quantities\", \"Curved step-by-step flow with numbered cooking icons\" ], \"typography\": \"High readability, modern sans-serif\", \"spacing\": \"Balanced, airy, uncluttered\" }, \"recipes\": [ { \"dish_name\": \"Traditional Polish Pierogi\", \"dish_presentation\": \"Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives\", \"ingredients\": [ { \"name\": \"All-purpose flour\", \"quantity\": \"2.5 cups\" }, { \"name\": \"Potatoes\", \"quantity\": \"3 medium\" }, { \"name\": \"Farmer cheese\", \"quantity\": \"200g\" }, { \"name\": \"Onion\", \"quantity\": \"1 medium\" }, { \"name\": \"Butter\", \"quantity\": \"40g\" }, { \"name\": \"Salt\", \"quantity\": \"1 tsp\" }, { \"name\": \"Water\", \"quantity\": \"0.75 cups\" } ], \"steps\": [ \"Prepare dough\", \"Cook and mash filling\", \"Fill and shape pierogi\", \"Boil until tender\", \"Serve with butter\" ], \"meta\": { \"calories\": \"270 kcal / serving\", \"time\": \"70 min\", \"servings\": 4 } }, { \"dish_name\": \"Vinaigrette Salad\", \"dish_presentation\": \"Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs\", \"ingredients\": [ { \"name\": \"Beetroot\", \"quantity\": \"2 medium\" }, { \"name\": \"Potatoes\", \"quantity\": \"2 medium\" }, { \"name\": \"Carrots\", \"quantity\": \"1 medium\" }, { \"name\": \"Pickled cucumbers\", \"quantity\": \"2 pcs\" }, { \"name\": \"Green peas\", \"quantity\": \"1 cup\" }, { \"name\": \"Sunflower oil\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Fresh dill\", \"quantity\": \"1 bunch\" } ], \"steps\": [ \"Boil vegetables\", \"Cool and dice\", \"Mix ingredients\", \"Dress salad\", \"Chill and serve\" ], \"meta\": { \"calories\": \"180 kcal / serving\", \"time\": \"30 min + chill\", \"servings\": 4 } }, { \"dish_name\": \"Solyanka Soup\", \"dish_presentation\": \"Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl\", \"ingredients\": [ { \"name\": \"Mixed meats\", \"quantity\": \"400g\" }, { \"name\": \"Onion\", \"quantity\": \"1 large\" }, { \"name\": \"Pickles\", \"quantity\": \"3 pcs\" }, { \"name\": \"Tomato paste\", \"quantity\": \"2 tbsp\" }, { \"name\": \"Olives\", \"quantity\": \"1/2 cup\" }, { \"name\": \"Garlic\", \"quantity\": \"2 cloves\" }, { \"name\": \"Bay leaf\", \"quantity\": \"1 pc\" }, { \"name\": \"Lemon\", \"quantity\": \"For serving\" } ], \"steps\": [ \"Simmer broth\", \"Sauté aromatics\", \"Add meats and pickles\", \"Season and simmer\", \"Serve with lemon\" ], \"meta\": { \"calories\": \"320 kcal / serving\", \"time\": \"90 min\", \"servings\": 5 } } ] }"
)
puts result.id
复制
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader("{\"model\":\"gpt-image-2\",\"prompt\":\"{ \\\"style\\\": \\\"Minimalist modern recipe infographic\\\", \\\"visual_aesthetic\\\": { \\\"photography_style\\\": \\\"Top-down / 3-quarter angle food photography\\\", \\\"design_language\\\": \\\"Scandinavian, editorial cookbook layout\\\", \\\"background\\\": \\\"Soft neutral beige / cream\\\", \\\"lighting\\\": \\\"Soft diffused light with gentle shadows\\\", \\\"detail_level\\\": \\\"Ultra-realistic, ultra-sharp, 8K resolution\\\" }, \\\"layout\\\": { \\\"composition\\\": \\\"Finished dish centered on a white ceramic plate or bowl\\\", \\\"elements\\\": [ \\\"Floating ingredient icons in soft circular frames\\\", \\\"Clean vector-style ingredient illustrations\\\", \\\"Clear ingredient labels with quantities\\\", \\\"Curved step-by-step flow with numbered cooking icons\\\" ], \\\"typography\\\": \\\"High readability, modern sans-serif\\\", \\\"spacing\\\": \\\"Balanced, airy, uncluttered\\\" }, \\\"recipes\\\": [ { \\\"dish_name\\\": \\\"Traditional Polish Pierogi\\\", \\\"dish_presentation\\\": \\\"Golden boiled dumplings filled with potato and cheese, lightly buttered and garnished with fresh chives\\\", \\\"ingredients\\\": [ { \\\"name\\\": \\\"All-purpose flour\\\", \\\"quantity\\\": \\\"2.5 cups\\\" }, { \\\"name\\\": \\\"Potatoes\\\", \\\"quantity\\\": \\\"3 medium\\\" }, { \\\"name\\\": \\\"Farmer cheese\\\", \\\"quantity\\\": \\\"200g\\\" }, { \\\"name\\\": \\\"Onion\\\", \\\"quantity\\\": \\\"1 medium\\\" }, { \\\"name\\\": \\\"Butter\\\", \\\"quantity\\\": \\\"40g\\\" }, { \\\"name\\\": \\\"Salt\\\", \\\"quantity\\\": \\\"1 tsp\\\" }, { \\\"name\\\": \\\"Water\\\", \\\"quantity\\\": \\\"0.75 cups\\\" } ], \\\"steps\\\": [ \\\"Prepare dough\\\", \\\"Cook and mash filling\\\", \\\"Fill and shape pierogi\\\", \\\"Boil until tender\\\", \\\"Serve with butter\\\" ], \\\"meta\\\": { \\\"calories\\\": \\\"270 kcal / serving\\\", \\\"time\\\": \\\"70 min\\\", \\\"servings\\\": 4 } }, { \\\"dish_name\\\": \\\"Vinaigrette Salad\\\", \\\"dish_presentation\\\": \\\"Colorful diced vegetables mixed with light dressing, neatly molded and topped with fresh herbs\\\", \\\"ingredients\\\": [ { \\\"name\\\": \\\"Beetroot\\\", \\\"quantity\\\": \\\"2 medium\\\" }, { \\\"name\\\": \\\"Potatoes\\\", \\\"quantity\\\": \\\"2 medium\\\" }, { \\\"name\\\": \\\"Carrots\\\", \\\"quantity\\\": \\\"1 medium\\\" }, { \\\"name\\\": \\\"Pickled cucumbers\\\", \\\"quantity\\\": \\\"2 pcs\\\" }, { \\\"name\\\": \\\"Green peas\\\", \\\"quantity\\\": \\\"1 cup\\\" }, { \\\"name\\\": \\\"Sunflower oil\\\", \\\"quantity\\\": \\\"2 tbsp\\\" }, { \\\"name\\\": \\\"Fresh dill\\\", \\\"quantity\\\": \\\"1 bunch\\\" } ], \\\"steps\\\": [ \\\"Boil vegetables\\\", \\\"Cool and dice\\\", \\\"Mix ingredients\\\", \\\"Dress salad\\\", \\\"Chill and serve\\\" ], \\\"meta\\\": { \\\"calories\\\": \\\"180 kcal / serving\\\", \\\"time\\\": \\\"30 min + chill\\\", \\\"servings\\\": 4 } }, { \\\"dish_name\\\": \\\"Solyanka Soup\\\", \\\"dish_presentation\\\": \\\"Rich hearty soup with sliced meats, olives, lemon, and herbs, served steaming in a ceramic bowl\\\", \\\"ingredients\\\": [ { \\\"name\\\": \\\"Mixed meats\\\", \\\"quantity\\\": \\\"400g\\\" }, { \\\"name\\\": \\\"Onion\\\", \\\"quantity\\\": \\\"1 large\\\" }, { \\\"name\\\": \\\"Pickles\\\", \\\"quantity\\\": \\\"3 pcs\\\" }, { \\\"name\\\": \\\"Tomato paste\\\", \\\"quantity\\\": \\\"2 tbsp\\\" }, { \\\"name\\\": \\\"Olives\\\", \\\"quantity\\\": \\\"1/2 cup\\\" }, { \\\"name\\\": \\\"Garlic\\\", \\\"quantity\\\": \\\"2 cloves\\\" }, { \\\"name\\\": \\\"Bay leaf\\\", \\\"quantity\\\": \\\"1 pc\\\" }, { \\\"name\\\": \\\"Lemon\\\", \\\"quantity\\\": \\\"For serving\\\" } ], \\\"steps\\\": [ \\\"Simmer broth\\\", \\\"Sauté aromatics\\\", \\\"Add meats and pickles\\\", \\\"Season and simmer\\\", \\\"Serve with lemon\\\" ], \\\"meta\\\": { \\\"calories\\\": \\\"320 kcal / serving\\\", \\\"time\\\": \\\"90 min\\\", \\\"servings\\\": 5 } } ] }\"}")
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)
}