Skip to navigationSkip to main contentSkip to footerScaleway Docs HomepageAsk our AI
Ask our AI

Integrating Generative APIs with OpenCode

OpenCode is a coding agent for your terminal and IDE. This guide shows you how to integrate Generative APIs models with OpenCode so you can use models such as Qwen3.5 for AI-powered code assistance and generation.

Before you start

To complete the actions presented below, you must have:

Configure OpenCode using the CLI

  1. Start OpenCode:

    opencode

    If this command returns command not found, ensure you have properly installed OpenCode (External link) and registered the tool in your terminal configuration. After installation, you can launch a new terminal or reload your current terminal configuration with:

    source ~/.bashrc # Or source ~/.zshrc if you use zsh
  2. Press Ctrl + P to display commands.

  3. Type provider to search for commands. Select Connect provider, then press Enter.

  4. Type scaleway to search for providers. Select Scaleway, then press Enter.

  5. Enter your SCW_SECRET_KEY as API key. Press Enter.

  6. Select a model in the list, for instance Qwen3.5 397B A17B.

  7. Type any prompt asking OpenCode to create or update code files. For example:

    "Write a fibonacci function in Python that computes the first 10 fibonacci 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.

  1. Create a ~/.config/opencode/opencode.json configuration file with the following content:

    Tip

    If you rely on OpenCode plugins, use OpenCode v1 and the configuration in the first tab (on this page). You might encounter incompatibility issues when using OpenCode v2.

    This configuration requires you to have set SCW_SECRET_KEY and SCW_PROJECT_ID as 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_ID

    This command should return the configured values.

  2. Start OpenCode:

    opencode

    The OpenCode terminal appears.

    If the command returns command not found, ensure you have properly installed OpenCode (External link) and registered the tool in your terminal configuration. After installation, you can launch a new terminal or reload your current terminal configuration with:

    source ~/.bashrc # Or source ~/.zshrc if you use zsh
  3. Press Ctrl + P to display commands.

  4. Select Switch model.

  5. Under Scaleway, select any model in the list, for instance Qwen3.5 397B A17B.

  6. Type any prompt asking OpenCode to create or update code files. For example:

    "Write a fibonacci function in Python that computes the first 10 fibonacci numbers"

For more details about configuration files, see OpenCode documentation about configuration options when using a JSON configuration file (External link).

Going further

  • You can explore additional OpenCode features in the OpenCode documentation (External link).
  • By default, OpenCode sends requests to https://api.scaleway.ai/v1 and runs them on your Scaleway default Project. If you want to run requests on a specific Project (for instance, to track specific billing), edit the OpenCode JSON configuration file and add the Project identifier to the URL https://api.scaleway.ai/###PROJECT_ID###/v1.
Still need help?

Create a support ticket
No Results