> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linxueyuan.online/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an agent task

> Creates a model task. Provide [text](https://docs.linxueyuan.online/guides/text) or
[image](https://docs.linxueyuan.online/guides/images) inputs to generate [text](https://docs.linxueyuan.online/guides/text)
or [JSON](https://docs.linxueyuan.online/guides/structured-outputs) outputs. Have the model call
your own [custom code](https://docs.linxueyuan.online/guides/function-calling) or use built-in
[tools](https://docs.linxueyuan.online/guides/tools) like [web search](https://docs.linxueyuan.online/guides/tools-web-search)
or [file search](https://docs.linxueyuan.online/guides/tools-file-search) to use your own data
as input for the model's task.




## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/agentlin/openapi.documented.yml post /tasks
openapi: 3.1.0
info:
  title: Agentlin API
  description: >-
    The Agentlin REST API. Please see https://linxueyuan.online/agentlin/ for
    more details.
  version: 2.3.0
  termsOfService: https://linxueyuan.online/policies/terms-of-use
  contact:
    name: Agentlin Support
    url: https://help.linxueyuan.online/
  license:
    name: MIT
    url: https://github.com/LinXueyuanStdio/agentlin/blob/master/LICENSE
servers:
  - url: https://api.linxueyuan.online/v1
security:
  - ApiKeyAuth: []
tags:
  - name: Tasks
    description: Create, retrieve, and cancel agent tasks.
  - name: Environment
    description: Interact with remote environments.
paths:
  /tasks:
    post:
      tags:
        - Tasks
      summary: Create an agent task
      description: >
        Creates a model task. Provide
        [text](https://docs.linxueyuan.online/guides/text) or

        [image](https://docs.linxueyuan.online/guides/images) inputs to generate
        [text](https://docs.linxueyuan.online/guides/text)

        or [JSON](https://docs.linxueyuan.online/guides/structured-outputs)
        outputs. Have the model call

        your own [custom
        code](https://docs.linxueyuan.online/guides/function-calling) or use
        built-in

        [tools](https://docs.linxueyuan.online/guides/tools) like [web
        search](https://docs.linxueyuan.online/guides/tools-web-search)

        or [file
        search](https://docs.linxueyuan.online/guides/tools-file-search) to use
        your own data

        as input for the model's task.
      operationId: createTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTask'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/TaskStreamingResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Client from 'agentlin_client';


            const client = new Client({
              apiKey: process.env['AGENTLIN_API_KEY'], // This is the default and can be omitted
            });


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


            console.log(task.id);
        - lang: Python
          source: |-
            import os
            from agentlin_client import Client

            client = Client(
                api_key=os.environ.get("AGENTLIN_API_KEY"),  # This is the default and can be omitted
            )
            task = client.tasks.create(
                stream=True,
                user_message_content="string",
            )
            print(task.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/LinXueyuanStdio/agentlin-client-go\"\n\t\"github.com/LinXueyuanStdio/agentlin-client-go/option\"\n)\n\nfunc main() {\n\tclient := agentlin.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttask, err := client.Tasks.New(context.TODO(), agentlin.TaskNewParams{\n\t\tStream: true,\n\t\tUserMessageContent: agentlin.MessageContentUnionParam{\n\t\t\tOfString: agentlin.String(\"string\"),\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", task.ID)\n}\n"
components:
  schemas:
    CreateTask:
      type: object
      description: >-
        Request payload for POST /tasks. Maps to the CreateTask Pydantic model
        in server.
      x-oaiMeta:
        name: CreateTask body
        group: tasks
        notes: |
          当 `stream=true` 时返回 SSE，且 `structured_output` 将被忽略并在服务端校验时报错。
        example: |
          {
            "user_message_content": [
              {"type": "input_text", "text": "用 3 句话讲个睡前故事"}
            ],
            "stream": true,
            "client_id": "aime",
            "request_id": "req-123",
            "session_id": "sess-1",
            "task_id": "task-1",
            "user_id": "user-1",
            "allowed_tools": ["web_search", "code_interpreter"],
            "disallowed_tools": ["image_generation"],
            "history_messages": [
              {"role": "system", "content": "你是有帮助的 AI 助手"}
            ]
          }
      properties:
        user_message_content:
          $ref: '#/components/schemas/MessageContent'
          description: |
            当前用户输入内容（多模态），按顺序提供给主 Agent。
            消息内容，字符串或内容项数组，工具协议兼容的 message_content（保留字段）。
        stream:
          type: boolean
          description: 是否启用流式（SSE）返回；true 则以 text/event-stream 推送 Task 事件。
        structured_output:
          type: object
          description: 期望的结构化输出 JSON Schema；仅非流式模式有效，流式模式下将被忽略。
          additionalProperties: true
        client_id:
          type: string
          description: 调用方客户端标识（如 AIME）。
        request_id:
          type: string
          description: 请求链路唯一 ID；便于将复杂调用串联在一起。
        session_id:
          type: string
          description: 会话 ID；用于跨多轮交互复用上下文。
        task_id:
          type: string
          description: 任务 ID；用于区分主任务与子任务。
        user_id:
          type: string
          description: 终端用户 ID。
        agent_config:
          $ref: '#/components/schemas/AgentConfig'
          description: 指定主 Agent 的配置；为空则按 client_id 推断默认 Agent。
        allowed_tools:
          type: array
          description: 允许使用的工具白名单；为 null 允许全部，空数组表示禁止所有。
          items:
            type: string
        disallowed_tools:
          type: array
          description: 禁用的工具黑名单；为 null 或空数组不生效。
          items:
            type: string
        allowed_subagents:
          type: array
          description: 允许使用的子代理白名单；为 null 允许全部，空数组禁止所有。
          items:
            type: string
        stop_tools:
          type: array
          description: 命中则停止代理循环的工具名列表；为 null 或空数组不生效。
          items:
            type: string
        client_tools:
          type: array
          description: 客户端自带工具定义；命中后会停止由服务端执行，等待客户端完成。
          items:
            $ref: '#/components/schemas/ToolData'
        history_messages:
          type: array
          description: 历史对话消息，用于提供上下文。
          items:
            $ref: '#/components/schemas/OutputItem'
        thought_messages:
          type: array
          description: 隐藏的助手思考内容（不可见思考轨迹），如有将并入上下文。
          items:
            $ref: '#/components/schemas/OutputItem'
        inference_args:
          type: object
          description: 推理参数覆盖项（如温度、最大 tokens 等），具体字段由后端实现决定。
          additionalProperties: true
        workspace_dir:
          type: string
          description: 文件系统工作目录；供文件工具与代码解释器使用。
        env:
          type: object
          description: Agent 的运行时环境变量键值对。
          additionalProperties:
            type: string
        log_dir:
          type: string
          description: 日志输出目录。
        rollout_save_dir:
          type: string
          description: 回溯（rollout）结果保存目录。
        return_rollout:
          type: boolean
          description: 是否在最终结果中返回 rollout 事件集合。
        include_compress_model_rollout:
          type: boolean
          description: 是否包含上下文压缩模型的 rollout 结果。
        include_subagent_rollout:
          type: boolean
          description: 是否包含子 Agent 的 rollout 结果。
      required:
        - user_message_content
        - stream
    TaskResponse:
      allOf:
        - $ref: '#/components/schemas/JSONRPCMessage'
        - type: object
          properties:
            result:
              $ref: '#/components/schemas/TaskObject'
              description: JSON-RPC result：任务对象。
            error:
              $ref: '#/components/schemas/JSONRPCError'
              description: JSON-RPC 错误对象（如失败时）。
      x-oaiMeta:
        name: CreateTask JSON response
        group: tasks
        notes: 非流式返回模型；当 stream=false 时返回。
        example: |
          {
            "jsonrpc": "2.0",
            "id": "req-123",
            "result": {
              "object": "task",
              "id": "task_abc",
              "session_id": "sess_1",
              "user_id": "u_1",
              "status": "completed",
              "created_at": 1720000000,
              "output": [
                {"type":"message", "role":"assistant", "content":[{"type":"output_text","text":"Hello"}], "status":"completed"}
              ],
              "usage": {"total_tokens": 42}
            }
          }
    TaskStreamingResponse:
      allOf:
        - $ref: '#/components/schemas/JSONRPCMessage'
        - type: object
          properties:
            result:
              $ref: '#/components/schemas/AgentTaskEvent'
              description: JSON-RPC result：单条任务事件（SSE）。
            error:
              $ref: '#/components/schemas/JSONRPCError'
              description: JSON-RPC 错误对象（如失败时）。
      x-oaiMeta:
        name: CreateTask streaming event
        group: tasks
        notes: 流式返回模型；当 stream=true 时，服务端通过 text/event-stream 推送如下事件帧（仅示例其中一种）。
        example: |
          {
            "jsonrpc": "2.0",
            "id": "req-123",
            "result": {
              "type": "task.text.delta",
              "item": {"type":"message","role":"assistant","content":[],"status":"in_progress"},
              "delta": "Hello",
              "agent_step": 1
            }
          }
    MessageContent:
      description: 消息内容，字符串或内容项数组，工具协议兼容的 message_content（保留字段）。
      oneOf:
        - type: string
        - $ref: '#/components/schemas/ContentItemList'
    AgentConfig:
      type: object
      description: The Agent configuration used by the server.
      x-oaiMeta:
        name: AgentConfig
        group: tasks
        notes: 运行主 Agent 的完整配置，通常由后端以默认配置加载，可在请求中覆盖。
        example: |
          {
            "agent_id": "default",
            "name": "CoreAgent",
            "description": "General-purpose assistant",
            "developer_prompt": "You are AgentLin, a helpful assistant.",
            "code_for_agent": "# helper hooks for agent lifecycle",
            "code_for_interpreter": "# bootstrap imports for notebooks",
            "allowed_tools": ["bash", "file_system", "web"],
            "tool_mcp_config": {
              "web": { "uri": "http://localhost:7777" }
            },
            "model": "gpt-4o-mini",
            "max_model_length": 128000,
            "max_response_length": 4096,
            "compress_prompt": "Summarize conversation context concisely.",
            "compress_model": "gpt-4o-mini",
            "compress_threshold_token_ratio": 0.8,
            "inference_args": { "temperature": 0.2, "top_p": 0.9 },
            "builtin_tools": [
              {
                "type": "function",
                "function": {
                  "name": "web_search",
                  "description": "Search the web for information.",
                  "parameters": {
                    "type": "object",
                    "properties": { "query": { "type": "string", "description": "Search query" } },
                    "required": ["query"]
                  }
                }
              }
            ],
            "code_interpreter_config": {
              "kernel": "python3",
              "connect_url": "http://127.0.0.1:8888/?token=secret"
            },
            "builtin_subagents": [
              { "name": "coder", "role": "assistant", "allowed_tools": ["bash", "file_system"] }
            ]
          }
      properties:
        agent_id:
          type: string
          description: Agent 唯一标识（目录名）。
        name:
          type: string
          description: Agent 名称。
        description:
          type: string
          description: Agent 描述。
        developer_prompt:
          type: string
          description: 主系统提示词（开发者指令）。
        code_for_agent:
          type: string
          description: 注入到 Agent 侧的代码片段。
        code_for_interpreter:
          type: string
          description: 注入到代码解释器侧的代码片段。
        allowed_tools:
          type: array
          items:
            type: string
          description: 默认允许使用的工具。
        tool_mcp_config:
          type: object
          additionalProperties: true
          description: MCP 服务器配置（工具来源）。
        model:
          type: string
          description: 主模型名称。
        max_model_length:
          type: integer
          description: 模型上下文最大 tokens。
        max_response_length:
          type: integer
          description: 模型生成的最大 tokens。
        compress_prompt:
          type: string
          description: 上下文压缩时使用的系统提示词。
        compress_model:
          type: string
          description: 用于压缩上下文的模型名称。
        compress_threshold_token_ratio:
          type: number
          description: 触发上下文压缩的 token 比例阈值。
        inference_args:
          type: object
          additionalProperties: true
          description: 默认推理参数覆盖项。
        builtin_tools:
          type: array
          items:
            $ref: '#/components/schemas/ToolData'
          description: 内置工具集合（含 CodeInterpreter/Task 等）。
        code_interpreter_config:
          type: object
          additionalProperties: true
          description: 代码解释器连接配置（Jupyter）。
        builtin_subagents:
          type: array
          items:
            type: object
          description: 内置子代理列表（名称/工具/提示词等）。
      required:
        - agent_id
        - name
        - description
        - developer_prompt
        - code_for_agent
        - code_for_interpreter
        - model
        - max_model_length
        - max_response_length
    ToolData:
      type: object
      properties:
        type:
          type: string
          enum:
            - function
          default: function
          description: 工具类型，此处固定为 function。
        function:
          $ref: '#/components/schemas/FunctionDefinition'
          description: 函数工具定义（名称/参数/描述）。
      required:
        - type
        - function
    OutputItem:
      title: OutputItem
      description: An output item produced by the agent/model.
      type: object
      discriminator:
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/ReasoningItem'
        - $ref: '#/components/schemas/MessageItem'
        - $ref: '#/components/schemas/ToolCallItem'
        - $ref: '#/components/schemas/ToolResultItem'
    JSONRPCMessage:
      type: object
      description: Base JSON-RPC 2.0 message.
      x-oaiMeta:
        name: JSON-RPC Message
        group: tasks
        example: |
          {
            "jsonrpc": "2.0",
            "id": "req-123"
          }
      properties:
        jsonrpc:
          type: string
          const: '2.0'
          description: JSON-RPC protocol version, always '2.0'.
        id:
          description: 请求/响应 ID，由客户端生成或服务器透传；可为字符串、整数或 null。
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
      required:
        - jsonrpc
    TaskObject:
      type: object
      description: The task object returned in JSON-RPC result.
      x-oaiMeta:
        name: TaskObject
        group: tasks
        notes: 代表一次完整任务的聚合结果与元信息。
        example: |
          {
            "object": "task",
            "id": "task_abc",
            "session_id": "sess_1",
            "user_id": "u_1",
            "status": "completed",
            "created_at": 1720000000,
            "output": [
              {"type":"message","role":"assistant","content":"hello"}
            ],
            "usage": {"input_tokens": 100, "output_tokens": 0, "total_tokens": 100},
            "metadata": {}
          }
      properties:
        object:
          type: string
          enum:
            - task
          description: 固定为 task。
        id:
          type: string
          description: 任务 ID。
        session_id:
          type: string
          description: 会话 ID。
        user_id:
          type: string
          description: 用户 ID。
        status:
          $ref: '#/components/schemas/TaskStatus'
          description: 任务状态。
        created_at:
          type: integer
          description: 任务创建时间（Unix 秒）。
        output:
          type: array
          description: 模型/代理生成的输出条目集合（多类型）。
          items:
            $ref: '#/components/schemas/OutputItem'
        usage:
          type: object
          additionalProperties: true
          description: token 用量统计信息。
        error:
          $ref: '#/components/schemas/JSONRPCError'
          description: 错误信息（失败时）。
        input_required:
          $ref: '#/components/schemas/ToolCallItem'
          description: 若任务等待外部输入，则给出需要执行的工具调用（如等待用户参数）。
        metadata:
          type: object
          additionalProperties: true
          description: 扩展元数据。
        previous_task_id:
          type: string
          description: 前置任务 ID（用于续写/衔接）。
        rollouts:
          type: array
          items:
            type: object
            additionalProperties: true
          description: 任务推演/回溯事件集合（可选）。
      required:
        - object
        - id
        - session_id
        - user_id
        - status
        - created_at
        - output
    JSONRPCError:
      type: object
      description: JSON-RPC error object.
      x-oaiMeta:
        name: JSON-RPC Error
        group: tasks
        example: |
          {
            "code": -32602,
            "message": "Invalid params: missing 'task_id'",
            "data": { "param": "task_id", "expected": "string" }
          }
      properties:
        code:
          type: integer
          description: 错误码（遵循 JSON-RPC 约定或服务端自定义）。
        message:
          type: string
          description: 错误信息。
        data:
          description: 自定义错误数据，任意 JSON 值或 null。
          anyOf:
            - type: object
            - type: array
            - type: string
            - type: number
            - type: integer
            - type: boolean
            - type: 'null'
      required:
        - code
        - message
    AgentTaskEvent:
      description: >
        Discriminated union of all task streaming and lifecycle events emitted
        by the server.

        Use the `type` field to determine the concrete schema of each event.
      anyOf:
        - $ref: '#/components/schemas/TaskCreatedEvent'
        - $ref: '#/components/schemas/TaskWorkingEvent'
        - $ref: '#/components/schemas/TaskQueuedEvent'
        - $ref: '#/components/schemas/TaskInputRequiredEvent'
        - $ref: '#/components/schemas/TaskPausedEvent'
        - $ref: '#/components/schemas/TaskCanceledEvent'
        - $ref: '#/components/schemas/TaskExpiredEvent'
        - $ref: '#/components/schemas/TaskCompletedEvent'
        - $ref: '#/components/schemas/TaskFailedEvent'
        - $ref: '#/components/schemas/TaskToolsUpdatedEvent'
        - $ref: '#/components/schemas/TaskContextCompressionCreatedEvent'
        - $ref: '#/components/schemas/TaskContextCompressionInProgressEvent'
        - $ref: '#/components/schemas/TaskContextCompressionCompletedEvent'
        - $ref: '#/components/schemas/TaskOutputItemAddedEvent'
        - $ref: '#/components/schemas/TaskOutputItemDoneEvent'
        - $ref: '#/components/schemas/TaskContentPartAddedEvent'
        - $ref: '#/components/schemas/TaskContentPartDoneEvent'
        - $ref: '#/components/schemas/TaskReasoningSummaryPartAddedEvent'
        - $ref: '#/components/schemas/TaskReasoningSummaryPartDoneEvent'
        - $ref: '#/components/schemas/TaskReasoningSummaryTextDeltaEvent'
        - $ref: '#/components/schemas/TaskReasoningSummaryTextDoneEvent'
        - $ref: '#/components/schemas/TaskReasoningTextDeltaEvent'
        - $ref: '#/components/schemas/TaskReasoningTextDoneEvent'
        - $ref: '#/components/schemas/TaskToolCallArgumentsDeltaEvent'
        - $ref: '#/components/schemas/TaskToolCallArgumentsDoneEvent'
        - $ref: '#/components/schemas/TaskToolResultDeltaEvent'
        - $ref: '#/components/schemas/TaskToolResultDoneEvent'
        - $ref: '#/components/schemas/TaskTextDeltaEvent'
        - $ref: '#/components/schemas/TaskTextDoneEvent'
        - $ref: '#/components/schemas/TaskImageDeltaEvent'
        - $ref: '#/components/schemas/TaskImageDoneEvent'
        - $ref: '#/components/schemas/TaskAudioDeltaEvent'
        - $ref: '#/components/schemas/TaskAudioDoneEvent'
        - $ref: '#/components/schemas/TaskFileDeltaEvent'
        - $ref: '#/components/schemas/TaskFileDoneEvent'
        - $ref: '#/components/schemas/TaskRolloutEvent'
      discriminator:
        propertyName: type
      x-oaiMeta:
        name: AgentTaskEvent
        group: tasks
        example: >
          { "type": "task.output_text.delta", "item_id": "msg_123",
          "output_index": 0, "content_index": 0, "delta": "Hello",
          "sequence_number": 1 }
    ContentItemList:
      title: Content Item List
      type: array
      description: 内容项数组。
      items:
        $ref: '#/components/schemas/ContentItem'
    FunctionDefinition:
      type: object
      properties:
        name:
          type: string
          description: 工具/函数名称（唯一标识）。
        description:
          type: string
          description: 函数的用途说明。
        parameters:
          type: object
          description: JSON Schema for the function parameters.
          additionalProperties: true
        strict:
          type: boolean
          default: false
          description: 是否启用严格参数校验。
      required:
        - name
        - parameters
    ReasoningItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - reasoning
          description: 推理项类型标识。
        id:
          type: string
          description: 推理项 ID。
        summary:
          type: array
          items:
            $ref: '#/components/schemas/TextContentItem'
          description: 推理摘要内容（结构化）。
        content:
          type: array
          items:
            $ref: '#/components/schemas/TextContentItem'
          description: 推理详细内容（可选）。
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
          description: 状态。
      required:
        - type
        - id
        - summary
      x-oaiMeta:
        name: Reasoning item
        group: tasks
        example: |
          {
            "type": "reasoning",
            "id": "rs_123",
            "summary": [
              {"type": "summary_text", "text": "对推理过程的简短概述"}
            ],
            "content": [
              {"type": "reasoning_text", "text": "分步推理内容……"}
            ],
            "status": "in_progress"
          }
    MessageItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - message
          description: 消息条目类型标识。
        id:
          type: string
          description: 消息 ID。
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
          description: 消息生成状态。
        role:
          type: string
          enum:
            - user
            - assistant
            - system
            - developer
          description: 消息角色。
        name:
          type: string
          description: 角色名称（可选）。
        message_content:
          $ref: '#/components/schemas/MessageContent'
          description: 消息内容，字符串或内容项数组，工具协议兼容的 message_content（保留字段）。
        block_list:
          type: array
          items:
            type: object
          description: 渲染块列表（图表/表格等富媒体）。
          additionalProperties: true
          x-oaiExpandable: false
      required:
        - type
        - role
        - message_content
      x-oaiMeta:
        name: Output message
        group: tasks
        example: |
          {
            "type": "message",
            "id": "msg_123",
            "role": "assistant",
            "status": "completed",
            "message_content": [
              {"type": "output_text", "text": "你好，我可以帮你。"}
            ],
            "block_list": []
          }
    ToolCallItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - tool_call
          description: 工具调用条目类型标识。
        id:
          type: string
          description: 工具调用条目 ID。
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
          description: 调用状态。
        call_id:
          type: string
          description: 工具调用唯一 ID（跨事件关联）。
        name:
          type: string
          description: 工具名称。
        arguments:
          type: string
          description: 工具调用参数（JSON 字符串）。
        language:
          type: string
          enum:
            - json
            - yaml
            - python
            - javascript
          description: 参数语言标注（可选）。
      required:
        - type
        - call_id
        - name
        - arguments
      x-oaiMeta:
        name: Tool call item
        group: tasks
        example: |
          {
            "type": "tool_call",
            "id": "tc_1",
            "status": "in_progress",
            "call_id": "call_1",
            "name": "get_weather",
            "arguments": "{\"city\":\"San Francisco\"}",
            "language": "json"
          }
    ToolResultItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - tool_result
          description: 工具结果条目类型标识。
        id:
          type: string
          description: 工具结果条目 ID。
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
          description: 结果状态。
        call_id:
          type: string
          description: 对应的工具调用 ID。
        message_content:
          $ref: '#/components/schemas/MessageContent'
          description: 消息内容，字符串或内容项数组，工具协议兼容的 message_content（保留字段）。
        block_list:
          type: array
          items:
            type: object
          description: 工具结果的渲染块列表。
          additionalProperties: true
          x-oaiExpandable: false
      required:
        - type
        - call_id
        - message_content
        - block_list
      x-oaiMeta:
        name: Tool result item
        group: tasks
        example: |
          {
            "type": "tool_result",
            "id": "tr_1",
            "status": "completed",
            "call_id": "call_1",
            "output": "{\"temp\":18}",
            "message_content": [
              {"type": "output_text", "text": "当前温度 18°C"}
            ],
            "block_list": []
          }
    TaskStatus:
      type: string
      description: |
        任务生命周期状态。
        CREATED：任务已创建但尚未开始。
        QUEUED：任务已排队，等待处理。
        WORKING：任务正在处理中。
        INPUT_REQUIRED：任务需要额外输入以继续。
        PAUSED：任务已暂停，需恢复后继续。
        COMPLETED：任务已成功完成。
        CANCELED：任务已取消，不会继续处理。
        EXPIRED：任务已过期，不会继续处理。
        FAILED：任务处理失败，不会重试。

        常见情况：
            1. CREATED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED
            2. CREATED -> WORKING -> INPUT_REQUIRED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED
            3. CREATED -> WORKING -> PAUSED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED
            4. CREATED -> QUEUED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED
            5. CREATED -> QUEUED -> WORKING -> INPUT_REQUIRED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED
            6. CREATED -> QUEUED -> WORKING -> PAUSED -> WORKING -> COMPLETED|FAILED|CANCELED|EXPIRED

        取消情况：
            1. CREATED -> CANCELED
            2. CREATED -> WORKING -> CANCELED
            3. CREATED -> QUEUED -> CANCELED
            4. CREATED -> QUEUED -> WORKING -> CANCELED
            5. CREATED -> QUEUED -> WORKING -> PAUSED -> CANCELED
            6. CREATED -> QUEUED -> WORKING -> INPUT_REQUIRED -> CANCELED

        过期情况：
            1. CREATED -> WORKING -> EXPIRED
            2. CREATED -> WORKING -> INPUT_REQUIRED -> EXPIRED
            3. CREATED -> WORKING -> PAUSED -> EXPIRED
            4. CREATED -> QUEUED -> EXPIRED
            5. CREATED -> QUEUED -> WORKING -> EXPIRED
            6. CREATED -> QUEUED -> WORKING -> INPUT_REQUIRED -> EXPIRED
            7. CREATED -> QUEUED -> WORKING -> PAUSED -> EXPIRED
      enum:
        - created
        - queued
        - working
        - input-required
        - paused
        - completed
        - canceled
        - expired
        - failed
    TaskCreatedEvent:
      type: object
      description: |
        An event that is emitted when a task is created.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.created`.
          enum:
            - task.created
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: |
            The task that was created.
        sequence_number:
          type: integer
          description: The sequence number for this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.created
        group: tasks
        example: |
          {
            "type": "task.created",
            "task": {
              "id": "task_67ccfcdd16748190a91872c75d38539e09e4d4aac714747c",
              "object": "task",
              "created_at": 1741487325,
              "status": "created",
              "error": null,
              "incomplete_details": null,
              "instructions": null,
              "max_output_tokens": null,
              "model": "gpt-4o-2024-08-06",
              "output": [],
              "parallel_tool_calls": true,
              "previous_task_id": null,
              "reasoning": {
                "effort": null,
                "summary": null
              },
              "store": true,
              "temperature": 1,
              "text": {
                "format": {
                  "type": "text"
                }
              },
              "tool_choice": "auto",
              "tools": [],
              "top_p": 1,
              "truncation": "disabled",
              "usage": null,
              "user": null,
              "metadata": {}
            },
            "sequence_number": 1
          }
    TaskWorkingEvent:
      type: object
      description: >
        Emitted when the task is actively being processed. Alias of
        `task.working`.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.working`.
          enum:
            - task.working
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: |
            The task that is currently being processed.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.working
        group: tasks
        example: |
          {
            "type": "task.working",
            "task": {
              "id": "task_abc",
              "object": "task",
              "created_at": 1741487325,
              "status": "working",
              "error": null,
              "incomplete_details": null,
              "instructions": null,
              "model": "gpt-4o",
              "output": [],
              "tools": [],
              "parallel_tool_calls": true,
              "metadata": {}
            },
            "sequence_number": 2
          }
    TaskQueuedEvent:
      type: object
      title: TaskQueuedEvent
      description: |
        Emitted when a task is queued and waiting to be processed.
      properties:
        type:
          type: string
          enum:
            - task.queued
          description: The type of the event. Always 'task.queued'.
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: The full task object that is queued.
        sequence_number:
          type: integer
          description: The sequence number for this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.queued
        group: tasks
        example: |
          {
            "type": "task.queued",
            "task": {
              "id": "res_123",
              "status": "queued",
              "created_at": "2021-01-01T00:00:00Z",
              "updated_at": "2021-01-01T00:00:00Z"
            },
            "sequence_number": 1
          }
    TaskInputRequiredEvent:
      type: object
      description: >
        Emitted when the task requires additional input to continue (e.g., tool
        output or user confirmation).
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.input_required`.
          enum:
            - task.input_required
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: The task object at the time input was requested.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.input_required
        group: tasks
        example: |
          {
            "type": "task.input_required",
            "task": {
              "id": "task_abc",
              "object": "task",
              "created_at": 1741487325,
              "status": "input_required",
              "output": [],
              "tools": [],
              "metadata": {}
            },
            "sequence_number": 5
          }
    TaskPausedEvent:
      type: object
      description: Emitted when the task is paused and will not continue until resumed.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.paused`.
          enum:
            - task.paused
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: The task object when it was paused.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.paused
        group: tasks
        example: |
          {
            "type": "task.paused",
            "task": { "id": "task_abc", "object": "task", "status": "paused" },
            "sequence_number": 7
          }
    TaskCanceledEvent:
      type: object
      description: Emitted when a task is canceled and will not be processed further.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.canceled`.
          enum:
            - task.canceled
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: The task object that was canceled.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.canceled
        group: tasks
        example: |
          {
            "type": "task.canceled",
            "task": { "id": "task_abc", "object": "task", "status": "canceled" },
            "sequence_number": 8
          }
    TaskExpiredEvent:
      type: object
      description: Emitted when a task expires and will not be processed.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.expired`.
          enum:
            - task.expired
          x-stainless-const: true
        task:
          $ref: '#/components/schemas/TaskObject'
          description: The task object that expired.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.expired
        group: tasks
        example: |
          {
            "type": "task.expired",
            "task": { "id": "task_abc", "object": "task", "status": "expired" },
            "sequence_number": 9
          }
    TaskCompletedEvent:
      type: object
      description: Emitted when the model task is complete.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.completed`.
          enum:
            - task.completed
          x-stainless-const: true
        task_id:
          type: string
          description: The ID of the task this event belongs to.
        task:
          $ref: '#/components/schemas/TaskObject'
        sequence_number:
          type: integer
        agent_step:
          type: integer
          description: The current agent step index when the audio is completed.
      required:
        - type
        - task_id
        - agent_step
        - sequence_number
      x-oaiMeta:
        name: task.completed
        group: tasks
        example: |
          {
            "type": "task.completed",
            "task_id": "task_abc",
            "sequence_number": 1,
            "agent_step": 0
            "task": {
              "id": "task_123",
              "object": "task",
              "created_at": 1740855869,
              "status": "completed",
              "error": null,
              "incomplete_details": null,
              "input": [],
              "instructions": null,
              "max_output_tokens": null,
              "model": "gpt-4o-mini-2024-07-18",
              "output": [
                {
                  "id": "msg_123",
                  "type": "message",
                  "role": "assistant",
                  "content": [
                    {
                      "type": "output_text",
                      "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.",
                      "annotations": []
                    }
                  ]
                }
              ],
              "previous_task_id": null,
              "reasoning_effort": null,
              "store": false,
              "temperature": 1,
              "text": {
                "format": {
                  "type": "text"
                }
              },
              "tool_choice": "auto",
              "tools": [],
              "top_p": 1,
              "truncation": "disabled",
              "usage": {
                "input_tokens": 0,
                "output_tokens": 0,
                "output_tokens_details": {
                  "reasoning_tokens": 0
                },
                "total_tokens": 0
              },
              "user": null,
              "metadata": {}
            }
          }
    TaskFailedEvent:
      type: object
      description: |
        An event that is emitted when a task fails.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.failed`.
          enum:
            - task.failed
          x-stainless-const: true
        sequence_number:
          type: integer
          description: The sequence number of this event.
        task:
          $ref: '#/components/schemas/TaskObject'
          description: |
            The task that failed.
      required:
        - type
        - task
        - sequence_number
      x-oaiMeta:
        name: task.failed
        group: tasks
        example: |
          {
            "type": "task.failed",
            "task": {
              "id": "task_123",
              "object": "task",
              "created_at": 1740855869,
              "status": "failed",
              "error": {
                "code": "server_error",
                "message": "The model failed to generate a task."
              },
              "incomplete_details": null,
              "instructions": null,
              "max_output_tokens": null,
              "model": "gpt-4o-mini-2024-07-18",
              "output": [],
              "previous_task_id": null,
              "reasoning_effort": null,
              "store": false,
              "temperature": 1,
              "text": {
                "format": {
                  "type": "text"
                }
              },
              "tool_choice": "auto",
              "tools": [],
              "top_p": 1,
              "truncation": "disabled",
              "usage": null,
              "user": null,
              "metadata": {}
            }
          }
    TaskToolsUpdatedEvent:
      type: object
      description: Emitted when the set of tools available to the task changes.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.tools.updated`.
          enum:
            - task.tools.updated
          x-stainless-const: true
        tools:
          type: array
          description: The updated list of tools available to the model for this task.
          items:
            type: string
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - tools
        - sequence_number
      x-oaiMeta:
        name: task.tools.updated
        group: tasks
        example: |
          {
            "type": "task.tools.updated",
            "tools": [ { "type": "function", "name": "search", "parameters": {}, "strict": true } ],
            "sequence_number": 3
          }
    TaskContextCompressionCreatedEvent:
      type: object
      description: Emitted when context compression is initiated for a task.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.context_compression.created`.
          enum:
            - task.context_compression.created
          x-stainless-const: true
        method:
          type: string
          description: The compression method (e.g., semantic, sliding-window).
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - method
        - sequence_number
      x-oaiMeta:
        name: task.context_compression.created
        group: tasks
        example: >
          { "type": "task.context_compression.created", "method": "semantic",
          "sequence_number": 10 }
    TaskContextCompressionInProgressEvent:
      type: object
      description: Emitted periodically to indicate context compression progress.
      properties:
        type:
          type: string
          description: >-
            The type of the event. Always
            `task.context_compression.in_progress`.
          enum:
            - task.context_compression.in_progress
          x-stainless-const: true
        progress:
          type: number
          format: float
          description: Progress percentage from 0 to 100.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - progress
        - sequence_number
      x-oaiMeta:
        name: task.context_compression.in_progress
        group: tasks
        example: >
          { "type": "task.context_compression.in_progress", "progress": 42.5,
          "sequence_number": 11 }
    TaskContextCompressionCompletedEvent:
      type: object
      description: Emitted when context compression completes.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.context_compression.completed`.
          enum:
            - task.context_compression.completed
          x-stainless-const: true
        tokens_saved:
          type: integer
          description: Number of tokens reduced after compression.
        ratio:
          type: number
          format: float
          description: Compression ratio (original/compressed).
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - tokens_saved
        - ratio
        - sequence_number
      x-oaiMeta:
        name: task.context_compression.completed
        group: tasks
        example: >
          { "type": "task.context_compression.completed", "tokens_saved": 1532,
          "ratio": 2.4, "sequence_number": 12 }
    TaskOutputItemAddedEvent:
      type: object
      description: Emitted when a new output item is added.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.output_item.added`.
          enum:
            - task.output_item.added
          x-stainless-const: true
        output_index:
          type: integer
          description: |
            The index of the output item that was added.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
        item:
          $ref: '#/components/schemas/OutputItem'
          description: |
            The output item that was added.
      required:
        - type
        - output_index
        - item
        - sequence_number
      x-oaiMeta:
        name: task.output_item.added
        group: tasks
        example: |
          {
            "type": "task.output_item.added",
            "output_index": 0,
            "item": {
              "id": "msg_123",
              "status": "in_progress",
              "type": "message",
              "role": "assistant",
              "content": []
            },
            "sequence_number": 1
          }
    TaskOutputItemDoneEvent:
      type: object
      description: Emitted when an output item is marked done.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.output_item.done`.
          enum:
            - task.output_item.done
          x-stainless-const: true
        output_index:
          type: integer
          description: |
            The index of the output item that was marked done.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
        item:
          $ref: '#/components/schemas/OutputItem'
          description: |
            The output item that was marked done.
      required:
        - type
        - output_index
        - item
        - sequence_number
      x-oaiMeta:
        name: task.output_item.done
        group: tasks
        example: |
          {
            "type": "task.output_item.done",
            "output_index": 0,
            "item": {
              "id": "msg_123",
              "status": "completed",
              "type": "message",
              "role": "assistant",
              "content": [
                {
                  "type": "output_text",
                  "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.",
                  "annotations": []
                }
              ]
            },
            "sequence_number": 1
          }
    TaskContentPartAddedEvent:
      type: object
      description: Emitted when a new content part is added.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.content_part.added`.
          enum:
            - task.content_part.added
          x-stainless-const: true
        task_id:
          type: string
          description: The ID of the task this event belongs to.
        item_id:
          type: string
        agent_step:
          type: integer
        output_index:
          type: integer
          description: |
            The index of the output item that the content part was added to.
        content_index:
          type: integer
          description: |
            The index of the content part that was added.
        part:
          $ref: '#/components/schemas/ContentItem'
          description: |
            The content part that was added.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - task_id
        - agent_step
      x-oaiMeta:
        group: tasks
        example: |
          {
            "type": "task.content_part.added",
            "task_id": "task_abc",
            "item_id": "msg_123",
            "agent_step": 0,
            "output_index": 0,
            "content_index": 0,
            "part": {
              "type": "output_text",
              "text": "",
              "annotations": []
            },
            "sequence_number": 1
          }
    TaskContentPartDoneEvent:
      type: object
      description: Emitted when a content part is done.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.content_part.done`.
          enum:
            - task.content_part.done
          x-stainless-const: true
        task_id:
          type: string
          description: The ID of the task this event belongs to.
        item_id:
          type: string
        agent_step:
          type: integer
        output_index:
          type: integer
          description: |
            The index of the output item that the content part was added to.
        content_index:
          type: integer
          description: |
            The index of the content part that is done.
        sequence_number:
          type: integer
          description: The sequence number for this event.
        part:
          $ref: '#/components/schemas/ContentItem'
          description: |
            The content part that is done.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - task_id
        - agent_step
      x-oaiMeta:
        group: tasks
        example: |
          {
            "type": "task.content_part.done",
            "task_id": "task_abc",
            "item_id": "msg_123",
            "agent_step": 0,
            "output_index": 0,
            "content_index": 0,
            "sequence_number": 1,
            "part": {
              "type": "output_text",
              "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.",
              "annotations": []
            }
          }
    TaskReasoningSummaryPartAddedEvent:
      type: object
      description: Emitted when a new reasoning summary part is added.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_summary_part.added`.
          enum:
            - task.reasoning_summary_part.added
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this summary part is associated with.
        output_index:
          type: integer
          description: |
            The index of the output item this summary part is associated with.
        summary_index:
          type: integer
          description: |
            The index of the summary part within the reasoning summary.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
        part:
          type: object
          description: |
            The summary part that was added.
          properties:
            type:
              type: string
              description: The type of the summary part. Always `summary_text`.
              enum:
                - summary_text
              x-stainless-const: true
            text:
              type: string
              description: The text of the summary part.
          required:
            - type
            - text
      required:
        - type
        - item_id
        - output_index
        - summary_index
        - part
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_summary_part.added
        group: tasks
        example: |
          {
            "type": "task.reasoning_summary_part.added",
            "item_id": "rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476",
            "output_index": 0,
            "summary_index": 0,
            "part": {
              "type": "summary_text",
              "text": ""
            },
            "sequence_number": 1
          }
    TaskReasoningSummaryPartDoneEvent:
      type: object
      description: Emitted when a reasoning summary part is completed.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_summary_part.done`.
          enum:
            - task.reasoning_summary_part.done
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this summary part is associated with.
        output_index:
          type: integer
          description: |
            The index of the output item this summary part is associated with.
        summary_index:
          type: integer
          description: |
            The index of the summary part within the reasoning summary.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
        part:
          type: object
          description: |
            The completed summary part.
          properties:
            type:
              type: string
              description: The type of the summary part. Always `summary_text`.
              enum:
                - summary_text
              x-stainless-const: true
            text:
              type: string
              description: The text of the summary part.
          required:
            - type
            - text
      required:
        - type
        - item_id
        - output_index
        - summary_index
        - part
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_summary_part.done
        group: tasks
        example: |
          {
            "type": "task.reasoning_summary_part.done",
            "item_id": "rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476",
            "output_index": 0,
            "summary_index": 0,
            "part": {
              "type": "summary_text",
              "text": "**Responding to a greeting**\n\nThe user just said, \"Hello!\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \"Hello! How can I assist you today?\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!"
            },
            "sequence_number": 1
          }
    TaskReasoningSummaryTextDeltaEvent:
      type: object
      description: Emitted when a delta is added to a reasoning summary text.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_summary_text.delta`.
          enum:
            - task.reasoning_summary_text.delta
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this summary text delta is associated with.
        output_index:
          type: integer
          description: >
            The index of the output item this summary text delta is associated
            with.
        summary_index:
          type: integer
          description: |
            The index of the summary part within the reasoning summary.
        delta:
          type: string
          description: |
            The text delta that was added to the summary.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - summary_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_summary_text.delta
        group: tasks
        example: |
          {
            "type": "task.reasoning_summary_text.delta",
            "item_id": "rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476",
            "output_index": 0,
            "summary_index": 0,
            "delta": "**Responding to a greeting**\n\nThe user just said, \"Hello!\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \"Hello! How can I assist you today?\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!",
            "sequence_number": 1
          }
    TaskReasoningSummaryTextDoneEvent:
      type: object
      description: Emitted when a reasoning summary text is completed.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_summary_text.done`.
          enum:
            - task.reasoning_summary_text.done
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this summary text is associated with.
        output_index:
          type: integer
          description: |
            The index of the output item this summary text is associated with.
        summary_index:
          type: integer
          description: |
            The index of the summary part within the reasoning summary.
        text:
          type: string
          description: |
            The full text of the completed reasoning summary.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - summary_index
        - text
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_summary_text.done
        group: tasks
        example: |
          {
            "type": "task.reasoning_summary_text.done",
            "item_id": "rs_6806bfca0b2481918a5748308061a2600d3ce51bdffd5476",
            "output_index": 0,
            "summary_index": 0,
            "text": "**Responding to a greeting**\n\nThe user just said, \"Hello!\" So, it seems I need to engage. I'll greet them back and offer help since they're looking to chat. I could say something like, \"Hello! How can I assist you today?\" That feels friendly and open. They didn't ask a specific question, so this approach will work well for starting a conversation. Let's see where it goes from there!",
            "sequence_number": 1
          }
    TaskReasoningTextDeltaEvent:
      type: object
      description: Emitted when a delta is added to a reasoning text.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_text.delta`.
          enum:
            - task.reasoning_text.delta
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this reasoning text delta is associated with.
        output_index:
          type: integer
          description: >
            The index of the output item this reasoning text delta is associated
            with.
        content_index:
          type: integer
          description: >
            The index of the reasoning content part this delta is associated
            with.
        delta:
          type: string
          description: |
            The text delta that was added to the reasoning content.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_text.delta
        group: tasks
        example: |
          {
            "type": "task.reasoning_text.delta",
            "item_id": "rs_123",
            "output_index": 0,
            "content_index": 0,
            "delta": "The",
            "sequence_number": 1
          }
    TaskReasoningTextDoneEvent:
      type: object
      description: Emitted when a reasoning text is completed.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.reasoning_text.done`.
          enum:
            - task.reasoning_text.done
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the item this reasoning text is associated with.
        output_index:
          type: integer
          description: |
            The index of the output item this reasoning text is associated with.
        content_index:
          type: integer
          description: |
            The index of the reasoning content part.
        text:
          type: string
          description: |
            The full text of the completed reasoning content.
        sequence_number:
          type: integer
          description: |
            The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - text
        - sequence_number
      x-oaiMeta:
        name: task.reasoning_text.done
        group: tasks
        example: |
          {
            "type": "task.reasoning_text.done",
            "item_id": "rs_123",
            "output_index": 0,
            "content_index": 0,
            "text": "The user is asking...",
            "sequence_number": 4
          }
    TaskToolCallArgumentsDeltaEvent:
      type: object
      description: Emitted when there is a partial function-call arguments delta.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.tool_call_arguments.delta`.
          enum:
            - task.tool_call_arguments.delta
          x-stainless-const: true
        item_id:
          type: string
          description: >
            The ID of the output item that the function-call arguments delta is
            added to.
        output_index:
          type: integer
          description: >
            The index of the output item that the function-call arguments delta
            is added to.
        sequence_number:
          type: integer
          description: The sequence number of this event.
        delta:
          type: string
          description: |
            The function-call arguments delta that is added.
      required:
        - type
        - item_id
        - output_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.tool_call_arguments.delta
        group: tasks
        example: |
          {
            "type": "task.tool_call_arguments.delta",
            "item_id": "item-abc",
            "output_index": 0,
            "delta": "{ \"arg\":"
            "sequence_number": 1
          }
    TaskToolCallArgumentsDoneEvent:
      type: object
      description: Emitted when function-call arguments are finalized.
      properties:
        type:
          type: string
          enum:
            - task.tool_call_arguments.done
          x-stainless-const: true
        item_id:
          type: string
          description: The ID of the item.
        name:
          type: string
          description: The name of the function that was called.
        output_index:
          type: integer
          description: The index of the output item.
        sequence_number:
          type: integer
          description: The sequence number of this event.
        arguments:
          type: string
          description: The function-call arguments.
      required:
        - type
        - item_id
        - name
        - output_index
        - arguments
        - sequence_number
      x-oaiMeta:
        name: task.tool_call_arguments.done
        group: tasks
        example: |
          {
            "type": "task.tool_call_arguments.done",
            "item_id": "item-abc",
            "name": "get_weather",
            "output_index": 1,
            "arguments": "{ \"arg\": 123 }",
            "sequence_number": 1
          }
    TaskToolResultDeltaEvent:
      type: object
      description: Emitted when there is a partial tool result output.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.tool_result.delta`.
          enum:
            - task.tool_result.delta
          x-stainless-const: true
        call_id:
          type: string
          description: The unique ID of the tool call producing this output.
        item_id:
          type: string
          description: The output item ID that the tool result delta is added to.
        output_index:
          type: integer
          description: The index of the output item that the tool result delta is added to.
        content_index:
          type: integer
          description: >-
            The index of the content part that the tool result delta is added
            to.
        delta:
          type: string
          description: The partial output produced by the tool.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - call_id
        - item_id
        - output_index
        - content_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.tool_result.delta
        group: tasks
        example: |
          {
            "type": "task.tool_result.delta",
            "call_id": "call_123",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 0,
            "delta": "partial text",
            "sequence_number": 9
          }
    TaskToolResultDoneEvent:
      type: object
      description: Emitted when a tool result output is finalized.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.tool_result.done`.
          enum:
            - task.tool_result.done
          x-stainless-const: true
        call_id:
          type: string
          description: The unique ID of the tool call producing this output.
        item_id:
          type: string
          description: The output item ID that the tool result belongs to.
        output_index:
          type: integer
          description: The index of the output item that the tool result belongs to.
        content_index:
          type: integer
          description: The index of the content part that the tool result belongs to.
        output:
          anyOf:
            - type: string
              description: Final text output of the tool.
            - $ref: '#/components/schemas/OutputItem'
              description: Final structured output of the tool.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - call_id
        - item_id
        - output_index
        - content_index
        - output
        - sequence_number
      x-oaiMeta:
        name: task.tool_result.done
        group: tasks
        example: |
          {
            "type": "task.tool_result.done",
            "call_id": "call_123",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 0,
            "output": "final tool output",
            "sequence_number": 10
          }
    TaskTextDeltaEvent:
      type: object
      description: Emitted when there is an additional text delta.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.output_text.delta`.
          enum:
            - task.output_text.delta
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the output item that the text delta was added to.
        output_index:
          type: integer
          description: |
            The index of the output item that the text delta was added to.
        content_index:
          type: integer
          description: |
            The index of the content part that the text delta was added to.
        delta:
          type: string
          description: |
            The text delta that was added.
        sequence_number:
          type: integer
          description: The sequence number for this event.
        logprobs:
          type: array
          description: |
            The log probabilities of the tokens in the delta.
          items:
            $ref: '#/components/schemas/TaskLogProb'
      required:
        - type
        - item_id
        - output_index
        - content_index
        - delta
        - sequence_number
        - logprobs
      x-oaiMeta:
        name: task.output_text.delta
        group: tasks
        example: |
          {
            "type": "task.output_text.delta",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 0,
            "delta": "In",
            "sequence_number": 1
          }
    TaskTextDoneEvent:
      type: object
      description: Emitted when text content is finalized.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.output_text.done`.
          enum:
            - task.output_text.done
          x-stainless-const: true
        item_id:
          type: string
          description: |
            The ID of the output item that the text content is finalized.
        output_index:
          type: integer
          description: |
            The index of the output item that the text content is finalized.
        content_index:
          type: integer
          description: |
            The index of the content part that the text content is finalized.
        text:
          type: string
          description: |
            The text content that is finalized.
        sequence_number:
          type: integer
          description: The sequence number for this event.
        logprobs:
          type: array
          description: |
            The log probabilities of the tokens in the delta.
          items:
            $ref: '#/components/schemas/TaskLogProb'
      required:
        - type
        - item_id
        - output_index
        - content_index
        - text
        - sequence_number
        - logprobs
      x-oaiMeta:
        name: task.output_text.done
        group: tasks
        example: |
          {
            "type": "task.output_text.done",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 0,
            "text": "In a shimmering forest under a sky full of stars, a lonely unicorn named Lila discovered a hidden pond that glowed with moonlight. Every night, she would leave sparkling, magical flowers by the water's edge, hoping to share her beauty with others. One enchanting evening, she woke to find a group of friendly animals gathered around, eager to be friends and share in her magic.",
            "sequence_number": 1
          }
    TaskImageDeltaEvent:
      type: object
      description: Emitted when there is a partial image output.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.output_image.delta`.
          enum:
            - task.output_image.delta
          x-stainless-const: true
        item_id:
          type: string
          description: The ID of the output item that the image delta was added to.
        output_index:
          type: integer
          description: The index of the output item that the image delta was added to.
        content_index:
          type: integer
          description: The index of the content part that the image delta was added to.
        delta:
          type: string
          description: Base64-encoded partial image data or data URL segment.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.output_image.delta
        group: tasks
        example: |
          {
            "type": "task.output_image.delta",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 1,
            "delta": "/9j/4AAQSkZJRg...",
            "sequence_number": 4
          }
    TaskImageDoneEvent:
      type: object
      description: Emitted when image output is finalized.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.output_image.done`.
          enum:
            - task.output_image.done
          x-stainless-const: true
        item_id:
          type: string
          description: The ID of the output item that the image output is finalized.
        output_index:
          type: integer
          description: The index of the output item that the image output is finalized.
        content_index:
          type: integer
          description: The index of the content part that the image output is finalized.
        image_url:
          anyOf:
            - type: string
              description: A URL pointing to the finalized image.
            - type: 'null'
        file_id:
          anyOf:
            - type: string
              description: A file ID referencing the finalized image.
            - type: 'null'
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - sequence_number
      x-oaiMeta:
        name: task.output_image.done
        group: tasks
        example: |
          {
            "type": "task.output_image.done",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 1,
            "image_url": "https://example.com/image.png",
            "sequence_number": 5
          }
    TaskAudioDeltaEvent:
      type: object
      description: Emitted when there is a partial transcript of audio.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.audio.delta`.
          enum:
            - task.audio.delta
          x-stainless-const: true
        task_id:
          type: string
          description: The ID of the task this event belongs to.
        delta:
          type: string
          description: |
            The partial transcript of the audio task.
        sequence_number:
          type: integer
          description: The sequence number of this event.
        agent_step:
          type: integer
          description: The current agent step index when this audio chunk is generated.
      required:
        - type
        - task_id
        - delta
        - sequence_number
        - agent_step
      x-oaiMeta:
        name: task.audio.delta
        group: tasks
        example: |
          {
            "type": "task.audio.delta",
            "task_id": "task_abc",
            "sequence_number": 1,
            "agent_step": 0,
            "delta": " ... partial transcript ... ",
            "sequence_number": 1
          }
    TaskAudioDoneEvent:
      type: object
      description: Emitted when the full audio transcript is completed.
      properties:
        type:
          type: string
          description: |
            The type of the event. Always `task.audio.done`.
          enum:
            - task.audio.done
          x-stainless-const: true
        task_id:
          type: string
          description: The ID of the task this event belongs to.
        sequence_number:
          type: integer
          description: The sequence number of this event.
        agent_step:
          type: integer
          description: The current agent step index when this audio chunk is generated.
      required:
        - type
        - task_id
        - sequence_number
      x-oaiMeta:
        name: task.audio.done
        group: tasks
        example: |
          {
            "type": "task.audio.done",
            "task_id": "task_123",
            "sequence_number": 1
          }
    TaskFileDeltaEvent:
      type: object
      description: Emitted when there is a partial file output.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.output_file.delta`.
          enum:
            - task.output_file.delta
          x-stainless-const: true
        item_id:
          type: string
          description: The ID of the output item that the file delta was added to.
        output_index:
          type: integer
          description: The index of the output item that the file delta was added to.
        content_index:
          type: integer
          description: The index of the content part that the file delta was added to.
        delta:
          type: string
          description: Base64-encoded partial file data.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - delta
        - sequence_number
      x-oaiMeta:
        name: task.output_file.delta
        group: tasks
        example: |
          {
            "type": "task.output_file.delta",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 2,
            "delta": "UEsDB...",
            "sequence_number": 6
          }
    TaskFileDoneEvent:
      type: object
      description: Emitted when file output is finalized.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.output_file.done`.
          enum:
            - task.output_file.done
          x-stainless-const: true
        item_id:
          type: string
          description: The ID of the output item that the file output is finalized.
        output_index:
          type: integer
          description: The index of the output item that the file output is finalized.
        content_index:
          type: integer
          description: The index of the content part that the file output is finalized.
        file_url:
          anyOf:
            - type: string
              description: A URL pointing to the finalized file.
            - type: 'null'
        filename:
          anyOf:
            - type: string
              description: The filename of the finalized file.
            - type: 'null'
        file_id:
          anyOf:
            - type: string
              description: A file ID referencing the finalized file.
            - type: 'null'
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - item_id
        - output_index
        - content_index
        - sequence_number
      x-oaiMeta:
        name: task.output_file.done
        group: tasks
        example: |
          {
            "type": "task.output_file.done",
            "item_id": "msg_123",
            "output_index": 0,
            "content_index": 2,
            "file_url": "https://example.com/report.csv",
            "filename": "report.csv",
            "sequence_number": 7
          }
    TaskRolloutEvent:
      type: object
      description: Emitted during multi-agent rollout to annotate intermediate steps.
      properties:
        type:
          type: string
          description: The type of the event. Always `task.rollout`.
          enum:
            - task.rollout
          x-stainless-const: true
        step:
          type: integer
          description: The rollout step index.
        agent_id:
          type: string
          description: The ID of the agent producing this step.
        message:
          type: string
          description: A human-readable message describing the step.
        sequence_number:
          type: integer
          description: The sequence number of this event.
      required:
        - type
        - step
        - agent_id
        - message
        - sequence_number
      x-oaiMeta:
        name: task.rollout
        group: tasks
        example: |
          {
            "type": "task.rollout",
            "step": 3,
            "agent_id": "planner",
            "message": "Created subgoal: fetch weather",
            "sequence_number": 12
          }
    ContentItem:
      title: Content Item
      description: A single content item within a message.
      type: object
      oneOf:
        - $ref: '#/components/schemas/TextContentItem'
        - $ref: '#/components/schemas/ImageContentItem'
        - $ref: '#/components/schemas/AudioContentItem'
        - $ref: '#/components/schemas/FileContentItem'
        - type: string
    TextContentItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
            - input_text
            - output_text
            - reasoning_text
            - summary_text
            - refusal
          description: 文本内容类型。
        text:
          type: string
          description: 文本内容。
        id:
          type: integer
          description: 可选的内容引用 ID。
        tags:
          type: array
          description: 可选标签，用于标记内容来源或用途（如 "added_by_reference_manager"）。
          items:
            type: string
        annotations:
          type: array
          description: 文本注释（如引用、链接、文件路径等），与后端 Annotation 模型一致。
          items:
            $ref: '#/components/schemas/Annotation'
        logprobs:
          type: array
          description: 每个 token 的对数概率信息（可选）。
          items:
            $ref: '#/components/schemas/LogProb'
      required:
        - type
        - text
      x-oaiMeta:
        name: Text content item
        group: tasks
        example: |
          {"type": "output_text", "text": "这是模型输出的文本。"}
    TaskLogProb:
      type: object
      description: >
        A logprob is the logarithmic probability that the model assigns to
        producing

        a particular token at a given position in the sequence. Less-negative
        (higher)

        logprob values indicate greater model confidence in that token choice.
      properties:
        token:
          description: A possible text token.
          type: string
        logprob:
          description: |
            The log probability of this token.
          type: number
        top_logprobs:
          description: |
            The log probability of the top 20 most likely tokens.
          type: array
          items:
            type: object
            properties:
              token:
                description: A possible text token.
                type: string
              logprob:
                description: The log probability of this token.
                type: number
      required:
        - token
        - logprob
    ImageContentItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - image
            - input_image
            - output_image
            - image_url
          description: 图片内容类型。
        image_url:
          $ref: '#/components/schemas/ImageURL'
          description: 图片 URL 信息。
      required:
        - type
        - image_url
      x-oaiMeta:
        name: Image content item
        group: tasks
        example: >
          {"type": "image_url", "image_url": {"url":
          "https://example.com/cat.png", "detail": "auto"}}
    AudioContentItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - input_audio
            - output_audio
            - audio
          description: 音频内容类型。
        input_audio:
          $ref: '#/components/schemas/InputAudio'
          description: 输入音频内容。
      required:
        - type
        - input_audio
      x-oaiMeta:
        name: Audio content item
        group: tasks
        example: >
          {"type": "input_audio", "input_audio": {"data": "<base64>", "format":
          "mp3"}}
    FileContentItem:
      type: object
      properties:
        type:
          type: string
          enum:
            - file
          description: 文件内容类型。
        file:
          $ref: '#/components/schemas/FileDetail'
          description: 文件详情。
      required:
        - type
        - file
      x-oaiMeta:
        name: File content item
        group: tasks
        example: >
          {"type": "file", "file": {"file_url":
          "https://example.com/report.pdf", "filename": "report.pdf"}}
    Annotation:
      discriminator:
        propertyName: type
      anyOf:
        - $ref: '#/components/schemas/AnnotationFileCitation'
        - $ref: '#/components/schemas/AnnotationURLCitation'
        - $ref: '#/components/schemas/AnnotationContainerFileCitation'
        - $ref: '#/components/schemas/AnnotationFilePath'
    LogProb:
      properties:
        token:
          type: string
        logprob:
          type: number
        bytes:
          items:
            type: integer
          type: array
        top_logprobs:
          items:
            $ref: '#/components/schemas/TopLogProb'
          type: array
      type: object
      required:
        - token
        - logprob
        - bytes
        - top_logprobs
      title: Log probability
      description: The log probability of a token.
    ImageURL:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: 图片的可访问 URL。
        detail:
          anyOf:
            - type: string
              enum:
                - low
                - high
                - auto
            - type: 'null'
          description: 清晰度等级，可选 low/high/auto。
      required:
        - url
    InputAudio:
      type: object
      properties:
        data:
          type: string
          description: Base64-encoded audio bytes
        format:
          type: string
          enum:
            - wav
            - mp3
          default: wav
      required:
        - data
        - format
    FileDetail:
      type: object
      properties:
        file_data:
          type: string
          description: Optional Base64-encoded file content
        file_url:
          type: string
          description: 远程文件的可访问 URL；与 file_data 二选一，可同时提供以便存档。
        filename:
          type: string
          description: 文件名（含扩展名），用于渲染与调试追踪。
      required:
        - file_url
        - filename
    AnnotationFileCitation:
      properties:
        type:
          type: string
          enum:
            - file_citation
          description: The type of the file citation. Always `file_citation`.
          default: file_citation
          x-stainless-const: true
        file_id:
          type: string
          description: The ID of the file.
        index:
          type: integer
          description: The index of the file in the list of files.
        filename:
          type: string
          description: The filename of the file cited.
      type: object
      required:
        - type
        - file_id
        - index
        - filename
      title: File citation
      description: A citation to a file.
    AnnotationURLCitation:
      properties:
        type:
          type: string
          enum:
            - url_citation
          description: The type of the URL citation. Always `url_citation`.
          default: url_citation
          x-stainless-const: true
        url:
          type: string
          description: The URL of the web resource.
        start_index:
          type: integer
          description: The index of the first character of the URL citation in the message.
        end_index:
          type: integer
          description: The index of the last character of the URL citation in the message.
        title:
          type: string
          description: The title of the web resource.
      type: object
      required:
        - type
        - url
        - start_index
        - end_index
        - title
      title: URL citation
      description: A citation for a web resource used to generate a model task.
    AnnotationContainerFileCitation:
      properties:
        type:
          type: string
          enum:
            - container_file_citation
          description: >-
            The type of the container file citation. Always
            `container_file_citation`.
          default: container_file_citation
          x-stainless-const: true
        container_id:
          type: string
          description: The ID of the container file.
        file_id:
          type: string
          description: The ID of the file.
        start_index:
          type: integer
          description: >-
            The index of the first character of the container file citation in
            the message.
        end_index:
          type: integer
          description: >-
            The index of the last character of the container file citation in
            the message.
        filename:
          type: string
          description: The filename of the container file cited.
      type: object
      required:
        - type
        - container_id
        - file_id
        - start_index
        - end_index
        - filename
      title: Container file citation
      description: A citation for a container file used to generate a model task.
    AnnotationFilePath:
      properties:
        type:
          type: string
          enum:
            - file_path
          description: The type of the file citation. Always `file_path`.
          default: file_path
          x-stainless-const: true
        index:
          type: integer
          description: The index of the file in the list of files.
        file_url:
          type: string
          description: The URL of the file cited.
      type: object
      required:
        - type
        - index
        - file_url
      title: File path citation
      description: A citation to a file path.
    TopLogProb:
      properties:
        token:
          type: string
        logprob:
          type: number
        bytes:
          items:
            type: integer
          type: array
      type: object
      required:
        - token
        - logprob
        - bytes
      title: Top log probability
      description: The top log probability of a token.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````