Skip to main content

muapi-langchain

LangChain integration for muapi.ai — 250+ generative media models behind a single key, exposed as LangChain tools, a document loader, and a Deep Agents recipe.

Install

pip install muapi-langchain

# For the Deep Agents demo:
pip install "muapi-langchain[deepagents]"

Or install directly from the repo (latest main):

pip install "git+https://github.com/SamurAIGPT/muapi-cli.git#subdirectory=integrations/langchain"

Set your API key:

export MUAPI_API_KEY="..."     # or: muapi auth configure

What's in the box

4 tools (capability gradient)

Tool What it does Costs credits?
muapi_select Rank models + skills for an intent No
muapi_generate Single-shot generation (image / video / audio / edit) Yes (per call)
muapi_run_skill Named multi-step recipe (UGC ad, storyboard, …) Yes (recipe)
muapi_creative_agent Open-ended brief → planner → executor Yes (variable)
from muapi_langchain import muapi_select, muapi_generate

print(muapi_select.invoke({
    "intent": "cinematic product photo of a sneaker",
    "kind": "image", "tier": "best", "limit": 3,
}))

print(muapi_generate.invoke({
    "prompt": "A glossy sneaker on a wet street at neon-lit night",
    "kind": "image", "tier": "best",
}))

MuapiAssetLoader — document loader

Hydrate prior muapi generations as Documents for RAG / eval.

from muapi_langchain import MuapiAssetLoader

docs = MuapiAssetLoader(request_ids=["req_abc", "req_def"]).load()
for d in docs:
    print(d.metadata["url"], "·", d.page_content[:80])

MuapiCostCallback — budget tracking

Pipe every muapi tool call through a callback that accumulates credit spend and aborts the agent when a budget cap is hit.

from muapi_langchain import MuapiCostCallback

cost_cb = MuapiCostCallback(
    budget_credits=500,
    on_event=lambda evt, payload: print(evt, payload),
)
agent.invoke({...}, config={"callbacks": [cost_cb]})
print(cost_cb.summary())

Deep Agents recipe

The recommended pattern: cheap tools (select, generate) on the main planner, heavy tools (run_skill, creative_agent) on a creative-specialist subagent, with interrupt_on for human approval of open-ended creative work.

See examples/deep_agents_demo.py for the full runnable example.

from deepagents import create_deep_agent
from muapi_langchain import PLANNER_TOOLS, SPECIALIST_TOOLS

agent = create_deep_agent(
    model=...,
    tools=PLANNER_TOOLS,
    subagents=[{
        "name": "creative-specialist",
        "description": "Heavy muapi workflows and open-ended briefs.",
        "system_prompt": "...",
        "tools": SPECIALIST_TOOLS,
    }],
    interrupt_on={
        "muapi_creative_agent": {"allowed_decisions": ["approve", "edit", "reject"]},
    },
)

Decision tree

User brief
  ├─ Don't know which model/skill?  → muapi_select          (free)
  ├─ Single asset, clear prompt?    → muapi_generate
  ├─ Matches a known recipe?        → muapi_run_skill
  └─ Multi-asset / multi-modal?     → muapi_creative_agent  (interrupt_on)

License

MIT.

Download files

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

Source Distribution

muapi_langchain-0.1.0.tar.gz (53.8 kB view details)

Uploaded Source

Built Distribution

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

muapi_langchain-0.1.0-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file muapi_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: muapi_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 53.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for muapi_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a38f13fa3bddb5d12114b74409480c71b21ae863078ba9130a89cc845d8a362e
MD5 7bddad51a06f14ba5806cdf8fde8c6ea
BLAKE2b-256 109fc97c148b8a71fc7201eb0a9b0ba23b75a3580f7470bb58b20fbedf7c6b2b

See more details on using hashes here.

File details

Details for the file muapi_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for muapi_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02f464bd325880170943e2db06ed441fb3f7ccccc271afa8db3ed81f0880fd74
MD5 ca56201c69231c0f87259cdfcf4e4771
BLAKE2b-256 7c018def4d3bdf0bd1f40a5ab85b1e73cc1bf4e1cd3c1af8c3426d22dcd068e2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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