# SEE2AI 音频转码

> SEE2AI audio transcode. Submit an audio URL with optional encoding settings, then poll for a stable hosted result URL.

## 📖 接入指引

**Endpoint**: `POST /api/v1/actions/see2ai_audio_transcode_v1`

**认证方式**: Bearer Token (租户 API Key)

### Endpoints

| Method | Path | Purpose |
| --- | --- | --- |
| `POST` | `/api/v1/actions/see2ai_audio_transcode_v1` | Submit the standard action request. |

> **⚠️ 重要提示**
> 
> 本 API 是 SEE2AI 平台标准化封装后的接口，**参数格式与任何上游 API 不同**。
> 请直接使用下方 Schema 中定义的参数，无需参考其他文档。
> 
> *例如：*
> *- 文本模型参数可能是 `query` 而不是 `messages` 数组*
> *- 视频模型参数可能是 `brief` (创意简报) 而不是复杂的配置项*

## 📥 输入参数 (Input Schema)

```json
{
  "$defs": {
    "AudioTranscodeSettings": {
      "properties": {
        "bitrate_mode": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional bitrate mode. Use cbr for constant bitrate or cae for adaptive AAC/M4A output.",
          "title": "Bitrate Mode"
        },
        "bitrate_kbps": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional target bitrate in kbps.",
          "title": "Bitrate Kbps"
        },
        "sample_rate": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional output sample rate in Hz.",
          "title": "Sample Rate"
        },
        "channels": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional output channel count, usually 1 or 2.",
          "title": "Channels"
        },
        "volume_method": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional loudness normalization method.",
          "title": "Volume Method"
        },
        "volume_integrated_loudness": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional target integrated loudness in LUFS when loudness normalization is enabled.",
          "title": "Volume Integrated Loudness"
        },
        "volume_true_peak": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional true peak ceiling in dBTP when loudness normalization is enabled.",
          "title": "Volume True Peak"
        }
      },
      "title": "AudioTranscodeSettings",
      "type": "object"
    },
    "MetadataTag": {
      "properties": {
        "key": {
          "description": "Metadata tag name to add or overwrite.",
          "title": "Key",
          "type": "string"
        },
        "value": {
          "description": "Metadata tag value.",
          "title": "Value",
          "type": "string"
        }
      },
      "required": [
        "key",
        "value"
      ],
      "title": "MetadataTag",
      "type": "object"
    }
  },
  "properties": {
    "audio_url": {
      "description": "Public http(s) URL of the source audio file.",
      "title": "Audio Url",
      "type": "string"
    },
    "container_format": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional output container format such as MP3, M4A, WAV, AAC, OGG, or FLAC.",
      "title": "Container Format"
    },
    "audio": {
      "anyOf": [
        {
          "$ref": "#/$defs/AudioTranscodeSettings"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional audio encoding settings."
    },
    "metadata_keep_tags": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional source metadata tag names to preserve.",
      "title": "Metadata Keep Tags"
    },
    "metadata_add_tags": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/MetadataTag"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional metadata tags to add or overwrite.",
      "title": "Metadata Add Tags"
    },
    "sync": {
      "default": false,
      "description": "Whether to wait synchronously. This Action currently supports async submit+poll; keep false.",
      "title": "Sync",
      "type": "boolean"
    }
  },
  "required": [
    "audio_url"
  ],
  "title": "ActionInput",
  "type": "object"
}
```

### 参数说明

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|--------|------|------|--------|------|
| `audio_url` | string | ✅ 是 | `-` | Public http(s) URL of the source audio file. |
| `container_format` | string / null | ❌ 否 | `-` | Optional output container format such as MP3, M4A, WAV, AAC, OGG, or FLAC. |
| `audio` | object / null | ❌ 否 | `-` | Optional audio encoding settings. |
| `metadata_keep_tags` | array / null | ❌ 否 | `-` | Optional source metadata tag names to preserve. |
| `metadata_add_tags` | array / null | ❌ 否 | `-` | Optional metadata tags to add or overwrite. |
| `sync` | boolean | ❌ 否 | `False` | Whether to wait synchronously. This Action currently supports async submit+poll; keep false. |

## 📤 输出结果 (Output Schema)

```json
{
  "properties": {
    "input_tokens": {
      "default": 0,
      "description": "输入消耗的词元数量",
      "title": "Input Tokens",
      "type": "integer"
    },
    "output_tokens": {
      "default": 0,
      "description": "输出消耗的词元数量",
      "title": "Output Tokens",
      "type": "integer"
    },
    "total_tokens": {
      "default": 0,
      "description": "总消耗的词元数量",
      "title": "Total Tokens",
      "type": "integer"
    },
    "model": {
      "default": "",
      "description": "实际使用的 SEE2AI 化身模型名称（由各 action 显式填写）",
      "title": "Model",
      "type": "string"
    },
    "source": {
      "default": "see2ai",
      "description": "服务来源（统一 `see2ai`；真实路由仅平台内部可见）",
      "title": "Source",
      "type": "string"
    },
    "cost_points": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算）",
      "title": "Cost Points"
    },
    "task_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SEE2AI platform task id for status polling.",
      "title": "Task Id"
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Task status: running, success, or failed.",
      "title": "Status"
    },
    "result_urls": {
      "description": "Stable SEE2AI hosted result URLs.",
      "items": {
        "type": "string"
      },
      "title": "Result Urls",
      "type": "array"
    },
    "audio_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Stable transcoded audio URL.",
      "title": "Audio Url"
    },
    "duration": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Output duration in seconds, when available.",
      "title": "Duration"
    },
    "expires_at": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Temporary upstream expiry timestamp, when available.",
      "title": "Expires At"
    },
    "estimated_cost": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Estimated platform token cost for submit.",
      "title": "Estimated Cost"
    },
    "warnings": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "List of non-blocking optimization suggestions produced by validation.",
      "title": "Warnings"
    }
  },
  "title": "ActionOutput",
  "type": "object"
}
```

### 输出字段说明

| 字段名 | 类型 | 说明 |
|--------|------|------|
| `input_tokens` | integer | 输入消耗的词元数量 |
| `output_tokens` | integer | 输出消耗的词元数量 |
| `total_tokens` | integer | 总消耗的词元数量 |
| `model` | string | 实际使用的 SEE2AI 化身模型名称（由各 action 显式填写） |
| `source` | string | 服务来源（统一 `see2ai`；真实路由仅平台内部可见） |
| `cost_points` | integer / null | 预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算） |
| `task_id` | string / null | SEE2AI platform task id for status polling. |
| `status` | string / null | Task status: running, success, or failed. |
| `result_urls` | array | Stable SEE2AI hosted result URLs. |
| `audio_url` | string / null | Stable transcoded audio URL. |
| `duration` | number / null | Output duration in seconds, when available. |
| `expires_at` | integer / null | Temporary upstream expiry timestamp, when available. |
| `estimated_cost` | integer / null | Estimated platform token cost for submit. |
| `warnings` | array / null | List of non-blocking optimization suggestions produced by validation. |

## 💡 调用示例

### cURL 示例

```bash
curl -X POST "https://see2ai.com/api/v1/actions/see2ai_audio_transcode_v1" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer sk-your-tenant-api-key" \
     -d '{
  "audio_url": "https://example.com/audio.mp3",
  "sync": false
}'
```

### Python 示例

```python
import requests

API_KEY = "sk-your-tenant-api-key"
ENDPOINT = "https://see2ai.com/api/v1/actions/see2ai_audio_transcode_v1"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

payload = {
  "audio_url": "https://example.com/audio.mp3",
  "sync": false
}

response = requests.post(ENDPOINT, json=payload, headers=headers)
result = response.json()

print(f"结果：{result}")
```

## 💰 计费说明

> Submit and running tasks are not charged. Terminal success charges by output audio duration using the SEE2AI audio editing tier, after the transcoded file is safely hosted by SEE2AI.

**注意**: 所有费用都以词元为单位，系统会自动从租户余额中扣除。

## ⚠️ 常见错误码

| HTTP 状态码 | 错误原因 | 解决方案 |
| --- | --- | --- |
| `401` | Authentication failed or tenant balance is insufficient | 检查 API Key 是否正确，或联系管理员充值 |
| `422` | Input validation failed | 检查请求参数是否符合 Schema 要求 |
| `503` | SEE2AI audio transcode service is temporarily unavailable | 请稍后重试 |

## 📞 技术支持

- **文档问题**: 查看 [SEE2AI 官方文档](https://see2ai.com/docs)
- **API 状态**: 访问 [服务状态页面](https://see2ai.com/status)
- **问题反馈**: 联系技术支持团队

---

**API 版本**: see2ai_audio_transcode_v1
**最后更新**: 2026-03-23
