Skip to main content

aichain

The provider-agnostic AI toolkit for Python.

Let your coding agent write your agents. Ship the code you tested. Leave any provider with one word. Pipelines and agents, small enough for Claude Code, Codex or Cursor to learn from one file and build on.

from yait_aichain import Model, Skill

skill = Skill(
    model  = Model("claude-haiku-5-5"),   # change this one word to switch providers
    input  = {"messages": [{"role": "user", "parts": ["Summarise: {text}"]}]},
)

result = skill.run(variables={"text": "..."})

Change "claude-haiku-5-5" to "gpt-6-luna", "gemini-3-flash-preview" or "grok-4.3" — nothing else changes.


Three promises

Your coding agent writes the agents. The whole contract is one 26 KB llms.txt, and the plugin for Claude Code, Codex and Cursor carries it with twenty worked recipes. Measured on tasks the docs were not written against: on twenty, a small model with the docs passed 15 in all three tries and Claude Code passed 19; on eleven for what 3.x added, both passed all eleven; and without the docs the same small model passed none of an earlier twenty (the measurements).

The code you tested is the code you ship. Only what you inject changes between a laptop and production: where state is stored, whose keys are used, what starts the run. A chain or an agent that waits for a person or a webhook parks, and resumes later in another process. An agent's state is its conversation, so one turn fits one serverless call. Spending stops at a ceiling in dollars, and keys can be resolved per request, per tenant.

No provider owns your code. Switching provider is changing the model name. When the new one cannot do what you asked — no top_k, no seed, a different image size — the result says what was adapted or dropped, instead of leaving you to find out from the output.


Highlights

  • Small enough to read in one go. llms.txt is 26 KB, the skill 4 KB, the whole library about 29,000 lines of Python.
  • One required dependency, urllib3 — and tomli on Python 3.10, which has no TOML reader of its own. YAML, MCP and local page fetching are extras you install when you use them.
  • The price of every call. Usage and cost come from the registry on every result, and max_cost is one budget in dollars shared by a Skill, a Chain, a Pool and an Agent.
  • A pipeline is data. Skills and Chains save to YAML and load back as they were; API keys are never written.
  • A skill for your coding agent — one package for Claude Code, Codex and Cursor.

What you build with it

Deterministic pipelines Skill — one model call with a template and an output format. Chain — steps in order, each output passed on by name. Pool — one Skill or Chain over many inputs at once.
Agents, by how hard the task is mode="agile" decides at every turn. mode="waterfall" writes a plan first — from a stronger planner_model if you like — and holds to it. team= lets it delegate to workers with conversations of their own. On τ²-bench a plain loop did best with a weak model and a planned run with a strong one.
Tools Search, fetch, decide, speech, transcription, images, embeddings, reranking, chunking, wait and gate — each made the same way, search("exa"). Any function becomes a tool with @tool; any REST API or MCP server goes into an agent in two lines.
Utilities Vectors for a vector collection, Shell for one folder to browse, read, write and run commands in, MCP and REST for connections. Your code calls their methods; the agent gets only the methods that are tools.
Control and measurement Usage and cost on every result. max_cost — one budget in dollars across every step. Permissions by risk class, and approve= for a person to decide. An event for every step. eval/ runs arms × cases × trials and reports accuracy, Pass^k and cost side by side.
Models 169 models from 16 cloud providers, plus any open-weight model on your own server, where the data never leaves your perimeter. Text and vision are models; image generation is a tool.

Install

pip install yait-aichain

One required dependency, urllib3 (and tomli on Python 3.10). Extras when you use what needs them: [yaml] to save and load, [mcp] for MCP servers, [fetch] to read pages locally — Installation. Keys, only for the providers you use:

export ANTHROPIC_API_KEY="…"
export BFL_API_KEY="…"
export DEEPSEEK_API_KEY="…"
export GOOGLE_AI_API_KEY="…"
export MOONSHOT_API_KEY="…"
export META_API_KEY="…"
export MINIMAX_API_KEY="…"
export MISTRAL_API_KEY="…"
export OPENAI_API_KEY="…"
export PERPLEXITY_API_KEY="…"
export DASHSCOPE_API_KEY="…"
export RECRAFT_API_TOKEN="…"
export STEPFUN_API_KEY="…"
export XAI_API_KEY="…"
export MIMO_API_KEY="…"
export ZAI_API_KEY="…"
export BRAVE_SEARCH_API_KEY="…"
export COHERE_API_KEY="…"
export EXA_API_KEY="…"
export FIRECRAWL_API_KEY="…"
export GOOGLE_API_KEY="…"
export PARALLEL_API_KEY="…"
export TAVILY_API_KEY="…"
export TYPESAFE_API_KEY="…"
export VOYAGE_API_KEY="…"

Use it from Claude Code, Codex or Cursor

One plugin carries the skill that teaches a coding agent to build on this library: SKILL.md, llms.txt and twenty worked recipes, generated by scripts/skill.py from the files this repository tests.

Claude Code

/plugin marketplace add yaitio/aichain
/plugin install yait-aichain@yait

Codex — add the repository as a marketplace, then install yait-aichain from it:

codex plugin marketplace add yaitio/aichain

Cursor — Customize → From GitHub Repository → yaitio/aichain, then install yait-aichain.

The skill alone works too: copy plugin/skills/yait-aichain/ into ~/.agents/skills/, which Codex and Cursor both read, or into ~/.claude/skills/ for Claude Code.

Learn more

Start Quickstart — five minutes, four steps · Concepts — six ideas, one screen each · Migrating to 4.0
Pipelines Skill · Chain · Pool · Pause and resume
Agents The loop and its modes · Driving the loop · An agent as a chain step
Tools How tools work · Search · Fetch · Decide · Chunk, embed, rerank · Speech and images
Utilities Vectors, Shell, REST, MCP
Control Cost and budget · Permissions · Observability · Eval
Models Models and options · Private models · the registry
Production From laptop to production · Build with your coding agent
API every class, function and parameter, generated from the code

Examples

→ examples/ — one concept per file

# File What it shows
01 01_skill.py Run a prompt against a model.
02 02_skill_models.py Same prompt, three providers.
03 03_skill_multimodal.py Text → Image → Text, three providers.
04 04_skill_save_load.py Save a skill to YAML, reload and run it.
05 05_tool_fetch.py A web page's text from its URL.
06 06_tool_mcp.py An MCP server as a utility: discover its tools, call them.
07 07_tool_custom.py Make any function a tool, and use it in a Chain.
08 08_chain.py Two skills in sequence, two different providers.
09 09_chain_tool_skill.py Tool + Skill in one chain.
10 10_chain_save_load.py Save a chain to YAML, reload and run it.
11 11_pool.py Run the same skill in parallel for multiple inputs.
12 12_pool_chain.py Chain as a Pool runner.
13 13_agent.py Basic agent with one tool.
14 14_agent_tools.py Agent with multiple tools, picks autonomously.
15 15_agent_orchestrator.py Orchestrator agent spawns sub-agents.
16 16_debug.py Inspect intermediate steps in Chain, Pool, and Agent.
17 17_chain_human_input.py Human-in-the-loop: pause a chain for manual input.
18 18_chain_external_trigger.py Pause a run until an EXTERNAL trigger resumes it.
19 19_image_edit.py Image → image (editing) across providers, one tool.
20 20_observability.py The step boundary: hooks, events, and an approval gate.
21 21_multi_turn.py Directed multi-turn reasoning in ONE Skill.
22 22_goal_mode.py A stop condition the harness can verify
23 23_private_model.py Run a model on hardware you control.
24 24_scaffold.py Scaffold — the model designs the team, then runs it

License

MIT


Changelog

Every release is in CHANGELOG.md — what changed, and why it changed. Releases before 2.0 are recorded incompletely; the file says which ones and why they were not reconstructed.

Metadata

Release files for yait-aichain 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yait-aichain 4.0.0
File Size Uploaded
yait_aichain-4.0.0.tar.gz 470.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yait-aichain 4.0.0
File Interpreter ABI Platform
yait_aichain-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 920.4 kB

Release files / yait_aichain-4.0.0.tar.gz

Download URL yait_aichain-4.0.0.tar.gz
Size 470.5 kB
Tags Source
SHA-256 checksum
How to use checksums
07a64d778e001554e566f0815c47008338dcb3da015bc6e6d5ac7b3237fdac8b
BLAKE2b-256 checksum
How to use checksums
2724643d66f530c89cb046d4b7af9b5669ddca1a6a9beff0b592cbc6db6c616c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / yait_aichain-4.0.0-py3-none-any.whl

Download URL yait_aichain-4.0.0-py3-none-any.whl
Size 449.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8988178309c8d9fcd95d2dcd1a64b49361c60d4866a191fda70fc19c66f9e11d
BLAKE2b-256 checksum
How to use checksums
b38300aa8ee51951692d90c9430d6e080509aed3aabdd505a458da90f52b732e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.19.0

2 release files

2.18.1

2 release files

2.18.0

2 release files

2.17.1

2 release files

2.17.0

2 release files

2.16.0

2 release files

2.15.0

2 release files

2.14.0

2 release files

2.13.0

2 release files

2.12.0

2 release files

2.11.0

2 release files

2.10.0

2 release files

2.9.3

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page