ADK.Phoenix.WebRouter (ADK v0.0.1-alpha.1)

Copy Markdown View Source

Plug router providing Python ADK-compatible HTTP endpoints.

This module implements the same REST API as Python ADK's adk web FastAPI server, enabling the adk-web React frontend to work with an Elixir backend as a drop-in replacement.

Endpoints

  • GET /list-apps — List available agent apps
  • GET /apps/:app_name/users/:user_id/sessions — List sessions
  • POST /apps/:app_name/users/:user_id/sessions — Create session
  • GET /apps/:app_name/users/:user_id/sessions/:session_id — Get session
  • DELETE /apps/:app_name/users/:user_id/sessions/:session_id — Delete session
  • POST /run_sse — Run agent with SSE streaming response
  • POST /run — Run agent synchronously
  • GET /health — Health check
  • GET /version — Version info
  • GET /debug/trace/:event_id — Get span attributes for a specific event
  • GET /debug/trace/session/:session_id — Get all spans for a session

Usage

Add to your Phoenix router or use standalone:

# In a Phoenix router
forward "/", ADK.Phoenix.WebRouter,
  agent_loader: MyApp.AgentLoader,
  session_store: {ADK.Session.Store.InMemory, []}

# Standalone with Bandit/Cowboy
Bandit.start_link(plug: {ADK.Phoenix.WebRouter, opts})

Options

  • :agent_loader — Module implementing list_agents/0 and load_agent/1 callbacks, or a map of %{app_name => agent} for simple cases.
  • :session_store{module, opts} tuple for session persistence. Defaults to {ADK.Session.Store.InMemory, []}.
  • :allow_origins — List of allowed CORS origins. Defaults to ["*"].

Summary

Functions

Callback implementation for Plug.call/2.

Initialize the router with options.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Initialize the router with options.

Options

  • :agent_loader — Map of %{app_name => agent} or module with list_agents/0 and load_agent/1
  • :session_store{module, opts} tuple
  • :allow_origins — CORS origins list