Skip to content

init()

minions.init(
api_key=None,
base_url=None,
tracing=False,
project=None,
db_path=None,
trace_url=None,
tracing_secret_token=None,
)

Call once, before creating any Minion. Configuration is process-wide.

ArgumentTypeDefaultDescription
api_keystrNoneSets one API key globally for LiteLLM. Omit it to use per-provider env vars (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, …), which is what you want with more than one provider in a process.
base_urlstrNoneCustom endpoint — Azure OpenAI, vLLM, any OpenAI-compatible API.
tracingboolFalseRecord runs, turns and tool calls.
projectstrNoneGroups traces. Required when tracing=True. In remote mode it must match the project the token belongs to.
db_pathstrNoneOverride the local SQLite path. Local mode only. Default: ~/.minion/traces.db.
trace_urlstrNonePush traces to a remote server instead of writing locally.
tracing_secret_tokenstrNoneProject-scoped mni_… token authenticating remote pushes.

No tracing (default) — no trace machinery runs, no file is created.

minions.init(api_key="sk-...")

Local — a SQLite file on this machine. Read it with minion serve.

minions.init(tracing=True, project="my-project")

Remote — pushed over HTTP to a server you run. Nothing is written locally.

minions.init(
tracing=True,
project="my-project",
trace_url="https://traces.mycompany.com",
tracing_secret_token="mni_xK9mP2...",
)

See Remote tracing.

init() raises ValueError immediately for a configuration that could never work:

ConditionError
tracing=True without projectproject is required when tracing=True
tracing_secret_token without trace_urltracing_secret_token requires trace_url
trace_url without tracing_secret_tokentrace_url requires tracing_secret_token
trace_url without tracing=Truetrace_url requires tracing=True

With trace_url set, init() also makes one verification request to the server before returning:

  • Token invalid or revokedValueError.
  • Token valid but scoped to a different projectValueError. The message deliberately does not reveal which project the token belongs to — a leaked token shouldn’t double as a way to enumerate project names.
  • Server unreachable → a warning is logged and init() continues. A down trace server must not stop your agent from starting.

This up-front check exists because the failure it catches is otherwise silent: the server would reject every push with a 403, each rejection would only be logged as a warning, and no trace would ever appear with nothing to explain why.

Everything after startup follows the opposite rule — see Tracing never breaks your agent.

Read by the library or the server rather than passed to init():

VariableRead byEffect
OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GROQ_API_KEY, …LiteLLMProvider credentials, matched to the model string
MINION_DB_PATHServerSQLite path. Ignored when DATABASE_URL is set. Also what minion serve --db-path sets
DATABASE_URLServersqlite:///… or postgresql://…. Takes priority over MINION_DB_PATH