HiAPI
  • 模型广场
  • 定价
搜索

搜索 HiAPI 模型、工具和资源。

  • 模型广场
  • 定价
HiAPI

一个 API,所有 AI 模型

通过一个生产级 API,调用领先模型生成图像、视频与音频。

免费获取 API Key

AI 图像 API

  • 全部图像模型
  • GPT Image 2.5 Flare
  • GPT Image 2.5 Sunburst
  • GPT Image 2
  • Nano Banana 2
  • Seedream 5.0 Pro
  • Qwen Image 2.0 Pro
  • FLUX 1.1 Pro

AI 视频 API

  • 全部视频模型
  • Seedance 2.5
  • FLUX.3 Video
  • Seedance 2.0
  • Veo 3.1
  • Kling 3.0

AI 音频 API

  • 全部音频模型
  • MiniMax Music 2.6
  • MiniMax Music 1.5
  • ElevenLabs v3
  • 文字生成音乐
  • 文字转语音

产品

  • 模型广场
  • 在线试用
  • 定价
  • 图片 API 成本计算器
  • 免费 GPT Image 2 生成器
  • 免费图片去背景
  • 免费 Nano Banana 图片生成器
  • 穿搭风格预览
  • 商品图实验室

开发者

  • Agent 接入
  • 文档
  • API 参考
  • Agent Skills
  • LLM 接入索引
  • 博客

公司

  • 关于我们
  • 联系支持
  • 服务条款
  • 隐私政策

© 2026 hiapi. 保留所有权利。

GitHub 开源项目PyPI Python SDK
此文暂无当前语言版本,显示原文。
  • What you'll build, and what you need first
  • The pricing shape you're optimizing for
  • Minimal runnable example
  • Production-grade patterns
  • Related hiapi resources
  • FAQ
教程2026年10月8日

Seedream API Cost Optimization: How to Cut Image Generation Costs on hiapi

hiapiseedreamcost-optimizationapi-tutorialimage-generation

最新模型

探索模型

目录
  • What you'll build, and what you need first
  • The pricing shape you're optimizing for
  • Minimal runnable example
  • Production-grade patterns
  • Related hiapi resources
  • FAQ

现在就用 HiAPI 生成

选一个模型,输入你的提示词,直接查看生成结果。

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

Seedream ships on hiapi as four distinct tiers — seedream-5.0-flash, seedream-5.0-lite, seedream-5.0-pro, and legacy seedream-4.5 — and each one bills differently. Pick the wrong tier or the wrong resolution for the job and you can pay 2-4x more per image for no visible quality gain. This guide shows the actual pricing shape of each tier and a working code pattern for calling the cheapest model that still meets your bar.

What you'll build, and what you need first

You'll build a small Python client that creates a Seedream image task through hiapi's unified task API, waits for the result, and picks resolution/model combinations deliberately instead of defaulting to whatever a tutorial copy-pasted. Before anything else, grab an API key from your hiapi dashboard — every request below sends it as Authorization: Bearer sk-....

The pricing shape you're optimizing for

Current per-image pricing (always confirm against the live pricing page before you ship, since rates do change):

  • seedream-5.0-flash — flat $0.025/image, same price for text-to-image and image-to-image. Cheapest tier on the platform; best for drafts, thumbnails, and anything you'll regenerate several times before picking a winner.
  • seedream-5.0-lite — flat $0.035/image, and critically, the same price whether you render at 2K or 4K. There's no cost reason to ever request 2K on this tier — 4K is a free upgrade.
  • seedream-4.5 (legacy) — flat $0.045/image for both endpoints.
  • seedream-5.0-pro — resolution-tiered, not flat: text-to-image is $0.05 at 1K and $0.10 at 2K; image-to-image is $0.06 at 1K and $0.10 at 2K. On this tier, resolution is where your budget actually goes — a 1K draft costs roughly half of a 2K final render.

That asymmetry is the whole optimization: lite rewards requesting higher resolution (it's free), pro punishes it (it roughly doubles cost). Treat them differently in your calling code instead of hard-coding one resolution everywhere.

Minimal runnable example

Every Seedream call goes through the same async task endpoints: create with POST /v1/tasks, then either poll GET /v1/tasks/{taskId} or receive a webhook callback. Model ids are bare — no leading models/ or vendor prefix.

import os
import time
import requests

API_KEY = os.environ["HIAPI_API_KEY"]  # starts with sk-
BASE_URL = "https://api.hiapi.ai/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}


def create_task(model: str, input_payload: dict) -> str:
    resp = requests.post(f"{BASE_URL}/tasks", headers=HEADERS,
                          json={"model": model, "input": input_payload}, timeout=30)
    resp.raise_for_status()
    return resp.json()["data"]["taskId"]


def wait_task(task_id: str, interval: float = 3.0, timeout: float = 180.0) -> dict:
    deadline = time.time() + timeout
    while time.time() < deadline:
        resp = requests.get(f"{BASE_URL}/tasks/{task_id}", headers=HEADERS, timeout=30)
        resp.raise_for_status()
        data = resp.json()["data"]
        if data["status"] == "success":
            return data
        if data["status"] == "fail":
            raise RuntimeError(data["error"])
        time.sleep(interval)
    raise TimeoutError(f"task {task_id} did not finish within {timeout}s")


# seedream-5.0-lite: 4K costs the same $0.035 as 2K, so always ask for 4K here.
task_id = create_task(
    "seedream-5.0-lite/text-to-image",
    {"prompt": "a minimalist product photo of a ceramic mug on a wooden table", "resolution": "4K"},
)
result = wait_task(task_id)
image_url = result["output"][0]["url"]
print(image_url)

resolution on seedream-5.0-lite only accepts 2K or 4K (no 1K). seedream-5.0-pro instead accepts 1K/2K and additionally requires aspect_ratio (one of 1:1, 4:3, 3:4, 16:9, 9:16, 2:3, 3:2, 21:9) — each Seedream tier has a slightly different input schema, so don't assume one model's accepted fields carry over to another.

Production-grade patterns

Pick the tier programmatically, not by habit. Keep a small cost table next to your call site and route by budget/quality need instead of hard-coding one model everywhere — treat the numbers as a cache of the pricing page, not the source of truth:

SEEDREAM_COST_USD = {
    ("seedream-5.0-flash", None): 0.025,
    ("seedream-5.0-lite", "2K"): 0.035,
    ("seedream-5.0-lite", "4K"): 0.035,   # same price — always prefer 4K
    ("seedream-5.0-pro", "1K"): 0.05,      # text-to-image; i2i 1K is $0.06
    ("seedream-5.0-pro", "2K"): 0.10,
}

def pick_model_for_draft_vs_final(is_final: bool) -> tuple[str, dict]:
    if not is_final:
        return "seedream-5.0-flash", {}  # $0.025, iterate freely
    return "seedream-5.0-pro", {"resolution": "2K"}  # $0.10, one shot at the end

Prefer callbacks to tight polling. Add callback to the create request instead of looping wait_task every few seconds in high-volume pipelines:

task_id_resp = requests.post(
    f"{BASE_URL}/tasks", headers=HEADERS,
    json={
        "model": "seedream-5.0-lite/text-to-image",
        "input": {"prompt": "...", "resolution": "4K"},
        "callback": {"url": "https://yourapp.example.com/webhooks/hiapi", "when": "final"},
    },
    timeout=30,
)

Your webhook handler receives one POST when the task reaches a terminal state (success or fail) instead of your worker burning requests in a poll loop. Polling is still the simpler option if you can't expose a public HTTPS endpoint (local dev, internal tools) — pick callbacks once you're running this at real volume.

Dedupe before you create a task, not after. The task API bills on creation, so a retried request (timeout, crashed worker, redeployed queue consumer) that resubmits the same job bills twice. Before calling create_task, check your own store for an existing task keyed by (model, input_hash) and skip creation if one's already in flight or already succeeded — hiapi's task endpoint has no built-in dedupe, so this has to live in your code.

Handle auth failures explicitly. An invalid or revoked key returns HTTP 401 with a structured body, not a generic error page:

{"error": {"code": "permission_denied", "type": "hiapi_error", "request_id": "..."}}

Check for error.code == "permission_denied" specifically so a bad key fails fast instead of retrying into a timeout.

Related hiapi resources

  • Pricing — current per-model rates; treat any number in this article as a snapshot, not a guarantee.
  • API keys dashboard — create and rotate keys.
  • Seedream 5.0 Lite — Text-to-Image and Image-to-Image model pages.
  • Seedream 5.0 Pro — Text-to-Image and Image-to-Image model pages.
  • Seedream 5.0 Flash model page.
  • Async task API reference — full create/poll/callback contract.
  • Authentication docs — key format and header requirements.

FAQ

Which Seedream model is cheapest for quick drafts or icons? seedream-5.0-flash at a flat $0.025/image — the cheapest tier on the platform, same price for text-to-image and image-to-image.

Does asking for 4K instead of 2K cost more on Seedream 5.0 Lite? No. seedream-5.0-lite is a flat $0.035/image regardless of whether resolution is 2K or 4K, so request 4K by default on this tier.

How much does Seedream 5.0 Pro cost per image? It's resolution-tiered: text-to-image is $0.05 at 1K and $0.10 at 2K; image-to-image is $0.06 at 1K and $0.10 at 2K. Unlike lite, resolution genuinely changes your bill here.

How do I avoid getting billed twice if my job retries? The task API has no server-side idempotency key, so dedupe client-side: store a key for (model, input_hash) before calling create_task and skip creation if that key is already in flight or already succeeded.

Should I poll or use a webhook callback? Poll GET /v1/tasks/{taskId} if you can't expose a public HTTPS endpoint (local dev, scripts). Switch to callback.url + when: "final" once you're running real volume — it replaces a poll loop with a single push notification per task.

What does an invalid API key return? HTTP 401 with {"error": {"code": "permission_denied", "type": "hiapi_error", "request_id": "..."}}. Check for that error code explicitly rather than retrying a bad key into a timeout.

Can I use these prices without an API key first? No — every /v1/tasks call requires a valid Authorization: Bearer sk-... header from a real key created in your dashboard; there's no keyless or trial-without-signup path for production generation.

最新模型

查看全部模型
  • GPT Image 2.5 Flare5 折最低 $0.025/张
  • GPT Image 2.5 Sunburst5 折最低 $0.025/张
  • GPT Image 2最低 $0.030/张
  • Nano Banana 25 折最低 $0.018/张

探索模型

文本图片视频音频
返回博客
GPT Image 2.5 Flare5 折最低 $0.050/张$0.025/张
GPT Image 2.5 Sunburst5 折最低 $0.050/张$0.025/张
GPT Image 2最低 $0.030/张
Nano Banana 25 折最低 $0.036/张$0.018/张
查看全部模型
文本对话与推理
图片生成与编辑
视频文生与图生
音频语音与音乐
开始生成
查看模型价格
查看全部文章
HiAPI 402 Error: How to Fix 'Insufficient Balance'

HiAPI 402 Error: How to Fix 'Insufficient Balance'

Seedance 2.0 Ext First-Frame Video Prompts: Anchor vs Interpolation

Seedance 2.0 Ext First-Frame Video Prompts: Anchor vs Interpolation

Seedance 2.0 Realistic Prompt: Making AI Video Look Like Real Phone Footage

Seedance 2.0 Realistic Prompt: Making AI Video Look Like Real Phone Footage

HiAPI Task Timeout and 504 Errors: How to Fix Them

HiAPI Task Timeout and 504 Errors: How to Fix Them

Building Multi-Model AI Apps with a Single Unified API on hiapi

Building Multi-Model AI Apps with a Single Unified API on hiapi

Seedance 2.0 Ext 2D Sticker Composite Prompt: Full Breakdown

Seedance 2.0 Ext 2D Sticker Composite Prompt: Full Breakdown

开始生成