Get account balance
curl --request GET \
--url https://api.siray.ai/v1/account/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.siray.ai/v1/account/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.siray.ai/v1/account/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.siray.ai/v1/account/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.siray.ai/v1/account/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.siray.ai/v1/account/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.siray.ai/v1/account/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_uuid": "f1c2d3e4-5a6b-7c8d-9e0f-1a2b3c4d5e6f",
"code": 200,
"message": "OK",
"data": {
"user_id": "user-3f8a2c1d",
"user_name": "alice",
"email": "alice@example.com",
"balance": 123.45,
"coupon_balance": 1.25,
"available_balance": 121.1,
"frozen_balance": 3.6
}
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}API documentation
Account Balance API
Retrieve the identity and balance summary (balance, coupon, available, and frozen amounts) of the account that owns the API key.
GET
/
v1
/
account
/
balance
Get account balance
curl --request GET \
--url https://api.siray.ai/v1/account/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.siray.ai/v1/account/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.siray.ai/v1/account/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.siray.ai/v1/account/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.siray.ai/v1/account/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.siray.ai/v1/account/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.siray.ai/v1/account/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_uuid": "f1c2d3e4-5a6b-7c8d-9e0f-1a2b3c4d5e6f",
"code": 200,
"message": "OK",
"data": {
"user_id": "user-3f8a2c1d",
"user_name": "alice",
"email": "alice@example.com",
"balance": 123.45,
"coupon_balance": 1.25,
"available_balance": 121.1,
"frozen_balance": 3.6
}
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}{
"request_uuid": "<string>",
"code": 401,
"message": "missing authorization header"
}Overview
Use this endpoint to inspect the account behind your API key: its identity (email, user ID, name) and a balance summary in US dollars.Use
available_balance to decide whether to issue new requests. It already accounts for amounts reserved by in-flight generation requests (frozen_balance), so no manual subtraction is needed.Endpoint
GET https://api.siray.ai/v1/account/balance
Authorization: Bearer <SIRAY_API_TOKEN>
Response structure
{
"request_uuid": "f1c2...",
"code": 200,
"message": "OK",
"data": {
"user_id": "user-3f8a2c1d",
"user_name": "alice",
"email": "alice@example.com",
"balance": 123.45,
"coupon_balance": 1.25,
"available_balance": 121.10,
"frozen_balance": 3.60
}
}
Fields
request_uuid: Identifier of this API call, useful for support and log correlation.code/message: Service-level indicators for the request outcome (200/OKon success).data.user_id: ID of the account that owns the API key.data.user_name: Name of that account.data.email: Email of that account.data.balance: Account balance in USD.data.coupon_balance: Remaining coupon balance in USD (expired coupons excluded).data.available_balance: Balance you can actually spend, in USD:available_balance = balance + coupon_balance − frozen_balance.data.frozen_balance: Total amount currently reserved by in-flight requests, in USD. It is0when no amount is frozen.
Usage example
curl -X GET "https://api.siray.ai/v1/account/balance" \
-H "Authorization: Bearer ${SIRAY_API_TOKEN}"
frozen_balanceis reserved by in-flight generation requests and is released automatically once they settle or expire;available_balancerecovers accordingly without any action on your side.
Errors
The endpoint returns the standard response envelope. Non-200 code values indicate failure and come with a message and no data.
| HTTP status | code | Typical cause |
|---|---|---|
| 401 | 401 | Missing or malformed Authorization header; unknown API key. |
| 403 | 403 | API key is disabled or expired, or the account is forbidden. |
| 500 | 500 | Upstream (billing) validation failure; retry later. |
Authorizations
API token passed as a Bearer token in the Authorization header.
Response
Account identity and balance summary
Account identity and balance summary response.
Identifier of this API call, useful for support and log correlation.
Service-level status code (200 on success).
Example:
200
Additional information about the request result.
Example:
"OK"
Account identity and balance summary. All amounts are USD rounded to two decimal places.
Show child attributes
Show child attributes
