Skip to content

Generalize apiKeyOptional across custom provider kinds #110

Description

@wch

Context

#109 added apiKeyOptional: true for custom Anthropic entries only. The anthropic-only scoping was deliberate — it's the only additional kind with wire-level anonymous support — but it introduces per-kind special cases that would disappear if the option were general:

  • schema.ts: the field is bolted onto the anthropic variant via .extend() instead of living in the shared customProviderVariantSchema factory; fragments may carry it for any kind but only anthropic survives merged validation.
  • resolve-catalog.ts: resolveAuthPolicies needs the entry.type === "anthropic" ? entry.apiKeyOptional : undefined conditional.

Generalizing would remove those, but most of #109's bulk is scoping-independent and stays: ResolvedCustomAuthPolicy + provenance resolution, the CUSTOM_KIND_API_KEY_OPTIONAL_DEFAULT mirror + shape guard, the watcher classification, and the wire-level client handling.

What generalizing requires

The per-kind work relocates rather than vanishes: each newly-supported kind needs its own anonymous-mode wire handling (the Anthropic sentinel/header-strip exists because the SDK falls back to ANTHROPIC_API_KEY; the OpenAI SDK has the same OPENAI_API_KEY fallback problem), plus wire-level tests proving no auth header or ambient env var leaks. Kinds already key-optional by default (openai-compatible, litellm, portkey) would treat the field as redundant-but-harmless.

Why do it

Not urgent — file for future consideration.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions