Answer: Set the OPENCODE_API_KEY environment variable (e.g., export OPENCODE_API_KEY="oc_sk_...") before running Pi, or run /login in Pi and select the provider; Pi stores the key in ~/.pi/agent/auth.json. Status: Confirmed Entry: tool/opencode/install-and-setup/configure-api-key Revision: 2 Digest: sha256:3d095acbe8d1af42 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:57:10Z Last changed: 2026-11-20T13:46:25Z (Login command: — → /login) Last verified: 2026-11-20T13:46:25Z Next check: 2026-11-21T13:46:25Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Environment variable | OPENCODE_API_KEY | [1] | 2026-11-20 Export command | export OPENCODE_API_KEY= "oc_sk_..." | [1] | 2026-11-20 Key storage path | ~/.pi/agent/auth.json | [1] | 2026-11-20 Login command | /login | [1] | 2026-11-20 Sources: [1] opencode. "Pi | OpenCode". https://opencode.ai/docs/console/harnesses/pi/ Role: primary. Accessed: 2026-11-20T13:46:25Z Quote: "Both providers read the key from OPENCODE_API_KEY ." (Supports: Environment variable) Quote: "export OPENCODE_API_KEY= "oc_sk_..."" (Supports: Export command) Quote: "Pi stores the key in ~/.pi/agent/auth.json ." (Supports: Key storage path) Quote: "You can also run /login in Pi and select the provider." (Supports: Login command) Snapshot SHA-256: cf045c05ca06c7a04e6b660033d201dc70cdad496dfc553e5db432de17db9d99 (captured 2026-11-19T13:36:17Z) 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-19T13:36:15Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:46:25Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:46:25Z Last attempt: 2026-11-20T13:46:25Z Notes and limitations: Extracted automatically from a single official source (section "Configure"). Related: https://latestn.com/tool/opencode/install-and-setup/connect-console-provider How do I set up opencode Console as a provider and connect my API key? https://latestn.com/tool/opencode/install-and-setup/connect-provider-and-select-model How do I connect a provider and select a model in opencode? https://latestn.com/tool/opencode/install-and-setup/console-get-started-connect How do I get started with the opencode Console and connect my workspace in OpenCode? https://latestn.com/tool/opencode/features/warming-interval-timing How often does opencode send warming requests and when does it stop? https://latestn.com/tool/opencode/install-and-setup/authenticate-opencode-for-acp How do I authenticate opencode before using it from an ACP client? https://latestn.com/tool/opencode/install-and-setup/claude-code-environment-variables How do I point Claude Code at OpenCode Console using environment variables? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T13:46:25Z | changed | Login command: — → /login | [1] 2026-11-20T13:46:25Z | changed | Key storage path: — → ~/.pi/agent/auth.json | [1] 2026-11-20T13:46:25Z | changed | Export command: — → export OPENCODE_API_KEY= "oc_sk_..." | [1] 2026-11-20T13:46:25Z | changed | Environment variable: — → OPENCODE_API_KEY | [1] 2026-11-20T13:46:25Z | changed | key storage location: ~/.pi/agent/auth.json → — | [1] 2026-11-20T13:46:25Z | changed | alternative method: /login → — | [1] 2026-11-20T13:46:25Z | changed | example export command: export OPENCODE_API_KEY= "oc_sk_..." → — | [1] 2026-11-20T13:46:25Z | changed | environment variable: OPENCODE_API_KEY → — | [1] 2026-11-13T03:57:10Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/opencode/install-and-setup/configure-api-key/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/opencode/install-and-setup/configure-api-key POST: https://latestn.com/dispute/tool/opencode/install-and-setup/configure-api-key with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/opencode/install-and-setup/configure-api-key?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I configure the OpenCode API key for Pi? Revision 2, last verified 2026-11-20T13:46:25Z. https://latestn.com/tool/opencode/install-and-setup/configure-api-key (accessed 2026-11-21T09:53:28Z). @misc{LatestN_tool_opencode_install_and_setup_configure_api_key_r2, title = {How do I configure the OpenCode API key for Pi?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/opencode/install-and-setup/configure-api-key}}, note = {Revision 2; digest sha256:3d095acbe8d1af42; last verified 2026-11-20T13:46:25Z; accessed 2026-11-21T09:53:28Z} } 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/opencode/install-and-setup/configure-api-key