Skip to content

Execution Platform Overview

This page is intentionally narrow: it documents the limited execution-related HTTP endpoints that Community Edition already references.

It is not the canonical onboarding surface for the full product. For OSS developers, start with Community API and treat this page as execution-platform notes only.

Integrating from an external AI agent or SaaS? See the AI Agent Integration Guide for a step-by-step walkthrough with token setup, curl examples, and response parsing.

Community API vs. Platform API

Choose the right entry point before building your integration:

Community APIPlatform API (this page)
Base URLYour Supabase instancehttps://api.lenserfight.com
AuthSupabase JWT or anon keyBearer token (LENSERFIGHT_API_KEY)
PurposeFull CRUD: lenses, lensers, threads, agents, workflowsExecution, billing, streaming
Start here ifBuilding on top of the OSS data layerTriggering AI execution or handling credits
DocsCommunity API ReferenceThis page

Most integrations use both: the Community API to read lens and workflow definitions, and the Platform API to execute them.


API URL is determined by ENV_MODE

The API base URL changes based on your environment:

EnvironmentURL
Production (ENV_MODE=production)https://api.lenserfight.com
Development (ENV_MODE=development)http://localhost:8786

Never hardcode the URL — always read it from the environment variable API_URL (frontend) or ENV_MODE (server-side).

Current HTTP surface

Path prefixWorkerDescription
/wallet/*lf-wallet-apiBalance, transactions, checkout, pricing
/execute/*lf-execution-proxyAI model execution (wallet, BYOK, image, stream)
/webhook/*lf-billing-webhookLemonSqueezy billing events

Community Edition should only rely on the /execute/* endpoints already used by the repo.

Authentication

JWT (User Context)

User-facing endpoints require a Supabase JWT via the Authorization header:

Authorization: Bearer <JWT_TOKEN>

The JWT is obtained by signing in via Supabase Auth. The lenser ID is extracted from the JWT sub claim.

API Key (Internal/Service)

Internal service-to-service endpoints use the platform API key via the X-Platform-Api-Key header. Only internal workers have this key — regular users cannot access these endpoints.

Response Contract

Every endpoint returns ApiResponseEnvelope<T>:

typescript
{
  data?: T       // Present on success
  error?: ApiError  // Present on failure
  meta?: ApiMeta    // Always present
}

ApiMeta

FieldTypeDescription
requestIdstringUnique request ID. Include in bug reports.
durationMsnumberServer-side processing time in milliseconds.
limitnumberPage size (paginated endpoints only).
offsetnumberRecord offset from start (paginated endpoints only).
totalnumberTotal records available (paginated endpoints only).
hasNextPagebooleanWhether more records exist (paginated endpoints only).

ApiError

FieldTypeDescription
codestringMachine-readable dot-notation code (e.g. wallet.not_found).
messagestringHuman-readable explanation.
detailsobjectOptional structured details (e.g. validation field errors).

Execution endpoints summary

MethodPathAuthDescription
POST/execute/walletJWTExecute AI request (charges wallet credits)
POST/execute/byokJWTExecute AI request (user's own API key, no charge)
POST/execute/imageJWTGenerate images via Fal.ai FLUX (charges credits)
POST/execute/streamJWTStream AI tokens via SSE (charges credits)

What this page does not promise

  • a complete public platform API
  • private worker contracts as a stable OSS integration surface
  • public battles, benchmarking, or enterprise APIs
  • self-host parity with private cloud execution infrastructure

Error Code Reference

error.codeHTTP StatusMeaning
auth.missing_token401No Authorization header or not Bearer format
auth.invalid_token401JWT expired, malformed, or sub claim missing
auth.profile_not_found404JWT valid but lenser profile not found
auth.unauthorized401Missing or invalid X-Platform-Api-Key
validation_error400Request body or query failed schema validation — see details
not_found404No route matched the request path
wallet.not_found404Wallet account not found for this lenser
wallet.insufficient_balance402Not enough credits to complete the operation
wallet.account_frozen403Account suspended by admin
wallet.spending_limit_exceeded429Daily or monthly spend cap reached
wallet.invalid_amount400Amount is invalid (e.g. zero or negative)
wallet.reservation_failed503Wallet service unavailable during reservation
pricing.not_found404No pricing configured for this model
execute.model_not_found404Model not in catalog or not active
execute.pricing_failed500Credit cost calculation failed
execute.invalid_messages400Messages array failed sanitization
execute.unsupported_provider400Provider has no platform key configured
execute.provider_failed502AI provider returned an error
execute.provider_mismatch400Requested provider doesn't match BYOK key's provider
execute.key_resolution_failed403BYOK key not found or not owned by this user
billing.variant_not_found404LemonSqueezy variant not found in billing schema
billing.session_failed500Failed to create checkout session
billing.upstream_error502LemonSqueezy API returned an error
webhook.invalid_signature401HMAC signature mismatch
webhook.invalid_json400Webhook body is not valid JSON
webhook.missing_session400session_id not present in custom_data
webhook.session_not_found404Checkout session not found
webhook.processing_failed500Webhook handler threw an unexpected error
internal_error500Unhandled server error

Rate limits

EndpointLimitWindow
POST /execute/wallet100 requestsPer minute per user
POST /execute/image30 requestsPer minute per user

Exceeded limits return HTTP 429 with a Retry-After header.