Read a virtual key's spend
import requests
url = "https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend \
--header 'X-Auth-Token: <api-key>'{
"virtual_key_id": "<string>",
"spent_usd": "<string>",
"requests": 0,
"window": {
"from": 0,
"to": 0
}
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}Gateway: Virtual Keys
Read a virtual key's spend
Aggregate spend and request count for one key over a window given in epoch milliseconds (default: current UTC calendar month). Returns 412 spend_source_unavailable on deploys without a ClickHouse spend source.
GET
/
api
/
gateway
/
v1
/
virtual-keys
/
{id}
/
spend
Read a virtual key's spend
import requests
url = "https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/spend \
--header 'X-Auth-Token: <api-key>'{
"virtual_key_id": "<string>",
"spent_usd": "<string>",
"requests": 0,
"window": {
"from": 0,
"to": 0
}
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Path Parameters
Minimum string length:
1Query Parameters
Required range:
x <= 8640000000000000Required range:
x <= 8640000000000000Last modified on August 5, 2026
Was this page helpful?