From 64339f06459b0ff940cae8bbda705371c216de39 Mon Sep 17 00:00:00 2001 From: Maxwell <145994855+ping-maxwell@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:21:29 -0700 Subject: [PATCH] docs: custom AI chat (#8523) Co-authored-by: Sandy --- .cspell/custom-words.txt | 2 +- .cspell/tech-terms.txt | 2 + docs/content/docs/concepts/api.mdx | 2 +- docs/content/docs/concepts/cli.mdx | 2 +- docs/content/docs/concepts/client.mdx | 2 +- docs/content/docs/concepts/cookies.mdx | 2 +- docs/content/docs/concepts/database.mdx | 2 +- docs/content/docs/concepts/email.mdx | 2 +- docs/content/docs/concepts/hooks.mdx | 2 +- docs/content/docs/concepts/oauth.mdx | 2 +- docs/content/docs/concepts/plugins.mdx | 2 +- docs/content/docs/concepts/rate-limit.mdx | 2 +- .../docs/concepts/session-management.mdx | 2 +- docs/content/docs/concepts/typescript.mdx | 2 +- docs/content/docs/concepts/users-accounts.mdx | 2 +- docs/content/docs/introduction.mdx | 38 +- landing/.env.example | 9 +- landing/app/api/docs/chat/route.ts | 22 +- landing/components/ai-chat.tsx | 49 +- landing/components/sidebar-content.tsx | 6 + landing/lib/ai-chat/rate-limit.ts | 46 ++ landing/lib/ai-chat/route.ts | 361 +++++++++++++ landing/package.json | 5 +- pnpm-lock.yaml | 474 ++++++------------ turbo.json | 6 +- 25 files changed, 625 insertions(+), 421 deletions(-) create mode 100644 landing/lib/ai-chat/rate-limit.ts create mode 100644 landing/lib/ai-chat/route.ts diff --git a/.cspell/custom-words.txt b/.cspell/custom-words.txt index ec455a4050..c7a994c7a1 100644 --- a/.cspell/custom-words.txt +++ b/.cspell/custom-words.txt @@ -14,4 +14,4 @@ uncompromised myapp Neue CCPA -CPRA +CPRA \ No newline at end of file diff --git a/.cspell/tech-terms.txt b/.cspell/tech-terms.txt index 0b368365d5..baa270f7c1 100644 --- a/.cspell/tech-terms.txt +++ b/.cspell/tech-terms.txt @@ -48,3 +48,5 @@ SIEM sess reactivations whsec +moonshotai +kimi \ No newline at end of file diff --git a/docs/content/docs/concepts/api.mdx b/docs/content/docs/concepts/api.mdx index e83d55c0ad..f36c85a034 100644 --- a/docs/content/docs/concepts/api.mdx +++ b/docs/content/docs/concepts/api.mdx @@ -1,6 +1,6 @@ --- title: API -description: Better Auth API. +description: Learn how to call Better Auth API endpoints on the server, pass body, headers, and query parameters, retrieve response headers, and handle errors. --- When you create a new Better Auth instance, it provides you with an `api` object. This object exposes every endpoint that exists in your Better Auth instance. And you can use this to interact with Better Auth server side. diff --git a/docs/content/docs/concepts/cli.mdx b/docs/content/docs/concepts/cli.mdx index 022eefba4d..313aa409e6 100644 --- a/docs/content/docs/concepts/cli.mdx +++ b/docs/content/docs/concepts/cli.mdx @@ -1,6 +1,6 @@ --- title: CLI -description: Built-in CLI for managing your project. +description: Learn about the Better Auth CLI commands for generating and migrating database schemas, initializing projects, generating secret keys, and gathering diagnostic info. --- Better Auth comes with a built-in CLI to help you manage the database schemas, initialize your project, generate a secret key for your application, and gather diagnostic information about your setup. diff --git a/docs/content/docs/concepts/client.mdx b/docs/content/docs/concepts/client.mdx index 975f8746ba..d2967f3fb2 100644 --- a/docs/content/docs/concepts/client.mdx +++ b/docs/content/docs/concepts/client.mdx @@ -1,6 +1,6 @@ --- title: Client -description: Better Auth client library for authentication. +description: Learn how to set up the Better Auth client for React, Vue, Svelte, and other frameworks, use hooks, configure fetch options, handle errors, and extend with client plugins. --- Better Auth offers a client library compatible with popular frontend frameworks like React, Vue, Svelte, and more. This client library includes a set of functions for interacting with the Better Auth server. Each framework's client library is built on top of a core client library that is framework-agnostic, so that all methods and hooks are consistently available across all client libraries. diff --git a/docs/content/docs/concepts/cookies.mdx b/docs/content/docs/concepts/cookies.mdx index b183baede8..617bc631c8 100644 --- a/docs/content/docs/concepts/cookies.mdx +++ b/docs/content/docs/concepts/cookies.mdx @@ -1,6 +1,6 @@ --- title: Cookies -description: Learn how cookies are used in Better Auth. +description: Learn how Better Auth uses cookies, including cookie prefixes, custom cookie attributes, cross-subdomain sharing, secure cookies, and handling Safari ITP with proxies. --- Cookies are used to store data such as session tokens, session data, OAuth state, and more. All cookies are signed using the `secret` key provided in the auth options or the `BETTER_AUTH_SECRET` environment variable. If you use [versioned secrets](/docs/reference/options#secrets) for rotation, encrypted cookie data (such as JWE session caches) will automatically use the current key and remain decryptable with previous keys. diff --git a/docs/content/docs/concepts/database.mdx b/docs/content/docs/concepts/database.mdx index 8c7e0ec9db..0b24156570 100644 --- a/docs/content/docs/concepts/database.mdx +++ b/docs/content/docs/concepts/database.mdx @@ -1,6 +1,6 @@ --- title: Database -description: Learn how to use a database with Better Auth. +description: Learn about database adapters, migrations, secondary storage with Redis, core schema (user, session, account, verification), custom tables, extending schemas, ID generation, database hooks, and plugin schemas. --- ## Adapters diff --git a/docs/content/docs/concepts/email.mdx b/docs/content/docs/concepts/email.mdx index 854c623a3d..58e4571302 100644 --- a/docs/content/docs/concepts/email.mdx +++ b/docs/content/docs/concepts/email.mdx @@ -1,6 +1,6 @@ --- title: Email -description: Learn how to use email with Better Auth. +description: Learn how to set up email verification, require verified emails for sign-in, auto sign-in after verification, handle post-verification callbacks, and implement password reset emails. --- Email is a key part of Better Auth, required for all users regardless of their authentication method. Better Auth provides email and password authentication out of the box, and a lot of utilities to help you manage email verification, password reset, and more. diff --git a/docs/content/docs/concepts/hooks.mdx b/docs/content/docs/concepts/hooks.mdx index c107f35d7a..acde7edb80 100644 --- a/docs/content/docs/concepts/hooks.mdx +++ b/docs/content/docs/concepts/hooks.mdx @@ -1,6 +1,6 @@ --- title: Hooks -description: Better Auth Hooks let you customize BetterAuth's behavior +description: Learn how to use before and after hooks to customize endpoint behavior, modify requests and responses, handle cookies, throw errors, access auth context, and run background tasks. --- Hooks in Better Auth let you "hook into" the lifecycle and execute custom logic. They provide a way to customize Better Auth's behavior without writing a full plugin. diff --git a/docs/content/docs/concepts/oauth.mdx b/docs/content/docs/concepts/oauth.mdx index 70d9e2f25c..d61e0aeacb 100644 --- a/docs/content/docs/concepts/oauth.mdx +++ b/docs/content/docs/concepts/oauth.mdx @@ -1,6 +1,6 @@ --- title: OAuth -description: How Better Auth handles OAuth +description: Learn how to configure social OAuth providers, sign in and link accounts, request scopes, pass additional data, refresh access tokens, map profiles, and customize provider options. --- Better Auth comes with built-in support for OAuth 2.0 and OpenID Connect. This allows you to authenticate users via popular OAuth providers like Google, Facebook, GitHub, and more. diff --git a/docs/content/docs/concepts/plugins.mdx b/docs/content/docs/concepts/plugins.mdx index 948bf4ca63..abeed84217 100644 --- a/docs/content/docs/concepts/plugins.mdx +++ b/docs/content/docs/concepts/plugins.mdx @@ -1,6 +1,6 @@ --- title: Plugins -description: Learn how to use plugins with Better Auth. +description: Learn how to use and create Better Auth plugins, including defining endpoints, schemas, hooks, middleware, rate limits, trusted origins, and building client plugins with custom actions and atoms. --- Plugins are a key part of Better Auth, they let you extend the base functionalities. You can use them to add new authentication methods, features, or customize behaviors. diff --git a/docs/content/docs/concepts/rate-limit.mdx b/docs/content/docs/concepts/rate-limit.mdx index 9c29f32bb9..b7c950987f 100644 --- a/docs/content/docs/concepts/rate-limit.mdx +++ b/docs/content/docs/concepts/rate-limit.mdx @@ -1,6 +1,6 @@ --- title: Rate Limit -description: How to limit the number of requests a user can make to the server in a given time period. +description: Learn how to configure rate limiting in Better Auth, including IP address detection, IPv6 support, custom rate limit windows, storage backends, error handling, and per-endpoint rules. --- Better Auth includes a built-in rate limiter to help manage traffic and prevent abuse. By default, in production mode, the rate limiter is set to: diff --git a/docs/content/docs/concepts/session-management.mdx b/docs/content/docs/concepts/session-management.mdx index 4115a53aa9..0cfdaee1eb 100644 --- a/docs/content/docs/concepts/session-management.mdx +++ b/docs/content/docs/concepts/session-management.mdx @@ -1,6 +1,6 @@ --- title: Session Management -description: Better Auth session management. +description: Learn about session management in Better Auth, including session expiration, freshness, cookie caching strategies, secondary storage, stateless sessions, and customizing session responses. --- Better Auth manages session using a traditional cookie-based session management. The session is stored in a cookie and is sent to the server on every request. The server then verifies the session and returns the user data if the session is valid. diff --git a/docs/content/docs/concepts/typescript.mdx b/docs/content/docs/concepts/typescript.mdx index b464b11381..7ccc313594 100644 --- a/docs/content/docs/concepts/typescript.mdx +++ b/docs/content/docs/concepts/typescript.mdx @@ -1,6 +1,6 @@ --- title: TypeScript -description: Better Auth TypeScript integration. +description: Learn about TypeScript configuration for Better Auth, including strict mode, inferring types for sessions and users, defining additional fields, and inferring additional fields on the client. --- Better Auth is designed to be type-safe. Both the client and server are built with TypeScript, allowing you to easily infer types. diff --git a/docs/content/docs/concepts/users-accounts.mdx b/docs/content/docs/concepts/users-accounts.mdx index 0851316bf9..af699e3204 100644 --- a/docs/content/docs/concepts/users-accounts.mdx +++ b/docs/content/docs/concepts/users-accounts.mdx @@ -1,6 +1,6 @@ --- title: User & Accounts -description: User and account management. +description: Learn how to manage users and accounts, including updating user info, changing emails and passwords, deleting users with verification, token encryption, and account linking and unlinking. --- Beyond authenticating users, Better Auth also provides a set of methods to manage users. This includes, updating user information, changing passwords, and more. diff --git a/docs/content/docs/introduction.mdx b/docs/content/docs/introduction.mdx index 68ae7c44fb..fe35d7f39b 100644 --- a/docs/content/docs/introduction.mdx +++ b/docs/content/docs/introduction.mdx @@ -35,33 +35,6 @@ Better Auth provides an MCP server so you can use it with any AI model that supp -#### CLI Options - -Use the Better Auth CLI to easily add the MCP server to your preferred client: - - - - ```bash title="terminal" - npx auth mcp --cursor - ``` - - - ```bash title="terminal" - npx auth mcp --claude-code - ``` - - - ```bash title="terminal" - npx auth mcp --open-code - ``` - - - ```bash title="terminal" - npx auth mcp --manual - ``` - - - #### Manual Configuration Alternatively, you can manually configure the MCP server for each client: @@ -69,7 +42,7 @@ Alternatively, you can manually configure the MCP server for each client: ```bash title="terminal" - claude mcp add --transport http better-auth https://mcp.inkeep.com/better-auth/mcp + claude mcp add --transport http better-auth https://context7.com/better-auth/better-auth ``` @@ -79,7 +52,7 @@ Alternatively, you can manually configure the MCP server for each client: "mcp": { "better-auth": { "type": "remote", - "url": "https://mcp.inkeep.com/better-auth/mcp", + "url": "https://context7.com/better-auth/better-auth", "enabled": true, } } @@ -90,14 +63,9 @@ Alternatively, you can manually configure the MCP server for each client: ```json title="mcp.json" { "better-auth": { - "url": "https://mcp.inkeep.com/better-auth/mcp" + "url": "https://context7.com/better-auth/better-auth" } } ``` - - -We provide a first‑party MCP, powered by [Inkeep](https://inkeep.com). You can alternatively use [`context7`](https://context7.com/) and other MCP providers. - - diff --git a/landing/.env.example b/landing/.env.example index 9abf53a3f2..dc3a99420e 100644 --- a/landing/.env.example +++ b/landing/.env.example @@ -1,8 +1,12 @@ # GitHub API - community stats GITHUB_TOKEN= -# Inkeep API - AI chat -INKEEP_API_KEY= +# Openrouter API - docs AI chat +OPENROUTER_API_KEY= + +# Upstash Redis - AI chat rate limiting +UPSTASH_REDIS_REST_URL= +UPSTASH_REDIS_REST_TOKEN= # Typesense - Docs search NEXT_PUBLIC_TYPESENSE_SERVER_URL= @@ -11,3 +15,4 @@ TYPESENSE_ADMIN_API_KEY= # Next.js - public URL NEXT_PUBLIC_URL=http://localhost:3000 + diff --git a/landing/app/api/docs/chat/route.ts b/landing/app/api/docs/chat/route.ts index b3bcd63189..e0ea8b3f56 100644 --- a/landing/app/api/docs/chat/route.ts +++ b/landing/app/api/docs/chat/route.ts @@ -1,21 +1 @@ -import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; -import { convertToModelMessages, streamText } from "ai"; - -const inkeep = createOpenAICompatible({ - name: "inkeep", - baseURL: "https://api.inkeep.com/v1", - apiKey: process.env.INKEEP_API_KEY, -}); - -export async function POST(req: Request) { - const { messages } = await req.json(); - - const result = streamText({ - model: inkeep.chatModel("inkeep-qa-expert"), - messages: await convertToModelMessages(messages, { - ignoreIncompleteToolCalls: true, - }), - }); - - return result.toUIMessageStreamResponse(); -} +export { POST } from "@/lib/ai-chat/route"; diff --git a/landing/components/ai-chat.tsx b/landing/components/ai-chat.tsx index 6319ed7905..4b9d086a3c 100644 --- a/landing/components/ai-chat.tsx +++ b/landing/components/ai-chat.tsx @@ -183,15 +183,7 @@ function MobileDrawerPanel() {
AI Chat - Powered by{" "} - - Inkeep AI - + Better Auth docs assistant

AI Chat

- Powered by{" "} - - Inkeep AI - + Better Auth docs assistant