众扬汇 AI 开放平台 API 文档

接入教程

支持的模型

平台已开通下列 fal-ai 模型通道,清单为示例,实际在售以「模型广场」为准。

模型 说明
fal-ai/flux-1/dev 画图
fal-ai/flux-1/dev/image-to-image 画图
fal-ai/flux-1/dev/redux 画图
fal-ai/flux-1/schnell 画图
fal-ai/flux-1/schnell/redux 画图
fal-ai/flux-pro/kontext 画图
fal-ai/flux-pro/kontext/max 画图
fal-ai/flux-pro/kontext/max/multi 画图
fal-ai/flux-pro/kontext/max/text-to-image 画图
fal-ai/flux-pro/kontext/multi 画图
fal-ai/flux-pro/kontext/text-to-image 画图

Fal-ai API 接口文档

约定
请求头携带 Authorization: Bearer <令牌>(官方口径为 Authorization: key <KEY>); 将官方的 https://queue.fal.run 替换为平台请求域名,输入、输出与请求方式与官方保持一致。

1. 生成任务

接口

text
POST {{BASE_URL}}/fal-ai/{{model}}

示例

shell
curl --request POST \
  --url {{BASE_URL}}/fal-ai/flux-1/dev \
  --header 'Authorization: Bearer your-key' \
  --header 'Content-Type: application/json' \
  --data '{
     "prompt": "Extreme close-up of a single cat eye, direct frontal view. Detailed iris and pupil. Sharp focus on eye texture and color. Natural lighting to capture authentic eye shine and depth. The word \"openai-hk\" is painted over it in big, white brush strokes with visible texture."
}'

具体的请求方式请查阅各模型说明。请注意:部分请求参数在中转过程中可能无法正确生效,建议先用 prompt 试跑;若发现某个参数不生效,可联系对接人核查维护。

返回体

json
{
  "status": "IN_QUEUE",
  "request_id": "551a32da-52b2-4be8-bf2f-bfb7cce2b324",
  "response_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324",
  "status_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324/status",
  "cancel_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324/cancel",
  "queue_position": 0
}

说明
返回体中的 response_url、status_url、cancel_url 为后续请求链接,需将 https://queue.fal.run 替换为平台请求域名。


2. 获取任务结果

获取结果的有效期待核,请务必及时保存。

接口

text
GET {BASE_URL}/fal-ai/{modelname}/requests/{request_id}

示例

返回中的 unit_price 为本次任务的消费额度,可用于计费核对。

shell
curl --request GET \
  --url {{BASE_URL}}/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324 \
  --header 'Authorization: Bearer hk-your-key' \
  --header 'Content-Type: application/json'

返回体.图片

结果在 images

json
{
    "cancel_url": "https://queue.fal.run/fal-ai/flux-1/requests/019e06a4-3218-7ad0-b907-eae764b029ac/cancel",
    "has_nsfw_concepts": [
        false
    ],
    "images": [
        {
            "content_type": "image/jpeg",
            "height": 768,
            "url": "https://v3b.fal.media/files/b/0a995c44/saUxQYNhUY3Id6Xh9Mk-s.jpg",
            "width": 1024
        }
    ],
    "logs": null,
    "metrics": {
        "inference_time": 7.414219856262207
    },
    "prompt": "Extreme close-up of a single tiger eye, direct frontal view. Detailed iris and pupil. Sharp focus on eye texture and color. Natural lighting to capture authentic eye shine and depth. The word \"FLUX\" is painted over it in big, white brush strokes with visible texture.",
    "request_id": "019e06a4-3218-7ad0-b907-eae764b029ac",
    "response_url": "https://queue.fal.run/fal-ai/flux-1/requests/019e06a4-3218-7ad0-b907-eae764b029ac",
    "seed": 1568725547,
    "status": "COMPLETED",
    "status_url": "https://queue.fal.run/fal-ai/flux-1/requests/019e06a4-3218-7ad0-b907-eae764b029ac/status",
    "timings": {
        "inference": 7.115621507997275
    },
    "unit_price": "0.025"
}

返回体.视频

结果在 video 字段中

json
{
  "video": {
    "url": "https://v3.fal.media/files/lion/eSsTNfWQRXfWGim1B8ZL5_output.mp4",
    "content_type": "video/mp4",
    "file_name": "output.mp4",
    "file_size": 946834
  },
  "unit_price": "0.025"
}

获取结果有时效,请务必保存。