Skip to main content
POST
/
tasks
JavaScript
import Client from 'agentlin';

const client = new Client({
  apiKey: 'My API Key',
});

const task = await client.tasks.create({ stream: true, user_message_content: 'string' });

console.log(task.id);
{
  "jsonrpc": "<string>",
  "id": "<string>",
  "result": {
    "object": "task",
    "id": "<string>",
    "session_id": "<string>",
    "user_id": "<string>",
    "status": "created",
    "created_at": 123,
    "output": [
      {
        "type": "reasoning",
        "id": "<string>",
        "summary": [
          {
            "type": "text",
            "text": "<string>",
            "id": 123,
            "tags": [
              "<string>"
            ],
            "annotations": [
              {
                "type": "file_citation",
                "file_id": "<string>",
                "index": 123,
                "filename": "<string>"
              }
            ],
            "logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ],
                "top_logprobs": [
                  {
                    "token": "<string>",
                    "logprob": 123,
                    "bytes": [
                      123
                    ]
                  }
                ]
              }
            ]
          }
        ],
        "content": [
          {
            "type": "text",
            "text": "<string>",
            "id": 123,
            "tags": [
              "<string>"
            ],
            "annotations": [
              {
                "type": "file_citation",
                "file_id": "<string>",
                "index": 123,
                "filename": "<string>"
              }
            ],
            "logprobs": [
              {
                "token": "<string>",
                "logprob": 123,
                "bytes": [
                  123
                ],
                "top_logprobs": [
                  {
                    "token": "<string>",
                    "logprob": 123,
                    "bytes": [
                      123
                    ]
                  }
                ]
              }
            ]
          }
        ],
        "status": "in_progress"
      }
    ],
    "usage": {},
    "error": {
      "code": 123,
      "message": "<string>",
      "data": {}
    },
    "input_required": {
      "type": "tool_call",
      "call_id": "<string>",
      "name": "<string>",
      "arguments": "<string>",
      "id": "<string>",
      "status": "in_progress",
      "language": "json"
    },
    "metadata": {},
    "previous_task_id": "<string>",
    "rollouts": [
      {}
    ]
  },
  "error": {
    "code": 123,
    "message": "<string>",
    "data": {}
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request payload for POST /tasks. Maps to the CreateTask Pydantic model in server.

user_message_content
required

当前用户输入内容(多模态),按顺序提供给主 Agent。 消息内容,字符串或内容项数组,工具协议兼容的 message_content(保留字段)。

stream
boolean
required

是否启用流式(SSE)返回;true 则以 text/event-stream 推送 Task 事件。

structured_output
object

期望的结构化输出 JSON Schema;仅非流式模式有效,流式模式下将被忽略。

client_id
string

调用方客户端标识(如 AIME)。

request_id
string

请求链路唯一 ID;便于将复杂调用串联在一起。

session_id
string

会话 ID;用于跨多轮交互复用上下文。

task_id
string

任务 ID;用于区分主任务与子任务。

user_id
string

终端用户 ID。

agent_config
object

指定主 Agent 的配置;为空则按 client_id 推断默认 Agent。

allowed_tools
string[]

允许使用的工具白名单;为 null 允许全部,空数组表示禁止所有。

disallowed_tools
string[]

禁用的工具黑名单;为 null 或空数组不生效。

allowed_subagents
string[]

允许使用的子代理白名单;为 null 允许全部,空数组禁止所有。

stop_tools
string[]

命中则停止代理循环的工具名列表;为 null 或空数组不生效。

client_tools
object[]

客户端自带工具定义;命中后会停止由服务端执行,等待客户端完成。

history_messages
OutputItem · object[]

历史对话消息,用于提供上下文。

An output item produced by the agent/model.

thought_messages
OutputItem · object[]

隐藏的助手思考内容(不可见思考轨迹),如有将并入上下文。

An output item produced by the agent/model.

inference_args
object

推理参数覆盖项(如温度、最大 tokens 等),具体字段由后端实现决定。

workspace_dir
string

文件系统工作目录;供文件工具与代码解释器使用。

env
object

Agent 的运行时环境变量键值对。

log_dir
string

日志输出目录。

rollout_save_dir
string

回溯(rollout)结果保存目录。

return_rollout
boolean

是否在最终结果中返回 rollout 事件集合。

include_compress_model_rollout
boolean

是否包含上下文压缩模型的 rollout 结果。

include_subagent_rollout
boolean

是否包含子 Agent 的 rollout 结果。

Response

OK

Base JSON-RPC 2.0 message.

jsonrpc
string
required

JSON-RPC protocol version, always '2.0'.

Allowed value: "2.0"
id

请求/响应 ID,由客户端生成或服务器透传;可为字符串、整数或 null。

result
object

JSON-RPC result:任务对象。

error
object

JSON-RPC 错误对象(如失败时)。