Skip to content

Add "Sign in with AI/ML API" OAuth flow - #4

Merged
Lookoff-AIMLAPI merged 1 commit into
mainfrom
add-aimlapi-oauth
Aug 25, 2026
Merged

Add "Sign in with AI/ML API" OAuth flow#4
Lookoff-AIMLAPI merged 1 commit into
mainfrom
add-aimlapi-oauth

Conversation

@Lookoff-AIMLAPI

Copy link
Copy Markdown
Member

Summary

Adds an OAuth-style login to the `aimlapi` provider, alongside the existing `AIMLAPI_API_KEY` env-var auth — matching how `openrouterProvider()` exposes both.

Unlike OpenRouter's PKCE browser-redirect flow, AI/ML API's login is a terminal-native email + one-time-code exchange (no browser or loopback server needed):

  1. Prompt for an email, check whether it's a new or existing account.
  2. Existing account: send a 6-digit code, prompt for it, verify → session token. (An account linked to a third-party sign-in provider is rejected with a pointer to the dashboard instead.)
  3. New account: create a passwordless account directly → session token.
  4. Mint a permanent API key labeled "pi CLI" and wrap it as an `oauth` credential the same way OpenRouter's key exchange already is in this codebase (permanent key, not an expiring access/refresh pair).

Test plan

  • New `aimlapi-oauth.test.ts` (7 cases: sign-in, sign-up, third-party-provider rejection, bad code, missing key in response, empty email) — all pass.
  • Full `packages/ai` suite (956 passed) — no regressions.
  • `tsgo --noEmit` clean.

Unlike OpenRouter's PKCE browser-redirect flow, AI/ML API's login is a
terminal-native email + one-time-code exchange: resolve whether the email
signs in or signs up, collect a verification code for an existing account
(or create a new passwordless account directly), exchange it for a session
token, then mint a permanent API key scoped to this login ("pi CLI"). The
result is wrapped as an "oauth" credential the same way OpenRouter's key
exchange already is in this codebase — a permanent key, not an expiring
access/refresh pair.

Exposed alongside the existing AIMLAPI_API_KEY auth, matching the
openrouterProvider() pattern.
@Lookoff-AIMLAPI
Lookoff-AIMLAPI merged commit 3c140ee into main Aug 25, 2026
3 checks passed
@Lookoff-AIMLAPI
Lookoff-AIMLAPI deleted the add-aimlapi-oauth branch August 25, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant