TypeScript SDK
Resources
Platform operations - apps, balance, payments, users, models
The EchoClient provides access to platform resources through dedicated modules. Each resource handles a specific domain of Echo platform operations.
Manage your Echo applications and retrieve app information.
const apps = await echo.apps.listEchoApps();
const app = await echo.apps.getEchoApp('app-id');
const appUrl = echo.apps.getAppUrl('app-id');
listEchoApps()
- List all your Echo applications
getEchoApp(appId)
- Get specific application details
getAppUrl(appId)
- Generate application URL
import type { EchoApp } from '@merit-systems/echo-typescript-sdk';
Prop | Type | Default |
---|
id
| string
| - |
name
| string
| - |
description?
| string
| - |
isActive
| boolean
| - |
createdAt
| string
| - |
updatedAt
| string
| - |
totalTokens?
| number
| - |
totalCost?
| number
| - |
apiKeys?
| ApiKey[]
| - |
_count?
| { apiKeys: number; llmTransactions: number; }
| - |
Check account balance and free tier usage across applications.
const balance = await echo.balance.getBalance();
const freeBalance = await echo.balance.getFreeBalance('app-id');
getBalance()
- Get total account balance across all apps
getFreeBalance(echoAppId)
- Get free tier balance for specific app
import type { Balance, FreeBalance, UserSpendInfo } from '@merit-systems/echo-typescript-sdk';
Prop | Type | Default |
---|
totalPaid
| number
| - |
totalSpent
| number
| - |
balance
| number
| - |
Prop | Type | Default |
---|
spendPoolBalance
| number
| - |
userSpendInfo
| UserSpendInfo
| - |
Prop | Type | Default |
---|
userId
| string
| - |
echoAppId
| string
| - |
spendPoolId
| string | null
| - |
amountSpent
| number
| - |
spendLimit
| number | null
| - |
amountLeft
| number
| - |
Handle payment links and credit purchases through Stripe integration.
const paymentLink = await echo.payments.createPaymentLink({
amount: 25,
description: 'Echo Credits'
});
const paymentUrl = await echo.payments.getPaymentUrl(10, 'Quick Top-up');
createPaymentLink(request)
- Create detailed payment link with options
getPaymentUrl(amount, description?, successUrl?)
- Quick payment URL generation
import type {
CreatePaymentLinkRequest,
CreatePaymentLinkResponse
} from '@merit-systems/echo-typescript-sdk';
Prop | Type | Default |
---|
amount
| number
| - |
description?
| string
| - |
successUrl?
| string
| - |
Prop | Type | Default |
---|
paymentLink
| { id: string; url: string; amount: number; currency: string; description?: string | undefined; }
| - |
Get information about supported LLM models, pricing, and capabilities.
const chatModels = await echo.models.listSupportedChatModels();
const imageModels = await echo.models.listSupportedImageModels();
listSupportedChatModels()
- Get all supported chat models with pricing and metadata
listSupportedImageModels()
- Get all supported image models with pricing and metadata
import type {
SupportedModel,
SupportedImageModel
} from '@merit-systems/echo-typescript-sdk';
Prop | Type | Default |
---|
model_id
| string
| - |
input_cost_per_token
| number
| - |
output_cost_per_token
| number
| - |
provider
| string
| - |
Prop | Type | Default |
---|
model_id
| string
| - |
text_input_cost_per_token
| number
| - |
image_input_cost_per_token
| number
| - |
image_output_cost_per_token
| number
| - |
provider
| string
| - |
Manage user information and referral code registration.
const user = await echo.users.getUserInfo();
const referralResult = await echo.users.registerReferralCode('app-id', 'REFERRAL123');
getUserInfo()
- Get current user information and spending data
registerReferralCode(echoAppId, code)
- Register referral code for benefits
import type {
User,
RegisterReferralCodeRequest,
RegisterReferralCodeResponse
} from '@merit-systems/echo-typescript-sdk';
Prop | Type | Default |
---|
id
| string
| - |
email
| string
| - |
name?
| string
| - |
totalPaid?
| number
| - |
totalSpent?
| number
| - |
createdAt
| string
| - |
updatedAt
| string
| - |
picture?
| string
| - |
Prop | Type | Default |
---|
echoAppId
| string
| - |
code
| string
| - |
Prop | Type | Default |
---|
success
| boolean
| - |
message
| string
| - |
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}`);
}