Admin API key for organization-level operations (managing projects, API keys). Create one in Settings > API Keys or via POST /api/api-keys. Format: sk-lw-{id}_{secret}.
Get pull request 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. Authenticate with an organization API key and nothing else: no project id is sent anywhere. A key created for you reads with your own access; an organization service key, such as one a continuous integration job holds, reads with the access its bindings grant. Rows appear only for projects the key may view, and cost only for those it may price.
Try this endpoint
app.langwatch.ai
API key · Authorization
Kept in this tab. Cleared when you reload.
The repository as "owner/name". Case is folded by the mapping store.
The pull request number.
The repository's host, e.g. github.com.
The response appears below.
Request and response examples
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/coding-agent/pull-request-usage"api_key = os.environ["LANGWATCH_API_KEY"]headers = { "Authorization": "Bearer " + api_key,}response = requests.get( origin + path, headers=headers,)print(response.json())const url = "https://app.langwatch.ai/api/v1/coding-agent/pull-request-usage";const response = await fetch(url, { method: "GET", headers: { "Authorization": "Bearer " + process.env.LANGWATCH_API_KEY, },});const data = await response.json();curl --request GET \ --url 'https://app.langwatch.ai/api/v1/coding-agent/pull-request-usage' \ --header "Authorization: Bearer $LANGWATCH_API_KEY"Call the LangWatch API from this project: Get pull request coding agent usage.Request: GET https://app.langwatch.ai/api/v1/coding-agent/pull-request-usageReference: https://langwatch.ai/docs/api-reference/coding-agents/get-pull-request-usage.mdAuthentication: send the Authorization header as a Bearer token, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.Success
application/json · Generated from schema
{ "pullRequest": { "repositoryHost": "string", "repositoryFullName": "string", "prNumber": 0, "headBranch": "string", "htmlUrl": "string", "state": "string", "isDraft": false, "authorLogin": "string", "prCreatedAtMs": 0, "prClosedAtMs": 0, "prMergedAtMs": 0 }, "rows": [ { "projectId": "string", "projectSlug": "string", "contributorLabel": "string", "contributorIsProject": false, "agent": "string", "models": [ "string" ], "sessionsCount": 0, "inputTokens": 0, "outputTokens": 0, "cacheReadTokens": 0, "cacheCreationTokens": 0, "totalTokens": 0, "costUsd": 0, "billedCostUsd": 0, "nonBilledCostUsd": 0 } ], "totals": { "sessionsCount": 0, "inputTokens": 0, "outputTokens": 0, "cacheReadTokens": 0, "cacheCreationTokens": 0, "totalTokens": 0, "costUsd": 0, "billedCostUsd": 0, "nonBilledCostUsd": 0 }, "modelBreakdown": [ { "model": "string", "inputTokens": 0, "outputTokens": 0, "cacheReadTokens": 0, "cacheCreationTokens": 0, "totalTokens": 0, "costUsd": 0, "tokensKnown": false, "aiUnits": 0 } ]}Bad Request
application/json · Generated from schema
{ "error": "string", "message": "string"}Unauthorized
application/json · Generated from schema
{ "error": "string", "message": "string"}Unprocessable Entity
application/json · Generated from schema
{ "error": "string", "message": "string"}Internal Server Error
application/json · Generated from schema
{ "error": "string", "message": "string"}Query parameters
repositorystringrequiredThe repository as "owner/name". Case is folded by the mapping store.
pullRequestintegerrequiredThe pull request number.
hoststringThe repository's host, e.g. github.com.
Responses
200Success
application/json
pullRequestobjectrequiredrowsobject[]requiredtotalsobjectrequiredmodelBreakdownobject[]required400Bad Request
application/json
errorstringrequiredmessagestring401Unauthorized
application/json
errorstringrequiredmessagestring422Unprocessable Entity
application/json
errorstringrequiredmessagestring500Internal Server Error
application/json
errorstringrequiredmessagestring