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.
Endpoints
| Method | Path | Purpose | Docs |
|---|---|---|---|
POST | /v1/chat | Chat completions, tools, multimodal input | Chat |
POST | /v1/complete | Single-prompt text completion | Completions |
POST | /v1/vision | Image understanding | Vision |
POST | /v1/embeddings | Vector embeddings (/v1/embed is an alias) | Embeddings |
POST | /v1/image | Image generation | Images |
POST | /v1/transcription | Audio transcription (speech-to-text) | Audio and STT |
POST | /v1/translation | Audio translation | Audio and STT |
POST | /v1/transcription/jobs | Async transcription jobs | Audio and STT |
POST | /v1/speech | Text-to-speech | Speech |
POST | /v1/audio | Generic audio input/output routing | Audio and STT |
POST | /v1/video | Video generation | Video |
POST | /v1/queue | Async background jobs for any endpoint above | Queue |
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 and CLI
Prefer the official clients when possible:
- CLI — terminal login, smoke tests, logs, traces, routes, keys, and CI checks
- JavaScript SDK
- Python SDK
The SDKs are for app code. The CLI is for humans, support workflows, automation, and AI agents that need stable --json command output.
Manual REST examples
Use REST from ecosystems without an official SDK, such as Ruby or Go, or from 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'),
code: data?.error?.code ?? data?.code,
});
throw new Error(data?.error?.code ?? 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"),
"code": response.json().get("error", {}).get("code"),
})
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'),
'code' => $response->json('error.code'),
]);
$response->throw();
}