Usage
Usage
Per-call headers, GET /v1/usage for totals by model, and GET /v1/generation for one call.
Per-call headers
| Header | Meaning |
|---|---|
x-predev-request-id | pdr_…, on every inference call; quote it when contacting support |
x-predev-credits-charged | Credits charged for this call, on completed non-streaming calls |
x-predev-credits-remaining | Workspace 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
}
]
}| Field | Meaning |
|---|---|
workspace | An opaque, stable id (ws_ and 16 hex characters) for the workspace the key belongs to |
project | The project named by x-predev-project-id, or null |
credits_remaining | Current balance; null when the workspace has no credit limit |
tier | Plan tier |
since | Start of the window |
totals.requests, totals.credits | Window totals |
by_model[].model, path | One row per model and endpoint |
by_model[].requests, credits | Volume and credits for that row |
by_model[].prompt_tokens, completion_tokens | Token totals |
by_model[].errors | Requests 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 } ]}The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
In: header
Query Parameters
Window length. Values outside 1 to 90 are clamped.
1 <= value <= 9030Header Parameters
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
Missing or invalid API key.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
More than 30 failed key attempts from this IP address in the current minute.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
Unexpected error.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.