跳转到主要内容
GUI-Plus

GUI-Plus OpenAI 兼容

通过 OpenAI 兼容接口调用 GUI-Plus 界面交互专用模型。

POST
/compatible-mode/v1/chat/completions
import os
from openai import OpenAI

system_prompt = """# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{"type": "function", "function": {"name": "computer_use", "description": "Use a mouse and keyboard to interact with a computer, and take screenshots.\n* This is an interface to a desktop GUI. You do not have access to a terminal or applications menu. You must click on desktop icons to start applications.\n* Some applications may take time to start or process actions, so you may need to wait and take successive screenshots to see the results of your actions. E.g. if you click on Firefox and a window doesn't open, try wait and taking another screenshot.\n* The screen's resolution is 1000x1000.\n* Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don't click boxes on their edges unless asked.", "parameters": {"properties": {"action": {"description": "The action to perform. The available actions are:\n* `key`: Performs key down presses on the arguments passed in order, then performs key releases in reverse order.\n* `type`: Type a string of text on the keyboard.\n* `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.\n* `left_click`: Click the left mouse button at a specified (x, y) pixel coordinate on the screen.\n* `left_click_drag`: Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.\n* `right_click`: Click the right mouse button at a specified (x, y) pixel coordinate on the screen.\n* `middle_click`: Click the middle mouse button at a specified (x, y) pixel coordinate on the screen.\n* `double_click`: Double-click the left mouse button at a specified (x, y) pixel coordinate on the screen.\n* `triple_click`: Triple-click the left mouse button at a specified (x, y) pixel coordinate on the screen (simulated as double-click since it's the closest action).\n* `scroll`: Performs a scroll of the mouse scroll wheel.\n* `hscroll`: Performs a horizontal scroll (mapped to regular scroll).\n* `wait`: Wait specified seconds for the change to happen.\n* `terminate`: Terminate the current task and report its completion status.\n* `answer`: Answer a question.\n* `interact`: Resolve the blocking window by interacting with the user.", "enum": ["key", "type", "mouse_move", "left_click", "left_click_drag", "right_click", "middle_click", "double_click", "triple_click", "scroll", "hscroll", "wait", "terminate", "answer", "interact"], "type": "string"}, "keys": {"description": "Required only by `action=key`.", "type": "array"}, "text": {"description": "Required only by `action=type`, `action=answer` and `action=interact`.", "type": "string"}, "coordinate": {"description": "(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=mouse_move` and `action=left_click_drag`.", "type": "array"}, "pixels": {"description": "The amount of scrolling to perform. Positive values scroll up, negative values scroll down. Required only by `action=scroll` and `action=hscroll`.", "type": "number"}, "time": {"description": "The seconds to wait. Required only by `action=wait`.", "type": "number"}, "status": {"description": "The status of the task. Required only by `action=terminate`.", "type": "string", "enum": ["success", "failure"]}}, "required": ["action"], "type": "object"}}}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>

# Response format

Response format for every step:
1) Action: a short imperative describing what to do in the UI.
2) A single <tool_call>...</tool_call> block containing only the JSON: {"name": <function-name>, "arguments": <args-json-object>}.

Rules:
- Output exactly in the order: Action, <tool_call>.
- Be brief: one for Action.
- Do not output anything else outside those two parts.
- If finishing, use action=terminate in the tool call."""

messages = [
  {
    "role": "system",
    "content": system_prompt
  },
  {
    "role": "user",
    "content": [
      {"type": "image_url", "image_url": {"url": "https://img.alicdn.com/imgextra/i2/O1CN016iJ8ob1C3xP1s2M6z_!!6000000000026-2-tps-3008-1758.png"}},
      {"type": "text", "text": "帮我打开浏览器"}
    ]
  }
]

client = OpenAI(
  api_key=os.getenv("DASHSCOPE_API_KEY"),
  base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
  model="gui-plus-2026-02-26",
  messages=messages,
  extra_body={"vl_high_resolution_images": True}
)

print(completion.choices[0].message.content)
{
  "choices": [
    {
      "message": {
        "content": "<tool_call>\n{\"name\": \"computer_use\", \"arguments\": {\"action\": \"left_click\", \"coordinate\": [2530, 314]}}\n</tool_call>",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 7750,
    "completion_tokens": 36,
    "total_tokens": 7786,
    "prompt_tokens_details": {
      "image_tokens": 6743,
      "text_tokens": 1007
    },
    "completion_tokens_details": {
      "text_tokens": 36
    }
  },
  "created": 1773133741,
  "system_fingerprint": null,
  "model": "gui-plus",
  "id": "chatcmpl-8b375016-abb8-9791-856c-74b2825c22d5"
}

鉴权

string
header
必填

千问 AI 平台 API Key。详见获取 API Key

请求体

application/json
enum<string>
必填

模型名称。

gui-plus,gui-plus-2026-02-26
object[]
必填

模型的对话历史,按时间顺序排列。

  • Option 1
  • Option 2
  • Option 3
boolean
默认值false

是否以流式方式输出回复。false:等待模型生成完整回复后一次性返回。true:模型边生成边返回数据块。

object

流式输出的配置项,仅在 streamtrue 时生效。

integer

限制模型输出的最大 Token 数。若生成内容超过此值,响应将被截断。默认值与最大值均为模型的最大输出长度。

boolean
默认值false

是否将输入图像的像素上限提升至 16384 Token 对应的像素量。开启后使用固定分辨率策略,像素上限为 12,845,056(忽略 max_pixels)。关闭时像素上限由 max_pixels 决定。

此参数不是标准 OpenAI 参数。 使用 Python SDK 时,通过 extra_body 传入:extra_body={"vl_high_resolution_images": True}

boolean

是否开启思考模式。仅 gui-plus-2026-02-26 支持混合思考。开启后思考内容通过 reasoning_content 返回。

此参数不是标准 OpenAI 参数。 使用 Python SDK 时,通过 extra_body 传入:extra_body={"enable_thinking": True}

integer

随机数种子,范围 [0, 2^31-1]。用于确保在相同输入和参数下生成结果可复现。

number
默认值0.01

采样温度,控制生成文本的多样性。取值范围 [0, 2)temperaturetop_p 二者只需设置其一。

number
默认值0.01

核采样的概率阈值。取值范围 (0, 1.0]temperaturetop_p 二者只需设置其一。

integer
默认值1

采样候选集的大小。None 或大于 100 时将禁用该功能。

此参数不是标准 OpenAI 参数。 使用 Python SDK 时,通过 extra_body 传入。

number
默认值1

连续序列中的重复度惩罚。1.0 表示不惩罚。对输出影响较大,建议保持默认值。

number
默认值1.5

控制生成文本的内容重复度。取值范围 [-2.0, 2.0]。正值降低重复度,负值增加重复度。

string

停止词。当模型生成的文本中出现指定字符串或 token_id 时,生成立即终止。不支持字符串与 token_id 混合。

响应

200-application/json
string

本次请求的唯一标识符。

object[]
integer

请求创建时的 Unix 时间戳。

string

本次请求使用的模型。

enum<string>
chat.completion
null
null
object