> ## 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.

# Make your first AI request

> Create an API key and send your first chat completion to the SinarCloud AI API at https://ai.sinarcloud.com/v1 with cURL, Python, or Node.js.

The SinarCloud AI API is compatible with the OpenAI API. You can call it with the official OpenAI SDKs by changing three values: the base URL, the API key, and the model alias. This quickstart walks you through your first chat completion and shows you where to find what it cost.

Before you start, sign in to the [console](https://console.sinarcloud.com) with your Google account. On your first sign-in, confirm your time zone to finish setting up your account. You also need a terminal and one of these: cURL on macOS or Linux, Python 3, or Node.js.

**1. Check your balance**

AI requests are paid from the same prepaid rupiah balance as your VPS.

In the console sidebar, under **Account**, click **Billing**. The **Current Credits** card at the top of the page shows how much balance you have left.

![Billing page with the Current Credits card, the Redeem and Add Credit buttons, and the Transactions and Payments tabs. The Payments tab is open and lists three QRIS top-ups with the status Succeeded under the Invoice, Amount, Status, Method, Created and Actions columns.](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/billing-payments.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=d5bd693dffc78526dc17d20e5f6321fe)

The Current Credits card shows your balance

A request starts only if your balance is above Rp 0, you have [token credits](https://docs.sinarcloud.com/ai/token-credits.md) left for the model you call, or the request can't cost you anything, for example under a 100% promotion. SinarCloud charges each request after it finishes, based on the tokens it used. This means a request can take your balance below zero.

To add balance:

1. Click **Add Credit**. The **Add credit** dialog opens on the same page.
2. Click a preset amount, or type an amount from Rp 15,000 to Rp 10,000,000 in **Amount**. **Balance after top-up** shows your balance once the payment is confirmed.
3. Click **Continue to payment**, then scan the QRIS code with any banking or e-wallet app that supports QRIS. Your balance goes up as soon as the payment is confirmed.

![Add credit dialog over the Billing page, with the default Rp 100,000 in the Amount field, the current balance to the right of the Amount label, the allowed range below the field, and preset buttons from 50,000 to 500,000. Below them are a summary with You pay, Fee Free and Balance after top-up, the note that credit is non-refundable and can't be withdrawn, and the Continue to payment button.](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/billing-top-up.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=717acbda0faf4c6c1583d816b277694f)

Choose an amount, then click Continue to payment

Balance you add can't be refunded or withdrawn. For details, see [Add balance](https://docs.sinarcloud.com/billing/top-up.md).

> [!TIP]
>
> If a gift popup opens in the console, it offers free token credits for one AI model. Nothing is added to your account until you click **Claim gift**. Claimed tokens appear under **AI** > **Token credits** and pay for that model's requests before your balance is charged. If the popup shows a **Claim by** date, claim the gift before then. Click **Later** to see the gift again the next time you open the console.

**2. Create an API key**

1. Under **AI**, click **API keys**. The **API Keys** page opens.
2. Click **Create API key**. You'll find the button next to **API endpoint** at the top of the page and in the **Your API keys** section. Both open the same dialog.
3. Enter a **Key name**, such as the app or environment that will use the key. You can rename the key later.
4. To make the key stop working at a set time, fill in **Expires at (optional)**. The field uses the time zone shown under it, which you can change in [Account settings](https://docs.sinarcloud.com/account/settings.md). Leave the field empty for a key that never expires.
5. Click **Create key**.
6. The dialog changes to **Your key is ready** and shows your key under **New secret key**. Click **Copy secret**, then click **Done**. If you close the dialog first, you can still copy the key later with **Copy** in the **Your API keys** list.

![Create an API key dialog open over the API Keys page, with a Key name field, an Expires at (optional) date and time field with the time zone shown under it, and Cancel and Create key buttons](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-api-key-create.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=5856c63de285ff4a1b440fae4c588b91)

Name the key and optionally set an expiry

> [!WARNING]
>
> Keep your API key private. Anyone who has it can make API requests using your account. If a key leaks, click **Revoke** next to it, then click **Revoke key** to confirm. A revoked key stops working right away, and you can't undo this.

**3. Save your API key**

The base URL is `https://ai.sinarcloud.com/v1`. On the **API Keys** page, the hint under the **API endpoint** box gives it. The box itself shows the full chat completions endpoint, `https://ai.sinarcloud.com/v1/chat/completions`.

![API Keys page with the quick start at the top: the API endpoint box showing https://ai.sinarcloud.com/v1/chat/completions with a copy icon and a Create API key button, the hint that gives https://ai.sinarcloud.com/v1 as the base URL, and a Quick start (cURL) sample request for deepseek/deepseek-v4-1-flash with its own copy icon. The Your API keys list starts below it.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-api-keys.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=120f522a148d183a67e641d660a89697)

The base URL is in the hint under API endpoint

In the terminal where you will run the examples, save your API key as an environment variable:

1. Under **Your API keys**, click **Copy** next to your key. You can skip this if you still have the key you copied in the previous step.
2. Run the command for your system. Replace `paste-your-api-key-here` with your key, and keep the quotes.

![The end of the Quick start (cURL) sample, followed by the Your API keys list with the number of keys, Refresh and Create API key buttons, and Key, Status, Created, Last used and Actions columns. Each key shows its name, the first characters of the key followed by dots, the scopes api:read and api:write, No expiry, the Active status, and Copy, Rename and Revoke actions.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-api-keys-list.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=485f41be9c2f3561f06d7acf80adde1d)

Copy is next to each key under Your API keys

> [tab] macOS and Linux
>
> ```bash theme={null}
> export SINARCLOUD_API_KEY="paste-your-api-key-here"
> ```

> [tab] Windows PowerShell
>
> ```powershell theme={null}
> $env:SINARCLOUD_API_KEY = "paste-your-api-key-here"
> ```

The variable lasts until you close the terminal, so run the examples in the same terminal.

**4. Choose a model**

1. Under **AI**, click **Models**.
2. To show chat models, click **Text** under the search box. To find a model, type its name, alias, or publisher in the search box, for example `deepseek`.
3. Compare prices. The **Input (Rp/1M)** and **Output (Rp/1M)** columns show each model's price per 1M tokens. Models tagged **ZDR** are zero data retention versions, which don't keep your prompts and responses after your request is complete.
4. Click **Details** on the model you want. The model's details open in a dialog.

![The Models page with Clear filters and Refresh at the top right and the search box below them, with deepseek entered. Under the search box, the All and Text mode buttons with counts sit above a table of DeepSeek models, one marked with the Popular sparkle icon and some tagged ZDR. The table has Model, Input, Output, Cache read, Cache write, and Context columns and a Details button on each row.](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/ai-models.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=62aacc42fd75bc459731e588f703775f)

Search for a model, then click Details

On the **Overview** tab, check that **Model capabilities** lists **Chat completions**, because this quickstart calls the chat completions endpoint. Below the model name is the model alias, which is also called the model ID. Click the copy icon next to it (**Copy model ID**) to copy it.

![The model details dialog for a DeepSeek model, showing its publisher, the Available, CHAT, and Popular badges, its alias with a copy icon, a button to get the model's API, and the Try in playground and Use via API buttons. Below are the prices per 1M tokens, with both cache write prices showing Not available, the context window and maximum output, and the Overview tab open with Supported inputs, Model capabilities with a description of each, and Publish date.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-model-details.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=b884851a91e53793346bdf6f50ad95af)

Check the model capabilities, then copy the alias

Model aliases are lowercase and usually look like `publisher/model`, for example `deepseek/deepseek-v4-1-flash`. The examples below use this alias. Replace it with the alias of the model you chose.

**5. Send a chat completion**

Run one of these examples in the same terminal where you set `SINARCLOUD_API_KEY`. The cURL example uses macOS and Linux shell syntax. On Windows, use the Python or Node.js example.

* **cURL:** paste the command into your terminal and press Enter.
* **Python:** install the SDK with `pip install openai`, save the code as `example.py`, and run `python example.py`. On macOS and Linux, use `pip3` and `python3` if `pip` or `python` isn't found.
* **Node.js:** install the SDK with `npm install openai`, save the code as `example.mjs`, and run `node example.mjs`.

```bash cURL theme={null}
curl "https://ai.sinarcloud.com/v1/chat/completions" \
  -H "Authorization: Bearer $SINARCLOUD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4-1-flash",
    "messages": [{"role": "user", "content": "Say hello in Indonesian."}]
  }'
```

```python Python theme={null}
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://ai.sinarcloud.com/v1",
    api_key=os.environ["SINARCLOUD_API_KEY"],
)

response = client.chat.completions.create(
    model="deepseek/deepseek-v4-1-flash",
    messages=[{"role": "user", "content": "Say hello in Indonesian."}],
)

print(response.choices[0].message.content)
```

```javascript Node.js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://ai.sinarcloud.com/v1",
  apiKey: process.env.SINARCLOUD_API_KEY,
});

const response = await client.chat.completions.create({
  model: "deepseek/deepseek-v4-1-flash",
  messages: [{ role: "user", content: "Say hello in Indonesian." }],
});

console.log(response.choices[0].message.content);
```

The response uses the OpenAI chat completion format. The model's reply is in `choices[0].message.content`. The cURL example prints the whole response as JSON. The Python and Node.js examples print only the reply.

You can also copy a ready-made request from the console. In the model's details, click **Use via API**. Under **Sample usage**, click **cURL**, **Python**, **TypeScript**, or **Go**, then click **Copy code**. The samples already include the base URL and the model's alias. Before you run one, replace `YOUR_API_KEY` with your key. The samples put the key in the code, so don't share or commit a file that contains it.

![The model details dialog for a DeepSeek model with the Use via API tab open. Under Sample usage, a note says to replace YOUR\_API\_KEY and that the API URL and model alias are already included. Tabs for cURL, Python, TypeScript, Go, OpenCode, OpenClaw and Hermes sit above the cURL sample, which has a Copy code button and sends a request to https://ai.sinarcloud.com/v1/chat/completions for deepseek/deepseek-v4-1-flash.](https://mintcdn.com/sinar-cloud/ShOrAB8ikH3IKe3Y/images/ai-model-api.png?fit=max\&auto=format\&n=ShOrAB8ikH3IKe3Y\&q=85\&s=a02384690b3208132a81614d1dbd7cb2)

Ready-made samples on the Use via API tab

On macOS or Linux, the **API keys** page has a ready-made request too. The **Quick start (cURL)** box holds a sample cURL request for a chat model. Click its copy icon (**Copy cURL**), replace `YOUR_API_KEY` with your key, and run it. To call a different model, swap in the alias of another model whose details list **Chat completions** under **Model capabilities**.

> [!TIP]
>
> Every response includes an `X-Request-Id` header, including error responses. To see it with cURL, add `-i` to the command. For a successful request, the same ID appears as **Request ID** in its details on the **Usage** page while it is among your 8 most recent requests. Include the ID when you [contact support](https://docs.sinarcloud.com/help/support.md), even for failed requests.

**6. Find the request in Usage**

Under **AI**, click **Usage**. The **Log & Usage** page opens on the **Log** tab, where **Recent requests** lists your 8 most recent settled requests with their model, time, tokens, cost, and latency.

Only requests whose charge is final appear here, so failed requests aren't listed. If you don't see your request yet, click **Refresh**.

![Log & Usage page with Date range, Model, and API key filters, a Refresh button, and cards for total charged, total saved, API requests, tokens processed, and average latency. The Log tab is open on the Recent requests list, with Show details on each request.](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/ai-usage.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=81c8d86294bf5b9247d4970ce519223f)

Recent requests on the Log tab

Click **Show details** on a request to see its **Request ID**, its status (**Settled**), and its input and output token counts. If token credits or a promotion lowered the price, the **Cost** column also shows the full price crossed out and the percentage you saved, and a **Charge breakdown** in the details shows how. The final cost is deducted from your balance.

![The Log tab's Recent requests table with the newest request expanded. Its details show the Request ID, the input and output tokens with the cache hit and cache writes, and a Settled status.](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/ai-usage-request-details.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=a85e3dd53c56ef7a7378756073ac4c6f)

Show details opens the request's Request ID, tokens, and status

## If the request fails

Errors use the OpenAI error format. The `code` field tells you what went wrong.

> [accordion] 401 invalid\_api\_key
>
> The API key is missing, mistyped, expired, or revoked. Check that the `Authorization` header is `Bearer` followed by a space and your key. If the key has expired or been revoked, create a new one.

> [accordion] 402 insufficient\_balance
>
> Your balance is Rp 0 or below, and you have no token credits left for this model. [Add balance](https://docs.sinarcloud.com/billing/top-up.md), then send the request again.

> [accordion] 404 model\_not\_found
>
> The model alias doesn't exist, the model isn't available right now, or it doesn't support chat completions. On the **Models** page, search for the model's name and copy its alias again. Then click **Details** and check that **Model capabilities** lists **Chat completions**. If the details show **Temporarily unavailable**, try again later or choose another model.

> [accordion] 429 rate\_limit\_exceeded
>
> Your account has too many requests in progress at the same time. Wait for one to finish, then try again. If the message is "The model is receiving too many requests right now. Retry shortly.", the model itself is busy. Try again in a moment, or choose another model.

> [accordion] 503 key\_provisioning\_pending
>
> Your key can't make requests. On the **API keys** page, its row shows **This API key is still being provisioned.** The key won't become usable by itself, so sending the request again doesn't help. Create a new key and use it instead. The old key may change to **Revoked** later, and you can ignore it. If new keys also show this message, [contact support](https://docs.sinarcloud.com/help/support.md).

> [accordion] 502, 503, or 504
>
> SinarCloud or the model is temporarily unavailable, or the model didn't respond in time. Wait a moment, then send the request again.

For other problems, see [Troubleshooting](https://docs.sinarcloud.com/help/troubleshooting.md).

## Next steps

> [card] [Send requests](https://docs.sinarcloud.com/ai/requests.md)
>
> Use streaming, other endpoints, and more request options.

> [card] [Models and pricing](https://docs.sinarcloud.com/ai/models.md)
>
> Compare models, capabilities, and prices per 1M tokens.

> [card] [Playground](https://docs.sinarcloud.com/ai/playground.md)
>
> Chat with a model in the console without writing code.

> [card] [Usage and spending](https://docs.sinarcloud.com/ai/usage.md)
>
> Track requests, tokens, and what you spend on each model.


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