Generate Images
Create an image given a prompt.
Try It
POST
/v1/images/generationshttps://api-platform.ope.aiAuthentication
Uses Bearer Token authentication.
- Header:
Authorization: Bearer <token> - Example:
Authorization: Bearer sk-xxxxxx
Request body (application/json)
| Field | Type | Required | Description | Default / Range |
|---|---|---|---|---|
model | string | Yes | Model for image generation | Qwen-Image |
prompt | string | Yes | Text description of the image | - |
size | string | Yes | Generated image size | Example: 1024x1024 |
n | integer | No | Number of images to generate | Default: 1 |
Request examples
The domain below is an example:
https://api-platform.ope.ai.
- cURL
- JavaScript
- Go
- Python
- Java
- C#
curl -X POST "https://api-platform.ope.ai/v1/images/generations" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen-Image",
"prompt": "Generate an image showcasing AI image generation capabilities.",
"size": "1024x1024"
}'
const url = "https://api-platform.ope.ai/v1/images/generations";
const apiKey = process.env.OPEAI_API_KEY;
const res = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "Qwen-Image",
prompt: "Generate an image showcasing AI image generation capabilities.",
size: "1024x1024",
}),
});
console.log(await res.json());
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"model":"Qwen-Image","prompt":"Generate an image showcasing AI image generation capabilities.","size":"1024x1024"}`)
req, _ := http.NewRequest("POST", "https://api-platform.ope.ai/v1/images/generations", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPEAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}
import os
import requests
resp = requests.post(
"https://api-platform.ope.ai/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ.get('OPEAI_API_KEY')}",
"Content-Type": "application/json",
},
json={"model": "Qwen-Image", "prompt": "Generate an image showcasing AI image generation capabilities.", "size": "1024x1024"},
timeout=60,
)
print(resp.json())
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("OPEAI_API_KEY");
String url = "https://api-platform.ope.ai/v1/images/generations";
String json = """
{ "model": "Qwen-Image", "prompt": "Generate an image showcasing AI image generation capabilities.", "size": "1024x1024" }
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public class Program
{
public static async Task Main()
{
var apiKey = Environment.GetEnvironmentVariable("OPEAI_API_KEY");
var url = "https://api-platform.ope.ai/v1/images/generations";
var json = """
{ "model": "Qwen-Image", "prompt": "Generate an image showcasing AI image generation capabilities.", "size": "1024x1024" }
""";
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await http.PostAsync(url, content);
Console.WriteLine((int)resp.StatusCode);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
}
}
Response example (200)
{
"created": 0,
"data": [
{
"b64_json": "string",
"url": "string"
}
],
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
}