Skip to content

Setting up OpenCode on NCShare

OpenCode is an open-source AI coding agent that can be run on a terminal. It can read, change, and run code and assist with agentic AI tasks. OpenCode natively supports a broad range of model providers, including Anthropic, OpenAI, and its own free models. It also makes it easy to use locally hosted models through Ollama and other compatible backends.

OpenCode can be used on NCShare, either through a SSH terminal or an Open OnDemand Jupyter/RStudio container terminal.

Once you are connected to NCShare, enter the following commands on the terminal to set up OpenCode,

curl -fsSL https://opencode.ai/install | bash

Then, you can launch opencode with the command,

opencode

and follow the instructions to get started.

If you are a Duke user, Duke's AI Gateway provides access to OpenAI models to Duke users freely or through a fund-code. To add OpenAI models to OpenCode, run /connect in the prompt and select "OpenAI" as the provider. Next, select "ChatGPT Pro/Plus (headless)" as the authentication method and follow instructions to complete the process.

You may then select models through the /model command in the prompt.

Important!

If you will be using opencode to perform computationally intensive tasks, first request an interactive session on NCShare and run it on that.