Browse the documentation

AEL 1.0.0

From console agent to HTTP API

In AEL, the Agent Engineering Language, a console agent needs no server: add the HTTP package and declare routes to make it a REST API, or remove them to go back to console-only. This tutorial runs the support agent of Your first agent, end to end all three ways a console program takes input, then serves the same typed agent over HTTP, and takes the server out again.

Step 1: build the console agent

ael build --target <target> -o build/support --release

The program carries no server code: nothing in it listens on the network.

Step 2: give it input three ways

./build/support "Where is my order?"
cat questions.txt | ./build/support
./build/support
  • An argument on the command line: the program answers and does not wait for more input.
  • Piped input on standard input: the program reads it until the input ends.
  • Typed at the console: the program asks for input and reads what you type.

Blank input, input that is too long and input that is not valid UTF-8 each give a defined result rather than a crash. The answer goes to standard output, and questions to the user and the time and token summary to standard error, so the answer can be piped on unchanged. Console and logging describes console input in full.

Step 3: add the HTTP package

ael pack add server/http

The project's pack.ael now declares server/http, with its request to listen on the network. ael pack add shows the dependencies and capabilities a package brings before anything changes.

Step 4: declare the routes

Routes live in a .routes.ael file, a file role that server/http adds:

# src/api/api.routes.ael
routes api(base_route = "/api/v1") {
    # Route declarations map methods and paths to the typed support agent.
}

Declaring routes opens no port: main mounts the routes and starts the server, and main decides when the server stops and drains. The handler is the same typed agent the console program runs: its input decodes from the request within size limits, and a malformed or oversized request is refused with a documented status.

Step 5: build and serve

ael check
ael build --target <target> -o build/support-api --release

Optional HTTP, gRPC, WebSocket and socket servers send each reply to the authenticated caller that asked for it. A request is authenticated before your handler runs, and the tenant and the caller's identity are set from that authentication, never from fields in the request body.

Step 6: remove the server again

  1. Delete the routes file and the code in main that mounts them.
  2. Remove the package:
ael pack remove server/http
ael check
ael build --target <target> -o build/support --release

The next build carries no server code. If anything still refers to the package, ael check names the reference, so you remove it deliberately: removing a package never edits your source.

Only what you use ships

Only what you use ships: an HTTP-only app carries no gRPC or WebSocket code, and a GET-only API no POST handlers. Each server is a separate package, added only when you choose it, and ael refmap lists anything that is installed but unused.

Honest limits

  • This page states no size, connection, request-rate or start-up figure; measure your own program on your own platform.
  • Calls your agent makes to models, MCP tools or other APIs are outbound client calls and need no server package.
  • Support for native gRPC clients does not imply support for gRPC from web browsers.