ساخت و ویرایش تصویر
API تصویر هم متنبهتصویر و هم ویرایش فایل را پشتیبانی میکند. مدل، اندازه، کیفیت و قالب ورودی بر قیمت اثر دارد؛ ویرایش از multipart/form-data استفاده میکند.
- برای ساخت از /v1/images/generations و برای ویرایش از /v1/images/edits استفاده کنید.
- size، quality، تعداد و محدودیت فایل هر مدل را بررسی کنید.
- هزینهٔ نهایی بر اساس نتیجهٔ تکمیلشده و usage است.
نمونههای کامل
همهٔ نمونههای قابل اجرای راهنمای اصلی در ادامه حفظ شدهاند. فقط بلوک متناسب با ابزار و سیستمعامل خود را اجرا کنید.
bash
curl https://nordrouter.com/v1/chat/completions \
-H "Authorization: Bearer sk-nr-YOUR-KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-flash-image-preview",
"modalities": ["image", "text"],
"messages": [{ "role": "user", "content": "A cozy cabin in the woods, watercolor" }]
}'python
from openai import OpenAI
client = OpenAI(base_url="https://nordrouter.com/v1", api_key="sk-nr-YOUR-KEY")
resp = client.chat.completions.create(
model="google/gemini-3.1-flash-image-preview",
modalities=["image", "text"],
messages=[{"role": "user", "content": "A cozy cabin in the woods, watercolor"}],
)
img_b64 = resp.choices[0].message.images[0]["image_url"]["url"] # data:image/png;base64,...python
resp = client.chat.completions.create(
model="google/gemini-3.1-flash-image-preview",
modalities=["image", "text"],
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Repaint the car blue and remove the background"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,<YOUR-PHOTO>"}},
],
}],
)bash
curl https://nordrouter.com/v1/images/generations \
-H "Authorization: Bearer sk-nr-YOUR-KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"prompt": "Coffee shop logo, minimalist, emerald on white",
"size": "1024x1024",
"n": 1
}'python
resp = client.images.generate(
model="openai/gpt-image-2",
prompt="Coffee shop logo, minimalist, emerald on white",
size="1024x1024",
)
img_b64 = resp.data[0].b64_jsonمستندات رسمی و پیوندها
| Model | ≈ per image | How to call |
|---|---|---|
google/gemini-3.1-flash-image-preview (Nano Banana) | ~$0.012 | chat + modalities |
google/gemini-3-pro-image (Nano Banana Pro) | ~$0.028 | chat + modalities |
openai/gpt-image-2 | ~$0.001–0.10 (varies by size & quality) | /v1/images/generations |
| Size · quality | Output tokens | Price |
|---|---|---|
| 1024×1024 · low | ~200 | ~$0.0014 |
| 1024×1024 · high | ~7,000 | ~$0.05 |
| 1536×1024 · high | ~10,500 | ~$0.076 |
| 2048×2048 · high | ~14,300 | ~$0.10 |
راهنماهای مرتبط
ابتدا اتصال را با یک درخواست متنی کوچک بررسی کنید؛ سپس streaming، فراخوانی ابزار، تصویر و قابلیتهای پیشرفته را اضافه کنید. کلید API را در کد عمومی یا frontend مرورگر قرار ندهید.