feat(docs): /v1/docs端点——四语言API文档(中英日韩)+index.ui按_lang分发ApiDoc(照sage docs同款逻辑)

This commit is contained in:
yumoqing 2026-09-05 15:43:20 +08:00
parent 8da377fc81
commit 2ee4b7893c
5 changed files with 626 additions and 0 deletions

View File

@ -0,0 +1,154 @@
# Pipeline Platform Model API Docs
---
# Unified Model Governance Inference API
Base url: `https://pipeline.opencomputing.cn/pipeline-llm/api/v1`
All endpoints require Bearer Token authentication (short-lived token, NOT the real model key).
Tenant isolation: requests are routed through the governance chain by the tenant bound to the token; real model keys never leave the server process.
---
## POST /v1/chat/completions
Unified model invocation entry (OpenAI-compatible). Synchronous models return in one round-trip; async models (image-to-video, etc.) are handled automatically by the server: submit task → poll → fetch result, returning a persisted local URL.
### Required Parameters
| Param | Type | Description |
|------|------|------|
| `messages` | array | Conversation messages, `[{"role": "user", "content": "..."}]` |
### Optional Parameters
| Param | Type | Description |
|------|------|------|
| `model` | string | Model name (e.g. `happyhorse-1.1-i2v`). Omit = tenant policy default model (primary→backup chain) |
| `temperature` | float | Sampling temperature |
| `tools` | array | Tool definitions (t2t models, OpenAI-compatible) |
| `_purpose` | string | Purpose marker: `utility` = auxiliary task (classify/select/summarize), uses utility model chain |
| `_timeout` | int | Per-call timeout in seconds (0=endpoint default; max 900) |
### Extra Parameters for Async Models (i2v / t2v / t2i ...)
| Param | Type | Description |
|------|------|------|
| `image_file` | string | Uploaded media (base64/data URL auto-converted to local public URL; http(s) URL used as-is). **Same-capability params uniformly use `xxx_file` naming** |
| `resolution` | string | Resolution, e.g. `480P` / `720P` / `1080P` |
| `duration` | int | Video duration (seconds) |
> Generated artifacts: upstream artifact URLs expire very quickly (video only 24h); the server persists them locally before returning.
### Request Example (chat)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "Hello"}]
}'
```
### Request Example (image-to-video, async)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.1-i2v",
"messages": [{"role": "user", "content": "The character starts rapping"}],
"image_file": "https://example.com/first-frame.png",
"resolution": "720P",
"duration": 5,
"_timeout": 600
}'
```
### Response Example (sync model)
```json
{
"choices": [
{"message": {"content": "Hello!", "role": "assistant"}, "finish_reason": "stop"}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5}
}
```
### Response Example (async model)
```json
{
"choices": [
{"message": {"content": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4", "role": "assistant"},
"finish_reason": "stop"}
],
"usage": {"duration": 5, "SR": 720, "video_count": 1},
"task_id": "e53dee87-...",
"media": {
"status": "SUCCEEDED",
"video": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4",
"usage": {"duration": 5, "SR": 720}
}
}
```
`media` is the unified output field (consistent across same-capability models): video → `video`, image → `image`, 3D model → `glb`.
### Error Response
Failures return OpenAI error structure with actionable messages (gate failures / timeout / missing template config all give specific reasons):
```json
{"error": {"message": "All models in chain unavailable. Last reason: ...", "type": "invalid_request_error", "code": "govern_error"}}
```
---
## GET /v1/models
List models available to the current tenant, grouped by capability (empty list if tenant has no governance policy).
### Optional Parameters
| Param | Type | Description |
|------|------|------|
| `catelogid` | string | Capability: `t2t` / `t2i` / `i2v` / `t2v` / `embedding` / `rerank` / `tts` / `asr` / `i2t`. Omit = all |
### Request Example
```bash
curl 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/models?catelogid=i2v' \
-H 'Authorization: Bearer ***'
```
### Response Example
```json
{
"object": "list",
"data": [
{"id": "happyhorse-1.1-i2v", "object": "model", "name": "happyhorse-1.1-i2v",
"catelogid": "i2v", "vendor": "Alibaba Bailian"}
]
}
```
---
## Authentication & Short-lived Token
- Tokens are issued by the platform (bound to tenant/project/task, with expiry and call limits, revocable)
- Usage: `Authorization: Bearer ***
- Tokens are NOT real model keys; real keys are resolved server-side only and never leave the process
## Billing
- Each call automatically creates a usage record (`llm_usage`), billed asynchronously per the pricing program (ppid) attached to the model
- Non-token pricing factors (video duration/resolution, etc.) are stored in the record's `usages` field

View File

@ -0,0 +1,154 @@
# パイプラインプラットフォーム モデル API ドキュメント
---
# モデルガバナンス統合推論 API
Base url: `https://pipeline.opencomputing.cn/pipeline-llm/api/v1`
すべての API エンドポイントには Bearer Token 認証が必要です(短期トークン、実際のモデルキーではありません)。
テナント分離:トークンに紐づくテナントに基づきガバナンスチェーン経由で実際のモデルとキーを解決します。実際のキーはサーバープロセス外に出ません。
---
## POST /v1/chat/completions
モデル呼び出しの統一入口OpenAI 互換形式。同期モデルは1回の往復で結果を返します。非同期モデル画像→動画などはサーバーが自動的に「タスク送信 → ポーリング → 結果取得」を完了し、ローカルに永続化されたアドレスを返します。
### 必須パラメータ
| パラメータ | 型 | 説明 |
|------|------|------|
| `messages` | array | 対話メッセージ配列、`[{"role": "user", "content": "..."}]` |
### 任意パラメータ
| パラメータ | 型 | 説明 |
|------|------|------|
| `model` | string | モデル名(例:`happyhorse-1.1-i2v`)。未指定 = テナントポリシーのデフォルトモデル(プライマリ→バックアップチェーンの先頭) |
| `temperature` | float | サンプリング温度 |
| `tools` | array | ツール定義t2t モデル、OpenAI 互換) |
| `_purpose` | string | 用途マーカー:`utility` = 補助タスク(分類/選択/要約)、補助モデルチェーンを使用 |
| `_timeout` | int | 1回の呼び出しのタイムアウト秒数0=エンドポイントデフォルト;上限 900 |
### 非同期モデルの追加パラメータi2v / t2v / t2i など)
| パラメータ | 型 | 説明 |
|------|------|------|
| `image_file` | string | アップロードメディアbase64/data URL は自動的にローカル公開 URL に変換http(s) URL はそのまま使用)。**同種機能のパラメータは統一して `xxx_file` 命名** |
| `resolution` | string | 解像度、例:`480P` / `720P` / `1080P` |
| `duration` | int | 動画の長さ(秒) |
> 生成物について:上流が返す画像/動画などの産物 URL は有効期限が非常に短い動画はわずか24時間ため、サーバーがローカルに永続化してから返します。
### リクエスト例(テキスト対話)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "こんにちは"}]
}'
```
### リクエスト例(画像→動画、非同期モデル)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.1-i2v",
"messages": [{"role": "user", "content": "キャラクターがラップを始める"}],
"image_file": "https://example.com/first-frame.png",
"resolution": "720P",
"duration": 5,
"_timeout": 600
}'
```
### レスポンス例(同期モデル)
```json
{
"choices": [
{"message": {"content": "こんにちは!", "role": "assistant"}, "finish_reason": "stop"}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5}
}
```
### レスポンス例(非同期モデル)
```json
{
"choices": [
{"message": {"content": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4", "role": "assistant"},
"finish_reason": "stop"}
],
"usage": {"duration": 5, "SR": 720, "video_count": 1},
"task_id": "e53dee87-...",
"media": {
"status": "SUCCEEDED",
"video": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4",
"usage": {"duration": 5, "SR": 720}
}
}
```
`media` フィールドは統一出力パラメータ(同種機能でフィールド名が一致):動画は `video`、画像は `image`、3D モデルは `glb`
### エラーレスポンス
失敗時は OpenAI エラー構造を返し、メッセージは実行可能な内容です(ゲート不通過/タイムアウト/テンプレート設定欠落など、すべて具体的な理由が示されます):
```json
{"error": {"message": "モデルチェーン全体が利用不可。最後の理由:…", "type": "invalid_request_error", "code": "govern_error"}}
```
---
## GET /v1/models
現在のテナントで利用可能なモデルを機能別に一覧表示(テナントにガバナンスポリシーが未設定の場合は空リスト)。
### 任意パラメータ
| パラメータ | 型 | 説明 |
|------|------|------|
| `catelogid` | string | 機能分類:`t2t` / `t2i` / `i2v` / `t2v` / `embedding` / `rerank` / `tts` / `asr` / `i2t`。未指定 = すべて |
### リクエスト例
```bash
curl 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/models?catelogid=i2v' \
-H 'Authorization: Bearer ***'
```
### レスポンス例
```json
{
"object": "list",
"data": [
{"id": "happyhorse-1.1-i2v", "object": "model", "name": "happyhorse-1.1-i2v",
"catelogid": "i2v", "vendor": "Alibaba Bailian"}
]
}
```
---
## 認証と短期トークン
- トークンはプラットフォームが発行(テナント/プロジェクト/タスクに紐づけ、有効期限と呼び出し上限あり、失効可能)
- 使用方法:`Authorization: Bearer ***
- トークンは実際のモデルキーではありません。実際のキーはサーバー側でのみ解決され、プロセス外に出ません
## 課金
- 呼び出しごとに自動的に使用量レコード(`llm_usage`が作成され、モデルに紐づく料金プランppidに基づき非同期で請求されます
- トークン以外の課金要素(動画の長さ/解像度など)はレコードの `usages` フィールドに記録されます

View File

@ -0,0 +1,154 @@
# 파이프라인 플랫폼 모델 API 문서
---
# 모델 거버넌스 통합 추론 API
Base url: `https://pipeline.opencomputing.cn/pipeline-llm/api/v1`
모든 API 엔드포인트는 Bearer Token 인증이 필요합니다 (단기 토큰, 실제 모델 키가 아님).
테넌트 격리: 토큰에 연결된 테넌트를 기준으로 거버넌스 체인을 통해 실제 모델과 키를 해결합니다. 실제 키는 서버 프로세스 외부로 나가지 않습니다.
---
## POST /v1/chat/completions
모델 호출 통합 입구 (OpenAI 호환 형식). 동기 모델은 한 번의 왕복으로 결과를 반환합니다. 비동기 모델 (이미지→비디오 등)은 서버가 자동으로 "작업 제출 → 폴링 → 결과 조회"를 완료하여 로컬에 영속화된 주소를 반환합니다.
### 필수 파라미터
| 파라미터 | 타입 | 설명 |
|------|------|------|
| `messages` | array | 대화 메시지 배열, `[{"role": "user", "content": "..."}]` |
### 선택 파라미터
| 파라미터 | 타입 | 설명 |
|------|------|------|
| `model` | string | 모델 이름 (예: `happyhorse-1.1-i2v`). 미지정 = 테넌트 정책 기본 모델 (주→백업 체인의 첫 번째) |
| `temperature` | float | 샘플링 온도 |
| `tools` | array | 도구 정의 (t2t 모델, OpenAI 호환) |
| `_purpose` | string | 용도 마커: `utility` = 보조 작업 (분류/선택/요약), 보조 모델 체인 사용 |
| `_timeout` | int | 1회 호출 타임아웃 초 (0=엔드포인트 기본값; 최대 900) |
### 비동기 모델 추가 파라미터 (i2v / t2v / t2i 등)
| 파라미터 | 타입 | 설명 |
|------|------|------|
| `image_file` | string | 업로드 미디어 (base64/data URL은 자동으로 로컬 공개 URL로 변환; http(s) URL은 그대로 사용). **동일 능력 파라미터는 통일된 `xxx_file` 명명 사용** |
| `resolution` | string | 해상도, 예: `480P` / `720P` / `1080P` |
| `duration` | int | 비디오 길이 (초) |
> 생성물 안내: 업스트림이 반환하는 이미지/비디오 등 산출물 URL은 유효기간이 매우 짧습니다 (비디오는 24시간뿐). 서버가 로컬에 영속화한 후 반환합니다.
### 요청 예시 (텍스트 대화)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "안녕하세요"}]
}'
```
### 요청 예시 (이미지→비디오, 비동기 모델)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.1-i2v",
"messages": [{"role": "user", "content": "캐릭터가 랩을 시작한다"}],
"image_file": "https://example.com/first-frame.png",
"resolution": "720P",
"duration": 5,
"_timeout": 600
}'
```
### 응답 예시 (동기 모델)
```json
{
"choices": [
{"message": {"content": "안녕하세요!", "role": "assistant"}, "finish_reason": "stop"}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5}
}
```
### 응답 예시 (비동기 모델)
```json
{
"choices": [
{"message": {"content": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4", "role": "assistant"},
"finish_reason": "stop"}
],
"usage": {"duration": 5, "SR": 720, "video_count": 1},
"task_id": "e53dee87-...",
"media": {
"status": "SUCCEEDED",
"video": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4",
"usage": {"duration": 5, "SR": 720}
}
}
```
`media` 필드는 통합 출력 파라미터입니다 (동일 능력 모델 간 필드명 일치): 비디오는 `video`, 이미지는 `image`, 3D 모델은 `glb`.
### 오류 응답
실패 시 OpenAI 오류 구조를 반환하며, 메시지는 실행 가능한 내용입니다 (게이트 실패/타임아웃/템플릿 설정 누락 등 모두 구체적인 사유를 제공합니다):
```json
{"error": {"message": "모델 체인 전체 사용 불가. 마지막 사유: …", "type": "invalid_request_error", "code": "govern_error"}}
```
---
## GET /v1/models
현재 테넌트에서 사용 가능한 모델을 능력별로 나열 (테넌트에 거버넌스 정책이 없으면 빈 리스트).
### 선택 파라미터
| 파라미터 | 타입 | 설명 |
|------|------|------|
| `catelogid` | string | 능력 분류: `t2t` / `t2i` / `i2v` / `t2v` / `embedding` / `rerank` / `tts` / `asr` / `i2t`. 미지정 = 전체 |
### 요청 예시
```bash
curl 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/models?catelogid=i2v' \
-H 'Authorization: Bearer ***'
```
### 응답 예시
```json
{
"object": "list",
"data": [
{"id": "happyhorse-1.1-i2v", "object": "model", "name": "happyhorse-1.1-i2v",
"catelogid": "i2v", "vendor": "Alibaba Bailian"}
]
}
```
---
## 인증과 단기 토큰
- 토큰은 플랫폼이 발급 (테넌트/프로젝트/작업에 연결, 만료 시간과 호출 상한 있음, 폐기 가능)
- 사용 방법: `Authorization: Bearer ***
- 토큰은 실제 모델 키가 아닙니다. 실제 키는 서버 측에서만 해결되며 프로세스 외부로 나가지 않습니다
## 과금
- 호출마다 자동으로 사용량 기록 (`llm_usage`)이 생성되며, 모델에 연결된 요금제 (ppid) 기준으로 비동기 정산됩니다
- 토큰 외 과금 요소 (비디오 길이/해상도 등)는 기록의 `usages` 필드에 저장됩니다

View File

@ -0,0 +1,154 @@
# 产线平台模型 API 文档
---
# 模型治理统一推理 API
Base url: `https://pipeline.opencomputing.cn/pipeline-llm/api/v1`
所有 API 端点需要 Bearer Token 认证(短期 token非真实模型 key
机构隔离:按 token 绑定的机构走治理链解析真实模型与密钥,真实密钥永不出服务进程。
---
## POST /v1/chat/completions
模型调用统一入口OpenAI 兼容格式)。同步模型一次往返返回结果;异步模型(图生视频等)由服务端自动完成「提交任务 → 轮询 → 取结果」,返回落地后的本地持久地址。
### 必填参数
| 参数 | 类型 | 说明 |
|------|------|------|
| `messages` | array | 对话消息数组,`[{"role": "user", "content": "..."}]` |
### 可选参数
| 参数 | 类型 | 说明 |
|------|------|------|
| `model` | string | 模型名称(如 `happyhorse-1.1-i2v`)。不传 = 机构策略缺省模型(主→备链第一个) |
| `temperature` | float | 采样温度 |
| `tools` | array | 工具定义t2t 模型OpenAI 兼容) |
| `_purpose` | string | 用途标记:`utility` = 辅助任务(分类/选择/摘要),走辅助模型链 |
| `_timeout` | int | 单次调用超时秒数0=端点默认;上限 900 |
### 异步模型额外参数(图生视频/文生视频/文生图等)
| 参数 | 类型 | 说明 |
|------|------|------|
| `image_file` | string | 上传媒体base64/data URL 自动转本地公网地址http(s) URL 原样使用)。**同类能力参数统一 `xxx_file` 命名** |
| `resolution` | string | 分辨率,如 `480P` / `720P` / `1080P` |
| `duration` | int | 视频时长(秒) |
> 生成物说明:上游返回的图片/视频等产物 URL 有效期极短(视频仅 24 小时),服务端会自动落地为本地持久文件再返回。
### 请求示例(文本对话)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "qwen3.8-max",
"messages": [{"role": "user", "content": "你好"}]
}'
```
### 请求示例(图生视频,异步模型)
```bash
curl -X POST 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/chat/completions' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.1-i2v",
"messages": [{"role": "user", "content": "画面中的角色开始动感说唱"}],
"image_file": "https://example.com/first-frame.png",
"resolution": "720P",
"duration": 5,
"_timeout": 600
}'
```
### 响应示例(同步模型)
```json
{
"choices": [
{"message": {"content": "你好!", "role": "assistant"}, "finish_reason": "stop"}
],
"usage": {"prompt_tokens": 10, "completion_tokens": 5}
}
```
### 响应示例(异步模型)
```json
{
"choices": [
{"message": {"content": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4", "role": "assistant"},
"finish_reason": "stop"}
],
"usage": {"duration": 5, "SR": 720, "video_count": 1},
"task_id": "e53dee87-...",
"media": {
"status": "SUCCEEDED",
"video": "https://pipeline.opencomputing.cn/idfile/tmp/.../xxx.mp4",
"usage": {"duration": 5, "SR": 720}
}
}
```
`media` 字段是统一出参(同类能力字段一致):视频 `video`、图片 `image`、3D 模型 `glb`
### 错误响应
失败返回 OpenAI 错误结构,消息真实可行动(门禁不过/超时/模板配置缺失等都会给出具体原因):
```json
{"error": {"message": "模型链全部不可用。最后原因:…", "type": "invalid_request_error", "code": "govern_error"}}
```
---
## GET /v1/models
按能力分类列出当前机构可用的模型(机构未配治理策略返回空列表)。
### 可选参数
| 参数 | 类型 | 说明 |
|------|------|------|
| `catelogid` | string | 能力分类:`t2t` / `t2i` / `i2v` / `t2v` / `embedding` / `rerank` / `tts` / `asr` / `i2t`。不传 = 全部 |
### 请求示例
```bash
curl 'https://pipeline.opencomputing.cn/pipeline-llm/api/v1/models?catelogid=i2v' \
-H 'Authorization: Bearer ***'
```
### 响应示例
```json
{
"object": "list",
"data": [
{"id": "happyhorse-1.1-i2v", "object": "model", "name": "happyhorse-1.1-i2v",
"catelogid": "i2v", "vendor": "阿里云百炼"}
]
}
```
---
## 认证与短期 token
- token 由平台签发(绑定机构/项目/任务,含过期时间与调用上限,可吊销)
- 使用方式:`Authorization: Bearer ***
- token 不是真实模型密钥;真实密钥只在服务端解析,永不出进程
## 计费
- 调用自动产生用量流水(`llm_usage`按模型挂的定价方案ppid异步出账
- 非 token 计价因子(视频时长/分辨率等)记录在流水的 `usages` 字段

View File

@ -0,0 +1,10 @@
{% set _lang = (params_kw._lang if params_kw else '') or 'zh' %}
{% set _l2 = _lang[:2]|lower %}
{% set lang = _l2 if _l2 in ['zh', 'en', 'ja', 'ko'] else 'zh' %}
{
"widgettype": "ApiDoc",
"options": {
"md_url": "{{entire_url('/pipeline-llm/api/v1/docs/api_' + lang + '.md')}}",
"height": "100%"
}
}