curl --request POST \
--url https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": false,
"stream_options": {},
"max_tokens": 2,
"max_completion_tokens": 2,
"tools": [
{}
],
"tool_choice": "<unknown>"
}
'import requests
url = "https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": False,
"stream_options": {},
"max_tokens": 2,
"max_completion_tokens": 2,
"tools": [{}],
"tool_choice": "<unknown>"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: false,
stream_options: {},
max_tokens: 2,
max_completion_tokens: 2,
tools: [{}],
tool_choice: '<unknown>'
})
};
fetch('https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions', 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.paywithlocus.com/api/wrapped/credits/v1/chat/completions",
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([
'model' => '<string>',
'messages' => [
[
]
],
'stream' => false,
'stream_options' => [
],
'max_tokens' => 2,
'max_completion_tokens' => 2,
'tools' => [
[
]
],
'tool_choice' => '<unknown>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.paywithlocus.com/api/wrapped/credits/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.paywithlocus.com/api/wrapped/credits/v1/chat/completions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}"
response = http.request(request)
puts response.read_body{}{
"success": false,
"error": "Payload too large",
"code": "REQUEST_BODY_TOO_LARGE",
"limitBytes": 4194304
}OpenAI-compatible metered chat completions
Accepts the OpenAI Chat Completions request shape. With stream=true, returns provider-native SSE without full-response buffering. Locus captures the fixed authorized charge before delivering the first byte.
curl --request POST \
--url https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"model": "<string>",
"messages": [
{}
],
"stream": false,
"stream_options": {},
"max_tokens": 2,
"max_completion_tokens": 2,
"tools": [
{}
],
"tool_choice": "<unknown>"
}
'import requests
url = "https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [{}],
"stream": False,
"stream_options": {},
"max_tokens": 2,
"max_completion_tokens": 2,
"tools": [{}],
"tool_choice": "<unknown>"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: '<string>',
messages: [{}],
stream: false,
stream_options: {},
max_tokens: 2,
max_completion_tokens: 2,
tools: [{}],
tool_choice: '<unknown>'
})
};
fetch('https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions', 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.paywithlocus.com/api/wrapped/credits/v1/chat/completions",
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([
'model' => '<string>',
'messages' => [
[
]
],
'stream' => false,
'stream_options' => [
],
'max_tokens' => 2,
'max_completion_tokens' => 2,
'tools' => [
[
]
],
'tool_choice' => '<unknown>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>"
],
]);
$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.paywithlocus.com/api/wrapped/credits/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.paywithlocus.com/api/wrapped/credits/v1/chat/completions")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paywithlocus.com/api/wrapped/credits/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {}\n ],\n \"stream\": false,\n \"stream_options\": {},\n \"max_tokens\": 2,\n \"max_completion_tokens\": 2,\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<unknown>\"\n}"
response = http.request(request)
puts response.read_body{}{
"success": false,
"error": "Payload too large",
"code": "REQUEST_BODY_TOO_LARGE",
"limitBytes": 4194304
}Authorizations
Tenant secret key (lcr_…). Server-side only.
Headers
Required only when the end-user JWT carries sid. Send the original high-entropy session value; sid is its SHA-256 fingerprint. Ignored for secret-key authentication.
16 - 128^[A-Za-z0-9][A-Za-z0-9._:-]{15,127}$One key per model request body; reuse it on an identical retry.
Case-sensitive immutable ID in the tenant namespace. Prefer an identity-provider subject, not an email address.
1 - 200^[A-Za-z0-9][A-Za-z0-9._:@/-]{0,199}$Required when this user's policy sets maxCallsPerLoop.
200Body
1x >= 1For reviewed reasoning models, an explicit value must be at least that model's recommendedMinOutputTokens (currently 4000); smaller budgets are rejected before dispatch or billing because hidden reasoning can exhaust the budget before visible output.
x >= 1Response
OpenAI JSON response, or unbuffered OpenAI SSE when stream=true
The response is of type object.