DeepThought: Integrating Coder Agent - OpenCode

Summary

Learn how to configure OpenCode to connect to USNH DeepThought. This article includes installation, API configuration, and setup instructions for integrating the OpenCode coding agent with DeepThought, allowing developers to securely analyze code, generate documentation, and make code changes from the command line.

Body

Summary

Learn how to configure OpenCode to connect to USNH DeepThought. This article includes installation, API configuration, and setup instructions for integrating the OpenCode terminal-based AI coding agent with DeepThought, enabling developers to analyze code, generate documentation, explain code, and make code changes directly from the command line.

How-To

Task: Configure OpenCode

This is a quickstart for using OpenCode an open-source terminal-based coding agent, configured to run against DeepThought. OpenCode can read through a codebase, explain it, write documentation, and make changes directly to files, all from the command line.

Capabilities

  • Analyze and modify code from the command line.
  • Generate documentation and explain code.
  • Keep AI requests within the USNH DeepThought environment.

Instructions

Step 1 - Install OpenCode

Install with the official install script:

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

Or, if you'd rather use a package manager:

npm install -g opencode-ai
brew install anomalyco/tap/opencode

Verify OpenCode installed correctly:

opencode --version

 

Windows

OpenCode runs natively on Windows, but the OpenCode team recommends WSL for the best experience, including better file performance and full terminal support. Either approach works with DeepThought.

Option A: WSL (recommended)

Install WSL if you do not already have it, then run the following command from your WSL terminal:

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

Access your Windows files under /mnt/c/, /mnt/d/, etc. For the smoothest experience, keep your repository inside the WSL filesystem, such as ~/code/.

Option B: Native Windows (PowerShell)

export DEEPTHOUGHT_API_KEY=your-key-here
npm install -g opencode-ai

Verify:

opencode --version

 

Step 2Get a DeepThought API Key

Create a DeepThought API key from the DeepThought Integrations page if you do not already have one. Optionally, add it to your shell profile (~/.zshenv or ~/.bash_profile, depending on your shell).

export DEEPTHOUGHT_API_KEY=your-key-here

Reload your shell so the change takes effect.

source ~/.bash_profile

 

Windows

Option A: WSL

In WSL, this works the same as macOS/Linux. Add the export line to your ~/.bashrc file instead.

echo 'export DEEPTHOUGHT_API_KEY=your-key-here' >> ~/.bashrc
source ~/.bashrc

Option B: Native Windows (PowerShell)

Set the API key for the current session:

$env:DEEPTHOUGHT_API_KEY = "your-key-here"

Or make it permanent across sessions:

setx DEEPTHOUGHT_API_KEY "your-key-here"

 

Step 3Connect OpenCode to DeepThought

Create the following file (if it doesn't already exist):

~/.config/opencode/opencode.json

Paste the following configuration into the file:

{
  "$schema": "https://opencode.ai/config.json",
  "enabled_providers": ["deepthought"],
  "model": "deepthought/ets:aws:us.anthropic.claude-sonnet-4-6",
  "provider": {
    "deepthought": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DeepThought",
      "options": {
        "baseURL": "https://dtcontroller.sr.unh.edu:4242/openai/v1",
        "apiKey": "{env:DEEPTHOUGHT_API_KEY}"
      },
      "models": {
        "ets:aws:us.anthropic.claude-sonnet-4-6": {
          "name": "DeepThought — Claude Sonnet 4.6",
          "tool_call": true,
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "ets:aws:us.anthropic.claude-sonnet-4-5-20250929-v1:0": {
          "name": "DeepThought — Claude Sonnet 4.5",
          "tool_call": true,
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "ets:aws:us.anthropic.claude-sonnet-4-20250514-v1:0": {
          "name": "DeepThought — Claude Sonnet 4.0",
          "tool_call": true,
          "limit": {
            "context": 200000,
            "output": 8192
          }
        },
        "ets:aws:us.anthropic.claude-haiku-4-5-20251001-v1:0": {
          "name": "DeepThought — Claude Haiku 4.5",
          "tool_call": true,
          "limit": {
            "context": 200000,
            "output": 8192
          }
        }
      }
    }
  }
}

This registers DeepThought as a custom OpenAI-compatible provider and lists one model (ets:aws:us.anthropic.claude-sonnet-4-6). Additional DeepThought models can be added under the models section if desired. After the initial setup, you should only need to modify this file when adding or updating available models.

Windows

Option A: WSL (recommended

In WSL, the path ~/.config/opencode/opencode.json works exactly as it does on macOS and Linux.

On native Windows, create the same file at:

%USERPROFILE%\.config\opencode\opencode.json

Option B: Native Windows (PowerShell)

From PowerShell, create the directory and open the configuration file:

mkdir "$env:USERPROFILE\.config\opencode" -Force
notepad "$env:USERPROFILE\.config\opencode\opencode.json"

Then paste the same JSON configuration shown above and save the file.

Step 3 -Try It on a Real Codebase

Navigate to any project folder you want OpenCode to work on:

cd ~/path/to/your/project
opencode

On native Windows in PowerShell, use a standard Windows path:

cd C:\path\to\your\project

In WSL, Windows drives are available under /mnt/c/, /mnt/d/, and so on. For example:

cd /mnt/c/Users/YourName/project

The first time OpenCode starts, run:

/models

Select DeepThought, and then select:

ets:aws:us.anthropic.claude-sonnet-4-6

Example: Document a Codebase, Then Make a Change

Ask OpenCode to explain and document the codebase:

Look through this repository, give me a summary of what it does, how it's structured, and write a README.md documenting the main modules and how to run it.

OpenCode will review the files in the directory, build an understanding of the project structure, and write a README.md file directly into the folder.

Then ask it to make a change:

In the README you just wrote, add a "Known Issues" section. Also, find the function that handles file uploads and add error handling for files larger than 10MB.

OpenCode will locate the relevant function, show the proposed edit, and apply the change directly to the file.

Other Things Worth Trying

Find every place in this codebase that calls the legacy auth API and list them.
Refactor the database connection logic into its own module and update all the imports that reference it.
Write unit tests for the functions in utils.py that don't have any test coverage yet.

 

Tips

  • OpenCode works directory by directory. Run opencode from inside the project you want it to work on.
  • It will show you what it's doing (reading files, running commands, writing edits) as it goes, rather than just producing a final answer.
  • If you want it to stop and not make a change, you can interrupt with Escape before it finalizes an edit.
  • If DeepThought doesn't show up under /models, double check opencode.json is valid JSON and that DEEPTHOUGHT_API_KEY is set in the shell you launched opencode from (run opencode debug config to see the resolved config).
  • On Windows, WSL is the better-supported path. Native Windows works, but if you hit odd shell or file-locking issues, try the same steps from a WSL terminal instead.

 

Need additional help?

If you have any additional questions, please fill out the Research Computing Center Request Form to reach RCC Support.

 

Details

Details

Article ID: 5506
Created
Thu 7/16/26 2:44 PM
Modified
Thu 7/16/26 3:15 PM
Applicable Institution(s):
Keene State College (KSC)
Plymouth State University (PSU)
University of New Hampshire (UNH)
USNH System Office