curl --request GET \
--url https://api.hopscotchlabs.ai/v1/key \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.hopscotchlabs.ai/v1/key"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.hopscotchlabs.ai/v1/key', 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.hopscotchlabs.ai/v1/key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hopscotchlabs.ai/v1/key"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hopscotchlabs.ai/v1/key")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hopscotchlabs.ai/v1/key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyRetrieve this key's spend and limit as numbers
The calling key’s charged spend this UTC day, this Monday-to-Sunday week and this month, with its credit limit and what is left of it: the figures GET /v1/key/usage returns, under a data object with money as JSON numbers. It suits a tool that already expects to read a key’s usage and limit in this shape. usage and usage_monthly are both this month’s spend, usage_weekly this week’s and usage_daily today’s; the week can begin in the previous month, so early in a month usage_weekly can exceed usage_monthly. label is the calling key’s id. limit and limit_remaining are null for a key with no limit, and limit_reset is null for a key with no limit or a limit that never resets. limit_remaining counts credit held for this key’s requests still in flight as spent, the way admission does. is_free_tier is always false.
Each amount is a JSON number written from the exact decimal’s own digits, never rounded on our side; a client that parses it into a double keeps about fifteen significant digits. Read GET /v1/key/usage for the same figures as exact decimal strings.
This read counts in a bucket of its own, 60 reads a minute per key shared by the workspace’s balance and spend reads, so polling it never spends the request rate your inference calls need. The workspace is the calling key’s own, and no id in the request can name another. Nothing here writes, and every answer carries Cache-Control: no-store and the instant it was read in as_of.
curl --request GET \
--url https://api.hopscotchlabs.ai/v1/key \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.hopscotchlabs.ai/v1/key"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.hopscotchlabs.ai/v1/key', 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.hopscotchlabs.ai/v1/key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hopscotchlabs.ai/v1/key"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hopscotchlabs.ai/v1/key")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hopscotchlabs.ai/v1/key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body