Skip to main content

Usage

Usage

Per-call headers, GET /v1/usage for totals by model, and GET /v1/generation for one call.

gethttps://api.pre.dev/v1/usageTry it

Per-call headers

HeaderMeaning
x-predev-request-idpdr_…, on every inference call; quote it when contacting support
x-predev-credits-chargedCredits charged for this call, on completed non-streaming calls
x-predev-credits-remainingWorkspace balance after the call; omitted when the workspace has no credit limit

Send x-predev-project-id: <projectId> on a request to attribute it to one of the workspace’s projects. Ids of projects the workspace does not own are ignored.

Usage totals

GET /v1/usage returns totals for the last days days (1 to 90, default 30), broken down by model and path. The read is not charged.

curl --fail-with-body "https://api.pre.dev/v1/usage?days=30" \
  -H "Authorization: Bearer $PREDEV_API_KEY"
{
  "workspace": "ws_3f9a1c07b2e4d5a8",
  "project": null,
  "credits_remaining": 412.5,
  "tier": "SoloPro",
  "since": "2026-08-28T00:00:00.000Z",
  "totals": { "requests": 1840, "credits": 87.5 },
  "by_model": [
    {
      "model": "deepseek/deepseek-v4.1-flash-1017",
      "path": "/chat/completions",
      "requests": 1702,
      "credits": 41.2,
      "prompt_tokens": 9120000,
      "completion_tokens": 1410000,
      "errors": 3
    },
    {
      "model": "anthropic/claude-sonnet-5",
      "path": "/messages",
      "requests": 138,
      "credits": 46.3,
      "prompt_tokens": 610000,
      "completion_tokens": 92000,
      "errors": 0
    }
  ]
}
FieldMeaning
workspaceAn opaque, stable id (ws_ and 16 hex characters) for the workspace the key belongs to
projectThe project named by x-predev-project-id, or null
credits_remainingCurrent balance; null when the workspace has no credit limit
tierPlan tier
sinceStart of the window
totals.requests, totals.creditsWindow totals
by_model[].model, pathOne row per model and endpoint
by_model[].requests, creditsVolume and credits for that row
by_model[].prompt_tokens, completion_tokensToken totals
by_model[].errorsRequests that returned an error

One generation

GET /v1/generation?id=<id> returns the record of one call, using the pdg-… id from the response body, or from a stream chunk once the stream ends. Only this workspace’s generations are visible. Stats can take a few seconds to appear after a call; a 404 with code not_ready means retry shortly.

curl --fail-with-body "https://api.pre.dev/v1/generation?id=pdg-7c1e4b52-9a3d-4f8e-b0c6-2d5a8e913f47" \
  -H "Authorization: Bearer $PREDEV_API_KEY"

The body’s data object reports the model, timing (latency, generation_time), finish_reason, whether the call streamed or was cancelled, token counts including reasoning and cached tokens, counts of images and other attachments, and credits: the credits charged for the call.

curl -X GET "https://api.pre.dev/v1/usage"
fetch("https://api.pre.dev/v1/usage", {  method: "GET"})
package mainimport (  "fmt"  "net/http"  "io/ioutil")func main() {  url := "https://api.pre.dev/v1/usage"  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/v1/usage"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/v1/usage"))  .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/v1/usage");var responseBody = await response.Content.ReadAsStringAsync();
use reqwest::{Result, Client};async fn main() -> Result<()> {  let client = Client::new();  let url = "https://api.pre.dev/v1/usage";  let res = client    .get(url)    .send()    .await?    .text()    .await?;  println!("{}", res);  Ok(())}
{  "workspace": "ws_3f9a1c07b2e4d5a8",  "project": null,  "credits_remaining": 412.5,  "tier": "EnterprisePremium",  "since": "2026-08-28T12:00:00.000Z",  "totals": {    "requests": 1840,    "credits": 87.5  },  "by_model": [    {      "model": "anthropic/claude-sonnet-5",      "path": "/messages",      "requests": 138,      "credits": 46.3,      "prompt_tokens": 610000,      "completion_tokens": 92000,      "errors": 0    },    {      "model": "deepseek/deepseek-v4.1-flash-1017",      "path": "/chat/completions",      "requests": 1702,      "credits": 41.2,      "prompt_tokens": 9120000,      "completion_tokens": 1410000,      "errors": 3    }  ]}
GET
/v1/usage

Authorization

AuthorizationBearer <token>

The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.

In: header

Query Parameters

days?integer

Window length. Values outside 1 to 90 are clamped.

Range1 <= value <= 90
Default30

Header Parameters

x-predev-project-id?string

Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.

Response Body

application/json

Usage totals.

TypeScript Definitions

Use the response body type in TypeScript.

application/json

application/json

application/json

Was this page helpful?