### Install and Run Vite Example Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/examples/vite/README.md Installs project dependencies using Bun and starts the development server for the Vite example. ```bash bun install bun run dev ``` -------------------------------- ### Quick Start Echo Project Setup (Bash) Source: https://github.com/merit-systems/echo/blob/master/README.md Use this command to quickly create a new application with Echo pre-configured. This streamlines the initial setup process. ```bash pnpx echo-start@latest ``` -------------------------------- ### Set Up Local Database Source: https://github.com/merit-systems/echo/blob/master/templates/nextjs-api-key-template/README.md Copy the example environment file, update it with your configuration, and run the database setup script. ```bash # Copy the example environment file cp env.example .env # Update .env with your configuration # Run the database setup script ./setup-db.sh ``` -------------------------------- ### Install Dependencies and Run Development Server (Bash) Source: https://github.com/merit-systems/echo/blob/master/README.md After filling out environment variables in `.env` files, use these commands to install project dependencies and start the development server. ```bash pnpm i pnpm dev ``` -------------------------------- ### Install Echo CLI with bun Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Use bun to install the Echo CLI globally to start a new project. ```bash bunx echo-start@latest --template ``` -------------------------------- ### Install Echo Template via CLI Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Use the echo-start CLI to quickly set up a new AI application template. You will be prompted for your Echo App ID during setup. ```bash npx echo-start@latest --template ``` -------------------------------- ### Install @merit-systems/ai-x402 with bun Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/x402/index.mdx Install the x402 SDK package using bun. ```bash bun add @merit-systems/ai-x402 ``` -------------------------------- ### Install Echo CLI with pnpm Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Use pnpm to install the Echo CLI globally to start a new project. ```bash pnpx echo-start@latest --template ``` -------------------------------- ### Install @merit-systems/ai-x402 with npm Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/x402/index.mdx Install the x402 SDK package using npm. ```bash npm install @merit-systems/ai-x402 ``` -------------------------------- ### Install Echo CLI with yarn Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Use yarn to install the Echo CLI globally to start a new project. ```bash yarn dlx echo-start@latest --template ``` -------------------------------- ### Install @merit-systems/ai-x402 with yarn Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/x402/index.mdx Install the x402 SDK package using yarn. ```bash yarn add @merit-systems/ai-x402 ``` -------------------------------- ### Install @merit-systems/ai-x402 with pnpm Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/x402/index.mdx Install the x402 SDK package using pnpm. ```bash pnpm add @merit-systems/ai-x402 ``` -------------------------------- ### Install Vercel AI SDK Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/next-js.mdx Install the Vercel AI SDK, which Echo integrates with. ```sh npm i ai ``` ```sh yarn add ai ``` ```sh pnpm add ai ``` ```sh bun add ai ``` -------------------------------- ### Start Production Server Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/README.md Starts the production-ready Next.js application. This command should be used after building the application. ```bash pnpm start ``` -------------------------------- ### Install Next.js API Key Management Echo Template Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Deploy a Next.js application for server-side API key management with database integration using Prisma. Includes Docker setup for local development. ```bash npx echo-start@latest --template nextjs-api-key-template ``` -------------------------------- ### Install Echo Next.js SDK Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/next/README.md Install the Echo Next.js SDK using pnpm. ```bash pnpm install @merit-systems/echo-next-sdk ``` -------------------------------- ### Basic Setup Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/client.mdx Instantiate the EchoClient with your API key. ```APIDOC ## Basic Setup Instantiate the `EchoClient` with your API key. ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; const echo = new EchoClient({ apiKey: 'your-api-key', }); ``` ``` -------------------------------- ### Start Development Server Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/README.md Starts the Next.js development server. The application will be accessible at http://localhost:3000. ```bash pnpm run dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/merit-systems/echo/blob/master/templates/assistant-ui/README.md Install the necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Echo TypeScript SDK with bun Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/index.mdx Install the Echo TypeScript SDK using bun. ```bash bun add @merit-systems/echo-typescript-sdk ``` -------------------------------- ### Setup Test Environment Source: https://github.com/merit-systems/echo/blob/master/packages/tests/integration/README.md Execute this command to set up the necessary test environment. ```bash pnpm env:setup ``` -------------------------------- ### Install Echo React SDK Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/react/README.md Install the Echo React SDK using pnpm. ```bash pnpm install @merit-systems/echo-react-sdk ``` -------------------------------- ### Global Installation of Echodex CLI Source: https://github.com/merit-systems/echo/blob/master/templates/echo-cli/README.md Optionally, link the Echodex CLI globally for system-wide access. Alternatively, use it directly via pnpm start. ```bash pnpm link --global ``` ```bash pnpm start ``` -------------------------------- ### Install Echo SDKs Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/cli.mdx Install the necessary SDKs for Echo, AI, and user input handling using your preferred package manager. ```sh npm i @merit-systems/echo-typescript-sdk ai enquirer open ``` ```sh yarn add @merit-systems/echo-typescript-sdk ai enquirer open ``` ```sh pnpm add @merit-systems/echo-typescript-sdk ai enquirer open ``` ```sh bun add @merit-systems/echo-typescript-sdk ai enquirer open ``` -------------------------------- ### Run Development Server Source: https://github.com/merit-systems/echo/blob/master/templates/assistant-ui/README.md Start the development server to view the application locally. Access it via http://localhost:3000. ```bash npm run dev ``` -------------------------------- ### Setup Echo Client Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/EXAMPLES.md Initialize the EchoClient with your API key and base URL. ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; const echo = new EchoClient({ apiKey: 'your-api-key-here', baseUrl: 'https://echo.merit.systems', }); ``` -------------------------------- ### Install Echo Next SDK Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/next-js.mdx Install the Echo Next SDK using your preferred package manager. ```sh npm i @merit-systems/echo-next-sdk ``` ```sh yarn add @merit-systems/echo-next-sdk ``` ```sh pnpm add @merit-systems/echo-next-sdk ``` ```sh bun add @merit-systems/echo-next-sdk ``` -------------------------------- ### Quick Start: Create OpenAI Provider with x402 Payment Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/x402/index.mdx Initialize an OpenAI provider with automatic x402 payment handling using a wallet client created via Coinbase Developer Platform. This setup is compatible with the Vercel AI SDK. ```typescript import { createX402OpenAI } from '@merit-systems/ai-x402'; import { generateText } from 'ai'; import { CdpClient } from '@coinbase/cdp-sdk'; import { toAccount } from 'viem/accounts'; // Create wallet using Coinbase Developer Platform const cdp = new CdpClient({ apiKeyId: process.env.CDP_API_KEY_ID, apiKeySecret: process.env.CDP_API_KEY_SECRET, walletSecret: process.env.CDP_WALLET_SECRET, }); const account = await cdp.evm.getOrCreateAccount({ name: process.env.CDP_WALLET_OWNER, }); const walletClient = toAccount(account); // Create OpenAI provider with automatic x402 payment handling const openai = createX402OpenAI(walletClient); // Use with Vercel AI SDK const { text } = await generateText({ model: openai('gpt-4o'), prompt: 'Hello world' }); ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/merit-systems/echo/blob/master/templates/assistant-ui/README.md Copy the example environment file and configure your Echo App ID. This is required for the application to connect to Echo. ```bash cp .env.example .env.local ``` ```dotenv NEXT_PUBLIC_ECHO_APP_ID=your-echo-app-id ``` -------------------------------- ### Install Echo React SDK and AI SDK (bun) Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/react.mdx Install the Echo React SDK and the Vercel AI SDK using bun. ```sh bun add @merit-systems/echo-react-sdk ai ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/merit-systems/echo/blob/master/templates/next-chat/README.md Clone the project repository and install the necessary dependencies using pnpm. ```bash git clone cd my-next-ai-app ``` ```bash pnpm install ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/README.md Installs all necessary project dependencies using pnpm. Ensure Node.js 18+ and pnpm are installed. ```bash pnpm install ``` -------------------------------- ### Install Echo SDK for Next.js Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/next-sdk/index.mdx Install the Echo SDK and the AI package using npm, pnpm, yarn, or bun. ```bash npm install @merit-systems/echo-next-sdk ai ``` ```bash pnpm add @merit-systems/echo-next-sdk ai ``` ```bash yarn add @merit-systems/echo-next-sdk ai ``` ```bash bun add @merit-systems/echo-next-sdk ai ``` -------------------------------- ### Start Development Servers Source: https://github.com/merit-systems/echo/blob/master/CONTRIBUTING.md Start both the Echo Control Plane and Echo Server development servers from the root directory. ```bash pnpm dev ``` -------------------------------- ### Install Echo React SDK and OpenAI Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/react-sdk/index.mdx Install the Echo React SDK and the openai package using npm, pnpm, yarn, or bun. ```bash npm install @merit-systems/echo-react-sdk openai ``` ```bash pnpm add @merit-systems/echo-react-sdk openai ``` ```bash yarn add @merit-systems/echo-react-sdk openai ``` ```bash bun add @merit-systems/echo-react-sdk openai ``` -------------------------------- ### Install Required Shadcn Base Components Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/installation.mdx Install the necessary base components from Shadcn that Echo Components depend on. ```bash npx shadcn@latest add popover npx shadcn@latest add skeleton npx shadcn@latest add avatar npx shadcn@latest add input npx shadcn@latest add tooltip ``` -------------------------------- ### Install Echo SDK for React Projects Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/installation.mdx Install the Echo SDK for React projects using npm. ```bash npm install @merit-systems/echo-react-sdk ``` -------------------------------- ### Install Echo TypeScript SDK with npm Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/index.mdx Install the Echo TypeScript SDK using npm. ```bash npm install @merit-systems/echo-typescript-sdk ``` -------------------------------- ### Install Echo TypeScript SDK with yarn Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/index.mdx Install the Echo TypeScript SDK using yarn. ```bash yarn add @merit-systems/echo-typescript-sdk ``` -------------------------------- ### Install Echo React SDK and AI SDK (pnpm) Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/react.mdx Install the Echo React SDK and the Vercel AI SDK using pnpm. ```sh pnpm add @merit-systems/echo-react-sdk ai ``` -------------------------------- ### Install Echo TypeScript SDK with pnpm Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/index.mdx Install the Echo TypeScript SDK using pnpm. ```bash pnpm add @merit-systems/echo-typescript-sdk ``` -------------------------------- ### Install Echo React SDK and AI SDK (npm) Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/react.mdx Install the Echo React SDK and the Vercel AI SDK using npm. ```sh npm i @merit-systems/echo-react-sdk ai ``` -------------------------------- ### Install Echo SDK for Next.js Projects Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/installation.mdx Install the Echo SDK for Next.js projects using npm. ```bash npm install @merit-systems/echo-next-sdk ``` -------------------------------- ### Install Echo React SDK and AI SDK (yarn) Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/react.mdx Install the Echo React SDK and the Vercel AI SDK using yarn. ```sh yarn add @merit-systems/echo-react-sdk ai ``` -------------------------------- ### Server Setup for Echo SDK Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/next/README.md Initialize the Echo instance in your server code, exporting necessary handlers and utilities. ```typescript // src/echo/index.ts import Echo from '@merit-systems/echo-next-sdk'; export const { // Echo Auth Routes handlers, // Server-side utilities getUser, isSignedIn, getEchoToken, // AI Providers openai, anthropic, google, } = Echo({ appId: process.env.NEXT_PUBLIC_ECHO_APP_ID!, }); ``` -------------------------------- ### Example CI Test Execution Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/test-validation.md An example of how to run tests within a CI/CD environment, specifically for GitHub Actions. ```yaml # Example GitHub Actions - name: Run tests run: npm run test:ci ``` -------------------------------- ### Chat Completions Go Example Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/raw-proxy.mdx Provides an example of making a chat completions request using Go's standard http library. JSON payload and headers must be correctly formatted. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://echo.router.merit.systems/v1/chat/completions" payload := map[string]interface{}{ "model": "gpt-4", "messages": []map[string]string{ {"role": "user", "content": "Hello!"}, }, } jsonData, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData)) req.Header.Set("Authorization", "Bearer your_echo_api_key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println(result) } ``` -------------------------------- ### Install Full Echo Components Registry Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/ui-components.mdx Command to install all Echo UI components at once using the Shadcn CLI. This command adds the entire registry to your project. ```bash npx shadcn@latest add https://echo-components.com/r/echo-account-react.json ``` -------------------------------- ### Echo React SDK Setup Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/react/README.md Wrap your application with EchoProvider and add sign-in and authentication state hooks. ```tsx import { EchoProvider, EchoSignIn, useEcho } from '@merit-systems/echo-react-sdk'; // 1. Wrap your app // 2. Add sign-in console.log(user)} /> // 3. Use authentication state const { user, balance, isAuthenticated, signOut } = useEcho(); ``` -------------------------------- ### Install Individual Echo Components Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/ui-components.mdx Command to install specific Echo UI components using the Shadcn CLI. Replace component names with the desired components from the registry. ```bash npx shadcn@latest add https://echo-components.com/r/echo-button.json npx shadcn@latest add https://echo-components.com/r/money-input.json npx shadcn@latest add https://echo-components.com/r/logo.json ``` -------------------------------- ### Initialize EchoClient Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/client.mdx Instantiate the EchoClient with your API key for basic setup. ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; const echo = new EchoClient({ apiKey: 'your-api-key', }); ``` -------------------------------- ### Run Database Migrations Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/README.md Generates the Prisma client and applies database schema changes. This is required before starting the development server. ```bash npx prisma generate npx prisma db push ``` -------------------------------- ### Check Sign-in Status and Get User Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/next-sdk/server.mdx Use `isSignedIn` to check if a user is authenticated and `getUser` to retrieve user data. This example demonstrates a common pattern for protecting routes and rendering user-specific content. ```typescript import { getUser, isSignedIn } from "@/echo"; export default async function Page() { const signedIn = await isSignedIn(); if (!signedIn) { return ; } else { const user = await getUser(); return ; } } ``` -------------------------------- ### Verify Project Dependencies Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/test-validation.md Lists the top-level dependencies installed in the project. ```bash npm list --depth=0 ``` -------------------------------- ### Create New Project with Assistant UI Template Source: https://github.com/merit-systems/echo/blob/master/templates/assistant-ui/README.md Use the Echo CLI to initialize a new project with the assistant-ui template. You will be prompted for your Echo App ID. ```bash npx echo-start@latest --template assistant-ui ``` -------------------------------- ### EchoProvider Setup Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/react-sdk/provider.mdx Wrap your application with EchoProvider to manage authentication state. Configure it with your Echo app ID. ```tsx import { EchoProvider } from '@merit-systems/echo-react-sdk'; function App() { return ( ); } ``` -------------------------------- ### Initialize EchoClient and Get Balance Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/README.md Initialize the EchoClient with an API key or use stored credentials. Then, retrieve the account balance. ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; // Initialize with API key const client = new EchoClient({ apiKey: 'echo_your_api_key_here', }); // Or use stored credentials from CLI const client = new EchoClient(); // Get account balance const balance = await client.getBalance(); console.log(`Balance: $${balance.balance}`); ``` -------------------------------- ### Create New Project with Echo Template Source: https://github.com/merit-systems/echo/blob/master/templates/next-video-template/README.md Use the Echo CLI to initialize a new project with the next-video-template. You will be prompted for your Echo App ID. ```bash npx echo-start@latest --template next-video-template ``` -------------------------------- ### Get User Info Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx Get authenticated user profile information. ```APIDOC ## Get User Info ### Description Get authenticated user profile information. ### Method GET ### Endpoint /api/v1/user ### Authentication API key or JWT token required ### Response #### Success Response (200) - **id** (string) - User ID - **email** (string) - User email address - **name** (string | null) - User's full name - **createdAt** (string) - Timestamp of user creation - **updatedAt** (string) - Timestamp of last user update - **totalPaid** (number) - Total amount paid by the user - **totalSpent** (number) - Total amount spent by the user ``` -------------------------------- ### Complete Platform Operations Example Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/typescript-sdk/resources.mdx Demonstrates a full platform operation flow including checking user info and balance, creating a payment link if needed, and listing available models and apps. Ensure your ECHO_API_KEY is set in the environment variables. ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; const echo = new EchoClient({ apiKey: process.env.ECHO_API_KEY }); async function platformDemo() { // Check user and balance const user = await echo.users.getUserInfo(); const balance = await echo.balance.getBalance(); console.log(`User: ${user.email}, Balance: $${balance.balance}`); // Create payment link if balance is low if (balance.balance < 5) { const payment = await echo.payments.createPaymentLink({ amount: 20, description: 'Account Top-up', }); console.log(`Payment link: ${payment.url}`); } // List available models const chatModels = await echo.models.listSupportedChatModels(); const imageModels = await echo.models.listSupportedImageModels(); console.log(`Available chat models: ${chatModels.length}`); console.log(`Available image models: ${imageModels.length}`); // Get app information const apps = await echo.apps.listEchoApps(); console.log(`Your apps: ${apps.length}`); } ``` -------------------------------- ### Get User Balance Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx Get authenticated user's credit balance. ```APIDOC ## Get User Balance ### Description Get authenticated user's credit balance. ### Method GET ### Endpoint /api/v1/balance ### Authentication API key or JWT token required ### Parameters #### Query Parameters - **echoAppId** (UUID, optional) - Get app-specific balance instead of global ### Response #### Success Response (200) - [Response details depend on the balance object structure] ``` -------------------------------- ### Get App Details Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx Get detailed app information for programmatic access. ```APIDOC ## Get App Details ### Description Get detailed app information for programmatic access. ### Method GET ### Endpoint /api/v1/apps/{id} ### Authentication API key or JWT token required ### Parameters #### Path Parameters - **id** (UUID) - Required - App ID ### Response #### Success Response (200) - [Response details depend on the App object structure] ``` -------------------------------- ### Run React Development Server Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/react.mdx Start your React project using npm, yarn, pnpm, or bun. Visit http://localhost:5173 to see your application. ```sh npm run dev ``` ```sh yarn dev ``` ```sh pnpm dev ``` ```sh bun dev ``` -------------------------------- ### Set Up Local Database Source: https://github.com/merit-systems/echo/blob/master/CONTRIBUTING.md Set up the PostgreSQL database for Echo Control locally. This can be done via a script or manually using Prisma commands. ```bash cd packages/app/control ./setup-db.sh ``` ```bash npx prisma generate npx prisma db push ``` -------------------------------- ### Get Supported Models Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx Get list of supported AI models with pricing information. ```APIDOC ## Get Supported Models ### Description Get list of supported AI models with pricing information. ### Method GET ### Endpoint /api/v1/supported-models ### Authentication None required ### Response #### Success Response (200) - **models** (Array) - List of supported AI models - **models_by_provider** (Record) - Models grouped by provider **SupportedModel Interface:** ```typescript interface SupportedModel { id: string; name: string; provider: string; inputPrice: number; outputPrice: number; contextLength: number; } ``` ``` -------------------------------- ### Basic EchoProvider Setup Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/react/src/stories/Introduction.mdx Wrap your application with EchoProvider to manage authentication state and configuration. Ensure you provide your Echo instance ID and server URL. ```tsx import { EchoProvider } from '@merit-systems/echo-react-sdk'; function App() { return ( {/* Your app components */} ); } ``` -------------------------------- ### Verify Echo Component Installation Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/installation.mdx Add the EchoAccount component to your app to verify a successful installation. ```tsx import { EchoAccount } from '@/components/echo-account-react'; export default function MyApp() { return (

My Echo App

); } ``` -------------------------------- ### Create Project with AuthJS Template Source: https://github.com/merit-systems/echo/blob/master/templates/authjs/README.md Use the Echo CLI to initialize a new project with the AuthJS template. You will be prompted for your Echo App ID. ```bash npx echo-start@latest --template authjs ``` -------------------------------- ### Install Vite React Echo Template Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Initialize a Vite-powered React application with Echo's client-side SDK. This template does not require a backend for AI calls. ```bash npx echo-start@latest --template vite ``` -------------------------------- ### Get Free Tier Balance Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx Get user's free tier spending information for a specific app. ```APIDOC ## Get Free Tier Balance ### Description Get user's free tier spending information for a specific app. ### Method POST ### Endpoint /api/v1/balance/{appId}/free ### Authentication API key or JWT token required ### Response #### Success Response (200) - **spendPoolBalance** (number) - Remaining free tier balance - **userSpendInfo** (UserSpendInfo) - User's spending information ``` -------------------------------- ### Get Supported Models Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx GET request to retrieve a list of supported AI models and their pricing information. No authentication required. ```http GET /api/v1/supported-models ``` -------------------------------- ### Initialize Shadcn CLI Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/installation.mdx Run this command to initialize Shadcn in your project if you haven't already. ```bash npx shadcn@latest init ``` -------------------------------- ### Environment Setup with .env Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/EXAMPLES.md Configure the Echo client using environment variables by creating a `.env` file. The client will automatically pick up `ECHO_API_KEY` and `ECHO_BASE_URL`. ```bash ECHO_API_KEY=your_api_key_here ECHO_BASE_URL=https://echo.merit.systems ``` -------------------------------- ### Seed Test Database Source: https://github.com/merit-systems/echo/blob/master/packages/tests/integration/README.md Run this command to populate the test database with initial data. ```bash pnpm db:seed ``` -------------------------------- ### Get User Info Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx GET request to retrieve the authenticated user's profile information. Requires API key or JWT token. ```http GET /api/v1/user ``` -------------------------------- ### Get App Information Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx GET request to retrieve detailed app information using its ID. Requires API key or JWT token. ```http GET /api/v1/apps/{id} ``` -------------------------------- ### EchoClient Initialization Source: https://context7.com/merit-systems/echo/llms.txt Demonstrates how to initialize the EchoClient using either an API key for server-side authentication or a custom token provider for OAuth flows. ```APIDOC ## EchoClient Initialization ### Description Initialize the `EchoClient` for interacting with the Echo API. Supports API key authentication for server-side applications and custom token providers for OAuth flows. ### Usage ```typescript import { EchoClient } from '@merit-systems/echo-typescript-sdk'; // API key authentication (server-side / scripts) const client = new EchoClient({ apiKey: process.env.ECHO_API_KEY!, baseUrl: 'https://echo.merit.systems', // optional, this is the default }); // Custom token provider (e.g. OAuth flow) import { OAuthTokenProvider } from '@merit-systems/echo-typescript-sdk'; const tokenProvider = new OAuthTokenProvider({ getTokenFn: () => Promise.resolve(myOAuthLib.getAccessToken()), refreshTokenFn: async () => { const newUser = await myOAuthLib.signinSilent(); return newUser.access_token; }, onRefreshErrorFn: (error) => { console.error('Token refresh failed:', error); myOAuthLib.signout(); }, }); const client = new EchoClient({ tokenProvider }); ``` ``` -------------------------------- ### Create Project with Echo Next.js Template Source: https://github.com/merit-systems/echo/blob/master/templates/next-image/README.md Use the Echo CLI to initialize a new project with the next-image template. You will be prompted for your Echo App ID. ```bash npx echo-start@latest --template next-image ``` -------------------------------- ### Install Echo Account Component for Next.js Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/index.mdx Use this command to install the Echo Account component optimized for Next.js applications. It includes support for server-side rendering. ```bash pnpm dlx shadcn@latest add https://echo-components.com/r/echo-account-next.json ``` -------------------------------- ### REST API: Get Balance Source: https://context7.com/merit-systems/echo/llms.txt Retrieve the user's balance information using a GET request to `/api/v1/balance`. Requires an `Authorization` header with your Bearer token. ```bash curl https://echo.merit.systems/api/v1/balance \ -H "Authorization: Bearer echo_YOUR_API_KEY" # {"totalPaid":100.0,"totalSpent":42.50,"balance":57.50,"currency":"USD"} ``` -------------------------------- ### Create Assistant UI App using bun Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/templates.mdx Initialize a new Assistant UI application integrated with Echo using bun. You will need an `app_id` from echo.merit.systems/new. ```sh bunx echo-start@latest --template assistant-ui --app-id YOUR_ECHO_APP_ID ``` -------------------------------- ### Conventional Commits Type Examples Source: https://github.com/merit-systems/echo/blob/master/CONTRIBUTING.md Examples of commit messages using different types like 'feat', 'fix', 'docs', 'refactor', and 'test' to categorize changes. ```bash feat(react-sdk): add support for streaming responses feat(cli): add local wallet self-custody authentication fix(server): correct token counting for Claude models docs(templates): add environment setup guide for next-chat docs(cli): update readme with local wallet instructions refactor(control): simplify balance calculation logic test(ts-sdk): add integration tests for provider initialization test(cli): add tests for wallet generation and signing ``` -------------------------------- ### Install Next.js Chat Echo Template Source: https://github.com/merit-systems/echo/blob/master/templates/README.md Set up a complete chat application using the Next.js template. Features include a full chat interface, real-time balance display, and streaming AI responses. ```bash npx echo-start@latest --template next-chat ``` -------------------------------- ### Create Assistant UI App using npm Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/getting-started/templates.mdx Initialize a new Assistant UI application integrated with Echo using npm. You will need an `app_id` from echo.merit.systems/new. ```sh npx echo-start@latest --template assistant-ui --app-id YOUR_ECHO_APP_ID ``` -------------------------------- ### REST API: Get User Info Source: https://context7.com/merit-systems/echo/llms.txt Fetch user information by making a GET request to `/api/v1/user`. Ensure your request includes the `Authorization` header with your Bearer token. ```bash curl https://echo.merit.systems/api/v1/user \ -H "Authorization: Bearer echo_YOUR_API_KEY" ``` -------------------------------- ### Create New Project with React Chat Template Source: https://github.com/merit-systems/echo/blob/master/templates/react-chat/README.md Use the Echo CLI to initialize a new React chat project. You will be prompted for your Echo App ID. ```bash npx echo-start@latest --template react-chat ``` -------------------------------- ### PR Template Example Source: https://github.com/merit-systems/echo/blob/master/CONTRIBUTING.md Example markdown structure for a Pull Request description, including sections for Description, Motivation, Changes, Testing, Breaking Changes, and Related Issues. ```markdown ## Description Adds support for Anthropic Claude models in the Echo Server. ## Motivation Users have requested support for Claude models. This PR adds routing and metering for Anthropic's API. ## Changes - Added Anthropic provider configuration - Implemented token counting for Claude models - Updated documentation with Claude examples - Added integration tests ## Testing - ✅ Unit tests pass - ✅ Integration tests added and passing - ✅ Manually tested with Claude 3.5 Sonnet - ✅ Tested metering accuracy ## Breaking Changes None ## Related Issues Closes #123 ``` -------------------------------- ### Get Free Tier Balance Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx POST request to get a user's free tier spending information for a specific app. Requires API key or JWT token. ```http POST /api/v1/balance/{appId}/free ``` -------------------------------- ### Scaffold New Project with Echo CLI Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/index.mdx Use the echo-start CLI tool to scaffold a new Next.js application with Echo integration. Choose your preferred package manager for installation. ```sh npx echo-start@latest --template next ``` ```sh yarn dlx echo-start@latest --template next ``` ```sh pnpx echo-start@latest --template next ``` ```sh bunx echo-start@latest --template next ``` -------------------------------- ### Launch Prisma Studio Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/README.md Opens the Prisma Studio GUI for viewing and editing database content. Useful for debugging and data management. ```bash npx prisma studio ``` -------------------------------- ### Install Echo Account Component for React Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/components/index.mdx Use this command to install the Echo Account component specifically for React applications. This component provides comprehensive user account management features. ```bash pnpm dlx shadcn@latest add https://echo-components.com/r/echo-account-react.json ``` -------------------------------- ### REST API: Get Free-Tier Balance Source: https://context7.com/merit-systems/echo/llms.txt Fetch the free-tier balance for a specific application ID using a GET request to `/api/v1/balance/:appId/free`. Include your Bearer token in the `Authorization` header. ```bash curl "https://echo.merit.systems/api/v1/balance/APP_UUID/free" \ -H "Authorization: Bearer echo_YOUR_API_KEY" # {"spendPoolBalance":10.0,"userSpendInfo":{"amountSpent":1.5,"amountLeft":8.5,...}} ``` -------------------------------- ### Get User Balance Source: https://github.com/merit-systems/echo/blob/master/packages/app/control/docs/advanced/api-reference.mdx GET request to retrieve the authenticated user's credit balance. Optionally, specify echoAppId for app-specific balance. Requires API key or JWT token. ```http GET /api/v1/balance ``` -------------------------------- ### Create X402 OpenAI with Automatic Payment Handling (Server) Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/aix402/README.md Instantiate an OpenAI client with automatic payment handling for x402. This requires a wallet client. ```typescript import { createX402OpenAI } from '@merit-systems/ai-x402/server'; import { streamText } from 'ai'; const openai = createX402OpenAI(walletClient); const result = streamText({ model: openai('gpt-4'), messages: [{ role: 'user', content: 'Hello!' }], }); ``` -------------------------------- ### Run Development Server in Next.js Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/examples/next/README.md Use these commands to start the development server for your Next.js application. Open http://localhost:3000 in your browser to view the result. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Troubleshoot Server Startup Source: https://github.com/merit-systems/echo/blob/master/packages/sdk/ts/test-validation.md Commands to check if a port is in use and to kill the process if necessary, often related to server startup issues. ```bash # Check if port 3001 is available lsof -i :3001 # Kill any processes using the port kill -9 ```