> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sinarcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Claude Code with SinarCloud

> Point Claude Code, Anthropic's coding agent, at SinarCloud in the terminal or in VS Code, and run it on SinarCloud models such as DeepSeek, paid from your rupiah balance.

[Claude Code](https://code.claude.com/docs) is Anthropic's coding agent for the terminal. It sends its requests in the Anthropic Messages format, which the SinarCloud AI API also accepts. Set a few environment variables, and Claude Code runs on the SinarCloud models you choose, such as `deepseek/deepseek-v4-1-flash`. You pay per token from your SinarCloud balance, so you don't need a Claude subscription.

This guide was last checked with Claude Code 2.1.311 in the terminal and Claude Code for VS Code 2.1.312.

> [!NOTE]
>
> Anthropic doesn't support running Claude Code on models other than Claude. Most features work with SinarCloud models, and the differences are listed under [What works differently](#what-works-differently).

## Before you start

* Set the `SINARCLOUD_API_KEY` environment variable as described in [Before you connect](https://docs.sinarcloud.com/integrations/before-you-connect.md).
* Install Claude Code. See [Set up Claude Code](https://code.claude.com/docs/en/setup) in Anthropic's documentation.

## Use Claude Code in the terminal

**1. Choose your models**

Claude Code needs a main model, plus a model for each of its `fable`, `opus`, `sonnet`, and `haiku` model names. In the console, under **AI**, click **Models**, then click **Details** on a model. Check that **Model capabilities** lists **Chat completions**, **Tool use**, and **Streaming**. Then click the copy icon next to the alias to copy it.

This guide uses `deepseek/deepseek-v4-1-flash` as the main model and for `sonnet` and `haiku`, and `deepseek/deepseek-v4-pro` for `fable` and `opus`.

![The details dialog for DeepSeek V4.1 Flash with its alias deepseek/deepseek-v4-1-flash and a copy icon, its prices per 1M tokens, its context window and maximum output, and Model capabilities that include Chat completions, Tool use, and Streaming](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-model-details.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=b884851a91e53793346bdf6f50ad95af)

Check the capabilities and copy the alias

**2. Point Claude Code at SinarCloud**

Claude Code's base URL is `https://ai.sinarcloud.com`, without `/v1`. Claude Code adds `/v1/messages` to the base URL itself. In the terminal where you set `SINARCLOUD_API_KEY`, run:

> [tab] macOS and Linux
>
> ```bash theme={null}
> export ANTHROPIC_BASE_URL="https://ai.sinarcloud.com"
> export ANTHROPIC_AUTH_TOKEN="$SINARCLOUD_API_KEY"
> export ANTHROPIC_MODEL="deepseek/deepseek-v4-1-flash"
> export ANTHROPIC_DEFAULT_FABLE_MODEL="deepseek/deepseek-v4-pro"
> export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek/deepseek-v4-pro"
> export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek/deepseek-v4-1-flash"
> export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek/deepseek-v4-1-flash"
> ```

> [tab] Windows PowerShell
>
> ```powershell theme={null}
> $env:ANTHROPIC_BASE_URL = "https://ai.sinarcloud.com"
> $env:ANTHROPIC_AUTH_TOKEN = $env:SINARCLOUD_API_KEY
> $env:ANTHROPIC_MODEL = "deepseek/deepseek-v4-1-flash"
> $env:ANTHROPIC_DEFAULT_FABLE_MODEL = "deepseek/deepseek-v4-pro"
> $env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek/deepseek-v4-pro"
> $env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek/deepseek-v4-1-flash"
> $env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek/deepseek-v4-1-flash"
> ```

![A terminal after eight export commands: SINARCLOUD\_API\_KEY set to the placeholder paste-your-api-key, ANTHROPIC\_BASE\_URL set to https://ai.sinarcloud.com, ANTHROPIC\_AUTH\_TOKEN set to \$SINARCLOUD\_API\_KEY, ANTHROPIC\_MODEL set to deepseek/deepseek-v4-1-flash, the Fable and Opus models set to deepseek/deepseek-v4-pro, and the Sonnet and Haiku models set to deepseek/deepseek-v4-1-flash](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-env.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=6d6ae78bd419bc9158e21615534bcbc6)

The variables set in the terminal, after SINARCLOUD\_API\_KEY

Here's what each variable does:

* `ANTHROPIC_BASE_URL` is Claude Code's base URL, without `/v1`.
* `ANTHROPIC_AUTH_TOKEN` is your SinarCloud API key. Claude Code sends it in the `Authorization` header and uses it right away, without asking you to approve it.
* `ANTHROPIC_MODEL` is the model Claude Code starts with.
* `ANTHROPIC_DEFAULT_FABLE_MODEL`, `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` set the SinarCloud models behind Claude Code's `fable`, `opus`, `sonnet`, and `haiku` model names, which appear in its model list. Claude Code also uses these names for background tasks and subagents, and its own models with these names don't exist on SinarCloud, so set all four.

Replace the aliases with the models you chose.

**3. Check the connection**

Before you open Claude Code, send one small request from the same terminal to check the URL and key:

> [tab] macOS and Linux
>
> ```bash theme={null}
> curl "$ANTHROPIC_BASE_URL/v1/messages" \
>   -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
>   -H "anthropic-version: 2023-06-01" \
>   -H "Content-Type: application/json" \
>   -d '{"model": "deepseek/deepseek-v4-1-flash", "max_tokens": 100, "messages": [{"role": "user", "content": "Say hello in Indonesian."}]}'
> ```

> [tab] Windows PowerShell
>
> ```powershell theme={null}
> Invoke-RestMethod -Method Post -Uri "$env:ANTHROPIC_BASE_URL/v1/messages" `
>   -Headers @{ "Authorization" = "Bearer $env:ANTHROPIC_AUTH_TOKEN"; "anthropic-version" = "2023-06-01" } `
>   -ContentType "application/json" `
>   -Body '{"model": "deepseek/deepseek-v4-1-flash", "max_tokens": 100, "messages": [{"role": "user", "content": "Say hello in Indonesian."}]}'
> ```

A reply with a `content` list means the URL and key work. If you get an error instead:

* `unsupported_endpoint`: `ANTHROPIC_BASE_URL` ends in `/v1`. Set it to `https://ai.sinarcloud.com` and try again.
* `authentication_error` with "Invalid API key.": the key is missing, mistyped, expired, or revoked.
* `not_found_error` with a message that starts with `model:`: the model alias is wrong, or the model isn't available right now.

**4. Start Claude Code**

In the same terminal, go to your project folder and start Claude Code:

```bash theme={null}
claude
```

Claude Code doesn't ask you to sign in to a Claude account, because `ANTHROPIC_AUTH_TOKEN` is set. The first time you start it, it asks a few setup questions instead:

1. Under **Choose the text style that looks best with your terminal**, select a style, such as **Light mode**, and press Enter.
2. Read the **Security notes** and press Enter.
3. If Claude Code asks **Use Claude Code's terminal setup?**, choose either option. It sets up Shift+Enter for new lines in your terminal.

The first time you start Claude Code in a folder, it asks whether you trust the folder. **No, exit** is selected at first. Press the down arrow to select **Yes, I trust this folder**, then press Enter.

![Claude Code's quick safety check asking whether this is a project you created or one you trust, with the options No, exit and Yes, I trust this folder, and Yes, I trust this folder selected](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-trust.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=a6e089ced5d163d81ce04fab7ee39612)

Trust the project folder to continue

**5. Check the model on the welcome screen**

Claude Code opens. Its header shows your model, `deepseek/deepseek-v4-1-flash`, with **API Usage Billing**, above your project folder.

Below the header, Claude Code warns that the model isn't recognized and that the context is assumed to be 200k tokens. That's expected. See [Context window](#context-window).

![Claude Code v2.1.311 started in \~/demo-shop. The header shows deepseek/deepseek-v4-1-flash · API Usage Billing. Below it are a warning that the model isn't recognized and the context is assumed to be 200k tokens, a notice that auto mode is now the default permission mode, and an empty prompt.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-start.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=7f409076729bfe9ae2ca2c76beced8bb)

Claude Code runs on your SinarCloud model

**6. Check the base URL in /status**

Type `/status` and press Enter. On the **Status** tab, check two lines:

* **Anthropic base URL** shows `https://ai.sinarcloud.com`.
* **Auth token** shows `ANTHROPIC_AUTH_TOKEN`, the variable that holds your key.

The **Model** line shows the model Claude Code uses. Press Esc to close the screen.

![The Status tab of /status listing Auth token: ANTHROPIC\_AUTH\_TOKEN, Anthropic base URL: https://ai.sinarcloud.com, Model: deepseek/deepseek-v4-1-flash, IDE: Connected to VS Code extension version 2.1.312, and Setting sources: User settings, with managed settings and organization policy not fetched with a custom ANTHROPIC\_BASE\_URL](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-status.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=9fa8fbc0c7b61fd3fa32d32aedec9c43)

/status shows the SinarCloud base URL

**7. Give Claude Code a task**

Type a task, such as a change you want in a file, and press Enter.

To see what Claude Code used, open **AI** > **Usage** in the console and choose the key you created for Claude Code in the **API key** filter.

![The Log & Usage page with the Date range, Model, and API key filters, cards of totals, and the Log tab's table of recent requests](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/ai-usage.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=81c8d86294bf5b9247d4970ce519223f)

Choose your Claude Code key in the API key filter

**8. Save the settings**

Variables you set in a terminal last until you close it. To use SinarCloud every time you start Claude Code, put the same values in the `env` block of your Claude Code user settings file: `~/.claude/settings.json` on macOS and Linux, or `%USERPROFILE%\.claude\settings.json` on Windows.

After your first run, the file already exists and holds the text style you chose, such as `"theme": "light"`. Add the `env` block inside its outer braces, and put a comma after the line before it. If the file doesn't exist, create it. Paste your full API key:

```json ~/.claude/settings.json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ai.sinarcloud.com",
    "ANTHROPIC_AUTH_TOKEN": "paste-your-api-key",
    "ANTHROPIC_MODEL": "deepseek/deepseek-v4-1-flash",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "deepseek/deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek/deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek/deepseek-v4-1-flash",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek/deepseek-v4-1-flash"
  }
}
```

![\~/.claude/settings.json open in an editor with theme set to light and an env block that sets ANTHROPIC\_BASE\_URL to https://ai.sinarcloud.com, ANTHROPIC\_AUTH\_TOKEN to paste-your-api-key, ANTHROPIC\_MODEL to deepseek/deepseek-v4-1-flash, the Fable and Opus models to deepseek/deepseek-v4-pro, and the Sonnet and Haiku models to deepseek/deepseek-v4-1-flash](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-settings-file.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=39fa9ad64a3d15f0f624df9984c632f5)

The env block in \~/.claude/settings.json

When the settings file and your terminal set the same variable, the settings file wins.

> [!WARNING]
>
> Don't put your API key in a project's `.claude/settings.json`. That file is usually committed to the repository and shared with everyone who clones it.

## Use Claude Code in VS Code

Claude Code also comes as a VS Code extension, which opens Claude Code in a panel next to your code. It uses the same variables as the terminal, but you set them in VS Code's settings.

**1. Install the extension**

In VS Code, open the **Extensions** view with `Ctrl+Shift+X` (`Cmd+Shift+X` on macOS) and search for `Claude Code for VS Code`. Click **Install** on the **Claude Code for VS Code** extension published by Anthropic.

![The Extensions view searched for Claude Code for VS Code, with the Claude Code for VS Code listing by Anthropic, its verified badge, and an Install button](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-vscode-install.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=a9d47440f2fc8bb475f95a6d9178b706)

Install Claude Code for VS Code, published by Anthropic

**2. Turn off the sign-in prompt**

Open VS Code's settings with `Ctrl+,` (`Cmd+,` on macOS), search for `Claude Code login`, and check **Disable Login Prompt**.

![The Claude Code: Disable Login Prompt setting with its checkbox checked, described as: When true, never prompt for login/authentication in the extension. Used when authentication is handled externally.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-vscode-login-setting.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=fb543d3c11827777053ed1d42f685498)

Check Disable Login Prompt

**3. Add the SinarCloud variables**

Open the Command Palette with `Ctrl+Shift+P` (`Cmd+Shift+P` on macOS) and run **Preferences: Open User Settings (JSON)**. The checkbox in the previous step added `"claudeCode.disableLoginPrompt": true` to this file. Add the `claudeCode.environmentVariables` setting after it, with the base URL `https://ai.sinarcloud.com`, your API key, and your models. Both keys go inside the file's outer braces:

```json settings.json theme={null}
{
  "claudeCode.disableLoginPrompt": true,
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "https://ai.sinarcloud.com" },
    { "name": "ANTHROPIC_AUTH_TOKEN", "value": "paste-your-api-key" },
    { "name": "ANTHROPIC_MODEL", "value": "deepseek/deepseek-v4-1-flash" },
    { "name": "ANTHROPIC_DEFAULT_FABLE_MODEL", "value": "deepseek/deepseek-v4-pro" },
    { "name": "ANTHROPIC_DEFAULT_OPUS_MODEL", "value": "deepseek/deepseek-v4-pro" },
    { "name": "ANTHROPIC_DEFAULT_SONNET_MODEL", "value": "deepseek/deepseek-v4-1-flash" },
    { "name": "ANTHROPIC_DEFAULT_HAIKU_MODEL", "value": "deepseek/deepseek-v4-1-flash" }
  ]
}
```

![settings.json in VS Code with claudeCode.disableLoginPrompt set to true and claudeCode.environmentVariables listing ANTHROPIC\_BASE\_URL with the value https://ai.sinarcloud.com, ANTHROPIC\_AUTH\_TOKEN with paste-your-api-key, ANTHROPIC\_MODEL with deepseek/deepseek-v4-1-flash, the Fable and Opus models with deepseek/deepseek-v4-pro, and the Sonnet and Haiku models with deepseek/deepseek-v4-1-flash](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-vscode-settings-json.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=467277a00316cc6823e76cb4e4dd8750)

The two keys in settings.json

The extension checks for a key in this setting before it starts Claude Code, so put your key here even if you saved it in `~/.claude/settings.json`. Save the file, then restart VS Code so the extension picks up the new values.

> [!NOTE]
>
> If VS Code is connected to a remote machine, such as your VPS over Remote - SSH, run **Preferences: Open Remote Settings (JSON)** instead and add `claudeCode.environmentVariables` there. In a remote window, VS Code greys out this setting in your user settings and doesn't pass it to the extension, so the panel lists Claude models.

> [!WARNING]
>
> VS Code saves these settings as plain text in your user profile, and Settings Sync can copy them to your other computers. Don't put your API key in a workspace's `.vscode/settings.json`, which is often committed to the repository.

**4. Open Claude Code**

Click the Claude Code icon (✻) in the editor toolbar or the Activity Bar, or click **✻ Claude Code** in the status bar. The panel opens next to your code without a sign-in screen, and the model under the prompt box shows your SinarCloud model.

![VS Code with src/server.js open on the left and the Claude Code panel on the right. The panel's prompt box shows the model deepseek/deepseek-v4-1-flash and the open file server.js attached.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-vscode-panel.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=890529d0adde52284d08518a763e5658)

Claude Code in VS Code, running on a SinarCloud model

**5. Switch models in the panel**

To switch models, click the model under the prompt box. The list shows the SinarCloud models you set, as the custom Opus, Fable, Sonnet, and Haiku models.

![Claude Code's Select a model list with Default (recommended) using deepseek/deepseek-v4-pro\[1m\], deepseek/deepseek-v4-pro as the custom Opus and Fable models, and deepseek/deepseek-v4-1-flash as the custom Sonnet and Haiku models, above the Effort and Ultracode settings](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/integrations/claude-code-vscode-models.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=dbcbe8f6b31e102f0a4fb88c31adf2f9)

The model list shows your SinarCloud models

To see what Claude Code used, open **AI** > **Usage** in the console and choose its key in the **API key** filter.

## Switch models

To switch to another SinarCloud model during a session, run `/model` followed by the model's alias:

```text theme={null}
/model deepseek/deepseek-v4-pro
```

To start Claude Code on a different model, run `claude --model` followed by the alias. Compare prices on the **Models** page first, because every step of Claude Code's work is a separate request.

## Context window

Claude Code doesn't recognize SinarCloud model aliases, so it assumes a context window of 200K tokens and compacts the conversation when it reaches that size. A model's real window is shown under **Context window (tokens)** in its details on the **Models** page.

The 200K default keeps requests smaller and cheaper, because Claude Code sends the whole conversation with every request. To let a session grow larger before Claude Code compacts it, set `CLAUDE_CODE_MAX_CONTEXT_TOKENS` to the model's window, the same way you set the other variables. For example, for a model with a 1,000,000-token window:

```bash theme={null}
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000
```

## What works differently

* **Web search doesn't work.** Claude Code's web search runs on the API side, which SinarCloud doesn't offer.
* **PDFs and other documents aren't sent.** SinarCloud doesn't accept them, so Claude Code leaves them out and tries again. To work with a document, convert it to text first.
* **Images need a model with image input.** If the model doesn't list **Image input** or **Vision**, Claude Code leaves the image out and tries again.
* **Claude account features aren't available.** Features that need a Claude account or Anthropic's servers, such as Remote Control, cloud sessions, and fast mode, don't work, and Claude subscription limits don't apply. You pay for each request from your SinarCloud balance. See Anthropic's [feature availability](https://code.claude.com/docs/en/feature-availability) page.

See [Compatibility](https://docs.sinarcloud.com/integrations/compatibility.md) for details.

## Troubleshooting

> [accordion] There's an issue with the selected model (...). It may not exist or you may not have access to it.
>
> Claude Code shows this message for two different problems:
>
> * `ANTHROPIC_BASE_URL` ends in `/v1`, so requests go to the wrong address. Set it to `https://ai.sinarcloud.com` in your terminal and in `~/.claude/settings.json`.
> * The model alias in the message doesn't exist or isn't available right now. Copy the alias again from the **Models** page, check all the `ANTHROPIC_MODEL` and `ANTHROPIC_DEFAULT_*_MODEL` variables, and check that the model lists **Chat completions**.

> [accordion] Failed to authenticate. API Error: 401 Invalid API key.
>
> Claude Code retries for a few minutes before it shows this message. The key in `ANTHROPIC_AUTH_TOKEN` is missing, mistyped, expired, or revoked. If you saved the key in `~/.claude/settings.json`, check it there too, because that value wins over your terminal. If the key has expired or been revoked, create a new one.

> [accordion] API Error: 402 Your balance is empty or negative and no token credits remain for this model.
>
> [Add balance](https://docs.sinarcloud.com/billing/top-up.md), then send your message again.

> [accordion] API Error: 400 Only caller-executed tools are supported.
>
> Claude Code tried to use a tool that runs on the API side, such as web search. Ask Claude Code to continue without it.

> [accordion] Claude Code asks you to sign in
>
> Claude Code didn't find `ANTHROPIC_AUTH_TOKEN` when it started. Set the variables in the terminal before you run `claude`, or save them in `~/.claude/settings.json`. A project's settings files apply only after Claude Code's first-run setup, so they don't prevent this prompt.

> [accordion] In VS Code, the panel asks you to sign in or lists Claude models
>
> The extension didn't get the SinarCloud variables. Check that **Disable Login Prompt** is checked and that `claudeCode.environmentVariables` is in your user settings, not a workspace's settings. If VS Code is connected to a remote machine, put `claudeCode.environmentVariables` in the remote settings instead, with **Preferences: Open Remote Settings (JSON)**. Then restart VS Code, because the extension reads these settings when it starts.

> [accordion] A warning that two credential sources are set
>
> You're also signed in to a Claude account. Claude Code uses `ANTHROPIC_AUTH_TOKEN` for requests, but the saved sign-in can cause unexpected behavior. To use only your SinarCloud key, run `/logout`.

For other problems, see [Troubleshooting](https://docs.sinarcloud.com/help/troubleshooting.md) and Anthropic's guide to [connecting Claude Code to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.