SnapeditAPI
Đăng nhậpBắt đầu miễn phí
Đăng nhập
API Reference

Generate image from text (OpenAI SDK)

Generate images from text prompts using the OpenAI SDK client.images.generate() method.

Setup

from openai import OpenAI
client = OpenAI(api_key='sk-snap-xxx', base_url='https://api.snapedit.app/v1')

Supported Models

ModelDescriptionCredit
snapedit/z-imageText to Image (Z-Image)9
snapedit/qwen-imageText to Image (Qwen)4

Examples

Python:

result = client.images.generate(
    model='snapedit/z-image',
    prompt='a cute cat sitting on a cloud',
    size='1024x1024'
)
print(result.data[0].url)

Node.js:

const result = await client.images.generate({
    model: 'snapedit/z-image',
    prompt: 'a cute cat sitting on a cloud',
    size: '1024x1024'
});
console.log(result.data[0].url);

Size Mapping

size is auto-converted to aspect_ratio:
- 1024x10241:1
- 1792x102416:9
- 1024x17929:16
- 1536x10243:2
- 1024x15362:3

post/v1/images/generations (OpenAI SDK)

AuthorizationThis endpoint requires an API key. Pass it in the api-key header on every request. Learn more

Responses

Image generated successfullySingleImageResponse

FieldTypeDescription
createdintegerUnix timestamp of when the response was created
dataobject[]
urlstringURL to download the result image
curl -X POST "https://api.snapedit.app/v1/images/generations (OpenAI SDK)" \
  -H "api-key: YOUR_API_KEY"
Response
{
  "created": 1745827200,
  "data": [
    {
      "url": "https://outputs.snapedit.app/outputs/abc123.png"
    }
  ]
}