Installation
View SourceLegion needs Elixir 1.18 and Erlang/OTP 26 or later.
- Add
:legionto your dependencies inmix.exsand runmix deps.get:
def deps do
[
{:legion, "~> 0.6"}
]
end To serve agents over MCP, add {:anubis_mcp, "~> 2.0"} too; see the
MCP guide.
- Legion instances are isolated supervision trees and should be included in your application's supervisor to run:
# lib/my_app/application.ex
children = [
MyApp.Repo,
Legion
]- Configure an LLM provider. The default model is
"openai:gpt-5.6-luna", so an OpenAI key is enough to start (all options):
# config/runtime.exs
config :req_llm, openai_api_key: System.get_env("OPENAI_API_KEY")- Verify the setup in
iex -S mix:
defmodule PingAgent do
@moduledoc "Answers trivial questions."
use Legion.Agent
end
Legion.execute(PingAgent, "Return the sum of 2 and 2")
#=> {:ok, "4"}Next steps
- Give agents tools and run them: Usage
- Drop Legion into an app you already have: Adding Legion to an existing app
- Pick a language and trust model for generated code: Sandboxes
- Monitor agents in a LiveView dashboard: legion_web
- Persist conversations across restarts:
Legion.Store.Postgres