{
  "schemaVersion": 1,
  "id": "example.openai-compatible",
  "name": "OpenAI Compatible 示例",
  "version": "1.0.0",
  "description": "文本、图片和异步视频的声明式中转插件示例，请按你的中转站文档修改。",
  "homepage": "https://example.com/docs",
  "baseUrlConfigKey": "baseUrl",
  "configFields": [
    {
      "key": "baseUrl",
      "label": "Base URL",
      "type": "url",
      "required": true,
      "placeholder": "https://relay.example.com/v1"
    },
    {
      "key": "apiKey",
      "label": "API Key",
      "type": "password",
      "required": true
    }
  ],
  "models": [
    {
      "id": "gpt-4.1",
      "name": "GPT 4.1",
      "capability": "text",
      "operation": "chat"
    },
    {
      "id": "gpt-4.1",
      "name": "GPT 4.1 Vision",
      "capability": "vision",
      "operation": "chat"
    },
    {
      "id": "gpt-image-1",
      "name": "GPT Image",
      "capability": "image",
      "operation": "image",
      "supportedResolutions": ["1K", "2K"],
      "supportedAspectRatios": ["1:1", "16:9", "9:16"],
      "maxReferenceImages": 8
    },
    {
      "id": "video-model-id",
      "name": "示例视频模型",
      "capability": "video",
      "operation": "video",
      "supportedResolutions": ["720p", "1080p"],
      "supportedAspectRatios": ["16:9", "9:16", "1:1"],
      "supportedDurations": ["5", "10"],
      "supportedGenerationModes": ["text-to-video", "image-to-video", "multi-reference"],
      "maxReferenceImages": 9
    }
  ],
  "operations": {
    "chat": {
      "timeoutSeconds": 600,
      "request": {
        "method": "POST",
        "path": "/chat/completions",
        "encoding": "json",
        "auth": {
          "type": "bearer",
          "configKey": "apiKey"
        },
        "body": {
          "model": "{{model}}",
          "messages": [
            {
              "role": "user",
              "content": "{{prompt}}"
            }
          ],
          "temperature": "{{temperature}}",
          "max_tokens": "{{maxTokens}}"
        }
      },
      "response": {
        "valuePaths": [
          "choices.0.message.content",
          "output_text",
          "text"
        ],
        "errorPaths": [
          "error.message",
          "message"
        ]
      }
    },
    "image": {
      "timeoutSeconds": 900,
      "request": {
        "method": "POST",
        "path": "/images/generations",
        "encoding": "json",
        "auth": {
          "type": "bearer",
          "configKey": "apiKey"
        },
        "body": {
          "model": "{{model}}",
          "prompt": "{{prompt}}",
          "aspect_ratio": "{{aspectRatio}}",
          "resolution": "{{resolution}}",
          "reference_images": "{{referenceImages}}"
        }
      },
      "response": {
        "valuePaths": [
          "data.0.url",
          "image.url",
          "image"
        ],
        "errorPaths": [
          "error.message",
          "message"
        ]
      }
    },
    "video": {
      "timeoutSeconds": 900,
      "request": {
        "method": "POST",
        "path": "/videos/generations",
        "encoding": "json",
        "auth": {
          "type": "bearer",
          "configKey": "apiKey"
        },
        "body": {
          "model": "{{model}}",
          "prompt": "{{prompt}}",
          "aspect_ratio": "{{aspectRatio}}",
          "resolution": "{{resolution}}",
          "duration": "{{duration}}",
          "generation_mode": "{{generationMode}}",
          "image": "{{image}}",
          "images": {
            "$map": {
              "from": "{{referenceImages}}",
              "as": "referenceImage",
              "template": {
                "url": "{{referenceImage}}",
                "role": "reference_image"
              }
            }
          }
        }
      },
      "response": {
        "valuePaths": [
          "video.url",
          "data.0.url",
          "url"
        ],
        "taskIdPaths": [
          "task_id",
          "id"
        ],
        "errorPaths": [
          "error.message",
          "message"
        ]
      },
      "poll": {
        "method": "GET",
        "path": "/tasks/{{taskId}}",
        "intervalMs": 5000,
        "maxAttempts": 120,
        "response": {
          "valuePaths": [
            "video.url",
            "data.0.url",
            "url"
          ],
          "statusPaths": [
            "status",
            "state"
          ],
          "failedValues": [
            "failed",
            "error",
            "cancelled"
          ],
          "errorPaths": [
            "error.message",
            "message"
          ]
        }
      }
    }
  }
}
