Skip to main content

API

Get credit balance

Read the credit balance selected by your authenticated account or organization.

gethttps://api.pre.dev/credits-balanceTry it
curl --fail-with-body https://api.pre.dev/credits-balance \
  -H "Authorization: Bearer $PREDEV_API_KEY"

Example response:

{ "success": true, "creditsRemaining": 42.5 }

Credit balances can be fractional. The key determines which account or organization balance is returned; there is no user or organization request parameter.

Use this for budgeting before generation. A balance check does not reserve credits, and specification costs vary. For browser submissions, also check your queue and in-flight limit.

In Node, call client.getCreditsBalance(). In Python, client.get_credits_balance() returns a CreditsBalanceResponse object, so read balance.creditsRemaining. This is an exception to the Python SDK’s dictionary-shaped specification and browser responses.

Errors

StatusWhen
401Missing or invalid key, or a personal key without a paid plan
500Unexpected error

Each status has an example body in the response examples. See errors and retries.

curl -X GET "https://api.pre.dev/credits-balance"
fetch("https://api.pre.dev/credits-balance", {  method: "GET"})
package mainimport (  "fmt"  "net/http"  "io/ioutil")func main() {  url := "https://api.pre.dev/credits-balance"  req, _ := http.NewRequest("GET", url, nil)  res, _ := http.DefaultClient.Do(req)  defer res.Body.Close()  body, _ := ioutil.ReadAll(res.Body)  fmt.Println(res)  fmt.Println(string(body))}
import requestsurl = "https://api.pre.dev/credits-balance"response = requests.request("GET", url)print(response.text)
import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.http.HttpResponse.BodyHandlers;import java.time.Duration;HttpClient client = HttpClient.newBuilder()  .connectTimeout(Duration.ofSeconds(10))  .build();HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()  .uri(URI.create("https://api.pre.dev/credits-balance"))  .GET()  .build();try {  HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());  System.out.println("Status code: " + response.statusCode());  System.out.println("Response body: " + response.body());} catch (Exception e) {  e.printStackTrace();}
using System;using System.Net.Http;using System.Text;var client = new HttpClient();var response = await client.GetAsync("https://api.pre.dev/credits-balance");var responseBody = await response.Content.ReadAsStringAsync();
use reqwest::{Result, Client};async fn main() -> Result<()> {  let client = Client::new();  let url = "https://api.pre.dev/credits-balance";  let res = client    .get(url)    .send()    .await?    .text()    .await?;  println!("{}", res);  Ok(())}
{  "success": true,  "creditsRemaining": 412.5}
GET
/credits-balance

Authorization

AuthorizationBearer <token>

Your pre.dev workspace API key (pdk_...) from Integrations, Built-in tab: https://pre.dev/projects/integrations?tab=built-in

In: header

Response Body

application/json

Credit balance.

TypeScript Definitions

Use the response body type in TypeScript.

application/json

application/json

application/json

Was this page helpful?