跳转到内容

API 参考

工具 API

以编程方式访问 4agent 工具目录。无需身份验证,所有响应均为 JSON。基础 URL:

https://4agent.dev/api/tools

机器可读约定: OpenAPI 3.1 JSON · 开发者快速入门

接口约定遵循 OpenAPI 3.1 规范 以及以下规范定义的标准 HTTP 响应语义: RFC 9110.

GET/api/tools

List all published tools. Returns the full catalog sorted by name.

参数

localestring可选展示语言:en、zh-CN、ja 或 es,默认 en;ID 和协议字段保持不变。

示例

curl https://4agent.dev/api/tools

响应

{
  "count": 211,
  "tools": [
    {
      "id": "browserbase",
      "name": "Browserbase",
      "tagline": "Headless browser infrastructure built for AI agents",
      "category": ["browser", "web-scraping"],
      "description": "...",
      "url": "https://www.browserbase.com",
      "api_endpoint": "https://api.browserbase.com",
      "auth_method": "api_key",
      "pricing": {
        "model": "usage",
        "free_tier": true,
        "starting_price": "$0/month"
      },
      "integration": {
        "mcp": true,
        "cli": false,
        "openapi": false,
        "sdk": ["typescript", "python"]
      },
      "tags": ["browser", "playwright", "puppeteer", "automation"],
      "verified": true
    }
  ]
}
GET/api/tools?q={query}

Full-text search across tool names, taglines, descriptions, categories, tags, and SDKs. Add view=summary for a smaller card-ready payload.

参数

qstring搜索词。匹配名称、简述、描述、分类、标签和 SDK 字段。
view"summary"可选。仅返回目录卡片所需字段。

示例

curl "https://4agent.dev/api/tools?q=email&view=summary"

响应

{
  "count": 5,
  "tools": [
    {
      "id": "agentmail",
      "name": "AgentMail",
      "tagline": "Email inbox API for AI agents",
      ...
    },
    ...
  ]
}
GET/api/tools?category={category}

Filter tools by category.

参数

categorystring分类标识符。可选值:sandbox, code-execution, email, communication, browser, web-scraping, file-storage, database, memory, vector-db, payment, auth, identity, monitoring, observability, search, data, deployment, hosting, audio, video。

示例

curl "https://4agent.dev/api/tools?category=browser"

响应

{
  "count": 9,
  "tools": [
    {
      "id": "browserbase",
      "name": "Browserbase",
      ...
    },
    ...
  ]
}
GET/api/tools?id={id}

Retrieve a single tool by its ID.

参数

idstring工具唯一标识符(以连字符分隔的小写名称)。

示例

curl "https://4agent.dev/api/tools?id=openrouter"

响应

{
  "tool": {
    "id": "openrouter",
    "name": "OpenRouter",
    "tagline": "Unified API for 300+ LLMs",
    "category": ["data", "search"],
    "description": "...",
    "url": "https://openrouter.ai",
    "api_endpoint": "https://openrouter.ai/api/v1",
    "auth_method": "api_key",
    "pricing": {
      "model": "usage",
      "free_tier": true,
      "starting_price": "Pay per token"
    },
    "integration": {
      "mcp": false,
      "cli": false,
      "openapi": true,
      "sdk": ["typescript", "python"]
    },
    "tags": ["llm", "ai", "inference", "api"],
    "verified": true
  }
}

错误响应

404工具不存在。按 ID 查询但没有匹配的已发布工具时返回。
{
  "error": "Tool not found",
  "code": "tool_not_found",
  "resolution": "Use GET /api/tools to list valid IDs or search with the q parameter."
}

Agent 使用方式

此 API 供 AI 智能体以编程方式发现和评估工具。工作流示例:

// Find tools that support MCP
const res = await fetch("https://4agent.dev/api/tools");
const { tools } = await res.json();
const mcpTools = tools.filter(t => t.integration.mcp);

// Search for a specific capability
const emailRes = await fetch(
  "https://4agent.dev/api/tools?q=email+inbox"
);
const { tools: emailTools } = await emailRes.json();

// Get details for a specific tool
const toolRes = await fetch(
  "https://4agent.dev/api/tools?id=agentmail"
);
const { tool } = await toolRes.json();
console.log(tool.api_endpoint); // https://api.agentmail.to