# Image Filter API `content-filter-image-standard` 图片内容检测模型的完整 API 参考。 ## 概览 Content Filter Image 会检测一个或多个图片 URL 中的受支持内容安全类别,并返回同步检测结果。当前检测类型为 `nsfw`。 ## 端点 ```http POST /api/v1/content/filter ``` ## 身份验证 ```http Authorization: Bearer YOUR_API_KEY ``` ## 请求参数 ### 必需参数 | 参数 | 类型 | 描述 | | ------------ | -------- | ---------------------------------------------------------------------- | | `model_name` | string | 必须为 `"content-filter-image-standard"` | | `type` | string | 检测类型。当前仅支持 `"nsfw"`。 | | `images` | string[] | 要检测的图片 URL。支持单图和多图检测。API 单次请求最多支持 20 张图片。 | ### 不支持 | 参数 | 描述 | | ------ | ----------------------------------------------- | | `text` | 文本检测请使用 `content-filter-text-standard`。 | ## 请求示例 ```javascript const response = await fetch('https://api.flaq.ai/api/v1/content/filter', { method: 'POST', headers: { Authorization: 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ model_name: 'content-filter-image-standard', type: 'nsfw', images: ['https://example.com/image-1.jpg', 'https://example.com/image-2.jpg'], }), }); const result = await response.json(); console.log(result.data); ``` ## 响应格式 ```json { "code": 0, "message": "success", "data": { "type": "nsfw", "flagged": true, "credits": 400, "detail": { "text": null, "images": [ { "url": "https://example.com/image-1.jpg", "checked": true, "flagged": true, "score": 96, "level": "high" }, { "url": "https://example.com/image-2.jpg", "checked": true, "flagged": false, "score": 0, "level": "none" } ] } } } ``` ## 响应数据 | 字段 | 类型 | 描述 | | -------------------- | ------- | ------------------------------------------ | | `data.type` | string | 请求使用的检测类型。 | | `data.flagged` | boolean | 任一成功检测的图片是否命中请求的检测类型。 | | `data.credits` | number | 本次请求消耗的 credits。 | | `data.detail.text` | null | 图片检测时始终为 `null`。 | | `data.detail.images` | array | 每个已提交图片 URL 的检测结果。 | ## 检测结果 `data.detail.images` 中的每一项都使用以下结构: | 字段 | 类型 | 描述 | | --------- | ------- | ----------------------------------------------------- | | `url` | string | 已检测图片 URL。 | | `checked` | boolean | 该项目是否成功完成检测。 | | `flagged` | boolean | 已检测项目是否命中请求的检测类型。 | | `level` | string | 风险等级:`"none"`、`"low"`、`"medium"` 或 `"high"`。 | | `score` | number | 检测分数。展示时建议使用 `level`。 | ### 结果说明 - 如果 `checked` 为 `false`,表示该图片未成功完成检测。此时 `score` 可能为 `0`,`level` 可能为 `"none"`,但该图片应被视 为检测失败,而不是无风险结果。 - `flagged` 仅描述图片完成检测后的检测结果。 - 当至少一张成功检测的图片被标记为命中时,`data.flagged` 为 `true`。 - `level` 是由检测分数映射得到的、适合展示的风险等级。 ## 错误处理 如果请求失败,API 会返回非零 `code` 或非 2xx HTTP 状态。请查看 `message` 字段获取详情。