ScriptGrain Scoring API
Free measurements of any text, against a profile or with none.
Free measurements of any text, against a profile or with none.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/scriptgrain-com:scriptgrain-com-scoring-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: ScriptGrain Scoring API
version: 1.0.0
summary: Voice profiles, drafts in a measured voice, and scores for any text, over HTTPS with an API key.
description: 'ScriptGrain measures how a person or brand writes (45 stylometric attributes in eight groups),
drafts new text in that voice, and scores any text against it. This file describes the public
REST API, version 1, as the code serves it. It is generated from `public/openapi.yaml` in the
ScriptGrain repository and checked against the API''s router in CI, so every route listed here
exists and every error code a handler can return is named below. Human documentation: . The same capabilities are exposed
as an MCP server at `https://mcp.scriptgrain.com/mcp` (). ## Authentication
Every request carries an API key: `Authorization: Bearer sg_live_`. Keys are minted in
the app under Settings, then API, and shown once. A key belongs to an organisation. A personal
workspace key acts as its owner and sees the owner''s personal-workspace rows. A team key acts as
the owner or admin who created it, sees only the team''s rows, puts what it creates in the team,
and stops working (`401 invalid_api_key`) once its creator is no longer a team owner or admin;
leaving or being removed from the team revokes the member''s keys for that team. API access is
open on every plan, including Free; a deployment can narrow it (`system_config`
`api_v1.allowed_plans`), in which case non-billing routes answer `403 plan_not_eligible`. Billing routes (`/v1/billing*`) are never plan-gated. Before any route runs, authentication can also answer `401 unauthorized` (header missing or
malformed), `401 invalid_api_key` (unknown or revoked key), `403 organisation_missing` (the
key''s organisation was deleted) or `402 no_subscription` (no billing record resolves). A
deployment missing its secrets answers `500 misconfigured`. These five are not repeated on each
operation below. ## Responses
Successes return the resource directly. Errors return one envelope:
```json
{ "error": { "code": "invalid_request", "message": "brief (string) is required." } }
```
Some errors add fields beside `message` (for example `credits_required` and
`credits_available` on `402 out_of_credits`, `profile_id` on a profile-creation refusal). Every response, success or error, carries an `X-Request-Id` header to quote at support. Invalid JSON in any request body is `400 invalid_json`. A path whose id segment is not a UUID
never reaches a handler: it is `404 not_found`. CORS: the preflight allows `GET`, `POST`, `DELETE` and `OPTIONS` with the `authorization`,
`content-type`, `accept` and `idempotency-key` headers, so every route can be called from a
browser page as well as from servers and tools. ## Rate limits
60 requests a minute per API key on every route (`429 rate_limited`). Some routes add an hourly
budget per account, stated on the operation (`x-rate-limit`): voice-match 200 an hour, profile
extraction 5 an hour, brand mimic 3 an hour, saved edits 200 an hour, invoice 30, portal link 20,
checkout link 10. Polling a job counts against the 60 a minute. ## Credits
Drafts, polish, humanize, page rewrites and brand mimic cost credits from the same pool the app
uses; everything else is free (`x-credits` on each operation). A draft, polish or humanize is
priced by length: up to 5,000 words 1 credit, up to 10,000 words 2, up to 15,000 words 3,
charged per produced variant **after** it is delivered, so a failed call costs nothing. A page
rewrite is 1 credit per 1,500 rewritable words (minimum 1). Brand mimic costs one brand-mimic
credit. A wallet short of the price answers `402 out_of_credits` (or `402 insufficient_credits`
on a page rewrite). Every route that calls a model can also answer `402 budget_exceeded` when the
account''s monthly AI-spend ceiling is reached. ## Long drafts and background jobs
A draft above 4,000 words, or a polish or humanize above 3,000 words, is written in the
background: the call answers `202 Accepted` with a `job` object and a `poll` path. Poll
`GET /v1/jobs/{id}` (or `GET /v1/generations/{id}` for a draft) every 10 to 30 seconds.'
termsOfService: https://scriptgrain.com/terms
contact:
name: ScriptGrain support
email: support@scriptgrain.com
url: https://scriptgrain.com/support
license:
name: ScriptGrain Terms of Service
url: https://scriptgrain.com/terms
servers:
- url: https://auth.scriptgrain.com/functions/v1/api-v1
description: Production. Every path below is appended to this base.
security:
- ApiKey: []
tags:
- name: Scoring
description: Free measurements of any text, against a profile or with none.
paths:
/v1/voice-match:
post:
operationId: scoreVoiceMatch
tags:
- Scoring
summary: Score any text against a complete profile
description: 'Scores `text` against a profile whose status is `complete`. Stylometric features are measured in
code, a Haiku judge covers the qualitative subset, and a weighted comparator produces the 0 to 1
score. `deltas` is the per-feature measurement the notes are rendered from. `score_context` lists
measured caveats that may make the score under-read (for example a short sample).
Limited to 200 scores an hour per account. Guest keys instead share the app''s free-check budget of
5 an hour per network.'
x-credits: free
x-rate-limit: '200 scores an hour per account (`rate_limited`), on top of 60 requests a minute per key; guest keys: 5 an hour per network'
x-plans: all plans
x-guest-allowed: true
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/VoiceMatchRequest'
example:
profile_id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
text: We shipped the new editor this morning. It is faster, quieter and a lot less fussy… (at least 20 words)
responses:
'200':
description: The score and the measurements behind it.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/VoiceMatchResponse'
example:
profile_id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
voice_match_score: 0.87
voice_match_notes: 'Sentence length and contraction use match closely… Context: short sample.'
deltas:
- feature: avg_sentence_length
label: Sentence length
similarity: 0.94
weight: 1.2
salient: true
detail: draft 13.8 words vs profile 14.2
score_context:
- 'Short sample: 24 words.'
word_count: 24
'400':
description: '`invalid_json`: body is not valid JSON. `invalid_request`: body not an object, `profile_id` not a string, `text` missing or empty, `text` over 50,000 characters, or `text` under 20 words.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
description: '`budget_exceeded`: the owner''s monthly AI-spend ceiling is reached.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: '`profile_not_accessible`: the profile is outside the key''s organisation and the owner''s personal workspace.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: '`profile_not_found`: no profile with that id.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: '`profile_not_ready`: the profile''s status is not `complete`.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: '`rate_limited`: more than 200 voice-match scores in the last hour for this account ("Voice-match scoring is limited to 200 an hour per account. Try again later."), or the global 60 requests a minute per key. Guest keys: the 5-an-hour free-check budget.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: '`internal_error`: the profile lookup failed.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'502':
description: '`upstream_error`: the scorer returned unparseable output.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/v1/compare-voice:
post:
operationId: compareVoice
tags:
- Scoring
summary: Compare pieces against a main piece, no profile needed
description: 'The off-voice check. The `main` piece is measured and judged into a pseudo-profile and each of the
1 to 3 `others` is scored against it. Each piece is either pasted `text` or a public `url`, not
both. URLs are fetched directly, with Firecrawl as the fallback on paid plans when the direct read
is thin. Each piece needs at least 120 words of text, and anything past 3,500 words is truncated
(`truncated: true`).
The score uses a pairwise-calibrated scale, not the profile scale. Bands: `on_voice` at 0.80 or
above, `drifting` at 0.55 or above, otherwise `off_voice`. When any piece is a URL, `notes`
carries a caution that on website copy the score reads brand voice only weakly; `notes` is always
present and is an empty array when nothing applies. Guest keys share the 5-an-hour free-check
budget per network.'
x-credits: free
x-rate-limit: '60 requests a minute per key (global); guest keys: 5 an hour per network'
x-plans: all plans (Firecrawl fallback for URL pieces on paid plans only)
x-guest-allowed: true
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CompareVoiceRequest'
example:
main:
label: About page
url: https://example.com/about
others:
- label: Launch post
text: Today we are opening the doors on our new studio… (at least 120 words)
- url: https://example.com/blog/how-we-hire
responses:
'200':
description: The comparison result.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/CompareVoiceResult'
example:
main:
label: About page
source:
kind: url
url: https://example.com/about
title: About us
words: 412
truncated: false
judge_ok: true
results:
- label: Launch post
source:
kind: text
words: 188
truncated: false
score: 0.71
raw: 0.655
band: drifting
compared: 18
judge_ok: true
top_differences:
- feature: avg_sentence_length
label: Sentence length
detail: this piece 22.1 words vs the main piece's 14.0
similarity: 0.42
top_matches: []
summary:
average: 0.71
on_voice: 0
drifting: 1
off_voice: 0
notes:
- 'Website pages: on marketing copy this score reads brand voice only weakly…'
'400':
description: '`invalid_json`: body is not valid JSON. `invalid_request`: body not an object; `main` or an `others[i]` not an object; a piece with both or neither of `text` and `url`; `text` over 50,000 characters or under 120 words; `url` not http(s); `others` not an array of 1 to 3 pieces.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
description: '`budget_exceeded`: the owner''s monthly AI-spend ceiling is reached.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: '`invalid_request`: a piece could not be resolved. A URL that is blocked, unreachable, slow, not an HTML or text page, redirects somewhere unreadable, or has under 120 words of readable text; or the pieces could not be compared. The message names the piece (`Main piece`, `Piece 1`...).'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
$ref: '#/components/responses/RateLimited'
'500':
$ref: '#/components/responses/InternalError'
/v1/ai-detect:
post:
operationId: aiDetect
tags:
- Scoring
summary: Score how human a text reads
description: Stylometric human-versus-AI analysis of a text, the same detector as the in-app free checker. `text` must be at least 50 words and at most 50,000 characters, measured after trimming. Signals the text does not support (quoted phrases absent from the text, or claims a code check disproves) are dropped before the answer is returned; the score itself is left as the model gave it.
x-credits: free
x-rate-limit: 60 requests a minute per key (global)
x-plans: all plans
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AiDetectRequest'
example:
text: Our team shipped the new onboarding flow on Tuesday, and honestly it was a scramble. Two of us were up until midnight fixing a bug in the email step that nobody had caught in review…
responses:
'200':
description: The detector result.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/AiDetectResult'
example:
human_score: 0.72
signals:
- marker: Uneven sentence lengths, from 4 to 31 words
direction: human
- marker: Stock connective "moreover" used twice
direction: ai
summary: Mostly human cadence with two stock connectives.
'400':
description: '`invalid_json`: the body is not valid JSON.
`invalid_request`: the body is not a JSON object, `text` is missing or blank, `text` is over 50,000 characters, or `text` is under 50 words.
'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
description: '`budget_exceeded`: the account has reached its monthly AI usage safety ceiling.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
$ref: '#/components/responses/RateLimited'
'500':
$ref: '#/components/responses/InternalError'
'502':
description: '`upstream_error`: the detector call failed or its result could not be parsed.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
responses:
RateLimited:
description: '`rate_limited`: more than 60 requests in a minute on this key, or a route''s hourly budget is used.'
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded (60 req/min per API key). Try again shortly.
InternalError:
description: '`internal_error`: a server-side failure. Quote `X-Request-Id` to support.'
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: internal_error
message: Unexpected server error. Quote your X-Request-Id to support.
Unauthorized:
description: '`unauthorized`: the `Authorization` header is missing or malformed. `invalid_api_key`: the key
is not recognised or was revoked. For a guest key also `guest_expired` and `guest_claimed`.
'
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: invalid_api_key
message: API key not recognised.
schemas:
AiDetectResult:
type: object
required:
- human_score
- signals
additionalProperties: true
description: The detector model's JSON with unverifiable signals removed. Fields beyond those listed may appear if the model returns them.
properties:
human_score:
type: number
minimum: 0
maximum: 1
description: Higher means more human.
signals:
type: array
items:
$ref: '#/components/schemas/DetectorSignal'
summary:
type: string
ComparePiece:
type: object
description: One piece, given as exactly one of `text` or `url`.
properties:
label:
type: string
maxLength: 80
description: Optional display label; trimmed and cut to 80 characters.
text:
type: string
maxLength: 50000
description: Pasted text, at least 120 words.
url:
type: string
format: uri
description: A public http(s) page.
oneOf:
- required:
- text
- required:
- url
DetectorSignal:
type: object
required:
- marker
- direction
properties:
marker:
type: string
description: The observed pattern, quoted from or measured on the text.
direction:
type: string
enum:
- human
- ai
description: Whether the marker points to human or machine writing.
AiDetectRequest:
type: object
required:
- text
properties:
text:
type: string
maxLength: 50000
description: At least 50 words and at most 50,000 characters, measured after trimming.
VoiceMatchRequest:
type: object
required:
- profile_id
- text
properties:
profile_id:
$ref: '#/components/schemas/Uuid'
text:
type: string
minLength: 1
maxLength: 50000
description: At least 20 words (counted after trimming) and at most 50,000 characters.
VoiceMatchResponse:
type: object
required:
- profile_id
- voice_match_score
- voice_match_notes
- deltas
- score_context
- word_count
properties:
profile_id:
$ref: '#/components/schemas/Uuid'
voice_match_score:
type: number
minimum: 0
maximum: 1
voice_match_notes:
type:
- string
- 'null'
description: Prose rendered from the deltas, with an optional trailing "Context:" sentence group.
deltas:
type: array
items:
$ref: '#/components/schemas/FeatureDelta'
score_context:
type: array
description: Measured caveats explaining why the score may under-read; empty when none apply.
items:
type: string
word_count:
type: integer
CompareVoiceDifference:
type: object
required:
- feature
- label
- detail
- similarity
properties:
feature:
type: string
label:
type: string
detail:
type: string
description: Reworded so "this piece" is the compared piece and "the main piece" is the baseline.
similarity:
type: number
minimum: 0
maximum: 1
Uuid:
type: string
format: uuid
description: A UUID. Path ids that are not UUID-shaped never match a route (404 `not_found`).
example: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
CompareVoiceRequest:
type: object
required:
- main
- others
properties:
main:
$ref: '#/components/schemas/ComparePiece'
others:
type: array
minItems: 1
maxItems: 3
items:
$ref: '#/components/schemas/ComparePiece'
Error:
type: object
description: 'The error envelope every failure returns. `error.code` is stable and listed in this
description''s error-code table; `error.message` is for people and may change. Some codes
add fields beside them (`credits_required`, `credits_available`, `profile_id`,
`generation_id`, `retry_after_seconds`). A guest key''s errors also carry `claim_url` and
`expires_at` at the top level.
'
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
examples:
- invalid_request
- out_of_credits
- profile_not_found
message:
type: string
additionalProperties: true
additionalProperties: true
example:
error:
code: invalid_request
message: brief (string) is required.
CompareVoicePieceResult:
type: object
required:
- label
- source
- words
- truncated
- score
- raw
- band
- compared
- judge_ok
- top_differences
- top_matches
properties:
label:
type: string
source:
$ref: '#/components/schemas/CompareVoicePieceSource'
words:
type: integer
truncated:
type: boolean
score:
type: number
minimum: 0
maximum: 1
description: Pairwise-calibrated score, rounded to two decimals.
raw:
type: number
description: Raw feature agreement before calibration, rounded to three decimals.
band:
type: string
enum:
- on_voice
- drifting
- off_voice
description: '`on_voice` at 0.80 or above, `drifting` at 0.55 or above, otherwise `off_voice`.'
compared:
type: integer
description: How many features were compared.
judge_ok:
type: boolean
description: '`false` when the judge failed for this piece or the main piece.'
top_differences:
type: array
maxItems: 3
description: Up to three features with similarity 0.6 or below, largest weighted gap first.
items:
$ref: '#/components/schemas/CompareVoiceDifference'
top_matches:
type: array
maxItems: 3
description: Up to three salient features with similarity 0.75 or above.
items:
$ref: '#/components/schemas/CompareVoiceDifference'
CompareVoicePieceSource:
oneOf:
- type: object
required:
- kind
properties:
kind:
type: string
enum:
- text
- type: object
required:
- kind
- url
- title
properties:
kind:
type: string
enum:
- url
url:
type: string
format: uri
title:
type: string
CompareVoiceResult:
type: object
required:
- main
- results
- summary
- notes
properties:
main:
$ref: '#/components/schemas/CompareVoiceMain'
results:
type: array
description: One entry per item in `others`, in order.
items:
$ref: '#/components/schemas/CompareVoicePieceResult'
summary:
type: object
required:
- average
- on_voice
- drifting
- off_voice
properties:
average:
type: number
description: Mean of the piece scores, two decimals.
on_voice:
type: integer
drifting:
type: integer
off_voice:
type: integer
notes:
type: array
items:
type: string
description: Reading notes; holds the website-copy caution when any piece is a URL, otherwise empty.
CompareVoiceMain:
type: object
required:
- label
- source
- words
- truncated
- judge_ok
properties:
label:
type: string
source:
$ref: '#/components/schemas/CompareVoicePieceSource'
words:
type: integer
truncated:
type: boolean
description: '`true` when the piece was cut to 3,500 words.'
judge_ok:
type: boolean
description: '`false` when the judge call failed and the score used measured features only.'
FeatureDelta:
type: object
description: One measured feature of a text against a profile, the evidence a voice-match score is built from.
required:
- feature
- label
- similarity
- weight
- salient
- detail
properties:
feature:
type: string
description: The feature's key, e.g. `avg_sentence_length`.
label:
type: string
description: The feature's name for people.
similarity:
type: number
minimum: 0
maximum: 1
description: Agreement between the text and the profile on this feature.
weight:
type: number
description: The feature's weight in the overall score.
salient:
type: boolean
description: false for weak-evidence agreements (both sides near zero on a rare habit); those are down-weighted and never headlined as a match.
detail:
type: string
description: The actual numbers, e.g. "draft 14.2 words per sentence vs profile 19.8".
example:
feature: avg_sentence_length
label: Average sentence length
similarity: 0.71
weight: 1.4
salient: true
detail: draft 14.2 words per sentence vs profile 19.8
headers:
X-Request-Id:
description: A 16-character hex id for this request. Quote it when contacting support.
schema:
type: string
pattern: ^[0-9a-f]{16}$
example: 8c99d4ada706a856
securitySchemes:
ApiKey:
type: http
scheme: bearer
bearerFormat: sg_live_<secret> or sg_guest_<token>
description: 'An API key minted in the app (Settings, then API), sent as `Authorization: Bearer sg_live_…`.
The secret is shown once; the server stores a SHA-256 hash. A guest token from
`POST /v1/guest` (`sg_guest_…`) is sent the same way and may call only the routes marked
`x-guest-allowed`.
'
externalDocs:
description: Human-readable API documentation
url: https://scriptgrain.com/docs/api.md