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

# Playground

> Chat with SinarCloud AI models in the console using one of your API keys, and see the tokens, latency, and cost of each reply.

The playground lets you chat with SinarCloud AI models in the console, so you can compare models and test prompts before you write code. Every message is a real request sent with one of your API keys, and it is billed the same way.

![Playground page in the SinarCloud console: the empty Conversation panel, marked Not saved with a New chat button, asks What would you like to try? and offers three starter prompts (Explain a concept, Help me write, Write some code) above the message box and Send button. On the right, the Chat settings panel shows Model with the model ID below it, Streaming switched on, API key with a Manage API keys link, and System prompt (optional).](https://mintcdn.com/sinar-cloud/Zz311Jgf5s_A88RD/images/ai-playground.png?fit=max\&auto=format\&n=Zz311Jgf5s_A88RD\&q=85\&s=e580217b11efe143477383b4a85142e2)

Conversation on the left, Chat settings on the right

## Before you start

You need:

* An API key. If you have none, or only revoked keys, the playground shows **Create an API key first** with a **Create API key** button. See [API keys](https://docs.sinarcloud.com/ai/api-keys.md).
* For models that aren't free, a balance above zero or token credits for the model you want to try. See [Add balance](https://docs.sinarcloud.com/billing/top-up.md).

## Open the playground

In the console sidebar, under **AI**, click **Playground**.

You can also open a model on the **Models** page and click **Try in playground** to start with that model selected. The playground only offers available models that support text chat. For any other model, the button is turned off and the model's details say **This model is not available in the chat playground.**

## Choose your chat settings

Set up the conversation in the **Chat settings** panel. On smaller screens, tap **Chat settings** to expand it.

* **Model**: Pick a chat model from the searchable list. The model ID below the list is the value you use as `model` in your own API requests.
* **Streaming**: Shows the reply as it is generated. It is on by default. Models that don't support streaming show **This model does not support streaming.**
* **API key**: Pick the key that sends your messages. Each key shows its name and the start of the key, never the secret. Only keys that are ready to use appear. If none of your keys can be used, for example because they have expired, the list is empty and the playground shows **No API keys are ready for chat**. [Create a new key](https://docs.sinarcloud.com/ai/api-keys.md). Click **Manage API keys** to open the **API keys** page.
* **System prompt (optional)**: Give the model instructions, such as a role or a writing style. It is sent with every message.

You can change any setting between messages, but not while a reply is being generated. If the models or your API keys can't be loaded, click **Try again** in the panel.

## Send a message

**1. Write a prompt**

Type in the message box, or click a starter prompt in a new conversation: **Explain a concept**, **Help me write**, or **Write some code**. Starter prompts only fill in the box, so you can edit them first.

**2. Send it**

Press Enter or click **Send**. Press Shift + Enter for a new line. While the reply is on its way, the playground shows **Waiting for the model…** and **Send** changes to **Stop**. With **Streaming** on, the reply appears as it is written and the status changes to **Generating response…**.

**3. Read the reply**

The reply appears under the model's name. Lists, tables and code blocks are formatted. Use the copy button next to the model's name to copy the whole reply, or the copy button on a code block to copy only that code.

If you click **Stop** after part of the reply has arrived, the playground keeps that part and marks it **Stopped**. Otherwise, your message goes back into the box. A stopped request may still be charged.

## Read the reply details

Under each reply, the playground shows the input, output, and total tokens, plus:

* **Cache hit**: the share of input tokens the model read from its cache, and how many tokens that was. Cached tokens are already counted in the input tokens. It can read **Cache hit: unavailable** until billing is final.
* **First token**: how long the first text took to arrive, for streamed replies only.
* **Latency**: how long the complete reply took.
* **Cost**: what the reply took from your balance, after any token credits or discounts. It reads **Cost: pending** until billing is final. Small replies can cost a fraction of a rupiah.

When billing is final, the token counts update to the numbers you were billed for.

If the cost can't be shown, the reply reads **Cost: unavailable**. If **Retry cost** appears next to it, click it to load the cost again. Otherwise, check the [Usage](https://docs.sinarcloud.com/ai/usage.md) page, which lists each request once it is charged.

## Conversations are not saved

The **Not saved** label means the conversation exists only in the open page. Reloading or leaving the page discards it and stops any reply still being generated. Usage up to that point may still be charged. Copy anything you want to keep.

Click **New chat** to clear the conversation and the message box. Your chat settings stay as they are.

## How playground messages are billed

You pay the model's prices shown on [Models and pricing](https://docs.sinarcloud.com/ai/models.md). [Token credits](https://docs.sinarcloud.com/ai/token-credits.md) for that model are used first, then your account balance, the same balance that pays for your VPS. Each charged request appears on the [Usage](https://docs.sinarcloud.com/ai/usage.md) page.

When the playground mentions your API key's credit, it means your account balance and token credits. API keys don't hold money of their own.

A reply is charged in full when it finishes, even if that takes your balance below zero. See [Balance and billing](https://docs.sinarcloud.com/billing/overview.md).

> [!TIP]
>
> Every message resends the whole conversation and the system prompt. The model sees earlier messages, but input tokens grow as the conversation gets longer. Click **New chat** when you change topics to keep costs down.

## If a message fails

The playground shows a notice above the message box and puts your message back so you can send it again. Common notices:

| Notice starts with | What to do |
| - | - |
| This API key does not have enough credit. | Your balance is zero or below, and no token credits remain for this model. [Add balance](https://docs.sinarcloud.com/billing/top-up.md), for example with **Add Credit** on the **Billing** page. |
| The selected key or your session is no longer valid. | The key expired or was revoked, or your session ended. Select another key or sign in again. |
| This API key cannot use the selected model. | Choose another model, or select another key. |
| This API key is still being provisioned. | The key can't make requests and won't become usable by itself. Select another key, or [create a new one](https://docs.sinarcloud.com/ai/api-keys.md). |
| The model could not accept this request. | The model may no longer be available, or the conversation may be too long for it. Check the model and the system prompt, or click **New chat** to start with a shorter history. |
| The request limit was reached. | Too many requests are running at once on your account, including API requests from your own apps, or the model is busy. Wait a moment, then send again. |
| Could not get a response. | The model didn't respond in time or is temporarily unavailable, or your connection dropped. Check your connection and try again later. If it keeps happening in a very long conversation, click **New chat** to start with a shorter history. |

If a streamed reply breaks off partway, the playground keeps what arrived and marks it **Interrupted**. See also [Troubleshooting](https://docs.sinarcloud.com/help/troubleshooting.md).

## Next steps

For options the playground doesn't send, such as a maximum reply length, call the API from your code.

> [card] [Send requests](https://docs.sinarcloud.com/ai/requests.md)
>
> Call the AI API from your own code.

> [card] [Usage and spending](https://docs.sinarcloud.com/ai/usage.md)
>
> Track your tokens and spending.


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