AI Quickstart
Top up with Lightning and make your first AI chat completion in under 5 minutes.
This guide takes you from zero to your first AI completion through the ZapAPI AI Gateway. You'll top up AI credits with Lightning, then call the OpenAI-compatible chat endpoint.
1. Get an API key
Create a zap_live_* API key from Dashboard → Projects → API Keys (or the
API Keys endpoint). The same key works for
payments and the AI Gateway.
2. Top up AI credits
Top up from AI → Billing in the dashboard, or over the API. Minimum 100 sats; Lightning topups earn a +5% bonus in credit.
curl -X POST https://api.zapapi.com/api/v1/ai/topup \
-H "Authorization: Bearer zap_live_your_key" \
-H "Content-Type: application/json" \
-d '{ "amountSats": 5000 }'Pay the returned paymentRequest BOLT11 invoice with any Lightning wallet —
or one-click Pay from wallet in the dashboard. Your balance credits
automatically when the invoice settles (+5% bonus included).
curl https://api.zapapi.com/api/v1/ai/topup/TOPUP_ID \
-H "Authorization: Bearer zap_live_your_key"curl https://api.zapapi.com/api/v1/ai/balance \
-H "Authorization: Bearer zap_live_your_key"3. Make your first completion
curl https://api.zapapi.com/api/v1/ai/chat/completions \
-H "Authorization: Bearer zap_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5.5",
"messages": [{"role": "user", "content": "Explain the Lightning Network in one paragraph."}]
}'Streaming works exactly like OpenAI's — add "stream": true and read SSE
deltas.
4. Use it from the OpenAI SDK
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.zapapi.com/api/v1/ai',
apiKey: process.env.ZAPAPI_KEY, // zap_live_…
});
const completion = await client.chat.completions.create({
model: 'anthropic/claude-sonnet-5.5',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0].message.content);Or use the official SDK, which adds typed sats billing, balance, topups and a streaming helper.
5. Browse models and prices
Every model's live price is listed in sats per 1M tokens:
curl "https://api.zapapi.com/api/v1/ai/models?type=chat" \
-H "Authorization: Bearer zap_live_your_key"Or browse the public catalog at zapapi.com/models — no account needed.
What's next
- Chat Completions — streaming, vision, tools, web search, thinking levels, routing suffixes
- Billing & Sats Pricing — exactly how charges are computed
- Auto-topup — NWC auto-refill so you never hit a 402