How the API works
The API follows the OpenAI API format. To move existing OpenAI code to SinarCloud, you change three settings: the base URL, the API key and the model alias. The base URL ishttps://ai.sinarcloud.com/v1. These endpoints are available under it:
Each model supports only some of these endpoints. The Models page shows each model’s capabilities, prices and model alias. Streaming responses are supported. Errors use the OpenAI error format. For examples and error codes, see Send requests.
Your account can have only a limited number of requests in progress at once. Extra requests fail with HTTP status
429 and the code rate_limit_exceeded. Retry when an earlier request finishes.
Authentication
Send your API key as a bearer token in theAuthorization header:
invalid_api_key. You create and revoke keys on the API keys page. A key stops working when you revoke it or when it expires.
How you pay
- Each model has its own price per 1M tokens, with separate prices for input and output tokens. Some models also have prices for reading from and writing to the prompt cache. See Models and pricing.
- Promotions and new-signup offers can lower a model’s price. When a promotion applies to you, the prices on the Models page include it. The price and promotion in effect when a request starts apply to that request. If a promotion has a spending limit and the limit runs out before the request finishes, the promotion may discount less.
- You are charged after a request finishes, for the tokens it used. The charge is deducted from your balance automatically.
- If you have token credits for the model, they pay for the request’s tokens before your balance does. Your balance pays only for the rest. Requests under a 100% promotion don’t use your token credits while the promotion covers them.
- If your balance is zero or negative and you have no token credits for the model, new requests to that model fail with HTTP status
402and the codeinsufficient_balance. Requests that can’t cost you anything, such as requests under a 100% promotion, still work. Add balance to continue. - Because the charge comes after the request, a request can take your balance below zero. Your next top-up covers the negative amount first.
Connect your code
The base URL ishttps://ai.sinarcloud.com/v1. Store your API key in an environment variable. See API keys.
- macOS and Linux
- Windows PowerShell
pip install openai. Then pass the three settings to the client. The example uses deepseek/deepseek-v4-1-flash. To call another chat model, replace it with that model’s alias. To copy an alias, click the copy icon next to it on the Models page.
Next steps
Make your first AI request
Create a key and send a request in a few minutes.
Models and pricing
Compare models, capabilities and prices per 1M tokens.
API keys
Create, rename and revoke the keys your apps use.
Send requests
Call each endpoint and handle errors.
Playground
Try a model from the console before you write code.
Usage and spending
Review requests, tokens and charges in detail.
Token credits
See prepaid tokens per model and when they expire.
Add balance
Top up the balance that pays for AI and VPS.