LightningAPI Documentation Centre

Everything you need to get started.

Connect your LightningAPI key to your favourite AI tools in a few simple steps. Choose your application, follow the verified guide, and start building.

Instant 1-Command Configuration
Windows PowerShell · macOS Terminal · Linux Bash

Configure Everything in 1 Command:npx lightningdeals

Skip manual JSON editing! Run npx lightningdeals in your terminal or PowerShell. The interactive CLI installer auto-detects your editors (Cursor, Claude Code, Codex, VS Code), creates configuration backups, injects your API key, sets endpoints, and tests connectivity in seconds.

$npx lightningdeals
Zero manual JSON editingAuto config file backupsImmediate connection test
Section A

Getting Started with LightningAPI

1. Introduction & System Overview

LightningAPI is a modern, unified AI API gateway providing high-speed, enterprise-grade access to frontier intelligence models—including Anthropic Claude, OpenAI, and Google Gemini—through a single, highly available endpoint.

Unified Endpoints

One key connects Claude Code, Cursor, Codex, Windsurf, and custom scripts.

Sub-15ms Routing

Edge-optimized reverse proxy with automatic health failovers.

Fair Accounting

Zero tokens or credits billed for failed or interrupted requests.

2. What is an API Key?

An API key is a unique, secret authentication token that your coding assistant (like Cursor, Claude Code, or VS Code) uses to verify your account with LightningAPI on every prompt.

Key Anatomy at LightningAPI

Every active LightningAPI key begins with the prefix ld_live_ (or ld_trial_ for free trials). Treat your key like a credit card: never share it in public repositories or client-side browser code.

3. How LightningAPI Works

When your tool sends a prompt, it connects to LightningAPI's gateway. The gateway verifies your key's quota, translates the protocol if necessary, routes to the healthiest cluster, streams tokens back in real-time, and settles usage in an immutable ledger.

Request Pipeline
Your Client (Cursor / Claude Code)
↳ HTTPS POST with ld_live_...
↳ LightningAPI Gateway (Authentication & Rate Limiting)
↳ Intelligent Model Cluster Routing
↳ Server-Sent Events (SSE) Stream Completion

4. How to Get Your API Key

  1. Create an Account: Register at lightningapi.pro/register.
  2. Choose a Plan: Select a 5-Hour Rolling Window plan, Credit Wallet top-up, or Token Pack.
  3. Copy Your Key: Go to Dashboard → API Keys and copy your active key.

5. Understanding Your Plan Architecture

LightningAPI supports three distinct billing structures so you only pay for what you actually use:

5-Hour Rolling Window

Designed for heavy coding. Your token allowance automatically regenerates continuously over every 5-hour rolling cycle.

Prepaid Credit Wallet

Deposit credits (e.g. $15, $35, $75). Credits never expire for 365 days and work across all supported models.

Consumable Token Packs

Buy high-volume token blocks (10M, 50M, 100M). Ideal for continuous agent runs and automated scripts.

6. Your First Successful Request

Copy and paste this command into your terminal to test your key immediately:

First API Request (Native cURL)
1curl -X POST "https://lightningapi.pro/v1/messages" \
2 -H "Content-Type: application/json" \
3 -H "x-api-key: ld_live_your_api_key_here" \
4 -H "anthropic-version: 2023-06-01" \
5 -d '{
6 "model": "claude-sonnet-5.5",
7 "max_tokens": 1024,
8 "messages": [
9 {"role": "user", "content": "Explain binary search in two sentences."}
10 ]
11 }'

7. Checking Your Key Status & Live Consumption

You can inspect your remaining tokens, active rolling quota, and recent request activity at any time using our dedicated verification tool:

Open Verify Key Toollightningapi.pro/check-key
Section B

Quick Setup & Environment Configuration

1. Windows Setup (PowerShell & Command Prompt)

In Windows PowerShell (run as Administrator for persistent user-wide variables), set your environment variables so tools like Claude Code and Codex can automatically authenticate:

Windows Persistent Setup
1$env:ANTHROPIC_BASE_URL="https://lightningapi.pro"
2$env:ANTHROPIC_AUTH_TOKEN="ld_live_your_api_key_here"
3$env:OPENAI_BASE_URL="https://lightningapi.pro/v1"
4$env:OPENAI_API_KEY="ld_live_your_api_key_here"

2. macOS Setup (Terminal & Zsh)

On macOS (default Zsh shell), append your environment variables to ~/.zshrc and reload your session:

macOS Persistent Setup (~/.zshrc)
1echo 'export ANTHROPIC_BASE_URL="https://lightningapi.pro"' >> ~/.zshrc
2echo 'export ANTHROPIC_AUTH_TOKEN="ld_live_your_api_key_here"' >> ~/.zshrc
3echo 'export OPENAI_BASE_URL="https://lightningapi.pro/v1"' >> ~/.zshrc
4echo 'export OPENAI_API_KEY="ld_live_your_api_key_here"' >> ~/.zshrc
5source ~/.zshrc

3. Linux Setup (Ubuntu / Debian / Fedora / Arch)

Linux Persistent Setup (~/.bashrc)
1echo 'export ANTHROPIC_BASE_URL="https://lightningapi.pro"' >> ~/.bashrc
2echo 'export ANTHROPIC_AUTH_TOKEN="ld_live_your_api_key_here"' >> ~/.bashrc
3echo 'export OPENAI_BASE_URL="https://lightningapi.pro/v1"' >> ~/.bashrc
4echo 'export OPENAI_API_KEY="ld_live_your_api_key_here"' >> ~/.bashrc
5source ~/.bashrc

4. Automatic Setup (1-Command CLI Installer)

LightningAPI provides a one-command interactive setup tool that auto-detects installed coding editors, creates configuration backups, injects endpoints, and tests connectivity in seconds:

1-Command CLI Installer
1npx lightningdeals

5. Manual Configuration Best Practices

If you prefer manual configuration over the automated CLI, ensure you configure both the Anthropic and OpenAI compatible endpoints in your editor settings files:

Variable NameTarget ValueUsed By
ANTHROPIC_BASE_URLhttps://lightningapi.proClaude Code, Cursor, Cline, Roo Code
ANTHROPIC_AUTH_TOKENld_live_your_key_hereClaude Code CLI
OPENAI_BASE_URLhttps://lightningapi.pro/v1Codex, Windsurf, TRAE, OpenAI SDK
OPENAI_API_KEYld_live_your_key_hereOpenAI Compatible Tools

6. Verifying Installation & Connectivity

Verify that your environment variables are active and that your API key connects successfully by requesting your authorized models:

Test Gateway Verification
1curl -s https://lightningapi.pro/v1/models \
2 -H "Authorization: Bearer $OPENAI_API_KEY" | grep -o '"id": "[^"]*"'
If the response lists models such as claude-sonnet-5.5 and gpt-4o, your environment is ready.

7. Changing or Rotating Your API Key

When upgrading your plan, rotating keys for security, or replacing an old key, update your active key in place without reinstalling tools:

  1. Generate a new key in Dashboard → API Keys.
  2. In your terminal or PowerShell profile, replace the old ld_live_... string with your new key.
  3. In Cursor, open Settings → Models and paste the new key into the Anthropic API Key input.
  4. In Claude Code, edit ~/.claude/settings.json and update ANTHROPIC_AUTH_TOKEN.

8. Removing Configurations & Clean Reset

To completely remove LightningAPI environment variables and revert your tools back to default cloud endpoints:

Clean Reset Commands
1# Unset for current session:
2unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN OPENAI_BASE_URL OPENAI_API_KEY
3
4# Remove from ~/.zshrc or ~/.bashrc:
5sed -i '' '/lightningapi/d' ~/.zshrc 2>/dev/null || sed -i '/lightningapi/d' ~/.bashrc 2>/dev/null
Section C

Connect Your Application (14+ Verified Guides)

Interactive Setup Assistant

Configure Any Tool in Seconds

Select your tool, operating system, and plan. The assistant generates the exact file paths and validated configurations tailored for your environment.

Prefer 1-Command Automatic Setup?Terminal / PowerShell

Run npx lightningdeals to auto-configure Cursor, Claude Code, Codex, and environment variables.

npx lightningdeals
Keys are processed locally only
Configuration for Claude Code (WINDOWS)
%USERPROFILE%\.claude\settings.json
Option A: Fast Terminal Command
$env:ANTHROPIC_BASE_URL="https://lightningapi.pro"
$env:ANTHROPIC_AUTH_TOKEN="ld_live_your_api_key_here"
claude
Option B: Configuration File
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://lightningapi.pro",
    "ANTHROPIC_AUTH_TOKEN": "ld_live_your_api_key_here",
    "ANTHROPIC_MODEL": "claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5.5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5.5"
  },
  "model": "claude-sonnet-5.5"
}

How to Verify Connection:

claude

Claude Code will automatically authenticate with LightningAPI and load your selected model.

1. Claude Code CLI

Native Anthropic Protocol

Claude Code is Anthropic's agentic command-line assistant. Configure your settings file or terminal environment to route requests through LightningAPI:

Configuration File: ~/.claude/settings.json (macOS/Linux) or %USERPROFILE%\.claude\settings.json (Windows)
~/.claude/settings.json
1{
2 "env": {
3 "ANTHROPIC_BASE_URL": "https://lightningapi.pro",
4 "ANTHROPIC_AUTH_TOKEN": "ld_live_your_api_key_here",
5 "ANTHROPIC_MODEL": "claude-sonnet-5.5",
6 "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5.5",
7 "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5.5",
8 "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5.5"
9 },
10 "model": "claude-sonnet-5.5"
11}
Verify by running claude in your terminal.

2. Cursor IDE

Anthropic & OpenAI Compatible

In Cursor, open Settings (Ctrl+, or Cmd+,) → Models:

  • Toggle on "Override Anthropic Base URL" and enter: https://lightningapi.pro
  • Enter your LightningAPI key in Anthropic API Key: ld_live_...
  • Add Model Name: claude-sonnet-5.5 or claude-opus-5.5
settings.json (Cursor User Settings)
1{
2 "cursor.cpp.overrideAnthropicApiKey": "ld_live_your_api_key_here",
3 "cursor.cpp.anthropicBaseUrl": "https://lightningapi.pro",
4 "cursor.general.model": "claude-sonnet-5.5"
5}

3. Codex CLI

OpenAI Compatible (/v1)

Codex connects via OpenAI compatibility mode. Set your environment variables:

1export OPENAI_BASE_URL="https://lightningapi.pro/v1"
2export OPENAI_API_KEY="ld_live_your_api_key_here"
3codex "Create a React modal component"

4. Visual Studio Code

Extensions & Global Proxy

Use LightningAPI inside official VS Code with AI coding extensions such as Continue, Cline, or Roo Code:

settings.json (VS Code Settings)
1{
2 "chat.defaultModel": "claude-sonnet-5.5",
3 "terminal.integrated.env.windows": {
4 "ANTHROPIC_BASE_URL": "https://lightningapi.pro",
5 "ANTHROPIC_AUTH_TOKEN": "ld_live_your_api_key_here",
6 "OPENAI_BASE_URL": "https://lightningapi.pro/v1",
7 "OPENAI_API_KEY": "ld_live_your_api_key_here"
8 },
9 "terminal.integrated.env.osx": {
10 "ANTHROPIC_BASE_URL": "https://lightningapi.pro",
11 "ANTHROPIC_AUTH_TOKEN": "ld_live_your_api_key_here",
12 "OPENAI_BASE_URL": "https://lightningapi.pro/v1",
13 "OPENAI_API_KEY": "ld_live_your_api_key_here"
14 }
15}

5. Windsurf IDE (Codeium Flow)

Cascade AI Engine

In Windsurf, open Settings → AI Provider Settings:

  • Select Provider: Custom OpenAI Compatible
  • API Endpoint: https://lightningapi.pro/v1
  • API Key: ld_live_your_api_key_here
  • Default Model: claude-sonnet-5.5 or gpt-4o

6. Cline (Autonomous Agent Extension)

Multi-Turn Agent

In VS Code, click the Cline sidebar icon and open extension Settings:

API Provider: Anthropic
Base URL: https://lightningapi.pro
API Key: ld_live_...
Model ID: claude-sonnet-5.5

7. Roo Code (Architect, Code & Ask Modes)

Autonomous Modes

Roo Code supports custom mode presets. Configure Anthropic provider with your LightningAPI key:

Roo Code Configuration
1{
2 "provider": "anthropic",
3 "baseUrl": "https://lightningapi.pro",
4 "apiKey": "ld_live_your_api_key_here",
5 "models": {
6 "code": "claude-sonnet-5.5",
7 "architect": "claude-opus-5.5",
8 "ask": "claude-haiku-5.5"
9 }
10}

8. Continue.dev

Add this model definition to your ~/.continue/config.json:

~/.continue/config.json
1{
2 "models": [
3 {
4 "title": "Claude Sonnet 5.5 (LightningAPI)",
5 "provider": "anthropic",
6 "model": "claude-sonnet-5.5",
7 "apiKey": "ld_live_your_api_key_here",
8 "apiBase": "https://lightningapi.pro"
9 },
10 {
11 "title": "GPT-4o (LightningAPI)",
12 "provider": "openai",
13 "model": "gpt-4o",
14 "apiKey": "ld_live_your_api_key_here",
15 "apiBase": "https://lightningapi.pro/v1"
16 }
17 ]
18}

9. TRAE SOLO

ByteDance AI IDE

In TRAE, open Settings → Model Management → Custom Model Provider:

  • Endpoint: https://lightningapi.pro/v1
  • API Key: ld_live_your_api_key_here
  • Model Name: claude-sonnet-5.5 or gpt-4o

10. Claude Desktop Native App

macOS & Windows Desktop

Configure Claude Desktop by editing its configuration file:

Path: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
claude_desktop_config.json
1{
2 "globalShortcut": "CommandOrControl+Shift+Space",
3 "env": {
4 "ANTHROPIC_BASE_URL": "https://lightningapi.pro",
5 "ANTHROPIC_API_KEY": "ld_live_your_api_key_here"
6 }
7}

11. Cherry Studio (Multi-Provider Chat Client)

In Cherry Studio Settings → Model Providers, add a custom provider:

  • Provider Type: OpenAI Compatible
  • Base URL: https://lightningapi.pro/v1
  • API Key: ld_live_your_api_key_here
  • Click "Fetch Models" to automatically populate all models authorized for your key.

12. n8n Workflow Automation

In n8n, connect LightningAPI using the OpenAI Chat Model node or Anthropic Chat Model node:

OpenAI Chat Model Node in n8n:

  • Credential: Create new OpenAI API credential
  • API Key: ld_live_your_api_key_here
  • Base URL override (under Node Options): https://lightningapi.pro/v1
  • Model: Select or enter gpt-4o or claude-sonnet-5.5

13. Python SDK Integration (Anthropic & OpenAI)

Install official SDKs and pass your LightningAPI custom base URL:

Python Examples (Streaming & Non-Streaming)
1import os
2from anthropic import Anthropic
3
4client = Anthropic(
5 base_url="https://lightningapi.pro",
6 api_key="ld_live_your_api_key_here"
7)
8
9with client.messages.stream(
10 model="claude-sonnet-5.5",
11 max_tokens=1024,
12 messages=[{"role": "user", "content": "Write a Python binary search function."}]
13) as stream:
14 for text in stream.text_stream:
15 print(text, end="", flush=True)

14. Node.js & TypeScript Integration

Use official Node.js SDKs with full TypeScript type safety:

Node.js & TypeScript Examples
1import Anthropic from '@anthropic-ai/sdk';
2
3const client = new Anthropic({
4 baseURL: 'https://lightningapi.pro',
5 apiKey: process.env.LIGHTNING_API_KEY || 'ld_live_your_key_here',
6});
7
8const stream = await client.messages.create({
9 model: 'claude-sonnet-5.5',
10 max_tokens: 1024,
11 stream: true,
12 messages: [{ role: 'user', content: 'Explain TypeScript generics in 2 sentences.' }],
13});
14
15for await (const chunk of stream) {
16 if (chunk.type === 'content_block_delta' && chunk.delta.type === 'text_delta') {
17 process.stdout.write(chunk.delta.text);
18 }
19}
Section D

Models & Intelligence Providers

1. Anthropic Claude Frontier Models

LightningAPI provides direct access to Anthropic's frontier intelligence family. Use these technical model IDs across all API requests:

Technical Model IDDisplay NameContext WindowMax OutputVision
claude-sonnet-5.5Claude Sonnet 5.51,000,00016,384Yes
claude-opus-5.5Claude Opus 5.51,000,00016,384Yes
claude-fable-5Claude Fable 51,000,0008,192Yes
claude-haiku-5.5Claude Haiku 5.5500,0008,192Yes
claude-sonnet-4.5Claude Sonnet 4.5200,0008,192Yes

2. OpenAI Frontier Models

OpenAI reasoning and multimodal models accessible via both /v1/chat/completions and native tooling:

Technical Model IDDisplay NameContext WindowMax OutputSpecialty
gpt-4oGPT-4o Omnimodal128,00016,384General coding, multimodal
gpt-4o-miniGPT-4o Mini128,00016,384Fast helper, high RPM
o1o1 Deep Reasoning200,000100,000Complex math, algorithms
o3-minio3-mini Reasoning200,000100,000Fast scientific reasoning
gpt-4.5GPT-4.5 Frontier128,00016,384Flagship reasoning

3. Google Gemini Models

Google's frontier multimodal intelligence with ultra-long 1,000,000 token context capability:

Technical Model IDDisplay NameContext WindowVision & Audio
gemini-4-argonGemini 4 Argon (1M Context)1,000,000Yes (Multimodal)
gemini-2.5-proGemini 2.5 Pro1,000,000Yes (Multimodal)
gemini-2.5-flashGemini 2.5 Flash1,000,000Yes (Fast)

4. Open-Weights & Frontier Labs

Cost-effective open-weights reasoning and code-specialized models routed through high-throughput edge nodes:

Technical Model IDLab / FamilyContextSpecialty
deepseek-reasonerDeepSeek R1 Reasoning64,000Chain-of-thought math & code
deepseek-chatDeepSeek V364,000High-throughput dialogue
qwen-2.5-coder-32bAlibaba Qwen128,000Specialized software synthesis
grok-2.0xAI Grok128,000Frontier reasoning & vision

5. Model Selection Guide for Developers

Choose the right model for your specific software engineering or agentic workload:

Full Repository Refactoring

Use claude-sonnet-5.5. Best-in-class multi-file editing, tool execution, and AST comprehension in Cursor and Claude Code.

Massive Document & Log Analysis

Use gemini-4-argon. Ingest up to 1,000,000 tokens of entire documentation trees, database dumps, and audio recordings.

Algorithmic & Scientific Reasoning

Use o3-mini or o1. Ideal for mathematical proofs, competitive programming, and formal verification.

Cost-Optimized Batch Workloads

Use deepseek-reasoner or qwen-2.5-coder-32b for high-volume automated unit test generation.

6. Technical Model IDs Quick Reference

Copy these exact strings into your JSON payloads and CLI configurations:

"claude-sonnet-5.5"
"claude-opus-5.5"
"claude-fable-5"
"claude-haiku-5.5"
"gpt-4o"
"gpt-4o-mini"
"o1"
"o3-mini"
"gemini-4-argon"
"gemini-2.5-pro"
"deepseek-reasoner"
"qwen-2.5-coder-32b"

7. Model Plan Permissions & Access Tiers

Plan tiers authorize access to distinct model families. If you receive HTTP 403 Model Denied, verify your plan permissions:

Plan ArchitectureClaude ModelsOpenAI ModelsGemini ModelsOpen-Weights
Claude Max (5-Hour Rolling)Full AccessAdd Credit PackAdd Credit PackAdd Credit Pack
Prepaid Credit WalletUniversalUniversalUniversalUniversal
Consumable Token PacksClaude PackOpenAI PackUniversal PackLocal Pack
Section E

API Reference & Protocol Specification

1. Authentication Standards & Header Formats

LightningAPI accepts credentials via two standard header formats depending on whether you are using the Anthropic protocol or the OpenAI compatible protocol:

Anthropic Protocol Header
x-api-key: ld_live_...

Required for /v1/messages. Also accepts anthropic-version: 2023-06-01.

OpenAI Compatible Header
Authorization: Bearer ld_live_...

Required for /v1/chat/completions and /v1/models.

2. Base URLs & Dual Protocols

LightningAPI hosts dual protocol endpoints with automatic header normalization:

Anthropic Native Base URL
https://lightningapi.pro

Used for Claude Code, Cursor Anthropic mode, and @anthropic-ai/sdk.

OpenAI Compatible Base URL
https://lightningapi.pro/v1

Used for Codex, Windsurf, LangChain, and openai official SDKs.

GET/v1/models (Key-Scoped Discovery)

OpenAI Compatible

Retrieves the list of models dynamically permitted by your authenticating key. Useful for editor auto-complete dropdowns:

GET /v1/models
1curl -X GET "https://lightningapi.pro/v1/models" \
2 -H "Authorization: Bearer ld_live_your_api_key_here"

POST/v1/messages

Native Anthropic Protocol

Sends a structured message sequence to Claude Frontier models with streaming, tool execution, and vision support:

POST /v1/messages Example
1curl -X POST "https://lightningapi.pro/v1/messages" \
2 -H "Content-Type: application/json" \
3 -H "x-api-key: ld_live_your_api_key_here" \
4 -H "anthropic-version: 2023-06-01" \
5 -d '{
6 "model": "claude-sonnet-5.5",
7 "max_tokens": 1024,
8 "messages": [
9 {"role": "user", "content": "Explain microservices in two sentences."}
10 ]
11 }'

POST/v1/chat/completions

OpenAI Compatible Protocol

Standard chat completions endpoint compatible with OpenAI, LangChain, and all OpenAI-compatible SDKs:

POST /v1/chat/completions Example
1curl -X POST "https://lightningapi.pro/v1/chat/completions" \
2 -H "Content-Type: application/json" \
3 -H "Authorization: Bearer ld_live_your_api_key_here" \
4 -d '{
5 "model": "gpt-4o",
6 "messages": [
7 {"role": "user", "content": "Explain idempotent API design."}
8 ]
9 }'

POST/v1/responses (Universal Unified Endpoint)

Universal Route

High-performance direct route supporting cross-model requests with automatic translation and unified response envelope:

POST /v1/responses Example
1curl -X POST "https://lightningapi.pro/v1/responses" \
2 -H "Content-Type: application/json" \
3 -H "Authorization: Bearer ld_live_your_api_key_here" \
4 -d '{
5 "model": "claude-sonnet-5.5",
6 "input": "Summarize this diff in bullet points",
7 "temperature": 0.2
8 }'

7. Server-Sent Events (SSE) Streaming Format

When "stream": true is passed, LightningAPI returns tokens via HTTP/2 SSE chunks with content-type: text/event-stream:

HTTP/2 200 OK
content-type: text/event-stream
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":" world"}}]}
data: [DONE]

8. Multimodal Vision & Image Payloads

Supported across claude-sonnet-5.5, gpt-4o, and gemini-4-argon. Pass either base64 encoded strings or public HTTPS image URLs:

Vision Payload Example (OpenAI Format)
1{
2 "model": "claude-sonnet-5.5",
3 "messages": [
4 {
5 "role": "user",
6 "content": [
7 { "type": "text", "text": "Describe the architecture diagram in this screenshot." },
8 {
9 "type": "image_url",
10 "image_url": { "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." }
11 }
12 ]
13 }
14 ]
15}

9. Token Counting & Pre-Request Estimation

LightningAPI provides exact token counts before execution to assist in budget management:

POST /v1/messages/count_tokens
1curl -X POST "https://lightningapi.pro/v1/messages/count_tokens" \
2 -H "Content-Type: application/json" \
3 -H "x-api-key: ld_live_your_api_key_here" \
4 -H "anthropic-version: 2023-06-01" \
5 -d '{
6 "model": "claude-sonnet-5.5",
7 "messages": [
8 {"role": "user", "content": "How many tokens is this prompt?"}
9 ]
10 }'

10. Rate Limits, Concurrency & Response Headers

All HTTP responses include telemetry headers indicating active concurrency and rolling quota limits:

Header NameDescription
x-ratelimit-limit-requestsMaximum requests permitted per minute (RPM).
x-ratelimit-remaining-requestsNumber of requests remaining in current window.
x-ratelimit-reset-requestsSeconds until the request count resets.
retry-afterReturned on HTTP 429 indicating seconds to wait before retrying.
Section F

Usage, Billing & Quotas

1. The Six Billing Architectures Explained

LightningAPI routes all requests through immutable ledger accounting. Depending on your purchase, your key operates under one of these models:

1. Claude Max (5-Hour Rolling Window):Tokens continuously replenish every minute as older usage rolls past the 5-hour boundary.
2. OpenAI (5-Hour Rolling Window):Rolling window access dedicated to OpenAI Frontier workloads.
3. Prepaid Credit Wallet:USD balance valid for 365 days across all models. Top up anytime.
4. Claude Consumable Token Packs:10M, 50M, 100M token blocks for Claude Frontier models.
5. OpenAI Consumable Token Packs:Bulk token blocks dedicated to GPT-4o and reasoning models.
6. Open-Weights Token Packs:Cost-efficient token blocks for DeepSeek, Qwen, and Grok.

2. 5-Hour Rolling Windows: Continuous Replenishment

Unlike traditional monthly subscriptions that cut off access when exhausted, a 5-hour rolling plan evaluates your usage over a moving 300-minute window. As each minute ticks forward, tokens consumed exactly 5 hours ago roll off your tally and become available again immediately.

Example: Continuous Refill in Action

If you consume 50,000 tokens at 10:00 AM, that exact 50,000-token capacity automatically returns to your available allowance at 3:00 PM without requiring any action or subscription reset.

3. Prepaid Credit Wallet: Pay-As-You-Go

The Prepaid Credit Wallet provides maximum flexibility:

  • Universal Model Access: Use your credits across Claude, OpenAI, Gemini, and DeepSeek with no restrictions.
  • 365-Day Balance Validity: Unused credits roll over and remain valid for a full calendar year.
  • Zero Overages: Requests stop safely if your balance reaches $0.00; you will never receive an unexpected bill.

4. Consumable Token Packs for Burst & Agent Workloads

Purchased in fixed allotments (10M, 50M, 100M tokens) with zero rolling window rate caps. Ideal for batch data extraction, CI/CD code verification pipelines, and high-concurrency multi-agent swarms.

5. Dashboard Telemetry & Real-Time Analytics

Monitor your API traffic in real-time at /dashboard/usage. Review token consumption per model, average latency graphs, and per-request settlement logs.

6. Validity, Renewal Cycles & Expiry Rules

Subscriptions renew automatically every 30 days unless canceled in the Customer Dashboard. If canceled, your active key retains its rolling quota until the end of the current billing period.

7. Fair Billing Guarantee

LightningAPI enforces strict transactional fairness:

Zero Charges on Upstream Failures

If an API request terminates with HTTP 500, 502, 503, 504, or if the client drops the TCP connection before receiving the first token chunk, zero tokens and zero credits are billed.

Section G

Troubleshooting & Error Library

1. Diagnostic Assistant & Error Library Overview

If your coding assistant or script encounters an error, use this guide to identify the exact HTTP status code, root cause, and verified resolution immediately:

400HTTP 400 — Invalid Request Format

Client Error

Cause: Malformed JSON syntax, missing required fields (such as messages array or model parameter), or exceeding max output token boundaries.

Resolution: Validate your JSON payload with a validator. Ensure messages is a non-empty array of objects with valid role and content fields.

401HTTP 401 — API Key Unrecognized or Invalid

Authentication

Cause: The provided key string does not exist, was truncated during copy-paste, or was deleted from the dashboard.

Resolution: Verify your key begins with ld_live_. Open Dashboard → API Keys to confirm its active status, or test it on our Verify Key diagnostic page.

402HTTP 402 — Credit Wallet Depleted ($0.00 Balance)

Payment Required

Cause: Your prepaid Pay-As-You-Go credit wallet balance has reached $0.00.

Resolution: Recharge credits from the Plans page. As soon as payment completes, your active key resumes immediately without modifying your editor or terminal settings.

403HTTP 403 — Model Not Permitted on Current Plan

Authorization

Cause: You requested a model outside your active plan's permissions (e.g. requesting OpenAI models while on a Claude-only plan).

Resolution: Switch your model in editor settings to an authorized model (e.g. claude-sonnet-5.5), or add a Pay-As-You-Go Credit pack to unlock Universal model access.

403HTTP 403 — Key Inactive or Suspended

Key State

Cause: The key was manually paused in the dashboard or associated with an expired subscription.

Resolution: Log into your Customer Dashboard and click "Resume Key" under API Keys, or renew your subscription under My Plan.

429HTTP 429 — 5-Hour Rolling Allowance Reached

Rolling Window

Cause: You have consumed all tokens permitted within your moving 5-hour rolling cycle.

Resolution: Tokens replenish continuously every minute as older usage expires past the 5-hour window. Alternatively, add Pay-As-You-Go credits for an instant buffer with zero wait time.

429HTTP 429 — Request Speed Limit Exceeded (RPM)

Speed Limit

Cause: Automated scripts or agent swarms sending too many rapid requests per second.

Resolution: Respect the retry-after response header and introduce exponential backoff (e.g. 1s, 2s, 4s).

500 / 503HTTP 500 / 503 — Temporary Cluster Congestion

Server Surge

Cause: Upstream intelligence cluster overload or transient cloud network drop.

Resolution: Retry in 3 to 5 seconds. The gateway automatically triggers failover to healthy secondary nodes. Zero tokens or credits are charged for failed requests.

10. Client Connection Issues (ECONNREFUSED / SSL Interception)

If your terminal throws ECONNREFUSED or self-signed certificate warnings:

  • Corporate Proxies / VPNs: Ensure your network permits outbound HTTPS traffic on port 443 to https://lightningapi.pro.
  • Base URL Protocol: Always include the https:// prefix. Never use plain http://.
  • Trailing Slashes: Do not add trailing slashes to Anthropic base URLs (use https://lightningapi.pro).
Section H

Security, Best Practices & Engineering Support

1. API Key Storage Hygiene & Security Standards

Your LightningAPI credentials provide access to frontier computing infrastructure. Adhere to these essential security rules:

  • Never Commit to Version Control: Always place API keys in .env files and include them in your .gitignore.
  • Never Expose in Frontend Bundles: Client-side JavaScript bundles (React, Vue, Vite) can be reverse engineered. Route requests through a secure server proxy.
  • IP & Origin Pinning: Configure allowed IP addresses in the Customer Dashboard for enterprise keys.

2. Storing Keys Securely in Environment Variables

Standard practice for local development across Python, Node.js, and CLI scripts:

.env.example
1# LightningAPI Environment Configuration
2ANTHROPIC_BASE_URL=https://lightningapi.pro
3ANTHROPIC_AUTH_TOKEN=ld_live_your_key_here
4
5OPENAI_BASE_URL=https://lightningapi.pro/v1
6OPENAI_API_KEY=ld_live_your_key_here

3. Emergency Key Rotation Procedure

If you believe your key was leaked or compromised, execute this 3-minute rotation drill:

  1. Log into Dashboard → API Keys.
  2. Click "Generate New Key" and copy the newly generated secret string.
  3. Update your active applications, editors, and terminal environment variables with the new key.
  4. Return to the dashboard and click "Revoke / Delete" on the compromised key. The revoked key will be blocked across all gateway clusters in under 5 seconds.

4. Frequently Asked Questions (Developer FAQ)

Does LightningAPI log prompt contents?

No. LightningAPI operates as a zero-persistence streaming proxy. Prompt and completion tokens stream through in memory and are never persisted to disk or used for training.

Can I use one key on multiple computers?

Yes. You can use your active API key across your desktop, laptop, and CI/CD pipelines simultaneously within your plan's concurrency limits.

What happens if my connection drops mid-stream?

Our fair accounting engine only charges for tokens actually streamed before disconnect, and charges zero tokens if the request encountered an error.