注册

Ideogram 图片生成接口 - QuickRouter API 中转接口

POST https://api.quickrouter.ai/ideogram/generate 在线调试 →
Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token

示例: Authorization: Bearer ********************

Generates images synchronously based on a given prompt and optional parameters. 具体参数请看官方文档:https://developer.ideogram.ai/api-reference/api-reference/describe 根据给定的提示和可选参数同步生成图像。 返回的图像 URL 在 24 小时内有效,超过该时间将无法访问图像。 已反代图片

请求参数

Header 参数
Content-Type string
必需
示例: application/json
Accept string
必需
示例: application/json
Authorization string
必需
示例: Bearer {{YOUR_API_KEY}}
Body 参数 application/json
image_request object
必需
图像请求对象 (必填)
prompt string
必需
用于生成图像的提示词 (必填)
aspect_ratio string
必需
图像宽高比 (可选) 可选值:ASPECT_10_16/ASPECT_16_10/ASPECT_9_16/ASPECT_16_9/ASPECT_3_2/ASPECT_2_3/ASPECT_4_3/ASPECT_3_4/ASPECT_1_1/ASPECT_1_3/ASPECT_3_1
model string
必需
使用的模型 (可选) 默认V_2,可选值:V_1/V_1_TURBO/V_2/V_2_TURBO
magic_prompt_option string
必需
是否使用MagicPrompt (可选) 可选值:AUTO/ON/OFF
seed integer
必需
随机种子 (可选) 范围:0-2147483647
style_type string
必需
风格类型 (可选) 可选值:AUTO/GENERAL/REALISTIC/DESIGN/RENDER_3D/ANIME
negative_prompt string
必需
反向提示词 (可选) 描述不想在图像中出现的内容
num_images integer
必需
生成图片数量 (可选) 范围:1-8,默认1
resolution string
必需
分辨率 (可选) 可选值包含从512x1536到1536x640等多种分辨率组合
color_palette object
必需
颜色调色板 (可选) { "image_request": { "aspect_ratio": "ASPECT_10_16", "magic_prompt_option": "AUTO", "model": "V_1", "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset." } } 请求
示例
{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}

请求示例代码

{
  "prompt": "a beautiful image",
  "model": "ideogram-3"
}
curl --location --request POST 'https://api.quickrouter.ai/ideogram/generate' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}'
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer YOUR_API_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
});

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: raw,
   redirect: 'follow'
};

fetch("https://api.quickrouter.ai/ideogram/generate", requestOptions)
   .then(response => response.text())
   .then(result => console.log(result))
   .catch(error => console.log('error', error));
import java.io.*;
import java.net.*;
import java.util.*;

URL url = new URL("https://api.quickrouter.ai/ideogram/generate");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Authorization", "Bearer YOUR_API_KEY");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
String jsonInputString = "{
    \"image_request\": {
        \"aspect_ratio\": \"ASPECT_10_16\",
        \"magic_prompt_option\": \"AUTO\",
        \"model\": \"V_1\",
        \"prompt\": \"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.\"
    }
}";
try(OutputStream os = conn.getOutputStream()) {
    byte[] input = jsonInputString.getBytes("utf-8");
    os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
import Foundation

let urlString = "https://api.quickrouter.ai/ideogram/generate"
guard let url = URL(string: urlString) else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let httpBody = "{
    \"image_request\": {
        \"aspect_ratio\": \"ASPECT_10_16\",
        \"magic_prompt_option\": \"AUTO\",
        \"model\": \"V_1\",
        \"prompt\": \"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.\"
    }
}"
request.httpBody = httpBody.data(using: .utf8)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8)!)
    }
}
task.resume()
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    body := strings.NewReader(`{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}`)
    req, _ := http.NewRequest("POST", "https://api.quickrouter.ai/ideogram/generate", body)
    req.Header.Set("Accept", "application/json")
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
    bodyBytes, _ := io.ReadAll(resp.Body)
    fmt.Println(string(bodyBytes))
}
<?php

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.quickrouter.ai/ideogram/generate',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => '{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}',
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Authorization: Bearer YOUR_API_KEY",
    "Content-Type: application/json",
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import http.client
import json

conn = http.client.HTTPSConnection("api.quickrouter.ai")
payload = json.dumps({
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
})
headers = {
   'Accept': 'application/json',
   'Authorization': 'Bearer YOUR_API_KEY',
   'Content-Type': 'application/json',
}
conn.request("POST", "/ideogram/generate", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
POST https://api.quickrouter.ai/ideogram/generate HTTP/1.1
Accept: application/json
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.quickrouter.ai/ideogram/generate");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{
    \"image_request\": {
        \"aspect_ratio\": \"ASPECT_10_16\",
        \"magic_prompt_option\": \"AUTO\",
        \"model\": \"V_1\",
        \"prompt\": \"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.\"
    }
}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.quickrouter.ai/ideogram/generate");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_KEY");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", @"{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
#import <Foundation/Foundation.h>

NSURL *url = [NSURL URLWithString:@"https://api.quickrouter.ai/ideogram/generate"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"Bearer YOUR_API_KEY" forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[@"{
    \"image_request\": {
        \"aspect_ratio\": \"ASPECT_10_16\",
        \"magic_prompt_option\": \"AUTO\",
        \"model\": \"V_1\",
        \"prompt\": \"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.\"
    }
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}];
[task resume];
require "uri"
require "net/http"
require "json"

url = URI("https://api.quickrouter.ai/ideogram/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = '{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}'
response = http.request(request)
puts response.read_body
(* Requires cohttp and lwt *)

let url = "https://api.quickrouter.ai/ideogram/generate" in
let headers = Cohttp.Header.of_list [
  ("Accept", "application/json");
  ("Authorization", "Bearer YOUR_API_KEY");
  ("Content-Type", "application/json");
] in
let body = Cohttp_lwt.Body.of_string '{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}' in
Lwt_main.run (
  Cohttp_lwt_unix.Client.request ?body:(Some body) ~method_:`POST ~headers (Uri.of_string url)
  >>= fun (resp, body) ->
  Cohttp_lwt.Body.to_string body >|= fun s -> print_endline s
)
import 'package:http/http.dart' as http;
import 'dart:convert';

var headers = {
  "Accept": "application/json",
  "Authorization": "Bearer YOUR_API_KEY",
  "Content-Type": "application/json",
};
var body = json.encode({
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
});
var response = await http.post(Uri.parse("https://api.quickrouter.ai/ideogram/generate"), headers: headers, body: body);
print(response.body);
library(httr)

url <- "https://api.quickrouter.ai/ideogram/generate"
body <- '{
    "image_request": {
        "aspect_ratio": "ASPECT_10_16",
        "magic_prompt_option": "AUTO",
        "model": "V_1",
        "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."
    }
}'
response <- post(url, body = body, add_headers("Accept" = "application/json", "Authorization" = "Bearer YOUR_API_KEY", "Content-Type" = "application/json"))
content(response, "text", encoding = "UTF-8")

返回响应

响应参数 🟢 200 OK · application/json
created string
必需
data array [object]
必需
is_image_safe boolean
可选
prompt string
可选
resolution string
可选
seed integer
可选
style_type null
可选
url string
可选
{ "created": "2024-12-15T17:32:00.965408+00:00", "data": [ { "is_image_safe": true, "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.", "resolution": "768x1232", "seed": 1785282233, "style_type": null, "url": "https://ideogram.ai/api/images/ephemeral/WkoxvqiOTaaCqG1nO2tQoA.png?exp=1734370337&sig=110fe96dc9e01002c8d837e5b4cde1aaa266195561d231ce76e19e095e478ffe" } ] }
示例
{
    "created": "2024-12-15T17:32:00.965408+00:00",
    "data": [
        {
            "is_image_safe": true,
            "prompt": "A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.",
            "resolution": "768x1232",
            "seed": 1785282233,
            "style_type": null,
            "url": "https://ideogram.ai/api/images/ephemeral/WkoxvqiOTaaCqG1nO2tQoA.png?exp=1734370337&sig=110fe96dc9e01002c8d837e5b4cde1aaa266195561d231ce76e19e095e478ffe"
        }
    ]
}