Troubleshooting
Common integration issues and how to fix them.
401 INVALID_API_KEY
- Confirm
Authorization: Bearer <key>— no typos or extra quotes - Verify the key is active and not revoked in the console
- Ensure the key is assigned a published route
503 NO_HEALTHY_PROVIDER
- The assigned route has no eligible model for the requested capability or
response_profile - Open AI Providers to verify provider connection health, and Routes to check model coverage for the endpoint
- Try a simpler request (plain chat without tools) to isolate capability mismatch
- Remember that vision, tools, audio, and video each require their own model capability on the route — see the capability matrix in Models & providers
INSUFFICIENT_CREDITS or free managed limit reached
- Add credits or switch the route to BYOK
- Free workspaces may have managed onboarding caps for chat, image, and embeddings
Stream ends with event: error
- Parse the SSE error payload — see Error handling
- Check credits, route eligibility, and guardrail settings
SDK rejects model or provider fields
Expected behavior. Remove model, provider, route, and policy from SDK calls.
CLI says Not authenticated
Run one of:
latentkit loginor:
export LATENTKIT_API_KEY="lk-..."For CI and AI agents, prefer LATENTKIT_API_KEY. For humans, latentkit login opens the browser approval flow.
CLI says Missing --tenant <workspace-id>
Logs, traces, usage, costs, providers, routes, keys, and connections are workspace-scoped commands. Pass your workspace id:
latentkit logs --tenant t_123 --days 1Use latentkit whoami --json and latentkit apps --json to inspect the account/app context.
CLI whoami shows Account : (unknown)
Your login may still be valid, but the current session does not include the account context needed by that command.
- Update the CLI to the latest version.
- Run
latentkit logout, thenlatentkit loginagain. - Confirm that the expected workspace app is selected with
latentkit apps. - If the account is still unknown, contact support and include the CLI version; do not send the local profile file or access token.
Browser build exposes or cannot read the key
- Do not use
NEXT_PUBLIC_LATENTKIT_API_KEY,VITE_LATENTKIT_API_KEY, or frontend env prefixes for secrets - Move the LatentKit call into a backend route, server action, serverless function, Laravel controller, FastAPI route, or similar server-side layer
- The browser should call your app endpoint, for example
/api/chat
PHP/Laravel request fails
- Confirm
LATENTKIT_API_KEYis present in the server environment; the package reads it throughconfig/latentkit.php - Clear and rebuild cached configuration after changing environment values:
php artisan config:clear && php artisan config:cache - Run
php artisan latentkit:checkto inspect the connected app, route, credits, and latest request without printing the key - Log the normalized exception request ID when a direct SDK or Laravel AI request fails; do not log provider response bodies
Python server hangs or leaks clients
- Use
with LatentKit(...)orasync with AsyncLatentKit(...)so the underlying HTTP client closes cleanly - Set a request timeout at your framework boundary if the request can be user-triggered
- Catch
LatentKitAPIErrorand logexc.status_code,exc.code, andexc.request_id
Console analytics show different totals
- Match the workspace, API key and selected range. Usage charts/history are workspace-wide; its Headline metrics selector only narrows requests, spend and tokens. A key Overview covers that key's traffic.
- Requests count completed calls; Recent Requests also includes errors. Upstream fallback attempts are separate trace steps, not extra customer requests. Purpose usage excludes calls without a purpose, and degraded attempts can include errors.
- 24h is a rolling window. 7d/30d use UTC calendar days; charts use UTC while request timestamps use your local timezone. Data outside retention is unavailable.
- BYOK spend is an estimate paid to your provider; Platform Access customer charges deduct LatentKit credits. Provider cost estimates and customer charges are different measurements.
- If provider cost was not recorded, the chart reports unavailable coverage rather than claiming zero cost. Partial charts show recorded estimates only; a missing latency sample is a gap.
- Recent Requests starts with 10 rows. Use Load more for older rows, or Refresh requests for a new snapshot. Filters search the full selected range, and a loading failure offers Retry.
Still stuck?
- Capture
X-LK-Request-IDfrom the failing response - Compare your payload with Chat examples
- Test the same key from Playground in the console