Skip to content

backend: distinguish platform vs BYOK errors in LLM logging #7290

Closed as not planned

Description

@beastoin

Problem

OpenAI errors in prod logs (RateLimitError, AuthenticationError, PermissionDeniedError) look identical whether they originate from our platform key or a user's BYOK key. This makes triage hard — we can't tell at a glance if it's our problem or a user's broken key.

What we see in prod today:

  • 31× RateLimitError insufficient_quota — all BYOK users with no credits
  • 5× AuthenticationError with key hint 0 — invalid BYOK key
  • 2× AuthenticationError with OpenRouter key mistakenly set as OpenAI key
  • 1× PermissionDeniedError on project proj_r5oIEByGgGNJktsG78vdQvDi — not our project

All of these log identically to platform key errors, polluting alerts and dashboards.

Root Cause

_OpenAIEmbeddingsProxy (utils/llm/clients.py:55-77) and _cached_openai_chat route to BYOK keys transparently — errors bubble up without tagging the source. There's no source=platform|byok distinction in log output.

Proposed Fix

Tag all LLM errors with source=platform|byok in the log message or structured labels so alerts and dashboards can filter. The BYOK context is already available via get_byok_key() at call time.

Code paths:

  • utils/llm/clients.py — _OpenAIEmbeddingsProxy._resolve(), _cached_openai_chat(), get_llm()
  • utils/byok.py — get_byok_key()

Impact

Without this, every BYOK user error triggers platform-level alerts, wasting on-call time investigating issues that are user-side.


by AI for @beastoin

Activity

  1. added
    bug
    p2
    on May 14, 2026
  2. beastoin commented on Jun 10, 2026

    @beastoin
    CollaboratorAuthor

    Closing as not planned per CTO directive (2026-06-10).


    by AI for @beastoin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions