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"
}
'import requests
url = "https://api.langdock.com/export/api-keys"
payload = {
"from": {
"date": "2024-01-01T00:00:00.000Z",
"timezone": "UTC"
},
"to": {
"date": "2024-01-31T23:59:59.999Z",
"timezone": "UTC"
},
"group_by": "model"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: {date: '2024-01-01T00:00:00.000Z', timezone: 'UTC'},
to: {date: '2024-01-31T23:59:59.999Z', timezone: 'UTC'},
group_by: 'model'
})
};
fetch('https://api.langdock.com/export/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.langdock.com/export/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => [
'date' => '2024-01-01T00:00:00.000Z',
'timezone' => 'UTC'
],
'to' => [
'date' => '2024-01-31T23:59:59.999Z',
'timezone' => 'UTC'
],
'group_by' => 'model'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langdock.com/export/api-keys"
payload := strings.NewReader("{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.langdock.com/export/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/export/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}
}
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}Usage Export API
API-Schlüssel-Nutzung exportieren
API-Endpunkt zum Exportieren von Nutzung und Kosten pro API-Schlüssel.
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"
}
'import requests
url = "https://api.langdock.com/export/api-keys"
payload = {
"from": {
"date": "2024-01-01T00:00:00.000Z",
"timezone": "UTC"
},
"to": {
"date": "2024-01-31T23:59:59.999Z",
"timezone": "UTC"
},
"group_by": "model"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: {date: '2024-01-01T00:00:00.000Z', timezone: 'UTC'},
to: {date: '2024-01-31T23:59:59.999Z', timezone: 'UTC'},
group_by: 'model'
})
};
fetch('https://api.langdock.com/export/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.langdock.com/export/api-keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => [
'date' => '2024-01-01T00:00:00.000Z',
'timezone' => 'UTC'
],
'to' => [
'date' => '2024-01-31T23:59:59.999Z',
'timezone' => 'UTC'
],
'group_by' => 'model'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.langdock.com/export/api-keys"
payload := strings.NewReader("{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.langdock.com/export/api-keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.langdock.com/export/api-keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": {\n \"date\": \"2024-01-01T00:00:00.000Z\",\n \"timezone\": \"UTC\"\n },\n \"to\": {\n \"date\": \"2024-01-31T23:59:59.999Z\",\n \"timezone\": \"UTC\"\n },\n \"group_by\": \"model\"\n}"
response = http.request(request)
puts response.read_body{
"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"
}
}
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}{
"error": "No data found",
"message": "No usage data found for the selected period"
}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.| Spalte | Beschreibung |
|---|---|
period_start | Startdatum des Berichts |
period_end | Enddatum des Berichts |
org_id | ID des Workspaces |
api_key_id | ID des API-Schlüssels |
api_key_name | Name des API-Schlüssels |
requests | Anzahl der API-Anfragen |
total_cost_usd | API-Nutzungskosten in USD |
Zusätzliche Spalten für BYOK-Workspaces
| Spalte | Beschreibung |
|---|---|
sum_prompt_tokens | Gesamte Input-Tokens |
sum_completion_tokens | Gesamte Output-Tokens |
cached_prompt_tokens | Cache-Read-Input-Tokens |
cache_creation_tokens | Cache-Write-Input-Tokens |
no_cache_tokens | Input-Tokens, die nicht aus dem Cache kamen |
Gruppierter Export
Mitgroup_by=model erhältst du eine Zeile pro API-Schlüssel und Modell.Autorisierungen
API key as Bearer token. Format "Bearer YOUR_API_KEY"
Body
application/json
War diese Seite hilfreich?
⌘I