← All tools

Web & HTTP

HTTP Request

Make authenticated REST calls.

http_request

Overview

Lets the agent talk to any online service. If there's an API somewhere — your own internal one, or a vendor's — this is the generic phone the agent uses to ask it for data or to send it something.

How it works

Performs a single HTTP request with the specified method (GET/POST/PUT/DELETE/PATCH), custom headers, query parameters, and body. Optionally injects a bearer token for the Authorization header. Returns the raw response body so the agent can parse it with json_transform or xml_parse as needed.

Example

When a user asks:

Call our internal pricing API for customer 12345.

the agent calls the tool:

http_request(method="GET", url="https://api.internal/pricing/12345", authToken="•••")

and gets back: whatever response your API returns — typically a JSON payload the agent can read.

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# api-bridge.yaml
name: api-bridge-crew
process: SEQUENTIAL

agents:
  - id: integrator
    role: API Integrator
    goal: Call internal REST services on behalf of the crew
    tools:
      - http_request

tasks:
  - id: api-bridge-task
    agent: integrator
    description: GET https://api.internal/pricing/12345 with the supplied bearer token and return the response.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.HttpRequestTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired HttpRequestTool httpRequestTool;

Agent integrator = Agent.builder()
    .role("API Integrator")
    .goal("Call internal REST services on behalf of the crew")
    .chatClient(chatClient)
    .tool(httpRequestTool)
    .build();

Task integratorTask = Task.builder()
    .description("GET https://api.internal/pricing/12345 with the supplied bearer token and return the response.")
    .agent(integrator)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(integrator)
    .task(integratorTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Calling custom internal REST APIs from agents
Webhook integrations in orchestration crews
Bearer-authenticated API calls (POST/PUT)
API probing in integration or QA agents

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/HttpRequestTool.java in the swarm-ai repository.

Open http_request on GitHub →