所有伺服器工具

Bash

openrouter:bash

適用於 Messages API 的 Anthropic 風格 bash 工具。當 engine 設為 openrouter 時,命令會在伺服器端的隔離容器中執行。當設為 auto 或 native 時,工具呼叫會傳回您的應用程式,以便在用戶端執行。

運作方式

適用於以 Claude 的 bash 工具建構的 Messages API 整合。在 Responses API 上執行沙箱命令,請使用 Shell。

  1. 您的模型 發出包含待執行指令的 bash 呼叫。

  2. 您的應用程式或 OpenRouter 執行這些工具:預設由您的應用程式執行,或在 engine 為 openrouter 時由 OpenRouter 沙箱執行。

  3. 您的模型 讀取 stdout、stderr 和結束代碼,然後繼續執行。

供應商與定價

engine: "openrouter" 會在 OpenRouter 沙箱中執行命令。auto 和 native 會將呼叫傳回您的應用程式執行。

  • Client-side

    免費

    工具呼叫會傳回您的應用程式以供執行。

  • OpenRouter sandbox

    US$0.0001 / second

    啟動容器的請求最低以 30.0s 計算

    指令會在伺服器端由 OpenRouter 營運的隔離容器中執行。

每個請求皆適用標準模型 token 費用。

使用此工具

當 parameters.engine 設為 openrouter 時,如本快速入門所示,OpenRouter 會在其沙箱中執行命令,並將輸出傳回模型。使用預設引擎 auto 或 native 時,工具呼叫會傳回您的應用程式,以便在用戶端執行。

可透過 API 使用。 Chatroom 使用 Shell,可在 Responses API 上使用相同的沙箱。

支援的 API:Anthropic Messages。

Shell
curl https://openrouter.ai/api/v1/messages \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "~anthropic/claude-opus-latest",
  "max_tokens": 1024,
  "tools": [
    {
      "type": "openrouter:bash",
      "parameters": {
        "engine": "openrouter"
      }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": "List the files in the working directory and count the lines in each."
    }
  ]
}'

設定、參數與範例請參閱文件。

閱讀整合指南

常見問題