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。
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."
}
]
}'文档中提供了设置、参数和示例。
阅读集成指南相关工具
代码与执行