Update spend key
curl --request PUT \
--url https://api.lava.so/v1/spend_keys/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"allowed_models": [
"<string>"
],
"allowed_providers": [
"<string>"
],
"spend_limit": {
"amount": "<string>"
},
"request_limit": {
"count": 5000000
},
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.lava.so/v1/spend_keys/{id}"
payload = {
"name": "<string>",
"allowed_models": ["<string>"],
"allowed_providers": ["<string>"],
"spend_limit": { "amount": "<string>" },
"request_limit": { "count": 5000000 },
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
allowed_models: ['<string>'],
allowed_providers: ['<string>'],
spend_limit: {amount: '<string>'},
request_limit: {count: 5000000},
rate_limit: {rpm: 2, burst: 2},
expires_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.lava.so/v1/spend_keys/{id}', 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.lava.so/v1/spend_keys/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'allowed_models' => [
'<string>'
],
'allowed_providers' => [
'<string>'
],
'spend_limit' => [
'amount' => '<string>'
],
'request_limit' => [
'count' => 5000000
],
'rate_limit' => [
'rpm' => 2,
'burst' => 2
],
'expires_at' => '2023-11-07T05:31:56Z'
]),
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.lava.so/v1/spend_keys/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.lava.so/v1/spend_keys/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/spend_keys/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"spend_key_id": "<string>",
"key_preview": "<string>",
"name": "<string>",
"wallet_id": "<string>",
"current_spend": "<string>",
"total_spend": "<string>",
"current_requests": 1,
"total_requests": 1,
"created_at": "2023-11-07T05:31:56Z",
"allowed_models": [
"<string>"
],
"allowed_providers": [
"<string>"
],
"spend_limit": {
"amount": "<string>"
},
"request_limit": {
"count": 5000000
},
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z"
}{
"error": {
"message": "Invalid authentication credentials",
"code": "forward_token_json_invalid",
"status": 400,
"issues": [
{
"path": [
"model"
],
"message": "Missing required field: model"
},
{
"path": [
"messages",
"0",
"content"
],
"message": "Invalid message content format"
}
]
}
}Spend Keys
Update spend key
Update settings for a spend key. Requires a merchant secret key (aks_live_* / aks_test_*).
PUT
/
spend_keys
/
{id}
Update spend key
curl --request PUT \
--url https://api.lava.so/v1/spend_keys/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"allowed_models": [
"<string>"
],
"allowed_providers": [
"<string>"
],
"spend_limit": {
"amount": "<string>"
},
"request_limit": {
"count": 5000000
},
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.lava.so/v1/spend_keys/{id}"
payload = {
"name": "<string>",
"allowed_models": ["<string>"],
"allowed_providers": ["<string>"],
"spend_limit": { "amount": "<string>" },
"request_limit": { "count": 5000000 },
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
allowed_models: ['<string>'],
allowed_providers: ['<string>'],
spend_limit: {amount: '<string>'},
request_limit: {count: 5000000},
rate_limit: {rpm: 2, burst: 2},
expires_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.lava.so/v1/spend_keys/{id}', 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.lava.so/v1/spend_keys/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'allowed_models' => [
'<string>'
],
'allowed_providers' => [
'<string>'
],
'spend_limit' => [
'amount' => '<string>'
],
'request_limit' => [
'count' => 5000000
],
'rate_limit' => [
'rpm' => 2,
'burst' => 2
],
'expires_at' => '2023-11-07T05:31:56Z'
]),
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.lava.so/v1/spend_keys/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.lava.so/v1/spend_keys/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/spend_keys/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"allowed_models\": [\n \"<string>\"\n ],\n \"allowed_providers\": [\n \"<string>\"\n ],\n \"spend_limit\": {\n \"amount\": \"<string>\"\n },\n \"request_limit\": {\n \"count\": 5000000\n },\n \"rate_limit\": {\n \"rpm\": 2,\n \"burst\": 2\n },\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"spend_key_id": "<string>",
"key_preview": "<string>",
"name": "<string>",
"wallet_id": "<string>",
"current_spend": "<string>",
"total_spend": "<string>",
"current_requests": 1,
"total_requests": 1,
"created_at": "2023-11-07T05:31:56Z",
"allowed_models": [
"<string>"
],
"allowed_providers": [
"<string>"
],
"spend_limit": {
"amount": "<string>"
},
"request_limit": {
"count": 5000000
},
"rate_limit": {
"rpm": 2,
"burst": 2
},
"expires_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z"
}{
"error": {
"message": "Invalid authentication credentials",
"code": "forward_token_json_invalid",
"status": 400,
"issues": [
{
"path": [
"model"
],
"message": "Missing required field: model"
},
{
"path": [
"messages",
"0",
"content"
],
"message": "Invalid message content format"
}
]
}
}Authorizations
Bearer token authentication used for standard API calls. Format: 'Bearer YOUR_API_KEY'
Path Parameters
Spend key ID
Body
application/json
Maximum string length:
255Available options:
active, paused Available options:
openai, anthropic Minimum array length:
1Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Updated spend key
Masked key preview (e.g., lava_sk_a1b2c3d4****)
Available options:
active, paused Request format this key accepts
Available options:
openai, anthropic Current spend in this cycle (decimal string)
Total spend tracked for this key across completed/current cycles (decimal string)
Current request count in this cycle
Required range:
x >= 0Total request count tracked for this key across completed/current cycles
Required range:
x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
⌘I