AgnicPay

Quickstart

Get up and running with AgnicPay in 5 minutes

Quickstart

Get started with AgnicPay and make your first X402 payment in under 5 minutes.

Step 1: Create an Account

Sign up at pay.agnic.ai with your email. We'll automatically create an embedded wallet for you with $5 in free credits.

Step 2: Generate API Token

  1. Go to your Dashboard
  2. Click Connect App
  3. Set your spending limits:
    • Per transaction: Maximum amount per API call
    • Daily limit: Total spend allowed per day
    • Monthly limit: Total spend allowed per month
  4. Click Generate Token
  5. Copy your token: agnic_tok_sk_live_...

Save your token securely! It's only shown once.

Step 3: Make Your First Request

Using the AI Gateway

The easiest way to start is with our OpenAI-compatible AI Gateway:

curl https://api.agnic.ai/v1/chat/completions \
  -H "X-Agnic-Token: agnic_tok_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Using the X402 Fetch Proxy

For any X402-enabled API, use our transparent proxy:

curl -X POST "https://api.agnic.ai/api/x402/fetch?url=https://api.example.com/data" \
  -H "X-Agnic-Token: agnic_tok_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Generate a summary"}'

Step 4: Check Your Balance

curl https://api.agnic.ai/api/balance \
  -H "X-Agnic-Token: agnic_tok_YOUR_TOKEN"

Response:

{
  "usdcBalance": "4.950000",
  "address": "0x1234...",
  "hasWallet": true,
  "network": "base-sepolia"
}

Using with OpenAI SDK

Python

from openai import OpenAI
 
client = OpenAI(
    api_key="agnic_tok_YOUR_TOKEN",
    base_url="https://api.agnic.ai/v1"
)
 
response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)
 
print(response.choices[0].message.content)

JavaScript/TypeScript

import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: 'agnic_tok_YOUR_TOKEN',
  baseURL: 'https://api.agnic.ai/v1'
});
 
const response = await client.chat.completions.create({
  model: 'openai/gpt-4o-mini',
  messages: [{ role: 'user', content: 'Hello!' }]
});
 
console.log(response.choices[0].message.content);

Alternative: Use the CLI

If you prefer the command line, install the agnic CLI:

# Login with email
npx agnic auth login [email protected]
npx agnic auth verify <flowId> <otp-from-email>
 
# Check balance
npx agnic balance
 
# Make an x402 payment
npx agnic x402 pay https://api.example.com/data
 
# Trade tokens
npx agnic trade 10 usdc eth

See the CLI reference for all commands.

Next Steps

On this page