Skip to main content
If you already have agents written in Python — using a framework like the OpenAI Agents SDK, LangChain/LangGraph, CrewAI, AutoGen, Pydantic AI, or LlamaIndex, or hand-written on top of a raw provider SDK — you don’t need to redefine them in the Portal. Point the Maitai CLI at your source and it will translate the code into Maitai Agents, capabilities, and sub-agent links. The CLI ships your code to Maitai, which uses Mojo (the same translator that powers Maitai’s natural-language tooling) to read the code and produce a canonical agent manifest. The manifest is then applied to your account.

Quickstart

maitai agents import path/to/your_agent.py \
  --application-name "My App" --create-application
That single invocation:
  1. Reads your source file (or every .py file in a directory).
  2. Sends it to Maitai for translation.
  3. Creates the agents, attaches their tools as capabilities, and wires sub-agent handoffs.
  4. Prints a summary including the agent IDs you can open in the Portal.

Single file vs. directory

You can point agents import at either a single .py file or a directory:
  • Single file — best for small agents that live in one module. The entire file is shipped as the source.
  • Directory — best for real projects (CrewAI crews, LangGraph subgraphs, custom agent packages). Every .py file in the directory tree is concatenated and shipped as one project, with file separators preserved so the translator knows which code came from which file.
For directory imports, everything in the directory is treated as part of the same agent project. If your repo has unrelated code mixed in, point at a smaller subdirectory containing just the agent files.
maitai agents import path/to/your_crewai_project/ \
  --application-name "Marketing Crew" --create-application
The total concatenated source is capped at 1 MB. If you hit that, prune non-agent code (tests, generated fixtures, vendored deps) or point at a smaller subdirectory.

What gets imported

Maitai’s translator looks for any unit of code that combines (1) a system prompt or instruction string conditioning an LLM with (2) an LLM call. Tools and handoffs are optional. That means:
  • Framework agents (Agent(name=..., instructions=..., tools=[...]) and similar) are recognized directly.
  • Hand-written loops that build a messages array with a system prompt and call client.chat.completions.create(...) are also recognized.
  • Tools / functions that the agent invokes become API Actions or LLM Actions depending on what they do.
  • Handoffs between agents — whether explicit (handoff()), task-pipeline (CrewAI), or implicit (one agent invoking another as a tool) — are translated into sub-agent links.
When the translator recognizes a known framework (CrewAI, LangGraph, Pydantic AI, etc.) it tags the import with Source recognized as: <framework>. When it doesn’t recognize anything, it still imports based on the code’s structure — the translator errs on the side of importing rather than silently skipping.

Flags

FlagEffect
--application-name "..."Target application by name. Required unless --application-id is set.
--application-id <id>Target an existing application by ID.
--create-applicationCreate the application if it doesn’t exist (paired with --application-name).
--updateIf an agent with the same name already exists, update it in place instead of failing.
--pruneWith --update, also remove actions and handoffs that exist in Maitai but are absent from the source.
--dry-runTranslate only — print the manifest, don’t create anything.
--print-manifestPrint the translated manifest alongside the apply summary.
--diffShow what would change against the current Maitai state before applying.
--diff-onlyLike --diff, but stop before applying.
--staticFall back to local introspection of an OpenAI Agents SDK module (legacy path; does not use Mojo).

How long does it take?

The import runs asynchronously: when you press enter, the CLI submits a translation job and polls its status until completion. A typical single-file agent finishes in 20-60 seconds; large multi-file projects can take 1-3 minutes. The CLI shows a live status indicator (Queued… → Translating source… → Applying manifest…) so you can see what’s happening. If the job fails (e.g. the translator couldn’t find any agents in the source), the CLI surfaces a clear error message describing what went wrong.

After import

Each imported agent shows up under your target application in the Portal. From there you can:
  • Edit prompts and capabilities like any other Maitai agent.
  • Publish a version and pin requests to it from your SDK calls.
  • Wire additional sub-agents or supplied actions that aren’t in the original source.
  • Configure routing and execution mode per agent.
Re-running agents import with --update is the easiest way to keep imported agents in sync with code changes; add --prune to also delete capabilities/handoffs that were removed from the source.

Examples

The Maitai repo includes a small fixture suite covering different frameworks and project layouts. Each is suitable as a starting template:
  • examples/agent_import/raw_openai_loop.py — hand-written agent on the raw OpenAI SDK
  • examples/agent_import/crewai_marketing_crew/ — multi-file CrewAI project (agents, tools, tasks, crew)
  • examples/agent_import/langgraph_support_pipeline/ — LangGraph with subgraphs in nested directories
  • examples/agent_import/pydantic_ai_support_bot.py — Pydantic AI with typed Agent[Deps, Output]
  • examples/agent_import/custom_devops_assistant/ — no framework, hand-written base class across multiple files

Next