Sign in with Utopixel
Let users sign in with their own Utopixel account and give your app a key that spends their balance. OAuth with PKCE, compatible with OpenRouter's flow.
Let your users bring their own Utopixel account: they approve your app once, you get an API key that spends their balance, and you never handle their billing. The flow is OAuth with PKCE and follows OpenRouter's, so code written for OpenRouter's flow works by changing the domain.
- Send the user to
https://utopixel.online/authwithcallback_url,code_challenge(base64url SHA-256 of yourcode_verifier) andcode_challenge_method=S256. - The user signs in, picks a workspace, can set a spending limit and expiry, and approves. We redirect to your
callback_urlwithcode(and yourstate). On deny we redirect witherror=access_denied. - Exchange the code within 10 minutes:
POST /api/v1/auth/keyswithcode,code_verifierandcode_challenge_method. The response JSON has akeyfield holding the newsk-vb-...key. Each code works once. The endpoint allows browser requests (CORS).
1// 1. PKCE: keep the verifier in the user's session, never in a URL2 const verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));3 const challenge = base64url(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier))));4 location.href = `https://utopixel.online/auth?callback_url=${encodeURIComponent("https://yourapp.com/callback")}` +5 `&code_challenge=${challenge}&code_challenge_method=S256&key_label=Your%20App&limit=10`;67 // 2. On /callback: exchange the one-time code for a key8 const res = await fetch("https://utopixel.online/api/v1/auth/keys", {9 method: "POST",10 headers: { "Content-Type": "application/json" },11 body: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: "S256" }),12 });13 const { key } = await res.json(); // sk-vb-..., spends the user's balance
Optional parameters: key_label (key name), limit (USD, up to two decimals), expiration (1-hour, 1-day, 7-days, 30-days, 90-days, 180-days, 1-year, never), state, workspace_id and required_workspace_id. The user can change the label, limit and expiry before approving. callback_url must be https, or http on localhost. Headless mode (no callback) is not supported.
Errors: 400 when code_challenge_method is not S256, 403 for an invalid code or verifier, 403 for an expired code. Users see the key, marked with your app's host, on their API keys page and can revoke it any time.