Skip to main content
OpenCode is an open source coding agent that runs in your terminal. It can send its requests to any OpenAI-compatible API. Add SinarCloud to OpenCode’s config file, and OpenCode runs on SinarCloud models, charged to your balance. This guide was last checked with OpenCode 1.19.4.

Before you start

  • Get an API key and a model alias as described in Before you connect. The base URL is https://ai.sinarcloud.com/v1.
1

Install OpenCode

Open a terminal in your project’s root folder. If you use VS Code, open your project, then open the Command Palette and run Terminal: Create New Terminal. The terminal opens in the project’s folder.Install OpenCode with npm, or see the OpenCode documentation for other ways to install it:
To check that it’s installed, run:
OpenCode prints its version, for example 1.19.4.
VS Code's Terminal panel. The command opencode --version printed 1.19.4.

OpenCode prints its version

2

Create opencode.json in your project

OpenCode reads its settings from a file named opencode.json. To use SinarCloud in one project, create opencode.json in the project’s root folder and paste the following into it. To use it in every project on macOS or Linux, create the file at ~/.config/opencode/opencode.json instead. If the file already exists, add the model and provider keys to it.
opencode.json
Save the file.
VS Code with a project open. The Explorer lists src, opencode.json and README.md, and opencode.json is open in the editor. It sets model to sinarcloud/deepseek/deepseek-v4-1-flash. Under the sinarcloud key, it sets npm to @ai-sdk/openai-compatible, name to SinarCloud, baseURL to https://ai.sinarcloud.com/v1 and apiKey to {env:SINARCLOUD_API_KEY}, and lists the model deepseek/deepseek-v4-1-flash named DeepSeek V4.1 Flash, with a context limit of 1000000 and an output limit of 393216.

opencode.json in the project's root folder, with the SinarCloud base URL

Here’s what each part does:
  • provider.sinarcloud adds SinarCloud to OpenCode under the ID sinarcloud. The @ai-sdk/openai-compatible package makes OpenCode use the OpenAI Chat Completions format.
  • baseURL makes OpenCode send its requests to https://ai.sinarcloud.com/v1.
  • {env:SINARCLOUD_API_KEY} makes OpenCode read your API key from the environment variable, so your key isn’t stored in the file.
  • Each key under models is a model alias from the Models page, and name is the name OpenCode shows for it. Set limit.context and limit.output to the model’s Context window (tokens) and Maximum output (tokens), which OpenCode uses to manage long conversations.
  • model sets the default model: sinarcloud/ followed by the model alias.
The console can write this file for you. On the Models page, click Details on a model, then open the Use via API tab and its OpenCode tab. It shows a config for that model with the base URL filled in. Before you save it, replace YOUR_API_KEY with {env:SINARCLOUD_API_KEY}.
3

Set your API key in the terminal

In the same terminal, set the SINARCLOUD_API_KEY environment variable to your API key, then check that it’s set:
Replace paste-your-api-key with your key, and keep the quotes. The check prints set without showing your key. If you already saved the key for every new terminal, as described in Before you connect, run only the check.
VS Code's Terminal panel with two commands: the export line that sets SINARCLOUD_API_KEY to the placeholder paste-your-api-key, and the check that the variable is set, which printed set.

The key is set in the terminal, and the check prints set

The variable lasts until you close the terminal, so start OpenCode from this terminal.
4

Start OpenCode

In the same terminal, in your project’s root folder, start OpenCode:
OpenCode opens in the terminal. In the prompt box, under the placeholder text, OpenCode shows the agent, Build, and the model, DeepSeek V4.1 Flash, followed by SinarCloud.
OpenCode's start screen in the terminal: the OpenCode logo, a hint to run /update to upgrade to OpenCode 2.0, and the prompt box with the placeholder Ask anything… and an example task. In the box, under the placeholder, is Build · DeepSeek V4.1 Flash SinarCloud. Below the box are the hints tab agents and ctrl+p commands.

OpenCode started, with DeepSeek V4.1 Flash from SinarCloud

5

Check the model with /models

Type /models and press Enter. In Select model, type sinarcloud to show only the models you added for SinarCloud. A dot marks the model OpenCode uses. To switch to another model you added, select it and press Enter. To close the list, press Esc.The full list also shows models under other headings, such as OpenCode. Only the models under SinarCloud use your SinarCloud API key.
OpenCode's Select model dialog with sinarcloud typed in its search box. The only result, DeepSeek V4.1 Flash with SinarCloud on the right, is highlighted and marked with a dot. At the bottom are the hints Connect provider ctrl+a and Favorite ctrl+f.

Select model, filtered to SinarCloud

6

Send a prompt

Type a task in the prompt box, for example Add a GET /products/:id route to src/server.js, and press Enter.
OpenCode's prompt box with the task Add a GET /products/:id route to src/server.js typed in, above Build · DeepSeek V4.1 Flash SinarCloud.

A task in OpenCode's prompt box, ready to send

To try the connection without opening the full interface, send a single prompt from the terminal instead:
The output starts with the agent and model that answered, for example build · deepseek/deepseek-v4-1-flash.
7

Find the requests in Usage

In the console, under AI, click Usage, then choose the key you created for OpenCode in the API key filter. When you start a session, OpenCode usually sends two requests: one that names the session and one for your prompt. Only requests whose charge is final appear, so click Refresh if you don’t see them yet.
Log & Usage page with the Date range, Model and API key filters, a Refresh button and five cards of totals, starting with Total charged and Total saved. Below them are the Log, Summary, Spending, Models and Tokens tabs, with the Log tab's Recent requests table showing a Show details button on each row.

The Usage page, with the API key filter at the top

Add more models

Add each model you want to use under models, with its alias as the key. To use a lower-cost model for small tasks such as naming sessions, set small_model. Otherwise, OpenCode uses your default model for them too.
opencode.json
Compare prices on the Models page before you choose a default model, because every step of an agent’s work is a separate request.

Troubleshooting

OpenCode shows errors from SinarCloud after Error:.
The API key is missing, mistyped, expired, or revoked. Check that SINARCLOUD_API_KEY is set in the terminal where you started OpenCode and that it holds your whole key. If the key has expired or been revoked, create a new one.
The model alias doesn’t exist, the model isn’t available right now, or it doesn’t support chat completions. Copy the alias again from the Models page and check that the key under models matches it exactly, and that model is sinarcloud/ followed by the same alias. Then check that the model’s Model capabilities list Chat completions.
Add balance, then send your prompt again.
For other problems, see Troubleshooting.