API / v1
AnyCast documentation
AnyCast is one API that turns messy text (emails, order notes, chat logs, and text/CSV/JSON exports pasted as text) into JSON that validates against the JSON Schema you send. Grammar-constrained decoding guarantees the structure of the output; extraction accuracy is evaluated separately.
Status: early access
Available now: accounts, API keys, the usage dashboard, request checks, these docs and a simulated playground.
January 2027: the extraction engine, Flex jobs, billing, and published accuracy and latency results.
Until launch, POST /api/v1/transform and GET /api/v1/jobs/{job_id} validate your key (and request body), log the call, and return 503 launching_soon. These responses are not billed. The request format below is the launch format, so you can build and test your integration now.
Sections marked Launch spec describe behavior that switches on in January 2027. Everything else is enforced by the live endpoint today.
Quickstart
- Create an account and a key. Sign up, then create a key under API keys. Keys look like
ac_live_followed by 48 hex characters and are shown once. - Store it as an environment variable.
export ANYCAST_API_KEY="ac_live_…" - Send a request with your text and schema:
Want to try schemas first? The playground simulates the launch contract in your browser and builds this request for you.
Request
POST https://anycast-systems.whop.site/api/v1/transform
Headers
| Header | Value |
|---|---|
Authorization | Bearer ac_live_… (required) |
Content-Type | application/json (required; anything else returns 400) |
Body
| Field | Type | Description |
|---|---|---|
input | string, required | The text to extract from. Non-empty, up to 200,000 characters. |
schema | object, required | A JSON Schema with root "type": "object". Up to 50 KB (serialized). See schema support. |
flex | boolean, optional | Default false. true runs the request as an asynchronous Flex job: 25% off whichever size runs (Standard or Large), results within 24 hours. |
allow_large | boolean, optional | Default false. true lets input over the Standard limit run as a Large call ($0.0008). Without it, long input returns 413 too_long_for_standard. See Limits & Large. |
webhook_url | string, optional | An https:// URL up to 2,000 characters. Only allowed with "flex": true. AnyCast POSTs the finished job object here, signed with a per-job webhook_secret returned in the 202 response. |
instructions | string, optional | Accepted by the request check (up to 2,000 characters). Reserved for extra extraction guidance. |
Response Launch spec
A successful Standard or Large call returns 200 with data (an object that validates against your schema) and missing (the paths of fields the text didn’t contain).
A Flex request returns 202 with a job instead; see Flex jobs. Errors return a non-2xx status with { "error": { "type": "…", "message": "…" } }; see Errors.
Missing fields Launch spec
data always validates against your schema. When the text doesn’t contain a field, what happens depends on how the schema declares it:
| Field not found, and the schema… | Result | Billed |
|---|---|---|
allows null, e.g. "type": ["string", "null"] | Returned as null, listed in missing. | Yes |
makes it optional (not in required) and not nullable | Omitted from data, listed in missing. | Yes |
| makes it required and not nullable | No data. HTTP 422 with "type": "incomplete_extraction" and a missing list. | No |
{
"error": {
"type": "incomplete_extraction",
"message": "Required, non-nullable fields not found in the text: order_id.",
"missing": ["order_id", "payment_terms"]
}
}
Paths use dots for nested objects and brackets for array items, for example ship_to.city or items[1].variant. Tip: declare a field nullable when “not stated” is an acceptable answer, and required + non-nullable only when you’d rather get a 422 than a record without it.
Structure vs accuracy
- Guaranteed (structure): grammar-constrained decoding guarantees that
dataparses and validates against your schema: types, required fields, nullable types, enums and supported formats. - Intended behavior (missing fields): AnyCast is designed to return
nullor omit a field rather than guess when the text doesn’t state it. - Not guaranteed (accuracy): a schema-valid value can still be wrong. Extraction accuracy is evaluated separately from schema compliance; measured accuracy and latency will be published after launch.
JSON Schema support at launch
Supported
- Root
"type": "object" propertiesandrequired- Nested objects
- Arrays (
items), including arrays of objects string,number,integer,boolean- Nullable types:
["string", "null"],["number", "null"],["integer", "null"],["boolean", "null"],["object", "null"],["array", "null"] enumformat:date,date-time,email
Not supported
$refacross documentsoneOf,anyOf,allOf- A root type other than
object
Supported inputs
Text only. Send emails, order notes, chat logs, support tickets, and text, CSV or JSON exports pasted as a string in input. Images, PDFs and file uploads are not accepted; extract their text first.
Limits & Large
Large is explicit opt-in. A call is never upgraded to Large unless you set "allow_large": true. A Large call costs $0.0008 ($800 per million), about 16.7× a Standard call, or $0.0006 ($600 per million) as a Flex job.
| Situation | Result | Billed |
|---|---|---|
| Input ≤ 1,500 tokens | Standard call | $0.000048 |
Input > 1,500 tokens, allow_large false or absent | 413 too_long_for_standard | No |
Input > 1,500 tokens, allow_large: true | Large call | $0.0008 |
Input > 1,500 tokens, flex: true + allow_large: true | Large Flex job (async) | $0.0006 |
Input > 1,500 tokens, flex: true without allow_large | 413 too_long_for_standard | No |
| Input > 32,000 tokens (any settings) | 413 input_too_long | No |
| Output would exceed 300 tokens (Standard) or 4,000 (Large) | 422 output_limit | No |
Enforced now vs at launch
| Limit | Value | Enforced |
|---|---|---|
| Request body | 6 MB | Now · 413 |
input length | 1–200,000 characters | Now · 400 |
schema size | 50 KB serialized | Now · 400 |
flex, allow_large | Booleans | Now · 400 |
webhook_url | https://, ≤ 2,000 characters, only with flex: true | Now · 400 |
instructions length | 2,000 characters | Now · 400 |
| Standard call | 1,500 input tokens (~6,000 characters), 300 output tokens | At launch · 413 / 422 |
| Large call | 32,000 input tokens, 4,000 output tokens | At launch · 413 / 422 |
| Missing required field | See Missing fields | At launch · 422 |
The 200,000-character request check is wider than the largest call. At launch, text must also fit the token limits of the call type.
Flex jobs Launch spec
Flex is asynchronous and 25% off whichever size runs: $0.000036 per Standard call, $0.0006 per Large call (long input also needs "allow_large": true). Results arrive within 24 hours, usually much sooner. Set "flex": true; optionally add a webhook_url.
1. Submit → 202 Accepted
If the request includes webhook_url, the 202 response also contains webhook_secret (whsec_…): unique to this job, shown only in this response and never retrievable again. Store it with the job_id. Without webhook_url there is no webhook_secret field.
2. Poll the job
GET https://anycast-systems.whop.site/api/v1/jobs/{job_id}
Job object
| Field | Description |
|---|---|
job_id | job_ followed by letters and digits. |
status | queued → running → succeeded or failed. |
result | { "data", "missing" } when succeeded, otherwise null. Same missing-field contract as a synchronous call. |
error | { "type", "message" } when failed (e.g. incomplete_extraction, output_limit), otherwise null. |
completed_at | ISO 8601 time the job finished, or null while queued or running. |
3. Webhook (optional)
When the job finishes (succeeded or failed), AnyCast sends POST to your webhook_url with the same job object as the body, plus an AnyCast-Signature header:
POST /hooks/anycast HTTP/1.1 Content-Type: application/json AnyCast-Signature: t=1799746887,v1=5d1f0c…e9a4
tis the Unix timestamp of the delivery attempt.v1is the hex HMAC-SHA256 of"<t>.<raw body>", keyed with that job’swebhook_secret.- Verify the signature with a constant-time comparison, and reject timestamps older than 5 minutes.
import crypto from "node:crypto";
// rawBody: the exact request body string; secret: the job's webhook_secret
function verifyAnyCast(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false; // older than 5 minutes
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(parts.v1 ?? "");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
Delivery and retries: each attempt times out after 10 seconds. Non-2xx responses and timeouts are retried with backoff for up to 24 hours. Respond with any 2xx to acknowledge. The job is always available from GET /api/v1/jobs/{job_id} for 7 days, so polling is the fallback if deliveries fail.
Billing & retention
- Billed only when the job reaches
succeeded. Failed jobs are not billed. - Results are kept for 7 days for retrieval, then deleted.
- Flex input text is held encrypted only until the job runs, then deleted.
Errors
Checks run in this order: API key, then body, then fields. Every error has the shape { "error": { "type", "message" } }. No error is billed.
| Status | type | When | Enforced |
|---|---|---|---|
401 | unauthorized | Missing or malformed Authorization header, or an unknown / revoked key. Includes WWW-Authenticate: Bearer. | Now |
400 | invalid_request | Content-Type isn’t application/json; body empty, not valid JSON, or not an object; schema missing, not an object, or over 50 KB; input empty, not a string, or over 200,000 characters; flex or allow_large not a boolean; webhook_url not an https URL ≤ 2,000 characters, or sent without flex: true; instructions not a string or over 2,000 characters. | Now |
413 | invalid_request | Request body over 6 MB. | Now |
413 | too_long_for_standard | Input over 1,500 tokens without allow_large: true (with or without flex). | At launch |
413 | input_too_long | Input over 32,000 tokens, regardless of allow_large. | At launch |
422 | incomplete_extraction | A required, non-nullable field isn’t in the text. Includes missing. | At launch |
422 | output_limit | The result would exceed the output cap: 300 tokens (Standard) or 4,000 (Large). | At launch |
405 | method_not_allowed | Wrong method: /transform takes POST, /jobs/{id} takes GET. | Now |
404 | not_found | Unknown endpoint, or a job id that isn’t job_ + letters/digits. | Now |
503 | launching_soon | Key and request are valid; extraction launches January 2027. Logged, not billed. | Now (until launch) |
503 | unavailable | The API is being configured or is temporarily unavailable. Retry with backoff. | Now |
{
"error": {
"type": "launching_soon",
"message": "AnyCast is launching soon. Your API key is valid and ready."
}
}
Billing rules
| Call type | Price | Per call | Example |
|---|---|---|---|
| Standard | $48 per million calls | $0.000048 | 100,000 calls = $4.80 |
Standard Flex ("flex": true) | $36 per million calls (25% off) | $0.000036 | 100,000 calls = $3.60; async |
Large ("allow_large": true) | $0.80 per thousand calls ($800 per million) | $0.0008 | 1,000 calls = $0.80; about 16.7× Standard |
Large Flex ("flex": true + "allow_large": true) | $0.60 per thousand calls ($600 per million, 25% off) | $0.0006 | 1,000 calls = $0.60; async |
- Prepaid credits by card. Automatic top-ups are optional.
- No subscription and no minimum spend.
- Price is per call, not per token.
- Large is used only when you set
allow_large: true; it is never applied automatically. - Never billed: errors, invalid keys,
413,422and503responses, and failed Flex jobs. Flex is billed only onsucceeded.
Data handling
- Standard and Large input is processed in memory and never stored.
- Flex input is held encrypted only until the job runs, then deleted. Flex results are kept for 7 days for retrieval, then deleted.
- Only metadata is logged: time, key, status, size and response time.
- API keys are stored hashed (SHA-256). We can’t show a key again after creation.
- Keys can be revoked instantly from the dashboard.
Other endpoints
| Endpoint | Returns |
|---|---|
GET /api/v1/jobs/{job_id} | The job object at launch. Today: checks your key, returns 404 for a malformed id, otherwise 503 launching_soon. |
GET /api/v1/health | { "ok": true, "version": "v1" } when the key service is configured. No key needed. |
GET /api/v1/key | { "valid": true, "key_id": "…" } for a valid key, otherwise 401. Use it to test a key without calling transform. |
All endpoints send CORS headers (Access-Control-Allow-Origin: *). Keep API keys on your server; don’t ship them in browser code.