curl --request GET \
--url https://api.lava.so/v1/requests/{request_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.lava.so/v1/requests/{request_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.lava.so/v1/requests/{request_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/requests/{request_id}",
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.lava.so/v1/requests/{request_id}"
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.lava.so/v1/requests/{request_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/requests/{request_id}")
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{
"request_id": "req_test_01EXAMPLE00000000000000001",
"status": "pending",
"provider": "openai",
"endpoint": "POST https://api.openai.com/v1/chat/completions",
"provider_key_type": "managed",
"model_usage": {
"input_tokens": 845,
"output_tokens": 412,
"total_tokens": 1257,
"input_characters": 0,
"output_characters": 0,
"total_characters": 0,
"input_seconds": 0,
"output_seconds": 0,
"total_seconds": 0,
"input_cost": "0.0169000000",
"output_cost": "0.0412000000",
"total_cost": "0.0581000000"
},
"cost": "0.0581000000",
"charge": {
"amount": "0.0058100000",
"rate_type": "percentage",
"breakdown": [
{
"tier": {
"start": 0,
"rate": "0.0000000000",
"type": "tokens_1m"
},
"tokens": 1000000,
"characters": 0,
"seconds": 0,
"cost": "0.0000000000"
}
]
},
"metadata": {
"key": "user_id",
"value": "123456"
},
"created_at": "2023-05-15T14:22:31Z",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"meter_id": "prd_test_01EXAMPLE00000000000000001",
"model": "gpt-4",
"response_id": "chatcmpl-abc123def456ghi789",
"timestamp": "2023-05-15T14:22:31Z"
}{
"error": {
"message": "Authorization header is required. Please include an 'Authorization' header with your request.",
"code": "auth_header_missing",
"status": 401
}
}{
"error": {
"message": "Request not found.",
"code": "request_not_found",
"status": 404
}
}{
"error": {
"message": "An internal server error occurred while processing your request.",
"code": "rest_internal_server_error",
"status": 500
}
}Get request
Get details of a specific API request
curl --request GET \
--url https://api.lava.so/v1/requests/{request_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.lava.so/v1/requests/{request_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.lava.so/v1/requests/{request_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/requests/{request_id}",
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.lava.so/v1/requests/{request_id}"
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.lava.so/v1/requests/{request_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/requests/{request_id}")
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{
"request_id": "req_test_01EXAMPLE00000000000000001",
"status": "pending",
"provider": "openai",
"endpoint": "POST https://api.openai.com/v1/chat/completions",
"provider_key_type": "managed",
"model_usage": {
"input_tokens": 845,
"output_tokens": 412,
"total_tokens": 1257,
"input_characters": 0,
"output_characters": 0,
"total_characters": 0,
"input_seconds": 0,
"output_seconds": 0,
"total_seconds": 0,
"input_cost": "0.0169000000",
"output_cost": "0.0412000000",
"total_cost": "0.0581000000"
},
"cost": "0.0581000000",
"charge": {
"amount": "0.0058100000",
"rate_type": "percentage",
"breakdown": [
{
"tier": {
"start": 0,
"rate": "0.0000000000",
"type": "tokens_1m"
},
"tokens": 1000000,
"characters": 0,
"seconds": 0,
"cost": "0.0000000000"
}
]
},
"metadata": {
"key": "user_id",
"value": "123456"
},
"created_at": "2023-05-15T14:22:31Z",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"meter_id": "prd_test_01EXAMPLE00000000000000001",
"model": "gpt-4",
"response_id": "chatcmpl-abc123def456ghi789",
"timestamp": "2023-05-15T14:22:31Z"
}{
"error": {
"message": "Authorization header is required. Please include an 'Authorization' header with your request.",
"code": "auth_header_missing",
"status": 401
}
}{
"error": {
"message": "Request not found.",
"code": "request_not_found",
"status": 404
}
}{
"error": {
"message": "An internal server error occurred while processing your request.",
"code": "rest_internal_server_error",
"status": 500
}
}Authorizations
Bearer token authentication used for standard API calls. Format: 'Bearer YOUR_API_KEY'
Path Parameters
Request ID
Response
Request details
Unique identifier for the AI API request
"req_test_01EXAMPLE00000000000000001"
Status of the request: 'pending' (request was created but not yet completed), 'completed' (request was completed and metered successfully), 'error' (request failed to be metered)
pending, completed, error "pending"
Provider used for the request (e.g., openai, anthropic, deepseek, mistral, xai, google)
"openai"
Full endpoint path used for the forwarded request
"POST https://api.openai.com/v1/chat/completions"
Indicates whether the provider key used for this request was managed by Lava ('managed'), explicitly provided by the customer ('unmanaged'), or resolved from the customer's stored credentials ('stored')
managed, unmanaged, stored "managed"
Show child attributes
Show child attributes
Base AI provider cost for this request in USD (high precision decimal as string)
"0.0581000000"
Show child attributes
Show child attributes
Metadata associated with the request, key-value pairs that can be used to help track the request in your system. Keys must contain only ASCII letters, numbers, and underscores (no spaces or special characters).
Show child attributes
Show child attributes
ISO 8601 timestamp when the request was created and initially recorded by Lava
"2023-05-15T14:22:31Z"
Identifier for the customer that made this request
"con_test_01EXAMPLE00000000000000001"
Identifier for the meter configuration used for this request
"prd_test_01EXAMPLE00000000000000001"
AI model used for the request (e.g., gpt-4, claude-3-opus)
"gpt-4"
Original response ID returned from the AI provider
"chatcmpl-abc123def456ghi789"
ISO 8601 request completion timestamp returned by the provider
"2023-05-15T14:22:31Z"