Skip to main content

An Intelligence Operating System.

Project description

PyPI - Version PyPI - Downloads Python Version codecov

lionagi

Orchestrate multi-agent AI workflows from the command line or Python.

Docs | Discord | PyPI | Changelog

Install

pip install lionagi

CLI provider auth — CLI aliases spawn subprocess tools, not REST API calls:

  • claude: install Claude Code CLIclaude login (subscription) or export ANTHROPIC_API_KEY=sk-ant-... (API key)
  • codex: requires ChatGPT Plus/Pro → npm install -g @openai/codexcodex login
  • Python API (iModel, Branch): export OPENAI_API_KEY=sk-... for gpt-4.1-mini default

First Flow

import asyncio
from lionagi import Branch

async def main():
    b = Branch()          # default: gpt-4.1-mini (requires OPENAI_API_KEY)
    reply = await b.communicate("Name 3 features of async Python, one sentence each.")
    print(reply)

asyncio.run(main())
# output:
1. Coroutines let you write non-blocking I/O without threads.
2. asyncio.gather runs multiple coroutines concurrently under one event loop.
3. async generators stream results lazily, pausing between each yield.

For multi-agent orchestration without Python, see CLI Quick Start.

Concepts

Term What it is
Branch Single conversation thread — message history, tools, model config. Primary API surface.
Session Coordinates multiple Branches; runs DAG workflows across them.
flow li o flow — orchestrator plans a DAG, workers execute with dependency edges resolved.
team Persistent inbox messaging between agents via li team send/receive.
operate branch.operate(instruction=…) — tool use + structured output + optional streaming.
persist Every run saved to ~/.lionagi/runs/{run_id}/. Resume with li agent -r <branch-id>.

CLI — li

# Single agent
li agent claude/sonnet "Explain the observer pattern in 3 sentences"

# Fan-out: N workers in parallel, optional synthesis
li o fanout claude/sonnet "Identify code smells in this codebase" -n 3 --with-synthesis

# DAG flow: orchestrator plans agents with dependency edges
li o flow claude/sonnet "Audit the auth module for security issues" --cwd .

# Team messaging: inbox coordination between agents
li team create "review" && li team send "Start analysis" -t <id> --to analyst

# Playbook: parametric flow spec at ~/.lionagi/playbooks/audit.playbook.yaml
li play audit --mode security "the auth service"

# Skill: print a CC-compatible reference body to stdout (for agent context injection)
li skill commit

# Resume any run
li agent -r <branch-id> "follow up on your findings"

Full reference → docs/cli-reference.md · Installable templates → examples/

Python API

Chat

from lionagi import Branch

b = Branch(chat_model="openai/gpt-5.4", system="You are a concise assistant.")
reply = await b.communicate("What causes rainbows?")

Structured output

from pydantic import BaseModel

class Summary(BaseModel):
    points: list[str]
    confidence: float

result = await b.operate(instruction="Summarize this text.", response_format=Summary)

Tools + ReAct

from lionagi.tools.types import ReaderTool

branch = Branch(tools=[ReaderTool])
result = await branch.ReAct(
    instruct={"instruction": "Summarize /path/to/paper.pdf"},
)

Full reference → docs/api/

Docs

Getting Started Install, first flow, API key setup
Concepts Branch, Session, flow, team, operate, persist
CLI Reference li agent, li o fanout, li o flow, li team — all flags
Cookbook 5 runnable scenarios: codebase audit, research synthesis, multi-model pipeline, team coordination, resumable background run
API Reference branch.operate, branch.ReAct, iModel, Session
Migration 0.22.5 → 0.22.6 Breaking changes: branch.instruct removed, run paths changed
Contributing Dev setup, PR workflow

Optional Extras

uv add "lionagi[reader]"    # Document reading (PDF, HTML, DOCX)
uv add "lionagi[mcp]"       # MCP server support
uv add "lionagi[ollama]"    # Local models via Ollama
uv add "lionagi[rich]"      # Rich terminal output
uv add "lionagi[graph]"     # Flow visualization
uv add "lionagi[postgres]"  # PostgreSQL persistence
uv add "lionagi[all]"       # Everything

Community

Citation

@software{Li_LionAGI_2023,
  author = {Haiyang Li},
  year   = {2023},
  title  = {LionAGI: Towards Automated General Intelligence},
  url    = {https://github.com/khive-ai/lionagi},
}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lionagi-0.22.9.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lionagi-0.22.9-py3-none-any.whl (440.1 kB view details)

Uploaded Python 3

File details

Details for the file lionagi-0.22.9.tar.gz.

File metadata

  • Download URL: lionagi-0.22.9.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for lionagi-0.22.9.tar.gz
Algorithm Hash digest
SHA256 7d4e4d5a6dbeb3566a3b8bb2993be3c81cd38e7d4d886ab13f2c04e910a66e9e
MD5 f2a51ab3d51b3d57b97a9d2840140a2e
BLAKE2b-256 5b1943281519bacf0c8c86d024b204fcd12beb83fe7b7a6a4a5e51db707b562e

See more details on using hashes here.

File details

Details for the file lionagi-0.22.9-py3-none-any.whl.

File metadata

  • Download URL: lionagi-0.22.9-py3-none-any.whl
  • Upload date:
  • Size: 440.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for lionagi-0.22.9-py3-none-any.whl
Algorithm Hash digest
SHA256 12a0c964144f68b9168f6c840cc66ebac39f4c7dc52dd5847181e8b91a639d03
MD5 1f1cdfd6fc746bdd05945e01bca3f12a
BLAKE2b-256 bad8dad71ade944ae325bfd966e3a009c2d5210c2befde7aedbfd237041f3a57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page