Skip to content

ai.provider().fetch() requires the provider key as a Worker secret, so it can't use AI Gateway stored keys or Unified Billing #845

Open

Description

@karthickeyan-dev

providerFetch always calls resolveProviderKey() and sends the key itself. If the secret is missing, for example GOOGLE_API_KEY for google-ai-studio, it answers 400 with ai: Missing GOOGLE_API_KEY secret. apiKeyEnv only changes which secret it reads. So an app can't let AI Gateway authenticate with a key stored in the gateway, or pay through Unified Billing.

The same path also drops init.signal: it passes only method, headers and body to fetch(), so a request can't be timed out. A Gemini call on Google's Flex tier can take up to 15 minutes, which is a queue consumer's whole time limit.

Ask:

  • An option for ai.provider().fetch() to send no provider key and let AI Gateway authenticate, as the Workers AI binding's gateway(id).run() does.
  • Pass init.signal through to fetch().

Workaround today: the app calls the binding's env.AI.gateway(id).run() directly, with inference.bindings.ai set in void.config.ts, and adds its own AbortSignal. That skips void/ai entirely.

Environment: Void 1.9.1.

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

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions