HTTPTool

org.llm4s.toolapi.builtin.http.HTTPTool
object HTTPTool

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, bounding the whole call (connect, every redirect hop and the body read)
  • Run as an agent's call, a POST, PUT, PATCH or DELETE carries the call's idempotency key as an Idempotency-Key header, so a server that honours it does the write once however often the agent runs the call; a header of that name set in the call's headers is kept instead

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)

}

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
HTTPTool.type

Members list

Value members

Concrete methods

def createSafe(config: HttpConfig): Result[ToolFunction[Map[String, Any], HTTPResult]]

Create an HTTP tool with the given configuration, returning a Result for safe error handling.

Create an HTTP tool with the given configuration, returning a Result for safe error handling.

Attributes

Concrete fields

val toolSafe: Result[ToolFunction[Map[String, Any], HTTPResult]]

Default HTTP tool instance, returning a Result for safe error handling.

Default HTTP tool instance, returning a Result for safe error handling.

Attributes