Answer: You can script aider from Python by importing Coder and Model, creating a coder with Coder.create(main_model=model, fnames=fnames), and then calling coder.run() with an instruction or in-chat "/" command. Status: Confirmed Entry: tool/aider/agents-and-automation/scripting-aider-python Revision: 1 Digest: sha256:46ca1f1aa41c7c6e (changes whenever the content changes) Timeline: Created: 2026-11-15T11:45:38Z Last changed: 2026-11-15T11:45:38Z Last verified: 2026-11-20T11:43:35Z Next check: 2026-11-21T11:43:35Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of import statement | from aider.coders import Coder | [1] | 2026-11-20 model import | from aider.models import Model | [1] | 2026-11-20 coder creation | Coder . create ( main_model = model , fnames = fnames ) | [1] | 2026-11-20 run instruction | coder . run ( "make a script that prints hello world" ) | [1] | 2026-11-20 in-chat command | coder . run ( "/tokens" ) | [1] | 2026-11-20 yes option | io = InputOutput ( yes = True ) | [1] | 2026-11-20 Sources: [1] Aider. "aider.chat/docs/scripting.html". https://aider.chat/docs/scripting.html Role: primary. Accessed: 2026-11-20T11:43:35Z Quote: "from aider.coders import Coder" (Supports: import statement) Quote: "from aider.models import Model" (Supports: model import) Quote: "coder = Coder . create ( main_model = model , fnames = fnames )" (Supports: coder creation) Quote: "coder . run ( "make a script that prints hello world" )" (Supports: run instruction) Quote: "coder . run ( "/tokens" )" (Supports: in-chat command) Quote: "io = InputOutput ( yes = True )" (Supports: yes option) Published: 2026-04-25T16:45:23Z Snapshot SHA-256: 674663a6c4c155a1d061ad522d970e45b0ce98774d9bb22a624d3bb6e7eb59d6 (captured 2026-11-13T02:56:36Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-15T11:45:38Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T11:43:35Z. No independent second source is configured for this entry Last successful check: 2026-11-20T11:43:35Z Last attempt: 2026-11-20T11:43:35Z Notes and limitations: Extracted automatically from a single official source (section "Python"). Related: https://latestn.com/tool/aider/commands-and-shortcuts/add-files-to-chat How do I add files to an Aider chat session? https://latestn.com/tool/aider/commands-and-shortcuts/add-files-to-chat-2 How do I add files to the chat in Aider? https://latestn.com/tool/aider/commands-and-shortcuts/ask-code-workflow How do I switch between ask mode and code mode in Aider? https://latestn.com/tool/aider/agents-and-automation/scripting-aider-command-line How do I run aider from the command line in a script? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-15T11:45:38Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/aider/agents-and-automation/scripting-aider-python/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/aider/agents-and-automation/scripting-aider-python POST: https://latestn.com/dispute/tool/aider/agents-and-automation/scripting-aider-python with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/aider/agents-and-automation/scripting-aider-python?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I use aider from Python code? Revision 1, last verified 2026-11-20T11:43:35Z. https://latestn.com/tool/aider/agents-and-automation/scripting-aider-python (accessed 2026-11-21T09:54:09Z). @misc{LatestN_tool_aider_agents_and_automation_scripting_aider_python_r1, title = {How do I use aider from Python code?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/aider/agents-and-automation/scripting-aider-python}}, note = {Revision 1; digest sha256:46ca1f1aa41c7c6e; last verified 2026-11-20T11:43:35Z; accessed 2026-11-21T09:54:09Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/aider/agents-and-automation/scripting-aider-python