Lightning API¶
The Lightning API is the hosted cloud API behind InferencePort AI Lightning.
Its base URL is https://sharktide-lightning.hf.space and the generation
routes live under /gen.
Authentication¶
Lightning accepts either of these bearer tokens:
A Supabase access token for the signed-in user.
A dashboard-generated Lightning API key.
Send both forms the same way:
curl https://sharktide-lightning.hf.space/subscription \
-H "Authorization: Bearer YOUR_TOKEN"
Generating API keys in the app¶
Sign in inside the desktop app.
Open
Settings.Open the
Accounttab.In
Lightning API, chooseGenerate API Key.Copy the key immediately. Only the unhashed secret is shown once.
Headers¶
Common request headers:
Authorization: Bearer <supabase-jwt-or-api-key>for authenticated usage.X-Client-ID: <stable-client-id>to bind free-tier and usage tracking to a stable desktop/browser client.Accept: application/jsonfor JSON endpoints.
Plan and usage endpoints¶
GET /subscription¶
Returns the authenticated user’s resolved plan and Stripe subscription view.
Response fields:
emailsigned_upplan_keyplan_namesubscription:nullfor free users, otherwise a list of active or recent subscription rowsauth_type:jwtorapi_key
GET /usage¶
Returns the current usage snapshot for the resolved identity.
Response fields:
plan_keyplan_namegenerated_atusage.cloudChatDailyusage.imagesDailyusage.videosDailyusage.audioWeekly
Each usage metric contains:
limitusedremainingwindowperiod
GET /tier-config¶
Returns the normalized plan catalog used by the app UI:
defaultPlanKeyplans[]withkey,name,url,price,limits, andorder
GET /tiers¶
Returns the paid plans only, mainly for upgrade UI.
Status and discovery endpoints¶
GET /¶
Permanent redirect to the public site.
GET /models¶
Scrapes the Ollama library page and returns public model metadata used by the marketplace UI.
GET /status¶
Returns overall Lightning service health with:
stateservicesnotificationslatest
HEAD /status/image, /status/video, /status/sfx, /status/text¶
Lightweight capability checks that return content-type headers only.
Generation endpoints¶
All generation routes are rooted at /gen.
POST /gen/chat/completions¶
OpenAI-compatible chat completions endpoint.
Important request fields:
messages: required arraystream: optional booleantools: optional tool listtool_choice: optional tool selection
Behavior notes:
Lightning chooses an upstream model automatically based on prompt complexity, code signals, tools, and image presence.
Authenticated requests consume
cloudChatDailyusage from the resolved plan.Streaming responses are returned as
text/event-stream.The first streaming metadata chunk includes
router_metadata.model_name.
Example:
curl https://sharktide-lightning.hf.space/gen/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Write a haiku about shipping software."}
]
}'
POST /gen/image and GET /gen/image/{prompt}¶
Image generation endpoint.
Request fields:
prompt: requiredmode: optional,fantasyorrealisticimage_urls: optional list with up to two URLs or base64 image strings
Notes:
Base64 image inputs are stored temporarily and re-served through
/asset-cdn/assets/{image_id}.Image generation consumes
imagesDailyusage.
POST /gen/video and GET /gen/video/{prompt}¶
Pollinations-backed video generation.
Request fields:
prompt: requiredratio: optional,3:2,2:3, or1:1mode: optional,normalorfunduration: optional integer, clamped to1through10image_urls: optional list with up to two URLs or base64 image strings
Video generation consumes videosDaily usage.
POST /gen/video/airforce and GET /gen/video/airforce/{prompt}¶
Alternate Airforce-backed video endpoint with the same auth model. It also
consumes videosDaily usage.
POST /gen/sfx and GET /gen/sfx/{prompt}¶
Music and sound-effect generation. Requires prompt and consumes
audioWeekly usage.
POST /gen/tts and GET /gen/tts/{prompt}¶
Text-to-speech generation. Requires prompt and also consumes
audioWeekly usage.
POST /gen/prompt_analyze¶
Returns the router’s chosen display model for a prompt payload. The request body
expects prompt as a message array.
Asset CDN¶
GET /asset-cdn/assets/{image_id}¶
Returns temporary PNG files created when image or video generation receives base64 image inputs.
Rate limits¶
Lightning currently tracks these metrics per resolved identity:
cloudChatDailyimagesDailyvideosDailyaudioWeekly
If no bearer token is present, Lightning falls back to a free-tier identity
derived from X-Client-ID when available, otherwise from request IP and
user-agent.
Failure modes¶
Common status codes:
400for invalid request payloads401for invalid, expired, or revoked bearer credentials413for prompts that exceed configured size limits429for plan rate-limit exhaustion500for upstream provider or server configuration failures