Zum Hauptinhalt springen
POST
/
export
/
api-keys
Export API key usage data
curl --request POST \
  --url https://api.langdock.com/export/api-keys \
  --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"
  },
  "group_by": "model"
}
'
{
  "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"
    }
  }
}
Dieser Endpunkt exportiert die API-Nutzung, gruppiert nach API-Schlüssel, für den gewählten Zeitraum.
Dedicated Deployment?Ersetze api.langdock.com durch <your-deployment>/api/public in allen Anfragen.
Details zu Voraussetzungen und Rate Limits findest du in der Hauptdokumentation zur Usage Export API.
Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen. Verwende API-Schlüssel serverseitig und speichere sie sicher. Mehr dazu findest du unter Best Practices für API-Schlüssel.

Enthaltene Daten

Standardmäßig gibt der API-Schlüssel-Export eine Zeile pro API-Schlüssel zurück.
SpalteBeschreibung
period_startStartdatum des Berichts
period_endEnddatum des Berichts
org_idID des Workspaces
api_key_idID des API-Schlüssels
api_key_nameName des API-Schlüssels
requestsAnzahl der API-Anfragen
total_cost_usdAPI-Nutzungskosten in USD

Zusätzliche Spalten für BYOK-Workspaces

SpalteBeschreibung
sum_prompt_tokensGesamte Input-Tokens
sum_completion_tokensGesamte Output-Tokens
cached_prompt_tokensCache-Read-Input-Tokens
cache_creation_tokensCache-Write-Input-Tokens
no_cache_tokensInput-Tokens, die nicht aus dem Cache kamen

Gruppierter Export

Mit group_by=model erhältst du eine Zeile pro API-Schlüssel und Modell.

Autorisierungen

Authorization
string
header
erforderlich

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Body

application/json

Request body for usage export endpoints

from
object
erforderlich

Start date and timezone for the export

to
object
erforderlich

End date and timezone for the export

group_by
enum<string>

Optional aggregation dimension.

Verfügbare Optionen:
model

Antwort

Export successful

Successful response from usage export endpoints

success
boolean
erforderlich

Indicates if the export was successful

Beispiel:

true

data
object
erforderlich

Export data information