org.llm4s.toolapi.builtin.http

HTTP tools for making web requests.

These tools provide safe HTTP access with configurable domain restrictions and method limitations.

== Configuration ==

All HTTP tools accept HttpConfig for request configuration:

  • Domain allowlists and blocklists for security
  • Allowed HTTP methods
  • Response size limits
  • Timeout configuration

== Available Tools ==

  • HTTPTool: Make HTTP requests (GET, POST, PUT, DELETE, etc.)

Attributes

Example
import org.llm4s.toolapi.builtin.http._
import org.llm4s.toolapi.ToolRegistry
// Read-only HTTP tool (GET/HEAD only)
val readOnlyTool = HTTPTool.create(HttpConfig.readOnly())
// Restricted to specific domains
val restrictedTool = HTTPTool.create(HttpConfig.restricted(
 Seq("api.example.com", "data.example.org")
))
// Full access with custom timeout
val fullTool = HTTPTool.create(HttpConfig(
 timeoutMs = 60000,
 maxResponseSize = 50 * 1024 * 1024
))
val tools = new ToolRegistry(Seq(restrictedTool))

Members list

Type members

Classlikes

case class HTTPResult(url: String, method: String, statusCode: Int, statusMessage: String, headers: Map[String, String], body: String, contentType: Option[String], contentLength: Long, truncated: Boolean, responseTimeMs: Long)

HTTP response result.

HTTP response result.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object HTTPResult

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
HTTPResult.type
object HTTPTool

Tool for making HTTP requests.

Tool for making HTTP requests.

Features:

  • Support for GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
  • Request headers and body
  • Domain allowlist/blocklist for security
  • Response size limits
  • Configurable timeout

Attributes

Example
{
import org.llm4s.toolapi.builtin.http._
val httpTool = HTTPTool.create(HttpConfig(
 allowedDomains = Some(Seq("api.example.com")),
 allowedMethods = Seq("GET", "POST")
))
val tools = new ToolRegistry(Seq(httpTool))
agent.run("Fetch data from https://api.example.com/data", tools)

}

Supertypes
class Object
trait Matchable
class Any
Self type
HTTPTool.type
case class HttpConfig(allowedDomains: Option[Seq[String]], blockedDomains: Seq[String], maxResponseSize: Long, timeoutMs: Int, followRedirects: Boolean, maxRedirects: Int, allowedMethods: Seq[String], userAgent: String)

Configuration for HTTP tool.

Configuration for HTTP tool.

Value parameters

allowedDomains

Optional list of allowed domains. If None, all domains are allowed.

allowedMethods

HTTP methods that are allowed.

blockedDomains

List of domains that are always blocked.

followRedirects

Whether to follow HTTP redirects.

maxRedirects

Maximum number of redirects to follow.

maxResponseSize

Maximum response size in bytes.

timeoutMs

Request timeout in milliseconds.

userAgent

User-Agent header to use.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object HttpConfig

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
HttpConfig.type

Value members

Concrete fields

val allTools: Seq[ToolFunction[_, _]]

All HTTP tools with default configuration.

All HTTP tools with default configuration.

Attributes