REST API Overview
Public /v1 runtime contract for LatentKit applications.
All public application traffic uses one base URL and one authorization header.
Base URL
https://ai.latentkit.comAuthentication
Authorization: Bearer <LATENTKIT_API_KEY>
Content-Type: application/jsonRoute resolution
The API key's assigned published route selects provider and model execution. Request bodies do not include model, provider, route, or policy.
Optional body field:
{ "response_profile": "balanced" }Values: fast, balanced, deep.
Core endpoints (V1 docs)
| Method | Path | Purpose |
|---|---|---|
POST | /v1/chat | Chat completions |
POST | /v1/embeddings | Vector embeddings |
POST | /v1/image | Image generation |
POST | /v1/complete | Text completion |
POST | /v1/vision | Vision |
POST | /v1/queue | Async queue jobs |
This documentation site covers the most common integration paths first. Additional /v1/* surfaces follow the same auth and routing model.
Response metadata
Successful responses can include route and provider metadata so you know which attempt succeeded. Failover attempts stay server-side — you receive one client response.
Correlation
Responses include X-LK-Request-ID. Log it with errors when contacting support or debugging.
SDKs
Prefer the official clients when possible:
Manual REST examples
Use REST from ecosystems without an official SDK, such as PHP, Ruby, Go, or serverless functions where you want a thin HTTP call.
const apiKey = process.env.LATENTKIT_API_KEY;
if (!apiKey) throw new Error('LATENTKIT_API_KEY is not set');
const response = await fetch('https://ai.latentkit.com/v1/chat', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
messages: [{ role: 'user', content: 'Say hello from LatentKit.' }],
response_profile: 'balanced',
}),
});
const data = await response.json();
if (!response.ok) {
console.error('LatentKit failed', {
status: response.status,
requestId: response.headers.get('X-LK-Request-ID'),
body: data,
});
throw new Error(data.error || data.code || 'latentkit_error');
}import os
import requests
response = requests.post(
"https://ai.latentkit.com/v1/chat",
headers={
"Authorization": f"Bearer {os.environ['LATENTKIT_API_KEY']}",
"Content-Type": "application/json",
},
json={
"messages": [{"role": "user", "content": "Say hello from LatentKit."}],
"response_profile": "balanced",
},
timeout=120,
)
if not response.ok:
print({
"status": response.status_code,
"request_id": response.headers.get("X-LK-Request-ID"),
"body": response.json(),
})
response.raise_for_status()$apiKey = getenv('LATENTKIT_API_KEY');
if (!$apiKey) {
throw new RuntimeException('LATENTKIT_API_KEY is not set');
}
$response = Illuminate\Support\Facades\Http::withToken($apiKey)
->acceptJson()
->post('https://ai.latentkit.com/v1/chat', [
'messages' => [
['role' => 'user', 'content' => 'Say hello from LatentKit.'],
],
'response_profile' => 'balanced',
]);
if ($response->failed()) {
logger()->warning('LatentKit failed', [
'status' => $response->status(),
'request_id' => $response->header('X-LK-Request-ID'),
'body' => $response->json(),
]);
$response->throw();
}