Skip to main content

Use Clovis with OpenCode from the command line

OpenCode is the recommended integration for using ClovisLLM as a command-line coding assistant. It can explore a project, explain or generate code, and run tasks from the terminal.

This quickstart installs OpenCode, configures the Clovis provider, and starts a first session. For advanced features, see the official OpenCode documentation (in English).

Prefer a graphical interface?

See the OpenCode Desktop guide. The Clovis provider configuration is identical and shared between both interfaces.

Prerequisites​

  • Node.js and npm installed;
  • a dedicated Clovis API key for OpenCode;
  • a terminal open with your usual user account.
Keep your key secret

Do not put the API key in opencode.json, and never commit it. The /connect command stores it separately from the configuration.

1. Install OpenCode​

For OpenCode 2, the official npm package is @opencode/cli. The same command works on all three platforms.

npm install -g @opencode/cli

Check the installation:

opencode --version

If the command is not recognized right away, close and reopen the terminal to reload the PATH.

2. Configure the Clovis provider​

OpenCode reads its configuration from the global opencode.json file (or opencode.jsonc if you prefer JSON comments). This file does not necessarily exist after installation: create it if needed, along with its parent folder.

The file is located here:

~/.config/opencode/opencode.json

Copy this configuration into the file:

{
"$schema": "https://opencode.ai/config.json",
"providers": {
"clovis": {
"name": "Clovis",
"env": ["CLOVIS_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://llm-gateway.clovis-ai.fr/v1"
},
"models": {
"ClovisLLM": {
"name": "ClovisLLM",
"limit": {
"context": 300000,
"output": 32000
}
}
}
}
},
"model": "clovis/ClovisLLM"
}

This configuration:

  • declares a provider with the ID clovis, compatible with the OpenAI API of the Clovis gateway;
  • declares the ClovisLLM model with its context and output limits;
  • selects ClovisLLM as the default model through the model property.

The same configuration is used by OpenCode Desktop. You can also place an opencode.json file at the root of a project to override the global configuration there.

3. Register the Clovis API key​

This step applies to OpenCode 2.

Move to the project you want to work on, then start OpenCode:

cd /path/to/your-project
opencode

Inside OpenCode:

  1. enter /connect;
  2. choose Clovis in the provider list;
  3. choose the API key entry method;
  4. paste your Clovis API key and confirm.
Why the provider ID must be clovis

OpenCode associates the stored key with the providers.clovis section of the configuration file. Any difference in case or spelling breaks this association.

You can check that the key is stored with:

opencode auth list
Without the interactive interface

The opencode auth login clovis --method key command stores the key without opening the interface. You can also set the CLOVIS_API_KEY environment variable before running opencode.

4. Select ClovisLLM​

The "model": "clovis/ClovisLLM" property from step 2 automatically selects ClovisLLM at startup.

To switch models, enter /models in OpenCode and choose ClovisLLM in the Clovis section. The opencode models command lists all available models from the terminal, including ClovisLLM.

5. Start a development session​

Run opencode from the root of your project, then send a first request, for example:

Explain the structure of this project and report the available test commands.

To guide the assistant on your repository conventions, create an AGENTS.md file at the root of the project describing the rules to follow, then commit it: OpenCode reads it automatically at each session.

6. Check the connection​

Verify that ClovisLLM is available:

opencode models

Then, in an OpenCode session, check that the active model shown is ClovisLLM and that the answer to a simple request comes from Clovis.

Troubleshooting​

ProblemCheck
opencode is not recognizedreopen the terminal, then check that the global npm directory is in the PATH
ClovisLLM does not appearcheck the path and syntax of opencode.json, then restart OpenCode
The key is not usedcheck that the provider chosen in /connect is exactly clovis, then run opencode auth list
The CLOVIS_API_KEY variable is not taken into accountthe variable must be visible to the OpenCode process; if in doubt, use /connect to store the key persistently
The gateway connection failscheck the base URL https://llm-gateway.clovis-ai.fr/v1 and your network access to the Clovis service
The native Windows installation causes problemsuse WSL, recommended by OpenCode for full compatibility

Go further​

To update an npm installation:

npm update -g @opencode/cli