import requests
url = "https://app.langwatch.ai/api/coding-agent/pull-request-usage"
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/coding-agent/pull-request-usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/coding-agent/pull-request-usage \
--header 'X-Auth-Token: <api-key>'{
"pullRequest": {
"repositoryHost": "<string>",
"repositoryFullName": "<string>",
"prNumber": 123,
"headBranch": "<string>",
"htmlUrl": "<string>",
"state": "<string>",
"isDraft": true,
"authorLogin": "<string>",
"prCreatedAtMs": 123,
"prClosedAtMs": 123,
"prMergedAtMs": 123
},
"rows": [
{
"projectId": "<string>",
"projectSlug": "<string>",
"contributorLabel": "<string>",
"contributorIsProject": true,
"agent": "<string>",
"models": [
"<string>"
],
"sessionsCount": 123,
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123,
"billedCostUsd": 123,
"nonBilledCostUsd": 123
}
],
"totals": {
"sessionsCount": 123,
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123,
"billedCostUsd": 123,
"nonBilledCostUsd": 123
},
"modelBreakdown": [
{
"model": "<string>",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123
}
]
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Get pull request coding agent usage
Assistant usage for one pull request: sessions, tokens and cost, grouped by contributor and agent, plus per-model totals, over the pull request’s whole lifetime rather than a time window. Every row and the totals split cost three ways: the part priced per token, the part a bundled subscription already covers, and the list-price total of both. Per-model totals carry the list price only. Cost is calculated from the tokens the agent reported and LangWatch’s model prices, so it estimates spend rather than restating a provider invoice. Requires a personal-project API key; rows appear only for projects the calling user may view, and cost only for those they may price.
import requests
url = "https://app.langwatch.ai/api/coding-agent/pull-request-usage"
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/coding-agent/pull-request-usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/coding-agent/pull-request-usage \
--header 'X-Auth-Token: <api-key>'{
"pullRequest": {
"repositoryHost": "<string>",
"repositoryFullName": "<string>",
"prNumber": 123,
"headBranch": "<string>",
"htmlUrl": "<string>",
"state": "<string>",
"isDraft": true,
"authorLogin": "<string>",
"prCreatedAtMs": 123,
"prClosedAtMs": 123,
"prMergedAtMs": 123
},
"rows": [
{
"projectId": "<string>",
"projectSlug": "<string>",
"contributorLabel": "<string>",
"contributorIsProject": true,
"agent": "<string>",
"models": [
"<string>"
],
"sessionsCount": 123,
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123,
"billedCostUsd": 123,
"nonBilledCostUsd": 123
}
],
"totals": {
"sessionsCount": 123,
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123,
"billedCostUsd": 123,
"nonBilledCostUsd": 123
},
"modelBreakdown": [
{
"model": "<string>",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheCreationTokens": 123,
"totalTokens": 123,
"costUsd": 123
}
]
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}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.
Query Parameters
The repository as "owner/name".
The pull request number.
Was this page helpful?