Documentation

🚀 Quick Start

Satilligence provides an OpenAI-compatible API that accepts Lightning payments via NWC (Nostr Wallet Connect). No API keys, no accounts - just connect your Lightning wallet.

1. Get your NWC Connection String

You need a wallet that supports NWC. Options include:

2. Make Your First Request

curl -X POST "https://api.satilligence.com/v1/nwc/chat/completions" \
  -H "Content-Type: application/json" \
  -H "X-NWC: nostr+walletconnect://WALLET_PUBKEY?relay=wss://relay.example.com&secret=YOUR_SECRET" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "What is Bitcoin?"}
    ],
    "max_tokens": 100
  }'

📖 API Reference

POST /v1/nwc/chat/completions

Headers

Header Required Description
X-NWC Yes Your NWC connection string
Content-Type Yes application/json

Request Body

{
  "model": "gpt-4o-mini",      // Required: gpt-4o, gpt-4o-mini, gpt-4-turbo
  "messages": [                 // Required: Array of messages
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "max_tokens": 1000,          // Optional: Maximum tokens in response
  "temperature": 0.7           // Optional: Randomness (0-2)
}

Response Headers

Header Description
X-Charged-Sats Amount charged upfront (2x estimate)
X-Cost-Sats Actual cost of the request
X-Refund-Sats Amount refunded
X-Refund-Status success, failed, or none

Payment Flow

  1. 1
    Estimate Cost

    We estimate input + output tokens based on your message and max_tokens

  2. 2
    Charge 2x Estimate

    Invoice created for 2x estimated cost as safety buffer

  3. 3
    Your Wallet Pays

    NWC automatically pays the invoice from your connected wallet

  4. 4
    AI Generates Response

    Request forwarded to OpenAI, response returned to you

  5. 5
    Instant Refund

    Difference between charged and actual cost refunded via Lightning

📊 Supported Models

Model Input (per 1M tokens) Output (per 1M tokens) Best For
gpt-4o-mini $0.15 $0.60 Fast, cheap tasks
gpt-4o $5.00 $15.00 General purpose
gpt-4-turbo $10.00 $30.00 Complex reasoning

💻 Integration Examples

Python

import requests

response = requests.post(
    "https://api.satilligence.com/v1/nwc/chat/completions",
    headers={
        "Content-Type": "application/json",
        "X-NWC": "nostr+walletconnect://..."
    },
    json={
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "Hello!"}]
    }
)

print(response.json())

JavaScript

const response = await fetch("https://api.satilligence.com/v1/nwc/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-NWC": "nostr+walletconnect://..."
  },
  body: JSON.stringify({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "Hello!" }]
  })
});

const data = await response.json();
console.log(data);