Integrating OpenCode with Scaleway's Generative APIs
OpenCode is a coding agent for terminal and IDE. You can integrate Scaleway's Generative APIs models to OpenCode.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A valid API key for API authentication
- Installed OpenCode on your local machine
Configure OpenCode using the CLI
-
Start OpenCode:
opencode -
Press
Ctrl + Pto display commands. -
Type
providerto search for commands. SelectConnect provider, then pressEnter. -
Type
scalewayto search for providers. SelectScaleway, then pressEnter. -
Enter your
SCW_SECRET_KEYas API key. PressEnter. -
Select a model in the list, for instance
Qwen3.5 397B A17B. -
Type any prompt asking OpenCode to create or update code files. For example:
"Write a fibonnaci function in python that computes the first 10 fibonnaci numbers"
Configure OpenCode using configuration files
You can configure OpenCode with Scaleway via configuration files. This allows you to reuse a configuration with different credentials.
-
Create a
~/.config/opencode/opencode.jsonconfiguration file with the following content:{ "$schema": "https://opencode.ai/config.json", "provider": { "scaleway": { "options": { "apiKey": "{env:SCW_SECRET_KEY}", "baseURL": "https://api.scaleway.ai/{env:SCW_PROJECT_ID}/v1" } } } }Where:
SCW_SECRET_KEYstands for the Scaleway API key you generated via the Identity and Access Management dashboardSCW_PROJECT_IDstands for your Scaleway Project identifier, which you can find on your Project Dashboard (click the Copy ID button)
This configuration requires you to have set
SCW_SECRET_KEYandSCW_PROJECT_IDas environment variables in your local terminal or configuration file, such as.zshrc. You can check that both these values are configured with the following command in your terminal:echo $SCW_SECRET_KEY echo $SCW_PROJECT_IDBoth configured values should display.
-
Start OpenCode:
opencodeThe OpenCode terminal appears.
-
Press
Ctrl + Pto display commands. -
Select
Switch model. -
Under
Scaleway, select any model in the list, for instanceQwen3.5 397B A17B. -
Type any prompt asking OpenCode to create or update code files. For example:
"Write a fibonnaci function in python that computes the first 10 fibonnaci numbers"
For more details about configuration files, see OpenCode's documentation about configuration options when using a JSON configuration file.
Going further
- You can explore additional OpenCode features in OpenCode's documentation.
- By default, requests are sent to
https://api.scaleway.ai/v1and performed on your Scaleway default Project. If you want to perform requests on a specific Project (for instance, to track specific billing), edit the OpenCode JSON configuration file and add the Project identifier to the URLhttps://api.scaleway.ai/###PROJECT_ID###/v1.