Aslan Documentation

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.

Getting Started

Quick Start

Get your AI agent making purchases in under 5 minutes.

Try Interactive Demo

Installation

terminal
# Install Aslan SDK
npm install @aslanpay/sdk

# Or using yarn
yarn add @aslanpay/sdk

Basic Setup

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);
}

Authentication

Aslan uses API keys for authentication. You can get your API key from the dashboard.

🔒 Keep your API keys secure

  • • Never commit API keys to version control
  • • Use environment variables in production
  • • Rotate keys regularly
  • • Use different keys for development and production

API Reference

authorize()

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
})

Response

{
  "id": "auth_1234567890",
  "amount": 2500,
  "status": "authorized",
  "description": "AWS credits for computation",
  "created_at": "2024-01-15T10:30:00Z"
}

confirm()

Confirm and execute an authorized payment.

await aslan.confirm({
  authorizationId: 'auth_1234567890'
})

refund()

Refund a completed payment.

await aslan.refund({
  paymentId: 'pay_1234567890',
  amount: 2500, // Optional: partial refund
  reason: 'Customer request'
})

Examples

OpenAI Integration

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"
  })
}

LangChain Integration

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
)

Integrations

OpenAI

Integrate with GPT-4, function calling, and assistants.

View Example →

LangChain

Add payment tools to LangChain agents.

View Example →

CrewAI

Enable multi-agent teams to make purchases.

View Example →

Custom Frameworks

REST API works with any framework.

View Example →

Security

🔒 Enterprise Security

  • • JWT-based authentication with rotating secrets
  • • Rate limiting and DDoS protection
  • • Complete audit trails for all transactions
  • • Granular spending controls and velocity limits
  • • Real-time fraud detection

Spending Controls

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
    }
  }
})

Need Help?

Get support from our team of AI and payments experts.