官网 / lastAI Cloud API 文档

lastAI Cloud API 文档

在你的应用中调用对话、搜索、图片和音视频模型,或提交 lastAI 插件。在接口参考中查参数、响应和错误,复制示例发起请求。

lastAI Cloud API
GET/v1/proxy/v1/models
curl -H "Authorization: Bearer $LASTAI_API_KEY" \
  "https://cloud.lastai.tianyunai.com/v1/proxy/v1/models"
GET/v1/media/models
curl -H "Authorization: Bearer $LASTAI_API_KEY" \
  "https://cloud.lastai.tianyunai.com/v1/media/models"

先完成一次调用Make your first request

  1. 在开发者中心创建 API KeyCreate an API key in the developer center,勾选你需要的模型与操作。完整密钥只显示一次。, then select the models and operations you need. Save the full key when it appears.
  2. 在终端设置 Cloud 域名和 API Key。下方命令适用于 Bash,Windows 可用 Git Bash。Set the Cloud origin and key in your terminal. The examples use Bash, including Git Bash on Windows.
  3. 读取 Key 的能力目录Read the key's capability catalog,再把完整模型 ID 填入请求。, then send the full model ID in a request.

设置环境变量Set environment variables

export LASTAI_CLOUD_ORIGIN=https://cloud.lastai.tianyunai.com
read -rs -p "lastAI API Key: " LASTAI_API_KEY
export LASTAI_API_KEY

调用一次对话Send a chat request

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Reply with one word: ready."}],"max_tokens":128}'

用 OpenAI Python SDK 调用Call with the OpenAI Python SDK

先运行 python -m pip install openai。使用能力目录里已授权的完整模型 ID。Run python -m pip install openai first. Use an authorized model ID from the catalog.

Python 示例Python example

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LASTAI_API_KEY"],
    base_url=os.environ["LASTAI_CLOUD_ORIGIN"] + "/v1/proxy/v1",
)

reply = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[{"role": "user", "content": "Reply with one word: ready."}],
    max_tokens=128,
)
print(reply.choices[0].message.content)

示例响应使用示例 ID,费用和结果字段随实际模型变化。带路径 ID 的命令请先把上一请求的 ID 赋给示例变量。Response samples use illustrative IDs. Values depend on the selected model. Set ID variables in later commands from the preceding response.

认证、回执和重试Authentication, receipts and retries

Authorization: Bearer …
服务端发请求时传入 API Key。公共目录允许匿名查看参考信息。Provide a server-side API key. Public catalogs allow anonymous reads of reference data.
X-Request-Id / X-LastAI-Usage-Id
前者用于排查 HTTP 请求,后者和模型回执、预留与最终扣费关联。The first traces HTTP requests. The second links model receipts, reservations and charges.
Idempotency-Key
每次新的计费请求生成新值。超时后保存原值,先查原单再决定是否重试。媒体轮询等到 COMPLETED 或 FAILED,建议逐步拉长间隔。Generate a new value for each new billable request. After a timeout, use the original value to look up the request first. Poll media until COMPLETED or FAILED, with backoff.
费用单位Charge units
钱包和计费字段的 cents 对应整数积分,100 积分对应 1 元。每次调用可先预留、再结算或释放。Wallet fields ending in cents use integer credits. 100 credits correspond to 1 CNY. Requests may reserve credits before settlement or release.

错误响应示例Error response example

{
  "code": "forbidden",
  "message": "forbidden"
}

准备插件清单和安装包Prepare the manifest and package

查看你的命名空间Find your namespace,然后在开发者中心给同一个 API Key 开启插件发布权限。, then enable plugin publishing on your developer-center API key.

用 npm pack 生成 .tgz。包内 package.json 必须声明 name、version、license、engines.dsh、dsh.bundle.patch,并包含 Cordis YAML。包必须自包含,不能包含安装脚本。Run npm pack to create a .tgz. Include name, version, license, engines.dsh and dsh.bundle.patch in package.json, and ship the Cordis YAML. Packages must be self-contained without install scripts.

manifest.json 示例 · 替换命名空间和 SHA-256Example manifest.json · replace the namespace and SHA-256

{
  "schema": "lastai.harness.plugin.release/v1",
  "name": "@your-namespace/my-plugin",
  "version": "1.0.0",
  "sha256": "REPLACE_WITH_LOWERCASE_SHA256_OF_TGZ",
  "title": {
    "zh": "我的插件",
    "en": "My plugin"
  },
  "description": {
    "zh": "插件用途",
    "en": "What the plugin does"
  },
  "license": "MIT",
  "platform": "any",
  "min_dsh": "0.2.2-rc.5",
  "max_dsh_exclusive": "0.3.0",
  "declaration": {
    "publisher": "@your-namespace",
    "permissions": [],
    "network": [],
    "dependencies": [],
    "uninstall": {
      "zh": "移除插件。",
      "en": "Remove the plugin."
    }
  }
}

同一命名空间每分钟最多 8 次上传,总暂存额度 64 MiB。包内容变更时请提高版本号。审核前保持私有,发布后进入公开分发。Each namespace can upload eight times per minute, up to a total 64 MiB of staging storage. Bump the version when bytes change. Releases become public after approval and publication.

插件调用 Cloud 模型Call Cloud models from a plugin

官方创作插件随客户端发布,已经通过专用工作室接口使用登录账号报价、确认、生成和读取原件。第三方插件使用 lastaiCloudModels,需由客户端提供这个 Host 服务,同时安装已审核并签名的插件版本。Windows 8.0.23 起提供通用 Host 接口。The bundled Creation Studio already uses its dedicated interface to quote, approve, generate and retrieve originals with the signed-in account. Third-party plugins use lastaiCloudModels and require a compatible client plus an approved and signed plugin release. The shared Host service is available starting with Windows 8.0.23.

模型调用按实际使用者的套餐、地区和钱包执行。每次付费操作由客户端提示用户确认,账单记录插件来源。发布用 API Key 留在开发者的发布环境。插件运行时由宿主持有会话并代为发起请求。Calls use the active user's plan, region and wallet. The client asks the user to approve each paid operation and attributes usage to the plugin. Keep the publishing API key in your release environment. The Host manages the user session and sends requests at runtime.

  1. 下载下面四个文件。把三处文件中的 @your-namespace 替换为你在开发者中心的命名空间。示例通过插件运行环境提供的工具注册模块注册原生工具。Download the four files below. Replace @your-namespace in the three files that reference it with your developer namespace. The example registers a native tool using the plugin runtime's tool registration module.
  2. 执行 npm pack。计算生成的 .tgz 的小写 SHA-256,填进 manifest.json。保留安装包和清单两个文件供送审。Run npm pack. Compute the tarball's lowercase SHA-256 and insert it in manifest.json. Keep the tarball and manifest as separate submission files.
  3. 提交审核Submit for review,安装市场中的已签名版本。先运行 catalog,再用返回的完整模型 ID 调用 chat 或 image。对话给出整数积分上限,生图自动获取当前报价。, then install the signed marketplace release. Run catalog before passing a full model ID to chat or image. Set an integer-credit cap for chat. Image generation obtains the current quote automatically.
查看插件源码和送审权限View the plugin source and review permissions

插件工具 · index.mjsPlugin tool · index.mjs

import { createMcpToolDefinition } from "@deepseek-ai/dsh-mcp-client";

export const name = "lastai-cloud-example";
export const inject = ["tools", "lastaiCloudModels"];

export function apply(ctx) {
  ctx.tools.register(createMcpToolDefinition(ctx, {
    name: "lastai_cloud_example",
    rawName: "lastai_cloud_example",
    description: "List available lastAI Cloud models, run one approved chat or image request, or read its original result. Reuse the same operation ID to recover a request.",
    inputSchema: {
      type: "object",
      properties: {
        action: { enum: ["catalog", "chat", "image", "receipt", "image_status"] },
        model: { type: "string" },
        prompt: { type: "string" },
        operationId: { type: "string", pattern: "^[A-Za-z0-9_-]{20,80}$" },
        maxCredits: { type: "integer", minimum: 0 }
      },
      required: ["action"],
      additionalProperties: false
    },
    async call(args, exec) {
      const { action, model, prompt, operationId, maxCredits } = args;
      const cloud = ctx.lastaiCloudModels;
      const reply = (value) => ({ content: [{ type: "text", text: JSON.stringify(value) }] });

      if (action === "catalog") {
        const response = await cloud.catalog(exec.signal);
        if (!response.ok) return reply({ http: response.status });
        const { models } = await response.json();
        return reply(models.map(({ id, operations, pricing, parameters }) =>
          ({ id, operations, pricing, parameters })));
      }

      if (!/^[A-Za-z0-9_-]{20,80}$/.test(operationId ?? "")) {
        return reply({ error: "Choose and keep a unique operation ID before submitting." });
      }
      try {
        let response;
        if (action === "receipt") {
          response = await cloud.receipt("chat", operationId, exec.signal);
        } else if (action === "image_status") {
          response = await cloud.mediaStatus(operationId, exec.signal);
        } else {
          if (!model || !prompt) return reply({ error: "Supply a catalog model and prompt." });
          const options = { exec, idempotencyKey: operationId };
          if (action === "chat") {
            if (!Number.isSafeInteger(maxCredits) || maxCredits < 0) {
              return reply({ error: "Supply a maximum charge in integer credits." });
            }
            response = await cloud.invoke("chat", {
              model, messages: [{ role: "user", content: prompt }], max_tokens: 128, stream: false
            }, { ...options, maxCredits });
          } else if (action === "image") {
            response = await cloud.submitMedia({ task_type: "IMAGE", model, input: { prompt } }, options);
          } else {
            return reply({ error: "Unknown action." });
          }
        }
        return reply({ operationId, http: response.status, result: await response.json() });
      } catch (error) {
        return reply({ operationId, error: error.message,
          recovery: "Read the original receipt or image status before retrying a submission." });
      }
    }
  }));
}

送审清单 · manifest.jsonReview manifest · manifest.json

{
  "schema": "lastai.harness.plugin.release/v1",
  "name": "@your-namespace/cloud-example",
  "version": "1.0.0",
  "sha256": "REPLACE_WITH_LOWERCASE_SHA256_OF_TGZ",
  "title": { "zh": "Cloud 模型示例", "en": "Cloud model example" },
  "description": { "zh": "调用账号可用的对话和图片模型。", "en": "Call chat and image models available to the signed-in account." },
  "license": "MIT",
  "platform": "any",
  "min_dsh": "0.2.2-rc.5",
  "max_dsh_exclusive": "0.3.0",
  "declaration": {
    "publisher": "@your-namespace",
    "permissions": ["cloud:model:chat", "cloud:model:image"],
    "network": [],
    "dependencies": [],
    "uninstall": { "zh": "在插件管理中卸载该插件。", "en": "Uninstall this plugin from the plugin manager." }
  }
}

catalog(signal)
返回用户和当前插件可用的模型、操作、参数与计价提示。Lists models, operations, parameters and pricing available to this user and plugin.
invoke(operation, input, options)
支持 chat、responses、embedding、transcription、search。options 包含当前原生工具的 exec、maxCredits 和 idempotencyKey。对话的视觉输入、工具调用另需 vision、tools 权限。开启流式时读取 SSE。Supports chat, responses, embedding, transcription and search. Pass the active tool exec, maxCredits and idempotencyKey. Chat image input and tool calls require the vision and tools permissions. Read SSE when streaming is enabled.
submitMedia(input, options)
接受 IMAGE、VIDEO、AUDIO_SPEECH、MUSIC 任务,其中 input 包含 task_type、model 和模型参数 input。宿主报价后弹出确认。另传 exec 和 idempotencyKey。Accepts IMAGE, VIDEO, AUDIO_SPEECH and MUSIC tasks. Input includes task_type, model and the model's input object. Pass exec and idempotencyKey. The Host obtains a quote before prompting for approval.
receipt / mediaStatus / mediaOriginal
提交前保存 20 至 80 位操作编号。超时先用原编号查回执或任务状态。任务完成后用 mediaOriginal(id, index, signal) 读取归档原件。Store the 20–80 character operation ID before submission. After a timeout, use it to read the original receipt or task. When the task completes, use mediaOriginal(id, index, signal) to read the archived bytes.

送审权限使用 cloud:model: 加操作名。上例只需要 cloud:model:chat 和 cloud:model:image。其他能力按实际使用声明。用户拒绝或套餐未授权时,应提示当前状态并结束该次调用。Use cloud:model: followed by the operation name in the review manifest. The example needs only cloud:model:chat and cloud:model:image. Declare additional operations as needed. If the user declines or their plan does not grant access, report the status and end the call.

模型发现Model discovery

读取能力与参考价格List capabilities and reference prices

GET/v1/model-access/catalog

可匿名,带 API Key 返回账号范围Public reference. An API key applies account scope.

匿名获取公开参考目录,带 Key 获取当前账号和 Key 可用的能力。Read the public reference catalog, or authenticate to see capabilities available to the account and key.

请求参数Request parameters

此接口没有路径参数、查询参数或请求体。No path parameters, query parameters, or request body.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
version / price_scopestring合同版本。价格范围是 reference 或 account。Contract version. Price scope is reference or account.
models[].id / provider / regionstring完整模型 ID、供应商和区域。Full model ID, provider and region.
models[].operations / capabilitiesarray允许的操作及模型支持的能力。Allowed operations and capabilities.
models[].pricing / parametersobject参考价格、请求参数或媒体 contract。Reference prices, parameters or media contract.
models[].verificationobject服务端已登记的能力验证状态。Recorded capability verification state.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/model-access/catalog" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "version": "lastai.model-capabilities.v1",
  "price_scope": "account",
  "models": [
    {
      "id": "deepseek/deepseek-v4-flash",
      "provider": "deepseek",
      "region": "cn",
      "operations": [
        "chat",
        "responses"
      ],
      "capabilities": [
        "input:text",
        "output:text"
      ],
      "pricing": {
        "currency": "CNY",
        "list_price_currency": "USD",
        "multiplier": 1
      },
      "parameters": {
        "context_tokens": 1048576,
        "display_name": "DeepSeek V4 Flash"
      },
      "verification": {
        "state": "available",
        "operations": {}
      }
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

列出 OpenAI 兼容模型List OpenAI-compatible models

GET/v1/proxy/v1/models

需要开发者中心的 API KeyDeveloper-center API key required

供 SDK 或应用选择模型。以 data[].id 和 chat_runtime_supported 判断是否可以用于对话。Discover model IDs for SDKs and applications. Use data[].id and chat_runtime_supported to select a chat model.

请求参数Request parameters

此接口没有路径参数、查询参数或请求体。No path parameters, query parameters, or request body.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
objectstring固定为 list。Always list.
data[]array当前可用的模型。Models available to the caller.
data[].idstring直接用于请求中的 model。Use this exact value as model.
data[].provider / category / regionstring供应商、用途类别和区域。Provider, category and region.
data[].display_namestring展示名,可能省略。Optional display name.
data[].chat_runtime_supported / capabilitiesboolean / array是否可用于对话与支持的能力。Chat availability and model capabilities.
data[].context / max_output_tokensinteger上下文和已知的输出上限,后者可能省略。Context size and known output limit, if available.
configured_providers / provider_labelsarray / object配置的供应商及展示名,模型仍以 data 为准。Configured providers and labels. Use data for per-key availability.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/models" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "object": "list",
  "configured_providers": [
    "deepseek"
  ],
  "provider_labels": {
    "deepseek": "DeepSeek"
  },
  "data": [
    {
      "id": "deepseek/deepseek-v4-flash",
      "object": "model",
      "owned_by": "deepseek",
      "provider": "deepseek",
      "name": "deepseek-v4-flash",
      "display_name": "DeepSeek-V4.1-Flash",
      "region": "cn",
      "category": "chat",
      "capabilities": [
        "input:text",
        "output:text",
        "stream"
      ],
      "chat_runtime_supported": true,
      "context": 1048576,
      "enabled": true
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

列出桌面 Key 兼容模型List desktop-key compatible models

GET/v1/proxy/harness/v1/models

需要开发者中心的 API KeyDeveloper-center API key required

返回桌面 Key 接入路径所使用的可用模型。Returns models for the desktop-key compatibility path.

请求参数Request parameters

此接口没有路径参数、查询参数或请求体。No path parameters, query parameters, or request body.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
objectstring固定为 list。Always list.
data[]array当前可用的模型。Models available to the caller.
data[].idstring直接用于请求中的 model。Use this exact value as model.
data[].provider / category / regionstring供应商、用途类别和区域。Provider, category and region.
data[].display_namestring展示名,可能省略。Optional display name.
data[].chat_runtime_supported / capabilitiesboolean / array是否可用于对话与支持的能力。Chat availability and model capabilities.
data[].context / max_output_tokensinteger上下文和已知的输出上限,后者可能省略。Context size and known output limit, if available.
configured_providers / provider_labelsarray / object配置的供应商及展示名,模型仍以 data 为准。Configured providers and labels. Use data for per-key availability.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/models" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "object": "list",
  "configured_providers": [
    "deepseek"
  ],
  "provider_labels": {
    "deepseek": "DeepSeek"
  },
  "data": [
    {
      "id": "deepseek/deepseek-v4-flash",
      "object": "model",
      "owned_by": "deepseek",
      "provider": "deepseek",
      "name": "deepseek-v4-flash",
      "display_name": "DeepSeek-V4.1-Flash",
      "region": "cn",
      "category": "chat",
      "capabilities": [
        "input:text",
        "output:text",
        "stream"
      ],
      "chat_runtime_supported": true,
      "context": 1048576,
      "enabled": true
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

对话、视觉与向量Chat, vision and embeddings

创建对话回复Create a chat completion

POST/v1/proxy/v1/chat/completions

需要开发者中心的 API KeyDeveloper-center API key required

支持同步、SSE、图片理解和函数调用,所需权限由内容和模型决定。Send a synchronous or streaming request, with vision or function calling where your key and model permit it.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 chat。Full model ID from the catalog, authorized for chat.
messagesarraybody · 必填Required消息列表。每项包含 role 和 content。Message list. Each item contains role and content.
messages[].rolestringbody · 必填Requiredsystem、user、assistant 或 tool,具体由模型支持情况决定。system, user, assistant or tool, depending on the model.
messages[].contentstring / arraybody · 可选Optional纯文本或内容块。图片使用 type=image_url 和 image_url.url。Text or content blocks. Images use type=image_url and image_url.url.
streambooleanbody · 可选Optional默认 false。true 返回 SSE。Defaults to false. Set true for SSE.
stream_options.include_usagebooleanbody · 可选Optional请求在流中返回 Token 用量。Request a usage frame in the stream.
max_tokensintegerbody · 可选Optional请求输出上限。可用范围见目录。Maximum generated tokens. Discover model limits from the catalog.
tools / tool_choicearray / string / objectbody · 可选Optional声明函数及选择方式。回传工具结果用 tool_call_id。Declare functions and how they are selected. Return tool results with tool_call_id.
temperature / top_pnumberbody · 可选Optional采样设置。实际支持取决于模型。Sampling controls. Support depends on the model.
reasoning_effort / reasoningstring / objectbody · 可选Optional支持推理档位的模型可按目录的 effort 参数设置。Optional reasoning controls for models with catalogued effort support.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / modelstring上游结果标识与模型名。账单 ID 见响应头。Result identifier and model. See the response header for the billing ID.
choices[].message.contentstring / null普通回复文本。工具调用时可能为 null。Reply text. Can be null for a tool call.
choices[].message.tool_callsarray工具调用及参数。由你的应用执行。Tool calls and arguments. Your application runs them.
choices[].finish_reasonstring例如 stop、length、tool_calls。For example stop, length, or tool_calls.
usageobject输入、输出及总 Token 统计。Input, output and total token usage.
choices[].deltaobject流式增量。以 data: [DONE] 结束。Streaming delta. The stream ends with data: [DONE].

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Reply with one word: ready."}],"max_tokens":128}'

响应示例 · JSONExample response · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "ready"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

流式请求与响应示例Streaming request and response

流式请求 · curlStreaming request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -N -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Accept: text/event-stream' \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Reply with one word: ready."}],"max_tokens":128,"stream":true,"stream_options":{"include_usage":true}}'

流式响应 · SSEStreaming response · SSE

data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"ready"},"finish_reason":null}]}

data: {"choices":[],"usage":{"prompt_tokens":13,"completion_tokens":1,"total_tokens":14}}

data: [DONE]

函数调用示例Function calling example

请求 · curlRequest · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Look up the status of order demo-100."}],"max_tokens":128,"tools":[{"type":"function","function":{"name":"get_order_status","description":"Read the status for an order number.","parameters":{"type":"object","properties":{"order_id":{"type":"string"}},"required":["order_id"]}}}],"tool_choice":{"type":"function","function":{"name":"get_order_status"}}}'

响应 · JSONResponse · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "finish_reason": "tool_calls",
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_demo",
            "type": "function",
            "function": {
              "name": "get_order_status",
              "arguments": "{\"order_id\":\"demo-100\"}"
            }
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

图片理解示例Image understanding example

请求 · curlRequest · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
LASTAI_IMAGE_BASE64=$(python -c 'from pathlib import Path; import base64; print(base64.b64encode(Path("reference.png").read_bytes()).decode())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":[{"type":"text","text":"What is shown in this image?"},{"type":"image_url","image_url":{"url":"data:image/png;base64,'"$LASTAI_IMAGE_BASE64"'"}}]}],"max_tokens":128}'

响应 · JSONResponse · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A red square on a blue background."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

桌面 Key 兼容对话Desktop-key compatible chat

POST/v1/proxy/harness/v1/chat/completions

需要开发者中心的 API KeyDeveloper-center API key required

面向 8.x 桌面 API Key 模式。请求与响应采用同一对话格式。For Desktop 8.x API key mode. Uses the same chat request and response format.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 chat。Full model ID from the catalog, authorized for chat.
messagesarraybody · 必填Required消息列表。每项包含 role 和 content。Message list. Each item contains role and content.
messages[].rolestringbody · 必填Requiredsystem、user、assistant 或 tool,具体由模型支持情况决定。system, user, assistant or tool, depending on the model.
messages[].contentstring / arraybody · 可选Optional纯文本或内容块。图片使用 type=image_url 和 image_url.url。Text or content blocks. Images use type=image_url and image_url.url.
streambooleanbody · 可选Optional默认 false。true 返回 SSE。Defaults to false. Set true for SSE.
stream_options.include_usagebooleanbody · 可选Optional请求在流中返回 Token 用量。Request a usage frame in the stream.
max_tokensintegerbody · 可选Optional请求输出上限。可用范围见目录。Maximum generated tokens. Discover model limits from the catalog.
tools / tool_choicearray / string / objectbody · 可选Optional声明函数及选择方式。回传工具结果用 tool_call_id。Declare functions and how they are selected. Return tool results with tool_call_id.
temperature / top_pnumberbody · 可选Optional采样设置。实际支持取决于模型。Sampling controls. Support depends on the model.
reasoning_effort / reasoningstring / objectbody · 可选Optional支持推理档位的模型可按目录的 effort 参数设置。Optional reasoning controls for models with catalogued effort support.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / modelstring上游结果标识与模型名。账单 ID 见响应头。Result identifier and model. See the response header for the billing ID.
choices[].message.contentstring / null普通回复文本。工具调用时可能为 null。Reply text. Can be null for a tool call.
choices[].message.tool_callsarray工具调用及参数。由你的应用执行。Tool calls and arguments. Your application runs them.
choices[].finish_reasonstring例如 stop、length、tool_calls。For example stop, length, or tool_calls.
usageobject输入、输出及总 Token 统计。Input, output and total token usage.
choices[].deltaobject流式增量。以 data: [DONE] 结束。Streaming delta. The stream ends with data: [DONE].

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Reply with one word: ready."}],"max_tokens":128}'

响应示例 · JSONExample response · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "ready"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

流式请求与响应示例Streaming request and response

流式请求 · curlStreaming request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -N -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Accept: text/event-stream' \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Reply with one word: ready."}],"max_tokens":128,"stream":true,"stream_options":{"include_usage":true}}'

流式响应 · SSEStreaming response · SSE

data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"ready"},"finish_reason":null}]}

data: {"choices":[],"usage":{"prompt_tokens":13,"completion_tokens":1,"total_tokens":14}}

data: [DONE]

函数调用示例Function calling example

请求 · curlRequest · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":"Look up the status of order demo-100."}],"max_tokens":128,"tools":[{"type":"function","function":{"name":"get_order_status","description":"Read the status for an order number.","parameters":{"type":"object","properties":{"order_id":{"type":"string"}},"required":["order_id"]}}}],"tool_choice":{"type":"function","function":{"name":"get_order_status"}}}'

响应 · JSONResponse · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "finish_reason": "tool_calls",
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_demo",
            "type": "function",
            "function": {
              "name": "get_order_status",
              "arguments": "{\"order_id\":\"demo-100\"}"
            }
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

图片理解示例Image understanding example

请求 · curlRequest · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
LASTAI_IMAGE_BASE64=$(python -c 'from pathlib import Path; import base64; print(base64.b64encode(Path("reference.png").read_bytes()).decode())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/chat/completions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","messages":[{"role":"user","content":[{"type":"text","text":"What is shown in this image?"},{"type":"image_url","image_url":{"url":"data:image/png;base64,'"$LASTAI_IMAGE_BASE64"'"}}]}],"max_tokens":128}'

响应 · JSONResponse · JSON

{
  "id": "chatcmpl_demo",
  "object": "chat.completion",
  "created": 1795910400,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A red square on a blue background."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 1,
    "total_tokens": 14
  }
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

创建 Responses 回复Create a Responses reply

POST/v1/proxy/v1/responses

需要开发者中心的 API KeyDeveloper-center API key required

使用兼容的 Responses 协议。后续请求发送上下文和工具结果。网页搜索另走搜索接口。Use the compatible Responses protocol. Send context and tool results with subsequent requests. Web search has its own endpoint.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 responses。Full model ID from the catalog, authorized for responses.
inputstring / arraybody · 必填Required文本,或消息、函数调用与函数结果组成的序列。Text or a sequence of messages, function calls and function results.
instructionsstringbody · 可选Optional此请求的补充指令。Additional instructions for this request.
streambooleanbody · 可选Optionaltrue 返回 SSE。Set true for SSE.
max_output_tokensintegerbody · 可选Optional生成上限。Maximum generated tokens.
tools / tool_choicearray / string / objectbody · 可选Optional客户应用执行的工具及选择方式。Client-side tools and desired tool selection.
temperature / top_pnumberbody · 可选Optional模型支持时可设置采样。Optional sampling controls where supported.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / statusstring响应标识与状态。Response identifier and status.
output[].content[].textstring输出消息中的文本。Text inside an output message.
output[].type / call_idstring输出类型。函数调用使用 call_id 关联结果。Output type. Link function outputs with call_id.
usageobject输入、输出及总 Token。Input, output and total tokens.
response.output_text.delta / response.completedSSE events流式文本和成功终态。失败或截断时查看终态事件。Streaming text and terminal success. Check the final event for failure or truncation.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/responses" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","input":"Reply with one word: ready.","max_output_tokens":128}'

响应示例 · JSONExample response · JSON

{
  "id": "resp_demo",
  "object": "response",
  "status": "completed",
  "model": "deepseek/deepseek-v4-flash",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "ready",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 13,
    "output_tokens": 1,
    "total_tokens": 14
  }
}

流式请求与响应示例Streaming request and response

流式请求 · curlStreaming request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -N -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/responses" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Accept: text/event-stream' \
  -H 'Content-Type: application/json' \
  --data '{"model":"deepseek/deepseek-v4-flash","input":"Reply with one word: ready.","max_output_tokens":128,"stream":true}'

流式响应 · SSEStreaming response · SSE

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"ready","output_index":0,"content_index":0}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_demo","status":"completed"}}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

生成文本向量Create embeddings

POST/v1/proxy/v1/embeddings

需要开发者中心的 API KeyDeveloper-center API key required

向量按 index 对应输入。响应示例中的向量保留前三维便于阅读。Match results to inputs using index. The example shortens the output vector to three values.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 embedding。Full model ID from the catalog, authorized for embedding.
inputstring / arraybody · 必填Required单段文本、文本数组或模型支持的 Token 数组。A string, string array or model-supported token arrays.
dimensionsintegerbody · 可选Optional按模型支持情况设置向量维数。Vector dimensions where supported by the model.
encoding_formatstringbody · 可选Optional按模型支持情况设置输出编码。Output encoding where supported by the model.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
data[].indexinteger输入项的零起始索引。Zero-based index of the input.
data[].embeddingarray / string默认是数值向量。指定受支持的编码时可返回字符串。Numeric vector by default. Supported encodings may return a string.
model / usagestring / object模型名和 Token 统计。Model name and token usage.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/embeddings" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"openrouter/baai/bge-base-en-v1.5","input":["Meeting notes"]}'

响应示例 · JSONExample response · JSON

{
  "object": "list",
  "model": "baai/bge-base-en-v1.5",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        0.03,
        -0.08,
        0.14
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 3,
    "total_tokens": 3
  }
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

桌面 Key 兼容向量Desktop-key compatible embeddings

POST/v1/proxy/harness/v1/embeddings

需要开发者中心的 API KeyDeveloper-center API key required

面向桌面 API Key 模式的向量接口。Embeddings in desktop API key mode.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 embedding。Full model ID from the catalog, authorized for embedding.
inputstring / arraybody · 必填Required单段文本、文本数组或模型支持的 Token 数组。A string, string array or model-supported token arrays.
dimensionsintegerbody · 可选Optional按模型支持情况设置向量维数。Vector dimensions where supported by the model.
encoding_formatstringbody · 可选Optional按模型支持情况设置输出编码。Output encoding where supported by the model.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
data[].indexinteger输入项的零起始索引。Zero-based index of the input.
data[].embeddingarray / string默认是数值向量。指定受支持的编码时可返回字符串。Numeric vector by default. Supported encodings may return a string.
model / usagestring / object模型名和 Token 统计。Model name and token usage.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/harness/v1/embeddings" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"openrouter/baai/bge-base-en-v1.5","input":["Meeting notes"]}'

响应示例 · JSONExample response · JSON

{
  "object": "list",
  "model": "baai/bge-base-en-v1.5",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        0.03,
        -0.08,
        0.14
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 3,
    "total_tokens": 3
  }
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

图片与音视频Images, audio and video

读取媒体模型合同List media model contracts

GET/v1/media/models

可匿名,带 API Key 返回账号范围Public reference. An API key applies account scope.

从这里确认具体模型接受的字段、枚举、参考图数量与估计费用。使用 Key 可查看它获准调用的模型。Discover model-specific fields, options, reference-image limits and estimated cost. Authenticate to see models permitted by the key.

请求参数Request parameters

此接口没有路径参数、查询参数或请求体。No path parameters, query parameters, or request body.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
[].id / kind / operationstring模型 ID、媒体类别和供应商操作。kind 为 image、video、voice 或 music。Model ID, media kind and provider operation. Kinds are image, video, voice or music.
[].contractobject含 required_inputs、optional_inputs、reference_images、parameters、execution 和 output。Includes required_inputs, optional_inputs, reference_images, parameters, execution and output.
[].billed_credits / billing_infonumber / object参考费用与预留方式。单位见 price_unit。Estimated credit cost and reservation rules. See price_unit for the unit.
[].option_valuesobject可以提交的选项值。Accepted option values.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/media/models" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

[
  {
    "id": "kie/z-image",
    "kind": "image",
    "operation": "z-image",
    "provider_id": "kie",
    "billed_credits": 3,
    "contract": {
      "media_kind": "image",
      "required_inputs": [
        "prompt"
      ],
      "optional_inputs": [],
      "parameters": []
    }
  }
]

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

创建媒体作业Create a media job

POST/v1/media/tasks

需要开发者中心的 API KeyDeveloper-center API key required

生成图片、视频、语音或音乐。先提交,之后根据任务 ID 查询终态。Generate images, video, speech or music. Submit once and poll the task ID for completion.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
task_typestringbody · 必填RequiredIMAGE、VIDEO、AUDIO_SPEECH 或 MUSIC。语音转写使用专门接口。IMAGE, VIDEO, AUDIO_SPEECH or MUSIC. Use the transcription endpoint for speech-to-text.
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 image / video / speech / music。Full model ID from the catalog, authorized for image / video / speech / music.
inputobjectbody · 必填Required按媒体目录的 contract 组装。常用字段包含 prompt、duration、resolution。Follow the media catalog contract. Common fields include prompt, duration and resolution.
input.reference_image_id / reference_image_idsstring / arraybody · 可选Optional支持参考图的模型可使用预上传得到的 ID。Models with reference-image support accept IDs from the upload endpoint.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
idstring用来查询任务的作业 ID。Task ID used to poll the job.
task_type / model / providerstring任务类型、模型与供应商。Task type, model and provider.
statusstringPENDING、PROCESSING、COMPLETED 或 FAILED。PENDING, PROCESSING, COMPLETED or FAILED.
inputobject服务端返回的输入信息。Input metadata returned by the server.
output.urls[]array完成后的原件链接。输出结构依模型而异。Original file URLs after completion. Output shape can vary by model.
cost_centsinteger作业当前费用。最终钱包流水与请求回执可用于对账。Current job cost. Reconcile against the final wallet and request receipt.
errorstring / null终态失败原因。Terminal failure reason.
created_at / updated_atstringUTC 时间。UTC timestamps.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/media/tasks" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"task_type":"IMAGE","model":"kie/z-image","input":{"prompt":"A single red square on a blue background, no text."}}'

响应示例 · JSONExample response · JSON

{
  "id": "mt_0360d983f3ef4d249e3229f16026c237c2dd61aa",
  "user_id": "usr_demo",
  "task_type": "IMAGE",
  "provider": "kie",
  "model": "kie/z-image",
  "status": "PROCESSING",
  "input": {
    "prompt": "A single red square on a blue background, no text."
  },
  "output": {},
  "cost_cents": 3,
  "external_id": "vendor_task_demo",
  "error": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

查询媒体作业Get a media job

GET/v1/media/tasks/{id}

需要开发者中心的 API KeyDeveloper-center API key required

用创建时的 Key 和作业 ID 查询。完成后读取 output,失败时查看 error 和退款记录。Use the submitting key and task ID. Read output on completion, or check error and refund entries on failure.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
idstringpath · 必填Required提交接口返回的作业 ID。Job ID from the submit response.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
idstring用来查询任务的作业 ID。Task ID used to poll the job.
task_type / model / providerstring任务类型、模型与供应商。Task type, model and provider.
statusstringPENDING、PROCESSING、COMPLETED 或 FAILED。PENDING, PROCESSING, COMPLETED or FAILED.
inputobject服务端返回的输入信息。Input metadata returned by the server.
output.urls[]array完成后的原件链接。输出结构依模型而异。Original file URLs after completion. Output shape can vary by model.
cost_centsinteger作业当前费用。最终钱包流水与请求回执可用于对账。Current job cost. Reconcile against the final wallet and request receipt.
errorstring / null终态失败原因。Terminal failure reason.
created_at / updated_atstringUTC 时间。UTC timestamps.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/media/tasks/$LASTAI_TASK_ID" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "id": "mt_0360d983f3ef4d249e3229f16026c237c2dd61aa",
  "user_id": "usr_demo",
  "task_type": "IMAGE",
  "provider": "kie",
  "model": "kie/z-image",
  "status": "COMPLETED",
  "input": {
    "prompt": "A single red square on a blue background, no text."
  },
  "output": {
    "urls": [
      "https://example.com/media/result.png"
    ]
  },
  "cost_cents": 3,
  "external_id": "vendor_task_demo",
  "error": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 404 核对 ID 与签发该请求的 Key,确认记录是否已生成。Check the ID and the original key, and confirm the record exists.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

列出媒体作业List media jobs

GET/v1/media/tasks

需要开发者中心的 API KeyDeveloper-center API key required

返回当前 Key 创建的作业,最新在前。Returns jobs created by the current key, newest first.

请求参数Request parameters

此接口没有路径参数、查询参数或请求体。No path parameters, query parameters, or request body.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
[]array作业数组,元素与单条作业接口一致。Array of the same job objects returned by the get endpoint.
idstring用来查询任务的作业 ID。Task ID used to poll the job.
task_type / model / providerstring任务类型、模型与供应商。Task type, model and provider.
statusstringPENDING、PROCESSING、COMPLETED 或 FAILED。PENDING, PROCESSING, COMPLETED or FAILED.
inputobject服务端返回的输入信息。Input metadata returned by the server.
output.urls[]array完成后的原件链接。输出结构依模型而异。Original file URLs after completion. Output shape can vary by model.
cost_centsinteger作业当前费用。最终钱包流水与请求回执可用于对账。Current job cost. Reconcile against the final wallet and request receipt.
errorstring / null终态失败原因。Terminal failure reason.
created_at / updated_atstringUTC 时间。UTC timestamps.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/media/tasks" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

[
  {
    "id": "mt_0360d983f3ef4d249e3229f16026c237c2dd61aa",
    "user_id": "usr_demo",
    "task_type": "IMAGE",
    "provider": "kie",
    "model": "kie/z-image",
    "status": "COMPLETED",
    "input": {
      "prompt": "A single red square on a blue background, no text."
    },
    "output": {
      "urls": [
        "https://example.com/media/result.png"
      ]
    },
    "cost_cents": 3,
    "external_id": "vendor_task_demo",
    "error": null,
    "created_at": "2026-11-29T00:00:00Z",
    "updated_at": "2026-11-29T00:00:00Z"
  }
]

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

上传参考图片Upload a reference image

POST/v1/media/reference-images

需要开发者中心的 API KeyDeveloper-center API key required

发送 PNG、JPEG 或 WebP 的原始文件字节。用返回的 reference_id 提交支持图片引用的模型作业。Send the raw bytes of a PNG, JPEG or WebP file. Use the returned reference_id in a job that supports reference images.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
Content-Typestringheader · 必填Required例如 image/png。For example image/png.
图像文件 / filebinarybody · 必填Required请求体为 1 字节至 20 MiB 的文件。须具备 image 或 video 权限。Raw file of 1 byte to 20 MiB. Requires image or video permission.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
reference_idstring媒体请求使用的图片引用。Image reference used by media requests.
urlstring托管图片地址。Hosted image URL.
sizeinteger实际上传字节数。Uploaded byte count.

请求示例 · curlExample request · curl

curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/media/reference-images" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H 'Content-Type: image/png' \
  --data-binary '@reference.png'

响应示例 · JSONExample response · JSON

{
  "reference_id": "media-inputs/usr_demo/reference.png",
  "url": "https://example.com/media/reference.png",
  "size": 4096
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 413 按该接口的大小上限重新打包。Repack under the endpoint size limit.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

同步生成图片Generate an image synchronously

POST/v1/proxy/v1/images/generations

需要开发者中心的 API KeyDeveloper-center API key required

兼容图片生成接口,等待相同媒体管线的结果。需要显式的完整模型 ID。长任务优先使用作业接口。Wait for the compatible image endpoint to return. Use a full model ID. Prefer async jobs for longer tasks.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 image。Full model ID from the catalog, authorized for image.
promptstringbody · 必填Required图片的自然语言描述。Natural-language image description.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
createdintegerUnix 时间戳(秒)。Unix timestamp in seconds.
data[].url / b64_jsonstring图片地址或 Base64 图片数据。Image URL or Base64 image data.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/images/generations" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"kie/z-image","prompt":"A single red square on a blue background, no text."}'

响应示例 · JSONExample response · JSON

{
  "created": 1795910400,
  "data": [
    {
      "url": "https://example.com/media/result.png"
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

同步生成图片兼容路径Synchronous image compatibility alias

POST/v1/images/generations

需要开发者中心的 API KeyDeveloper-center API key required

请求体和结果与同步生成图片主接口一致。Same request and response as the primary synchronous image endpoint.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 image。Full model ID from the catalog, authorized for image.
promptstringbody · 必填Required图片的自然语言描述。Natural-language image description.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
createdintegerUnix 时间戳(秒)。Unix timestamp in seconds.
data[].url / b64_jsonstring图片地址或 Base64 图片数据。Image URL or Base64 image data.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/images/generations" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"kie/z-image","prompt":"A single red square on a blue background, no text."}'

响应示例 · JSONExample response · JSON

{
  "created": 1795910400,
  "data": [
    {
      "url": "https://example.com/media/result.png"
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

转写音频Transcribe audio

POST/v1/proxy/v1/audio/transcriptions

需要开发者中心的 API KeyDeveloper-center API key required

使用 JSON 携带 Base64 音频。选择目录中支持 transcription 的模型。Send Base64 audio in JSON. Choose a model supporting transcription.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
modelstringbody · 必填Required目录返回的完整模型 ID,须授权 transcription。Full model ID from the catalog, authorized for transcription.
input_audio.datastringbody · 必填Required原文件的 Base64 编码,无 data: 前缀。解码后上限见模型目录的 transcription_max_bytes。Base64 without a data: prefix. See transcription_max_bytes in the catalog for the decoded limit.
input_audio.formatstringbody · 必填Required源文件格式,例如 wav 或 mp3。Source file format, for example wav or mp3.
languagestringbody · 可选Optional可选语言提示,例如 en。Optional language hint such as en.
Idempotency-Keystringheader · 建议Recommended每个新请求使用不同值,最长 128 个 ASCII 字符。Unique per new request, up to 128 ASCII characters.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
textstring转写文字。Transcribed text.
model / usagestring / object模型与服务返回的用量信息。Model and available usage information.

请求示例 · curlExample request · curl

LASTAI_REQUEST_KEY=$(python -c 'import uuid; print(uuid.uuid4())')
LASTAI_AUDIO_BASE64=$(python -c 'from pathlib import Path; import base64; print(base64.b64encode(Path("sample.wav").read_bytes()).decode())')
curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/proxy/v1/audio/transcriptions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"openrouter/openai/whisper-large-v3-turbo","input_audio":{"data":"'"$LASTAI_AUDIO_BASE64"'","format":"wav"},"language":"en"}'

响应示例 · JSONExample response · JSON

{
  "text": "The meeting starts at nine.",
  "model": "openai/whisper-large-v3-turbo"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 502 上游未能完成请求。重试前确认原请求和扣费。The upstream service could not complete the request. Check the original request and charge before retrying.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

请求回执Request receipts

按请求 ID 查回执Get a receipt by request ID

GET/v1/model-access/requests/{id}

需要开发者中心的 API KeyDeveloper-center API key required

用发出原请求的 Key 查询。同步调用见响应头 x-lastai-usage-id,媒体使用作业 ID。SSE 完结后可能仍在结算。Use the same key as the original request. For synchronous calls, use x-lastai-usage-id. For media jobs, use the task ID. A stream may finish before settlement completes.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
idstringpath · 必填Required账单请求 ID 或媒体作业 ID。Billing request ID or media task ID.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / operation / model_idstring请求号、操作名和完整模型 ID。Request ID, operation and full model ID.
statestringreserved、settled 或 released。reserved, settled or released.
held_cents / charged_centsinteger预留积分与实际扣分。Reserved and charged credits.
opened_at / finished_atstring / null记账与终态时间。Admission and terminal timestamps.
input_tokens / output_tokensinteger / null有 Token 统计时返回数值。Token counts when available.
supplier_request_idstring / null上游供应商提供的请求标识。Supplier request ID when available.
wallet_entries[]array带 kind、amount_cents、balance_after_cents 和 reference 的钱包流水。Wallet entries with kind, amount_cents, balance_after_cents and reference.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/model-access/requests/$LASTAI_USAGE_ID" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "id": "model_1c15239ca365ff2dd85d639eb025d2723939383bf26472ce2577c137f2de5183",
  "model_id": "deepseek/deepseek-v4-flash",
  "operation": "chat",
  "state": "settled",
  "held_cents": 1,
  "charged_cents": 0,
  "opened_at": "2026-11-29T00:00:00Z",
  "finished_at": "2026-11-29T00:00:00Z",
  "input_tokens": 13,
  "output_tokens": 1,
  "supplier_request_id": null,
  "wallet_entries": [
    {
      "id": "txn_demo",
      "user_id": "usr_demo",
      "kind": "USAGE_REFUND",
      "amount_cents": 1,
      "balance_after_cents": 50,
      "reference": "model_1c15239ca365ff2dd85d639eb025d2723939383bf26472ce2577c137f2de5183",
      "description": "scoped model settlement",
      "created_at": "2026-11-29T00:00:00Z"
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 404 核对 ID 与签发该请求的 Key,确认记录是否已生成。Check the ID and the original key, and confirm the record exists.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

按幂等键查原请求Recover the original request

GET/v1/model-access/requests/original

需要开发者中心的 API KeyDeveloper-center API key required

连接中断或没有收到响应头时使用。原请求必须携带 Idempotency-Key。异步媒体用原作业 ID 查询。Use after a disconnect or missing response headers. The original request must have an Idempotency-Key. For async media, poll the original task ID.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
operationstringquery · 必填Required原同步操作,例如 chat、responses、embedding、transcription 或 search。Original synchronous operation such as chat, responses, embedding, transcription or search.
Idempotency-Keystringheader · 必填Required必须与原请求完全相同。Must exactly match the original request.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / operation / model_idstring请求号、操作名和完整模型 ID。Request ID, operation and full model ID.
statestringreserved、settled 或 released。reserved, settled or released.
held_cents / charged_centsinteger预留积分与实际扣分。Reserved and charged credits.
opened_at / finished_atstring / null记账与终态时间。Admission and terminal timestamps.
input_tokens / output_tokensinteger / null有 Token 统计时返回数值。Token counts when available.
supplier_request_idstring / null上游供应商提供的请求标识。Supplier request ID when available.
wallet_entries[]array带 kind、amount_cents、balance_after_cents 和 reference 的钱包流水。Wallet entries with kind, amount_cents, balance_after_cents and reference.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/model-access/requests/original?operation=chat" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -H "Idempotency-Key: $LASTAI_REQUEST_KEY"

响应示例 · JSONExample response · JSON

{
  "id": "model_1c15239ca365ff2dd85d639eb025d2723939383bf26472ce2577c137f2de5183",
  "model_id": "deepseek/deepseek-v4-flash",
  "operation": "chat",
  "state": "settled",
  "held_cents": 1,
  "charged_cents": 0,
  "opened_at": "2026-11-29T00:00:00Z",
  "finished_at": "2026-11-29T00:00:00Z",
  "input_tokens": 13,
  "output_tokens": 1,
  "supplier_request_id": null,
  "wallet_entries": [
    {
      "id": "txn_demo",
      "user_id": "usr_demo",
      "kind": "USAGE_REFUND",
      "amount_cents": 1,
      "balance_after_cents": 50,
      "reference": "model_1c15239ca365ff2dd85d639eb025d2723939383bf26472ce2577c137f2de5183",
      "description": "scoped model settlement",
      "created_at": "2026-11-29T00:00:00Z"
    }
  ]
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 404 核对 ID 与签发该请求的 Key,确认记录是否已生成。Check the ID and the original key, and confirm the record exists.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

发布插件Plugin publishing

上传插件并送审Upload a plugin for review

POST/v1/harness/publishing/publish

API Key 需要插件发布权限API key with plugin publishing permission required

在开发者中心给 API Key 开启发布权限。上传成功进入 review,审核和签名后上架。相同版本、清单和字节可安全重试。Enable publishing on a developer-center API key. A successful upload enters review and goes live after review and signing. Exact retries reuse the same submission.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
manifestbinarybody · 必填Requiredmultipart 清单文件,最多 16 KiB,包名和摘要须与 tgz 一致。Multipart manifest file, up to 16 KiB. Name and digest must match the package.
tarballbinarybody · 必填Requirednpm pack 生成的 .tgz,最多 8 MiB。The .tgz produced by npm pack, up to 8 MiB.
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 201 / 200

字段Field类型Type含义Description
id / namespace / name / versionstring提交 ID、命名空间、包名和语义版本。Submission ID, namespace, package name and semantic version.
statestringdraft、review、approved、rejected、candidate、published 或 withdrawn。draft, review, approved, rejected, candidate, published or withdrawn.
manifest / sha256 / integrity / patchstring原始清单、包的摘要、npm 完整性及 Cordis YAML 路径。Original manifest, package digest, npm integrity and Cordis YAML path.
size_bytes / created_at / updated_atinteger / string包大小与记录时间。Package size and timestamps.
review_receipt / reviewerstring / null结构化审核回执以 JSON 字符串返回。Structured review receipt as a JSON string, plus the reviewer.
signature / signing_keystring / null经签名后返回签名与签名公钥。Signature and public key after signing.

请求示例 · curlExample request · curl

curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/publish" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -F 'manifest=@manifest.json;type=application/json' \
  -F 'tarball=@plugin.tgz;type=application/octet-stream'

响应示例 · JSONExample response · JSON

{
  "id": "018ca058-87cd-73d1-8f0a-ded18bcd929c",
  "namespace": "@lastai-user-0123456789abcdef01234567",
  "name": "@lastai-user-0123456789abcdef01234567/my-plugin",
  "version": "1.0.0",
  "manifest": "{\"schema\":\"lastai.harness.plugin.release/v1\"}",
  "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "integrity": "sha512-YWJj",
  "patch": "cordis.patch.yml",
  "size_bytes": 1842,
  "state": "review",
  "review_receipt": null,
  "reviewer": null,
  "signature": null,
  "signing_key": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 413 按该接口的大小上限重新打包。Repack under the endpoint size limit.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

列出插件提交记录List plugin submissions

GET/v1/harness/publishing/submissions

API Key 需要插件发布权限API key with plugin publishing permission required

读取当前命名空间最近提交的最多 200 条记录。List up to 200 recent submissions in the current namespace.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
[]array提交对象数组。Array of submission records.
id / namespace / name / versionstring提交 ID、命名空间、包名和语义版本。Submission ID, namespace, package name and semantic version.
statestringdraft、review、approved、rejected、candidate、published 或 withdrawn。draft, review, approved, rejected, candidate, published or withdrawn.
manifest / sha256 / integrity / patchstring原始清单、包的摘要、npm 完整性及 Cordis YAML 路径。Original manifest, package digest, npm integrity and Cordis YAML path.
size_bytes / created_at / updated_atinteger / string包大小与记录时间。Package size and timestamps.
review_receipt / reviewerstring / null结构化审核回执以 JSON 字符串返回。Structured review receipt as a JSON string, plus the reviewer.
signature / signing_keystring / null经签名后返回签名与签名公钥。Signature and public key after signing.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/submissions" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

[
  {
    "id": "018ca058-87cd-73d1-8f0a-ded18bcd929c",
    "namespace": "@lastai-user-0123456789abcdef01234567",
    "name": "@lastai-user-0123456789abcdef01234567/my-plugin",
    "version": "1.0.0",
    "manifest": "{\"schema\":\"lastai.harness.plugin.release/v1\"}",
    "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "integrity": "sha512-YWJj",
    "patch": "cordis.patch.yml",
    "size_bytes": 1842,
    "state": "review",
    "review_receipt": null,
    "reviewer": null,
    "signature": null,
    "signing_key": null,
    "created_at": "2026-11-29T00:00:00Z",
    "updated_at": "2026-11-29T00:00:00Z"
  }
]

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

查询插件审核状态Get submission and review status

GET/v1/harness/publishing/submissions/{id}

API Key 需要插件发布权限API key with plugin publishing permission required

查看指定版本的审核进度和可用审核回执。Read review progress and the available receipt for a release.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
idstringpath · 必填Required上传响应中的提交 ID。Submission ID from the upload response.
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / namespace / name / versionstring提交 ID、命名空间、包名和语义版本。Submission ID, namespace, package name and semantic version.
statestringdraft、review、approved、rejected、candidate、published 或 withdrawn。draft, review, approved, rejected, candidate, published or withdrawn.
manifest / sha256 / integrity / patchstring原始清单、包的摘要、npm 完整性及 Cordis YAML 路径。Original manifest, package digest, npm integrity and Cordis YAML path.
size_bytes / created_at / updated_atinteger / string包大小与记录时间。Package size and timestamps.
review_receipt / reviewerstring / null结构化审核回执以 JSON 字符串返回。Structured review receipt as a JSON string, plus the reviewer.
signature / signing_keystring / null经签名后返回签名与签名公钥。Signature and public key after signing.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/submissions/$LASTAI_SUBMISSION_ID" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "id": "018ca058-87cd-73d1-8f0a-ded18bcd929c",
  "namespace": "@lastai-user-0123456789abcdef01234567",
  "name": "@lastai-user-0123456789abcdef01234567/my-plugin",
  "version": "1.0.0",
  "manifest": "{\"schema\":\"lastai.harness.plugin.release/v1\"}",
  "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "integrity": "sha512-YWJj",
  "patch": "cordis.patch.yml",
  "size_bytes": 1842,
  "state": "review",
  "review_receipt": null,
  "reviewer": null,
  "signature": null,
  "signing_key": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 404 核对 ID 与签发该请求的 Key,确认记录是否已生成。Check the ID and the original key, and confirm the record exists.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

查询上传失败记录List upload validation failures

GET/v1/harness/publishing/submissions/failures

API Key 需要插件发布权限API key with plugin publishing permission required

查阅当前命名空间内最近被拒的上传及原因。Read recent rejected uploads and their reasons for this namespace.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
[].id / action / atstring事件 ID、动作和时间。Event ID, action and timestamp.
[].data.namespace / reasonstring命名空间及格式、摘要等校验失败原因。Namespace and format or integrity validation error.

请求示例 · curlExample request · curl

curl -i "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/submissions/failures" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

[
  {
    "id": "018ca31d-6731-7238-84bc-a25c8715be78",
    "action": "harness.publishing.upload_rejected",
    "actor": "usr_demo",
    "at": "2026-11-29T00:00:00Z",
    "data": {
      "namespace": "@lastai-user-0123456789abcdef01234567",
      "reason": "bad request: plugin tarball does not match the manifest SHA-256"
    }
  }
]

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

仅保存插件草稿Upload a plugin draft

POST/v1/harness/publishing/submissions

API Key 需要插件发布权限API key with plugin publishing permission required

需要将上传与送审拆开时使用。创建后状态为 draft,接着调用草稿送审。Use when upload and review submission need separate steps. The returned state is draft.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
manifestbinarybody · 必填Requiredmultipart 清单文件,最多 16 KiB,包名和摘要须与 tgz 一致。Multipart manifest file, up to 16 KiB. Name and digest must match the package.
tarballbinarybody · 必填Requirednpm pack 生成的 .tgz,最多 8 MiB。The .tgz produced by npm pack, up to 8 MiB.
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 201 / 200

字段Field类型Type含义Description
id / namespace / name / versionstring提交 ID、命名空间、包名和语义版本。Submission ID, namespace, package name and semantic version.
statestringdraft、review、approved、rejected、candidate、published 或 withdrawn。draft, review, approved, rejected, candidate, published or withdrawn.
manifest / sha256 / integrity / patchstring原始清单、包的摘要、npm 完整性及 Cordis YAML 路径。Original manifest, package digest, npm integrity and Cordis YAML path.
size_bytes / created_at / updated_atinteger / string包大小与记录时间。Package size and timestamps.
review_receipt / reviewerstring / null结构化审核回执以 JSON 字符串返回。Structured review receipt as a JSON string, plus the reviewer.
signature / signing_keystring / null经签名后返回签名与签名公钥。Signature and public key after signing.

请求示例 · curlExample request · curl

curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/submissions" \
  -H "Authorization: Bearer $LASTAI_API_KEY" \
  -F 'manifest=@manifest.json;type=application/json' \
  -F 'tarball=@plugin.tgz;type=application/octet-stream'

响应示例 · JSONExample response · JSON

{
  "id": "018ca058-87cd-73d1-8f0a-ded18bcd929c",
  "namespace": "@lastai-user-0123456789abcdef01234567",
  "name": "@lastai-user-0123456789abcdef01234567/my-plugin",
  "version": "1.0.0",
  "manifest": "{\"schema\":\"lastai.harness.plugin.release/v1\"}",
  "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "integrity": "sha512-YWJj",
  "patch": "cordis.patch.yml",
  "size_bytes": 1842,
  "state": "draft",
  "review_receipt": null,
  "reviewer": null,
  "signature": null,
  "signing_key": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 413 按该接口的大小上限重新打包。Repack under the endpoint size limit.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.

将草稿送审Submit a draft for review

POST/v1/harness/publishing/submissions/{id}/submit

API Key 需要插件发布权限API key with plugin publishing permission required

把此命名空间的 draft 转成 review。可重复查询或提交已在审核中的版本。Move a draft in your namespace to review. An already-reviewing version can be submitted again without creating a new record.

请求参数Request parameters

字段Field类型Type位置与必填Location and requirement含义Description
idstringpath · 必填Required上传响应中的提交 ID。Submission ID from the upload response.
X-LastAI-Plugin-Namespacestringheader · 可选Optional所属的自定义命名空间。省略时用账号默认命名空间。An owned namespace. Omit to use the account default.

响应字段Response fields · HTTP 200

字段Field类型Type含义Description
id / namespace / name / versionstring提交 ID、命名空间、包名和语义版本。Submission ID, namespace, package name and semantic version.
statestringdraft、review、approved、rejected、candidate、published 或 withdrawn。draft, review, approved, rejected, candidate, published or withdrawn.
manifest / sha256 / integrity / patchstring原始清单、包的摘要、npm 完整性及 Cordis YAML 路径。Original manifest, package digest, npm integrity and Cordis YAML path.
size_bytes / created_at / updated_atinteger / string包大小与记录时间。Package size and timestamps.
review_receipt / reviewerstring / null结构化审核回执以 JSON 字符串返回。Structured review receipt as a JSON string, plus the reviewer.
signature / signing_keystring / null经签名后返回签名与签名公钥。Signature and public key after signing.

请求示例 · curlExample request · curl

curl -i -X POST "$LASTAI_CLOUD_ORIGIN/v1/harness/publishing/submissions/$LASTAI_SUBMISSION_ID/submit" \
  -H "Authorization: Bearer $LASTAI_API_KEY"

响应示例 · JSONExample response · JSON

{
  "id": "018ca058-87cd-73d1-8f0a-ded18bcd929c",
  "namespace": "@lastai-user-0123456789abcdef01234567",
  "name": "@lastai-user-0123456789abcdef01234567/my-plugin",
  "version": "1.0.0",
  "manifest": "{\"schema\":\"lastai.harness.plugin.release/v1\"}",
  "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "integrity": "sha512-YWJj",
  "patch": "cordis.patch.yml",
  "size_bytes": 1842,
  "state": "review",
  "review_receipt": null,
  "reviewer": null,
  "signature": null,
  "signing_key": null,
  "created_at": "2026-11-29T00:00:00Z",
  "updated_at": "2026-11-29T00:00:00Z"
}

错误和重试Errors and retry behavior
  • HTTP 400 检查字段、模型合同、媒体格式或钱包余额。Check fields, model contracts, media format or wallet balance.
  • HTTP 401 检查 Bearer Key、有效期和是否撤销。Check Bearer authorization, expiry and revocation.
  • HTTP 403 核对套餐、Key 的模型及操作范围,或命名空间归属。Check plan access, key permissions or namespace ownership.
  • HTTP 404 核对 ID 与签发该请求的 Key,确认记录是否已生成。Check the ID and the original key, and confirm the record exists.
  • HTTP 409 先查原单。相同插件版本的内容有变时提高版本号。Look up the original request first. Bump the plugin version if its contents changed.
  • HTTP 429 检查速率、并发和 UTC 日预算,再按退避策略重试。Check rate limits, concurrency and the UTC daily budget before backing off.
  • HTTP 503 服务暂不可用或原请求待确认。保留原幂等键。The service is unavailable or the original request is pending. Keep its idempotency key.