Aslan is the universal payment infrastructure for AI agents. Enable any AI agent to make autonomous purchases with enterprise-grade security, real-time spending controls, and sub-400ms authorization.
# Install Aslan SDK
npm install @aslanpay/sdk
# Or using yarn
yarn add @aslanpay/sdk
const { Aslan } = require('@aslanpay/sdk');
const aslan = new Aslan({
apiKey: process.env.ASLAN_API_KEY,
environment: 'production' // or 'sandbox'
});
// Enable AI agent to make purchases
async function enableAIPurchases() {
const result = await aslan.purchase({
amount: 2500, // $25.00
description: 'AWS credits for AI training',
agentId: 'gpt-4-assistant'
});
console.log('Purchase successful:', result);
}
Aslan uses API keys for authentication. You can get your API key from the dashboard.
Authorize a payment for an AI agent.
await aslan.authorize({
amount: 2500, // Required: Amount in cents
description: 'string', // Required: Purchase description
agentId: 'string', // Optional: Agent identifier
metadata: {} // Optional: Additional data
})
{
"id": "auth_1234567890",
"amount": 2500,
"status": "authorized",
"description": "AWS credits for computation",
"created_at": "2024-01-15T10:30:00Z"
}
Confirm and execute an authorized payment.
await aslan.confirm({
authorizationId: 'auth_1234567890'
})
Refund a completed payment.
await aslan.refund({
paymentId: 'pay_1234567890',
amount: 2500, // Optional: partial refund
reason: 'Customer request'
})
import OpenAI from 'openai'
import { Aslan } from '@aslanpay/sdk'
const openai = new OpenAI()
const aslan = new Aslan({ apiKey: process.env.ASLAN_API_KEY })
const completion = await openai.chat.completions.create({
model: "gpt-4",
messages: [{ role: "user", content: "Buy AWS credits" }],
tools: [{
type: "function",
function: {
name: "purchase",
description: "Make a purchase",
parameters: {
type: "object",
properties: {
amount: { type: "number" },
description: { type: "string" }
}
}
}
}]
})
// If AI decides to make a purchase
if (completion.choices[0].message.tool_calls) {
const purchase = await aslan.authorize({
amount: 2500,
description: "AWS credits"
})
}
from langchain.tools import Tool
from aslanpay import Aslan
aslan = Aslan(api_key="your_api_key")
def purchase_tool(amount: int, description: str):
"""Make a purchase with AI agent"""
return aslan.authorize(
amount=amount,
description=description
)
purchase = Tool(
name="purchase",
description="Make purchases for the AI agent",
func=purchase_tool
)
const aslan = new Aslan({
apiKey: 'your_api_key',
limits: {
daily: 10000, // $100 daily limit
perTransaction: 5000, // $50 per transaction
velocity: {
count: 10, // Max 10 transactions
window: 3600 // Per hour
}
}
})
Get support from our team of AI and payments experts.