Integrations/REST API

MegaLens REST API

Run a MegaLens review from any script, CI job or tool that can send an HTTP request, not only from an IDE.

Use cases

CI/CD pipelines

You can call the API from your CI job and fail the build on findings you choose. No IDE required.

PR automation

Your own bot can post the findings as pull request comments. Findings include a severity and a next step, and a file and line when the code was sent.

Custom platforms

Build MegaLens review into your own tools. Internal dashboards, Slack bots, code review portals, anything with HTTP.

Large jobs

Send large jobs to POST /api/v1/analyses and fetch the result later from GET /api/v1/analyses/{id}. Up to 500 KB of context per job.

Quick start

A full review takes a few minutes, so it runs in the background. Start it with one POST, then ask for the result with GET.

1. Start the review

curl -X POST https://megalens.ai/api/v1/analyses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: build-1234" \
  -d '{
    "skill": "code_intelligence",
    "mode": "multi",
    "tier": "standard",
    "prompt": "Review this function",
    "context": "..."
  }'

It answers at once with 202 Accepted and a run id:

{
  "runId": "RUN_ID",
  "status": "queued",
  "mode": "multi",
  "tier": "standard",
  "skill": "code_intelligence"
}

The Idempotency-Key header is optional. If you send the same key again, you get the run you already started instead of a second, paid one.

2. Ask for the result

curl https://megalens.ai/api/v1/analyses/RUN_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

status is queued, running, completed, failed or cancelled. While the run is going, the response has a Retry-After header: wait that many seconds before you ask again. When it is completed, the findings are in result. When it failed, the reason is in error. Asking for the result does not use up a call.

Endpoints

MethodEndpointDescription
POST/api/v1/analysesFull review. Returns a run id to poll.
GET/api/v1/analyses/{id}Status and result of a review you started.
POST/api/v1/analyzeQuick review, answers in seconds. Waits for the answer, so use it only with mode quick.
GET/api/v1/usageCalls used and remaining today for this key.

Skills

Each skill configures the review pipeline for a specific domain. Pass the skill name in the skill field.

code_intelligenceCode Intelligence
security_auditSecurity Audit
full_auditFull Audit
researchResearch
seoSEO
saas_launchSaaS Launch
wordpressWordPress
legalLegal
generalGeneral
planningPlanning
diff_auditDiff Audit

Modes

quickQuick

A review by a single engine. It answers fastest, so use it for simple checks where you need a quick answer.

multiMulti

Several models review independently. A final check reviews their findings. Use POST /api/v1/analyses for multi. It takes a few minutes.

Tiers

TierReviewing modelsFinal checkSecond check
free2YesNo
standard3YesNo
deep3YesYes

Pricing

REST API access needs a plan or pay-as-you-go credits. REST API calls are paid from pay-as-you-go credits.

Plus and Pro

From $19 a month

A monthly allowance of reviews with model usage included: up to 100 reviews on Plus, 300 on Pro. MegaLens selects up to four reviewing models. Cancel any time.

Pay-as-you-go credits

$9 per 1M tokens, max $3 a review

Blended rate, prepaid from $20. No provider key needed.

How model costs are paid

On a plan, model usage is part of your monthly allowance. Otherwise, pay-as-you-go credits: $9 per 1M blended tokens, capped at $3 per review, prepaid from $20. See all plans

Multi engine review via HTTP.

Use it from CI, bots or your own tools. No IDE needed.