LatentKit

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.com

Authentication

Authorization: Bearer <LATENTKIT_API_KEY>
Content-Type: application/json

Route resolution

The API key's assigned published route selects provider and model execution. Request bodies do not include model, provider, route, or policy.

Two optional body fields adjust routing without naming a model:

{ "purpose": "extraction", "response_profile": "balanced" }
  • response_profile — how much effort the route spends. Values: fast, balanced, thinking.
  • purpose — which published route handles the request. The values are declared per workspace, so read yours from GET /v1/me rather than hardcoding one. An unknown purpose falls back to the assigned route instead of failing. See Purposes.

Endpoints

MethodPathPurposeDocs
GET/v1/meKey context: app, assigned route, credits, configured purposesPurposes
POST/v1/chatChat completions, tools, multimodal inputChat
POST/v1/completeSingle-prompt text completionCompletions
POST/v1/visionImage understandingVision
POST/v1/embeddingsVector embeddings (/v1/embed is an alias)Embeddings
POST/v1/imageImage generationImages
POST/v1/transcriptionAudio transcription (speech-to-text)Audio and STT
POST/v1/translationAudio translationAudio and STT
POST/v1/transcription/jobsAsync transcription jobsAudio and STT
POST/v1/speechText-to-speechSpeech
POST/v1/audioGeneric audio input/output routingAudio and STT
POST/v1/videoVideo generationVideo
POST/v1/queueAsync background jobs for any endpoint aboveQueue

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:

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();
}

Errors and limits

On this page