> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# 7. Serve an HTTP API

> Mount an explicit local router and make a request from a client.

[Support assistant tutorial](/learn/support-assistant)

This checkpoint uses matching `@agentium/core@4.0.0` and `@agentium/transport@4.0.0` packages. V4 requires an explicit local or authenticated security mode.

```bash theme={null}
npm install express
npm install --save-dev @types/express
```

It serves a basic support Agent on loopback. Add the tools you have verified in earlier checkpoints to the `support` Agent as needed.

## Complete checkpoint

```typescript support.ts theme={null}
import express from "express";
import { Agent, openai } from "@agentium/core";
import { createAgentRouter } from "@agentium/transport";

const support = new Agent({
  name: "support",
  model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
  instructions: "Help customers with orders. Ask for an order ID when it is missing.",
});
const app = express();
app.use(express.json({ limit: "1mb" }));
app.use("/api", createAgentRouter({
  registry: false,
  agents: { support },
  security: { mode: "local" },
}));
const server = app.listen(3000, "127.0.0.1", () => {
  console.log("Support API: http://127.0.0.1:3000/api/agents/support/run");
});

let closing = false;
function shutdown() {
  if (closing) return;
  closing = true;
  server.close((error) => {
    void support.close().catch(console.error);
    if (error) { console.error(error); process.exitCode = 1; }
  });
}
process.once("SIGINT", shutdown);
process.once("SIGTERM", shutdown);
```

## Run it

```bash theme={null}
npx tsx support.ts
```

## Verify the result

In another terminal, make a request:

```bash theme={null}
curl http://127.0.0.1:3000/api/agents/support/run \
  -H 'Content-Type: application/json' \
  -d '{"input":"Where is my order?"}'
```

The response should contain an agent answer asking for an order ID. `registry: false` exposes only the explicit `support` map. Stop the server with Ctrl+C.

The shutdown handler stops new connections and closes the Agent after existing connections finish. A production host also needs bounded drain time, cancellation for active requests, and cleanup for separately owned resources.

Local mode is for trusted local use. Before exposing this API, implement verified identity and resource ownership through [authenticated hosting](/ship/authentication). Do not solve deployment by changing the bind address alone.

<Card title="Prepare the application for deployment" icon="arrow-right" href="/learn/ship">Continue to the next chapter.</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.