Account Balance
Returns the balance view for the account bound to the current credential.
This endpoint is not just a bare balance number. It also returns user, group, and display-currency information, making it suitable for wallet cards, status bars, and lightweight polling.
Endpoint
http
GET https://api.sakrylle.com/v1/account/balanceHeaders
| Name | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk-xxxxxxxxxxxxxxxx or Bearer sk_oauth_xxxxxxxxxxxxxxxx |
Response fields
| Field | Type | Description |
|---|---|---|
user_id | integer | User ID |
username | string | Username |
credit_remaining | number | Current balance |
currency_display | string | Display currency, always CNY |
rate_multiplier | number | Current group multiplier |
group_id | integer | Current group ID |
group_name | string | Current group name |
allow_image_generation | boolean | Whether the current group allows image-generation-related capability |
Response example
json
{
"user_id": 42,
"username": "alice",
"credit_remaining": 23.71,
"currency_display": "CNY",
"rate_multiplier": 0.5,
"group_id": 3,
"group_name": "GPT-Pro",
"allow_image_generation": true
}OAuth access
When called with an OAuth token, this endpoint requires:
account:balance:read- or
account:read
Notes
- Good for lightweight “wallet balance + current group” UI
credit_remainingfollows the same display semantics as the Consoleallow_image_generationis a group capability hint, not a guarantee that image models exist;/v1/modelsremains the source of truth
Errors
401 authentication_error— authentication failed403 insufficient_scope/permission_error— missing OAuth scope or access denied
Code samples
bash
curl https://api.sakrylle.com/v1/account/balance \
-H "Authorization: Bearer $SAKRYLLE_API_KEY"python
import httpx
resp = httpx.get(
"https://api.sakrylle.com/v1/account/balance",
headers={"Authorization": "Bearer sk-xxxxxxxxxxxxxxxx"},
)
print(resp.json())javascript
const resp = await fetch("https://api.sakrylle.com/v1/account/balance", {
headers: { Authorization: "Bearer sk-xxxxxxxxxxxxxxxx" },
});
console.log(await resp.json());go
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET",
"https://api.sakrylle.com/v1/account/balance", nil)
req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxxxxxxxx")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}rust
use reqwest::Client;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = Client::new();
let resp: serde_json::Value = client
.get("https://api.sakrylle.com/v1/account/balance")
.bearer_auth("sk-xxxxxxxxxxxxxxxx")
.send()
.await?
.json()
.await?;
println!("{resp:#}");
Ok(())
}java
import java.net.URI;
import java.net.http.*;
public class AccountBalance {
public static void main(String[] args) throws Exception {
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.sakrylle.com/v1/account/balance"))
.header("Authorization", "Bearer sk-xxxxxxxxxxxxxxxx")
.GET()
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());
}
}csharp
using System.Net.Http.Headers;
var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "sk-xxxxxxxxxxxxxxxx");
var resp = await http.GetAsync("https://api.sakrylle.com/v1/account/balance");
Console.WriteLine(await resp.Content.ReadAsStringAsync());