curl --request GET \
--url https://api.openworklabs.com/v1/gateway/usage/me \
--header 'x-api-key: <api-key>'import requests
url = "https://api.openworklabs.com/v1/gateway/usage/me"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.openworklabs.com/v1/gateway/usage/me', 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://api.openworklabs.com/v1/gateway/usage/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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.openworklabs.com/v1/gateway/usage/me"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.openworklabs.com/v1/gateway/usage/me")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openworklabs.com/v1/gateway/usage/me")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"usage": {
"groupBy": "model",
"days": 183,
"from": "2023-12-25",
"to": "2023-12-25",
"timezone": "UTC",
"totalTokens": 4503599627370495,
"unreportedRequests": 4503599627370495,
"totalCostMicroUsd": 4503599627370495,
"unpricedRequests": 4503599627370495,
"series": [
{
"id": "<string>",
"label": "<string>"
}
],
"daily": [
{
"date": "2023-12-25",
"totalTokens": 4503599627370495,
"values": {},
"totalCostMicroUsd": 4503599627370495,
"costValues": {}
}
],
"filterOptions": [
{
"id": "<string>",
"label": "<string>"
}
],
"emptyReason": "no_teams",
"requestCount": 4503599627370495,
"uncountableRequests": {
"ok": 4503599627370495,
"upstream_error": 4503599627370495,
"upstream_unreachable": 4503599627370495,
"client_aborted": 4503599627370495,
"rejected": 4503599627370495
}
},
"tokenMix": [
{
"seriesId": "<string>",
"measuredRequests": 4503599627370495,
"uncachedInputTokens": 4503599627370495,
"outputTokens": 4503599627370495,
"cacheReadTokens": 4503599627370495,
"cacheWriteTokens": 4503599627370495
}
],
"models": [
{
"id": "<string>",
"name": "<string>",
"providerName": "<string>",
"providerId": "<string>",
"upstreamModelId": "<string>",
"seriesId": "<string>",
"price": {
"input": 500000,
"output": 500000,
"cacheRead": 500000,
"cacheWrite": 500000,
"contextTiers": [
{
"input": 500000,
"output": 500000,
"cacheRead": 500000,
"cacheWrite": 500000,
"above": 4503599627370495
}
]
}
}
]
}{
"error": "invalid_request",
"details": [
{
"message": "<string>",
"path": [
"<string>"
]
}
],
"message": "<string>",
"capability": "<string>"
}{
"error": "unauthorized"
}{
"error": "forbidden",
"reason": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Read own Gateway usage by UTC day
The caller’s own AI Gateway usage, by model, over the last days UTC calendar days including today (default 30, 1-366): the same report as GET /v1/inference-providers/usage with groupBy=model, scoped to the caller’s membership and without organization filter options. Reads raw request logs and retained rollups; cost is the stored approximate cost in integer micro-USD, never repriced. tokenMix lists, per model series, the input (excluding cache), output, cache read and cache write tokens of requests that reported both input and output tokens. models lists the Gateway models the caller can use now, with the listed price from the model’s catalog config (USD per 1M tokens) or null when it has none. Any member can read their own usage; no Gateway permission is needed. Requires enabled Gateway management.
curl --request GET \
--url https://api.openworklabs.com/v1/gateway/usage/me \
--header 'x-api-key: <api-key>'import requests
url = "https://api.openworklabs.com/v1/gateway/usage/me"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.openworklabs.com/v1/gateway/usage/me', 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://api.openworklabs.com/v1/gateway/usage/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$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.openworklabs.com/v1/gateway/usage/me"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
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.openworklabs.com/v1/gateway/usage/me")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.openworklabs.com/v1/gateway/usage/me")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"usage": {
"groupBy": "model",
"days": 183,
"from": "2023-12-25",
"to": "2023-12-25",
"timezone": "UTC",
"totalTokens": 4503599627370495,
"unreportedRequests": 4503599627370495,
"totalCostMicroUsd": 4503599627370495,
"unpricedRequests": 4503599627370495,
"series": [
{
"id": "<string>",
"label": "<string>"
}
],
"daily": [
{
"date": "2023-12-25",
"totalTokens": 4503599627370495,
"values": {},
"totalCostMicroUsd": 4503599627370495,
"costValues": {}
}
],
"filterOptions": [
{
"id": "<string>",
"label": "<string>"
}
],
"emptyReason": "no_teams",
"requestCount": 4503599627370495,
"uncountableRequests": {
"ok": 4503599627370495,
"upstream_error": 4503599627370495,
"upstream_unreachable": 4503599627370495,
"client_aborted": 4503599627370495,
"rejected": 4503599627370495
}
},
"tokenMix": [
{
"seriesId": "<string>",
"measuredRequests": 4503599627370495,
"uncachedInputTokens": 4503599627370495,
"outputTokens": 4503599627370495,
"cacheReadTokens": 4503599627370495,
"cacheWriteTokens": 4503599627370495
}
],
"models": [
{
"id": "<string>",
"name": "<string>",
"providerName": "<string>",
"providerId": "<string>",
"upstreamModelId": "<string>",
"seriesId": "<string>",
"price": {
"input": 500000,
"output": 500000,
"cacheRead": 500000,
"cacheWrite": 500000,
"contextTiers": [
{
"input": 500000,
"output": 500000,
"cacheRead": 500000,
"cacheWrite": 500000,
"above": 4503599627370495
}
]
}
}
]
}{
"error": "invalid_request",
"details": [
{
"message": "<string>",
"path": [
"<string>"
]
}
],
"message": "<string>",
"capability": "<string>"
}{
"error": "unauthorized"
}{
"error": "forbidden",
"reason": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
Was this page helpful?