Use this page when your product needs sign-in, session-backed gateway access, and more than a single chat route.Documentation Index
Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt
Use this file to discover all available pages before exploring further.
Build a signed-in Next.js workbench with OAuth and a unified AI Stats proxy.
Sample project
- GitHub: examples/oauth-client-nextjs
- Local repo path:
examples/oauth-client-nextjs
What this app covers
- OAuth 2.1 + PKCE login
- session-backed token storage and refresh
- a unified proxy for control and generation routes
- model discovery
- a chat flow over
/responses - a generic endpoint tester for other gateway routes
When to start with this example
Use this when:- end users should sign in with delegated access
- you need more than a simple chat page
- you want one secure server route for several AI Stats endpoints
- you only need a simple API-key chat UI
- you want a script or CLI first
Key files
app/page.tsxapp/dashboard/page.tsxapp/dashboard/GatewayWorkbench.tsxapp/api/gateway/[...surface]/route.tslib/oauth.tslib/session.ts
Why the sample is structured this way
1. OAuth stays separate from gateway logic
The app isolates:- auth start and callback logic
- encrypted session handling
- token refresh
2. One proxy route handles the gateway calls
The catch-all proxy route:- checks the endpoint allowlist
- injects the current bearer token
- refreshes tokens when needed
- forwards request and response bodies
3. The dashboard doubles as an internal workbench
The workbench page is not only chat:- it discovers models
- it exercises
/responses - it can test non-chat endpoints too
Run the sample
NEXT_PUBLIC_OAUTH_CLIENT_IDOAUTH_CLIENT_SECRETNEXT_PUBLIC_AISTATS_URLNEXT_PUBLIC_REDIRECT_URISESSION_SECRETNEXT_PUBLIC_GATEWAY_URL
http://localhost:3000.
How to make it your own
- trim the proxy allowlist to the endpoints your product really needs
- keep the workbench internally while building a cleaner user-facing UI on top
- swap the generic tester for purpose-built product flows once the integration stabilizes