Title: How to Use OpenCode for AI-Assisted Python Coding – Real Python
Open Graph Title: How to Use OpenCode for AI-Assisted Python Coding – Real Python
Description: Learn how to use OpenCode, an open-source AI coding assistant, with a free Gemini API key to analyze and refactor Python code in your terminal.
Open Graph Description: Learn how to use OpenCode, an open-source AI coding assistant, with a free Gemini API key to analyze and refactor Python code in your terminal.
Mail addresses
?subject=Python article for you&body=How to Use OpenCode for AI-Assisted Python Coding on Real Python
https://realpython.com/opencode-guide/
Opengraph URL: https://realpython.com/opencode-guide/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "How to Use OpenCode for AI-Assisted Python Coding",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/opencode-guide/",
"lastReviewed": "2026-09-22",
"author": {
"@type": "Person",
"name": "Leodanis Pozo Ramos",
"image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
"url": "https://realpython.com/team/lpozoramos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"reviewedBy": [
{
"@type": "Person",
"name": "Aldren Santos",
"image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
"url": "https://realpython.com/team/asantos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Brenda Weleschuk",
"image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
"url": "https://realpython.com/team/bweleschuk/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Philipp Acsany",
"image": "https://realpython.com/cdn-cgi/image/width=1920,height=1920,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/pacsany.19bcf16f5a00.jpg",
"url": "https://realpython.com/team/pacsany/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
}
]
},
"datePublished": "2026-05-13T14:00:00+00:00",
"dateModified": "2026-09-22T18:05:15.753070+00:00",
"publisher": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": {
"@type": "ImageObject",
"url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
"width": 512,
"height": 512
},
"description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
"slogan": "Become a Python Expert",
"email": "info@realpython.com",
"sameAs": [
"https://github.com/realpython",
"https://www.youtube.com/realpython",
"https://twitter.com/realpython",
"https://x.com/realpython",
"https://www.linkedin.com/company/realpython-com/",
"https://www.facebook.com/learnrealpython",
"https://www.instagram.com/realpython",
"https://www.tiktok.com/@realpython.com"
]
},
"author": {
"@type": "Person",
"name": "Leodanis Pozo Ramos",
"image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
"url": "https://realpython.com/team/lpozoramos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"description": "Learn how to use OpenCode, an open-source AI coding assistant, with a free Gemini API key to analyze and refactor Python code in your terminal.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Is OpenCode free to use?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYes, it\u0026rsquo;s free and open source. The software itself has no cost, and you can connect it to Google Gemini\u0026rsquo;s free tier to use it without any subscription fees. Paid AI providers like Anthropic or OpenAI can also be connected if you prefer their models.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "What is AGENTS.md in OpenCode?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003e\u003ccode\u003eAGENTS.md\u003c/code\u003e is a project configuration file read at the start of every session. It contains guidelines about your project\u0026rsquo;s architecture, coding style, and conventions, giving the AI consistent context across all your interactions. Run \u003ccode\u003e/init\u003c/code\u003e to have OpenCode generate it automatically from your project structure.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "What is the difference between the Plan and Build modes in OpenCode?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eThe \u003cem\u003ePlan\u003c/em\u003e mode proposes changes and explains the approach without modifying any files, while the \u003cem\u003eBuild\u003c/em\u003e mode applies changes directly to your project. Switch between them with the \u003cspan class=\"keys\"\u003e\u003ckbd class=\"key-tab\"\u003eTab\u003c/kbd\u003e\u003c/span\u003e key. The \u003cem\u003ePlan\u003c/em\u003e mode is useful for reviewing a strategy before committing to significant code changes.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do you reference a specific file in an OpenCode prompt?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eType \u003ccode\u003e@\u003c/code\u003e in the OpenCode prompt to open a fuzzy file picker. Start typing a partial filename to narrow the results, then select the file to add it as context. The file\u0026rsquo;s contents become visible to the AI for that prompt.\u003c/p\u003e"
}
}
]
}
}
| author | Real Python |
| theme-color | #18354c |
| color-scheme | light dark |
| twitter:card | summary_large_image |
| twitter:image | https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg |
| og:image | https://files.realpython.com/media/How-to-Use-OpenCode-for-AI-Assisted-Engineering_Watermarked.737726d966fd.jpg |
| twitter:creator | @realpython |
| og:type | article |
| og:site_name | Real Python |
| apple-mobile-web-app-title | Real Python |
Links:
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover
Robots: max-image-preview:large