LatentKit

Troubleshooting

Common integration issues and how to fix them.

401 missing or 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 all_providers_exhausted

  • The assigned route has no eligible model for the requested capability or response_profile
  • Open AI Router or Routes to verify provider connections and model coverage
  • Try a simpler request (plain chat without tools) to isolate capability mismatch

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

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 config/services.php maps latentkit.key to env('LATENTKIT_API_KEY')
  • Clear cached config after changing env values: php artisan config:clear
  • Log $response->header('X-LK-Request-ID') when a REST request fails

Python server hangs or leaks clients

  • Use with LatentKit(...) or async 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 LatentKitAPIError and log exc.status_code, exc.code, and exc.request_id

Still stuck?

  1. Capture X-LK-Request-ID from the failing response
  2. Compare your payload with Chat examples
  3. Test the same key from AI Router in the console

On this page