跳转到主要内容
POST
/
agent
/
{projectId}
/
job
Create agent job
curl --request POST \
  --url https://api.mintlify.com/v2/agent/{projectId}/job \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>"
}
'
{
  "id": "<string>",
  "status": "active",
  "source": {
    "repository": "<string>",
    "ref": "<string>"
  },
  "model": "<string>",
  "prLink": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "archivedAt": "2023-11-07T05:31:56Z"
}
此端点创建一个在后台运行的代理任务。与流式传输响应的 v1 API 不同,v2 API 会立即返回一个任务 ID,您可以使用它来轮询状态。

与 v1 的主要区别

  • 即发即忘:请求立即返回任务 ID
  • 基于轮询:使用获取代理任务检查状态并获取 PR 链接
  • 简化请求:使用单个 prompt 字符串而不是消息数组
  • 对话式:使用发送消息发送后续消息

工作流程

  1. 使用此端点创建任务
  2. 存储返回的 id
  3. 轮询获取代理任务端点,直到 statuscompletedfailed
  4. PR 创建后从响应中获取 prLink

速率限制

代理 API 有以下限制:
  • 每个 Mintlify 项目每小时 100 次使用

授权

Authorization
string
header
必填

The Authorization header expects a Bearer token. Use an admin API key (prefixed with mint_). This is a server-side secret key. Generate one on the API keys page in your dashboard.

路径参数

projectId
string
必填

Your project ID. Can be copied from the API keys page in your dashboard.

请求体

application/json
prompt
string
必填

The task instructions for the agent to execute.

响应

Agent job created successfully. The job runs in the background.

id
string

Unique identifier for the agent job.

status
enum<string>

Current status of the agent job.

可用选项:
active,
completed,
archived,
failed
source
object

Information about the source repository.

model
string

The AI model used for this job.

URL of the pull request created by the agent. Null until the PR is created.

createdAt
string<date-time>

Timestamp when the job was created.

archivedAt
string<date-time> | null

Timestamp when the job was archived. Null if still active.