curl --request GET \
--url https://polza.ai/api/v1/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://polza.ai/api/v1/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://polza.ai/api/v1/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://polza.ai/api/v1/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://polza.ai/api/v1/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://polza.ai/api/v1/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://polza.ai/api/v1/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{
"amount": "1234.56",
"available": "1200.06",
"updatedAt": "2026-04-30T12:00:00.000Z",
"reservedAmount": "12.50",
"spentAmount": "845.30"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}GET Balance (устарел)
Запрос текущего баланса аккаунта
curl --request GET \
--url https://polza.ai/api/v1/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://polza.ai/api/v1/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://polza.ai/api/v1/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://polza.ai/api/v1/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://polza.ai/api/v1/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://polza.ai/api/v1/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://polza.ai/api/v1/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{
"amount": "1234.56",
"available": "1200.06",
"updatedAt": "2026-04-30T12:00:00.000Z",
"reservedAmount": "12.50",
"spentAmount": "845.30"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}{
"error": {
"code": "BAD_REQUEST",
"message": "Недопустимое значение параметра",
"trace_id": "550e8400-e29b-41d4-a716-446655440000",
"details": {},
"metadata": {
"reason": "noProvidersForModel",
"raw": "The parameter `duration` specified in the request is not valid",
"provider_name": "alibaba"
}
},
"trace_id": "550e8400-e29b-41d4-a716-446655440000"
}GET /v2/balance. v1 продолжает работать, но новых возможностей в нём не будет.Примеры
curl "https://polza.ai/api/v1/balance" \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
response = requests.get(
'https://polza.ai/api/v1/balance',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()
print(f"Баланс: {data['amount']} руб.")
const response = await fetch('https://polza.ai/api/v1/balance', {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const data = await response.json();
console.log(`Баланс: ${data.amount} руб.`);
Ответ (200)
{
"amount": "1234.56000000",
"available": "1200.06000000",
"reservedAmount": "12.50000000",
"spentAmount": "845.30000000",
"updatedAt": "2026-04-30T12:00:00.000Z"
}
| Поле | Тип | Описание |
|---|---|---|
amount | string | Баланс организации в рублях. Если ключ выпущен участником с личным лимитом расходов — остаток этого лимита |
available | string | Доступно к трате: остаток за вычетом резерва под выполняющиеся запросы и с учётом лимитов ключа и участника |
reservedAmount | string | Зарезервировано под выполняющиеся запросы. Не возвращается при личном лимите участника |
spentAmount | string | Потрачено организацией за всё время. Не возвращается при личном лимите участника |
updatedAt | string | Время последнего обновления баланса (ISO 8601) |
amount для ключа участника с личным лимитом подменяется остатком лимита. В новом коде используйте GET /v2/balance: там amount — всегда баланс организации, а доступная сумма — available.Мониторинг баланса
import requests
import time
def check_balance(api_key, min_balance=100):
response = requests.get(
'https://polza.ai/api/v1/balance',
headers={'Authorization': f'Bearer {api_key}'}
)
data = response.json()
balance = float(data['amount'])
if balance < min_balance:
print(f"Внимание! Баланс низкий: {balance} руб.")
return balance
# Проверка каждый час
while True:
balance = check_balance('YOUR_API_KEY')
print(f"Текущий баланс: {balance} руб.")
time.sleep(3600)
Авторизации
API ключ передаётся в заголовке: Authorization: Bearer <POLZA_AI_API_KEY>
Ответ
Доступный остаток в рублях. Для ключа участника с личным лимитом — остаток лимита (для нового кода используйте GET /v2/balance), иначе баланс организации.
"1234.56"
Доступно к трате в рублях: остаток организации за вычетом резерва под выполняющиеся запросы, не больше остатков лимитов расходов ключа и участника.
"1200.06"
Время последнего обновления баланса
"2026-04-30T12:00:00.000Z"
Зарезервировано под выполняющиеся запросы организации. Не возвращается, если у участника задан личный лимит (значение относится к организации в целом и может превышать остаток лимита).
"12.50"
Всего потрачено организацией за всё время. Не возвращается, если у участника задан личный лимит (значение относится к организации в целом и может превышать остаток лимита).
"845.30"
Была ли эта страница полезной?