For the complete documentation index, see llms.txt. Every page is also served as Markdown at its URL followed by .md.

standards
Structured generationAgents

Structured generation

Ask a model of your workspace's catalogue for an object that satisfies your own JSON Schema, journaled and charged like every AI call.


POST /ai/generate/object runs one generation for your own code: you give a prompt, a JSON Schema and, optionally, a model of the workspace's catalogue; Standards answers with an object that satisfies the schema. A classifier, a judge or an extractor needs no model key and no AI SDK of its own, and what it spends shows in the workspace's usage.

The request

curl -X POST "https://api.standards.new/v1/ai/generate/object" \
  -H "Authorization: Bearer stndrds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-5.5",
    "system": "Say whether the document is a bank account statement.",
    "prompt": "IBAN FR76 3000 6000 0112 3456 7890 189 …",
    "schema": {
      "type": "object",
      "properties": { "isStatement": { "type": "boolean" }, "reason": { "type": "string" } },
      "required": ["isStatement", "reason"]
    }
  }'
FieldDescription
promptWhat the model answers. Required.
schemaThe JSON Schema the object must satisfy. Required. A $ref is read when it is # or #/$defs/<name> naming an entry of the root's $defs (#/definitions/<name> under draft-07 and draft-04), recursion included when it goes through a property or an item; a recursion that applies itself more than once to the same value (two of its $refs in one allOf, anyOf or oneOf, or beside each other in one schema) is refused, since an answer would cost a check per path through the copies, but a binary tree (left and right both { "$ref": "#" }) is read; any other $ref (external, or spelled otherwise), or one that loops back to itself without descending ({ "$ref": "#" }), is refused. pattern and patternProperties are refused: describe a format in the prompt instead. At most 64 levels deep and 1,000 objects and arrays, counted both as written and with each $ref read in place.
systemInstructions sent as the system message.
modelA model id of the workspace's catalogue, with or without its provider prefix. Omitted, the workspace's utility model answers. Either runs at its lowest reasoning effort.

The answer is 201:

{
  "object": { "isStatement": false, "reason": "A transfer order, with a bank detail attached." },
  "model": "claude-haiku-5.5",
  "usage": { "inputTokens": 412, "outputTokens": 38 }
}

model is the catalogue id of the model that answered. An answer the schema refuses is asked again with the reason, at most twice, and usage sums every attempt. An answer nested deeper than 64 levels is refused the same way, before the schema checks it.

Refusals

StatusCodeWhen
400AI_INVALID_MODELmodel is not in the workspace's catalogue.
400AI_MODEL_DISABLEDmodel is one the workspace disabled (disabled models).
400SCHEMA_VALIDATION_FAILEDschema is not a JSON Schema Standards reads, uses a refused keyword, or exceeds its bounds.
402CREDITS_EXHAUSTEDThe workspace has no credits left for the call.
403SCHEMA_FORBIDDENThe caller lacks agents:read.
500AI_GENERATION_FAILEDThe model never produced a valid object, or stopped at its output cap.

The 400 refusals are answered before any model is called, so they cost nothing.

From the SDK

import { createStandards } from "@standards/client";
import * as z from "zod";

const standards = createStandards();
const verdict = z.strictObject({ isStatement: z.boolean(), reason: z.string() });

const { object } = await standards.ai.generateObject({
  model: "anthropic/claude-haiku-5.5",
  prompt: documentText,
  schema: z.toJSONSchema(verdict),
});

const { isStatement } = verdict.parse(object);

object arrives as unknown: parse it with the schema you sent to get its type.

Charged like a chat turn

The call is written to the AI journal before it runs and priced when the AI Gateway reports its cost, as every generation is. It needs agents:read, the grant that lets a member spend the workspace's AI by chatting with an agent.

Next steps