Quickstart
Get up and running with Agnic in 5 minutes
Quickstart
Get started with Agnic and make your first X402 request in under 5 minutes.
Step 1: Create an Account
Sign up at app.agnic.ai with your email. We'll automatically create an embedded wallet for you with $5 in free credits.
Step 2: Generate API Token
- Go to your Dashboard
- Click Connect App
- 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
- Click Generate Token
- 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"}'X402 Payments is an opt-in feature. If you haven't already, enable it under Settings → Credits → Enable X402 Payments in the dashboard. It's a one-time step.
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 request
npx agnic x402 pay https://api.example.com/dataSee the CLI reference for all commands.