Documentation / Conception / Guides pratiques / Expose an agent as an API

Expose an agent as an API

Any agent can be published as an HTTP endpoint so external systems invoke it directly, without a workflow around it. In the Agents page, open the agent and enable Exposition API; pick an authentication mode (none, basic, or a dedicated header/API key backed by a credential — see Manage credentials).

Each call runs as a durable run of the system workflow agent-invoke.workflow.yaml, so the turn is audited like any run. The agent keeps its eligible tools (eligibility is judged when the agent is saved: control-flow, human-task and dynamic nodes are out; a sink needs its manifest's agentTool opt-in; and a tool's required context must be composable by the caller — i.e. registered context kinds). Ambient context is composed opportunistically from the agent's inputs: any input matching a registered kind's id field (e.g. patientId) becomes that kind's context for the whole turn, tools included.

Plain JSON surface

  • POST /api/agents/<nodeTypeId>/invoke — body { "inputs": { <port>: value } }, validated against the agent's typed input ports (400 details each mismatch); answers { "outputs": { <port>: value } }.
  • GET /api/agents/<nodeTypeId>/schema — the derived request/response JSON Schemas.
  • GET /api/openapi.json — the OpenAPI document covering every exposed agent (and every webhook). A non-exposed agent answers like an unknown one.

OpenAI-compatible surface

The same agents are also served behind the standard OpenAI API, so any OpenAI client works unchanged:

base_url = https://<host>/api/openai/v1
model    = <nodeTypeId>            # ex. agent.extraction-de-symptomes
api_key  = <credential header value>
  • GET /models lists the exposed agents.
  • POST /chat/completions maps the last user message onto the agent's inputs: verbatim text when the agent has a single String input (conversational case), otherwise the message content must be a JSON object keyed by port names (types validated). The assistant content is the single String output verbatim, otherwise the JSON output record. stream: true answers one complete SSE chunk then [DONE].
  • Authentication reuses the agent's setting; Authorization: Bearer <value> is accepted for header credentials (an OpenAI client cannot set a custom header name).

Where to see what's exposed

The Endpoints module lists every exposed agent with its invoke URL, its base_url/model pair, its auth and its schema link — next to the inbound webhooks.

75 documents4 sectionssource : /docs · généré au build