Node.js
import GetimgAI from "getimg-ai";
const client = new GetimgAI();
const { balance, currency } = await client.billing.retrieveBalance();from getimg import GetimgAI
client = GetimgAI()
result = client.billing.retrieve_balance()
curl --request GET \
--url https://api.getimg.ai/v2/billing/balance \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getimg.ai/v2/billing/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.getimg.ai/v2/billing/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.getimg.ai/v2/billing/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getimg.ai/v2/billing/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{
"currency": "USD",
"balance": "12.3456"
}{
"error": {
"message": "Incorrect API key provided. You can manage your API keys at https://getimg.ai/app/developer/api-keys",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key",
"doc_url": "https://docs.getimg.ai/guides/authentication"
}
}{
"error": {
"message": "Too many requests hit the API too quickly.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit"
}
}{
"error": {
"message": "Something went wrong on our end.",
"type": "invalid_request_error",
"param": null,
"code": "server_error"
}
}Billing
Get the current balance
Retrieve the current API balance shared by the API key’s workspace.
GET
/
v2
/
billing
/
balance
Node.js
import GetimgAI from "getimg-ai";
const client = new GetimgAI();
const { balance, currency } = await client.billing.retrieveBalance();from getimg import GetimgAI
client = GetimgAI()
result = client.billing.retrieve_balance()
curl --request GET \
--url https://api.getimg.ai/v2/billing/balance \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getimg.ai/v2/billing/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.getimg.ai/v2/billing/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.getimg.ai/v2/billing/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getimg.ai/v2/billing/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{
"currency": "USD",
"balance": "12.3456"
}{
"error": {
"message": "Incorrect API key provided. You can manage your API keys at https://getimg.ai/app/developer/api-keys",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key",
"doc_url": "https://docs.getimg.ai/guides/authentication"
}
}{
"error": {
"message": "Too many requests hit the API too quickly.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit"
}
}{
"error": {
"message": "Something went wrong on our end.",
"type": "invalid_request_error",
"param": null,
"code": "server_error"
}
}Authorizations
Send your API key as a bearer token:
Authorization: Bearer sk_<secret>.
Response
The workspace balance in USD, as a decimal string with four fractional digits. A workspace with no billing set up returns a zero balance. Responses are sent with Cache-Control: no-store.