Skip to main content
POST
/
export
/
models
Export model usage data
curl --request POST \
  --url https://api.langdock.com/export/models \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "from": {
    "date": "2024-01-01T00:00:00.000Z",
    "timezone": "UTC"
  },
  "to": {
    "date": "2024-01-31T23:59:59.999Z",
    "timezone": "UTC"
  }
}
'
{
  "success": true,
  "data": {
    "filePath": "agents-usage/workspace-id/agents-usage-2024-01-01-2024-01-31-abc12345.csv",
    "downloadUrl": "https://storage.example.com/signed-url",
    "dataType": "assistants",
    "recordCount": 1250,
    "dateRange": {
      "from": "2024-01-01T00:00:00.000Z",
      "to": "2024-01-31T23:59:59.999Z"
    }
  }
}
Using a dedicated deployment?Replace api.langdock.com with <your-deployment>/api/public in all requests.
For details on prerequisites and rate limits, please refer to the main Usage Export API documentation.
Langdock intentionally blocks browser-origin requests to protect your API key and ensure your applications remain secure. For more information, please see our guide on API Key Best Practices.
This endpoint exports AI model usage data, including request counts per model.

Data Included

By default, the model export returns one row per normalized model name, provider, and BYOK state.
ColumnDescription
period_startStart date of the report
period_endEnd date of the report
org_idID of the workspace
nameNormalized model name
providerModel provider
bring_your_keysWhether usage came from a BYOK model
requestsNumber of requests

Additional Columns for BYOK Workspaces

ColumnDescription
sum_prompt_tokensTotal input tokens
sum_completion_tokensTotal output tokens
sum_cached_prompt_tokensCache-read input tokens
sum_cache_creation_tokensCache-write input tokens
no_cache_tokensInput tokens that were not served from cache
total_cost_usdEstimated provider cost in USD
Because BYOK workspaces supply their own model keys, Langdock can provide you with an export of your token consumption data.

Grouped Export

Use group_by=source to return one row per model and source, such as WEB or MOBILE. BYOK workspaces can also use group_by=deployment to return one row per model and deployment.

Usage Analysis

With this export you can:
  • Calculate costs using your provider’s pricing
  • Identify which models receive the most requests
  • Track usage trends over time
  • Optimize model selection for different use cases

Authorizations

Authorization
string
header
required

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Body

application/json

Request body for usage export endpoints

from
object
required

Start date and timezone for the export

to
object
required

End date and timezone for the export

group_by
enum<string>

Optional aggregation dimension. deployment is only available for BYOK workspaces.

Available options:
source,
deployment

Response

Export successful

Successful response from usage export endpoints

success
boolean
required

Indicates if the export was successful

Example:

true

data
object
required

Export data information