AI Simulation API

One model, atypica-persona-1, simulates people. Give it who they are, what they can do, and what has happened so far; it returns what they think, say and do next. Three endpoints cover one person, a group of people who perceive each other, and a moderated session that runs to a research goal.

EndpointSimulates
/v1/persona/responsesOne person
/v1/group/responsesSeveral people who see and hear each other
/v1/simulation/responsesAn interview, focus group or co-creation session, run by a built-in moderator to a goal

The API is stateless. The caller keeps the history (items) and sends all of it with every request; each response returns only the new items, which the caller appends before the next request.

Examples in Action

Runs recorded from the live API, played back item by item: two scenarios each for one person and for a group, and one session of each format. Lines marked "from the app" are what the calling app adds; everything else came back from the API. A divider marks where one request ended and why.

A shopper decides between a new product on promotion and her usual one. The app plays the store: it reports what the purchase did and adds the cashier's question.

POST /v1/persona/responses · sent with every request, besides items
profile
Lin, 29, UI designer in Shenzhen. Reads ingredient labels, watches prices, curious about new things but hates wasting money.
tools
think, say, buy(item: new cold brew | usual instant coffee)
3 requests

Press Play to watch the requests come back.

Authentication

Send a personal API key in the Authorization header. Create one in Account Settings → API Keys. Usage is charged to the key owner's token balance and shows on the account usage page, one row per request.

Authorization: Bearer atypica_...

Base URL: https://atypica.musedam.cc

Quick Start

One request to the Persona API:

curl https://atypica.musedam.cc/v1/persona/responses \
  -H "Authorization: Bearer $ATYPICA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "atypica-persona-1",
    "profile": "Lin, 29, UI designer in Shenzhen. Reads ingredient labels, watches prices.",
    "tools": [{ "type": "think" }, { "type": "say" }],
    "items": [
      { "type": "stimulus", "content": "A store clerk asks: want to try our new oat latte?" }
    ]
  }'
{
  "id": "resp_9p32WcgPDKezk9qvMDPVAhzV",
  "model": "atypica-persona-1",
  "output": [
    { "type": "say", "content": "Sure—is it a free sample? And is the oat milk sweetened?" }
  ],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 1429, "output_tokens": 44 }
}

The person may think before speaking or not; think items appear only when they do. To continue, append output and a new stimulus to items and send the request again.

Persona API

POST/v1/persona/responses

Simulates one person. profile says who they are; tools says what they can do; items is everything they have perceived and done so far. The response is what they do next, until they wait for something new to happen or take an action whose result the caller has to report.

FieldTypeDescription
modelstringRequired. Only atypica-persona-1
profilestringRequired. Who this person is, 1 to 20,000 characters
toolsarrayRequired. What this person can do, see Tools
itemsarrayRequired. The history so far, see Items
streambooleanOptional. true streams the response, see Streaming

Group API

POST/v1/group/responses

Simulates several people in one place who see and hear each other. Each time, the model decides who reacts next from what just happened, and that person reacts from their own view. The request ends when nobody has anything more to react to. The group models only the people: the world, rules, a moderator or a referee come in from the caller as stimulus or action_result.

The request is the same as the Persona API, with personas instead of profile. Items written by a person carry a persona field.

{
  "model": "atypica-persona-1",
  "personas": [
    { "name": "Lin", "profile": "29, UI designer, reads labels, watches prices. Partner of Zhe." },
    { "name": "Zhe", "profile": "31, programmer, has bought the same instant coffee for eight years." }
  ],
  "tools": [{ "type": "think" }, { "type": "say" }],
  "items": [
    { "type": "stimulus", "content": "Saturday afternoon, the two of them reach the coffee shelf. A new cold brew is half price on the second pack." }
  ]
}
FieldTypeDescription
personasarrayRequired. 1 to 10 of { name, profile }. name is 1 to 64 characters, unique, one line, without < > " 「 」; it is how the others refer to this person and the persona value on their items

Simulation API

POST/v1/simulation/responses

Runs a research session with a built-in moderator. The caller gives the format, the goal and optionally a guide; the moderator follows the format's method, asks until the goal can be answered, and then ends the session. The participants are a group as in the Group API.

One request is one turn of the moderator: the moderator says one thing, and the participants react to it. Append output to items and send the next request; repeat until stop_reason is end_simulation.

{
  "model": "atypica-persona-1",
  "format": "focus_group",
  "goal": "Find out how people feel about ready-made meals, what worries them, and when they would buy one.",
  "guide": "1. Opening: does each person eat ready-made meals, first reaction.\n2. Show a sample: braised pork, $4.20 a box, five minutes to heat. Would each buy it, and why.\n3. Closing: one sentence each on where they stand now.",
  "personas": [
    { "name": "Grace", "profile": "41, two kids, cooks carefully but is always busy." },
    { "name": "Rain", "profile": "24, rents a room with one induction hob, mostly orders delivery." }
  ],
  "tools": [{ "type": "think" }, { "type": "say" }],
  "items": [
    { "type": "stimulus", "content": "A meeting room. The participants sit around a table." }
  ]
}
FieldTypeDescription
formatstringRequired. interview (one-to-one; personas has exactly one person), focus_group or co_creation. Each format has its own built-in method, which the caller cannot change
goalstringRequired. What this session has to find out, 1 to 4,000 characters. The session ends when it can be answered
guidestringOptional. The caller's discussion guide: stages, what to ask, what to show, 1 to 20,000 characters. Without it, the format's own stages are used
personasarrayRequired. The participants, as in the Group API

A participant cannot be named after the moderator's title in that format: 访谈员 (interview), 主持人 (focus group) or 引导者 (co-creation). The participants hear the moderator as that title.

The moderator's words come back as moderator items. To intervene, add a stimulus between two requests (for example new material put on the table): the moderator takes it up first, then carries on with the guide. A stimulus never changes the format or the goal. To interview several people, run one interview per person.

There is no fixed limit on the length of a session: the moderator decides when the goal is covered. Callers that need a cap can stop sending requests after a number of turns.

Tools

tools is what a person can do: 1 to 64 entries, shared by all members of a group. think and say are built in, at most one of each. An action is anything else the caller defines, such as buying, clicking or leaving; the person decides whether and when to take it, and the caller reports what happened.

{ "type": "think" }
{ "type": "say" }
{
  "type": "action",
  "name": "buy",
  "description": "Put one product in the shopping cart",
  "parameters": {
    "type": "object",
    "required": ["item"],
    "properties": { "item": { "type": "string", "enum": ["new cold brew", "usual instant coffee"] } }
  }
}
  • name: 1 to 64 characters of letters, digits, _ and -; unique; not think, say, wait, __proto__, constructor or prototype.
  • description: 1 to 4,000 characters.
  • parameters: a subset of JSON Schema with "type": "object" at the top, at most 16,000 characters as JSON and up to 5 levels deep. Property names follow the same rule as an action's name. Anything outside the keywords below returns 400 invalid_tools, including every $ keyword, anyOf / oneOf / allOf, pattern, format, const and default.
Field typeAllowed keywords
anytype (one string), description, enum
objectproperties, required, additionalProperties (only false)
arrayitems (required), minItems, maxItems
stringminLength, maxLength
number, integerminimum, maximum
booleannone

Items

items in the request and output in the response are the same kind of entry. In the Group and Simulation APIs, think, say and action carry the person's persona name.

{ "type": "stimulus", "content": "..." }
{ "type": "moderator", "content": "..." }
{ "type": "think", "persona": "Lin", "content": "..." }
{ "type": "say", "persona": "Lin", "content": "..." }
{ "type": "action", "persona": "Zhe", "id": "act_1", "name": "buy", "arguments": { "item": "usual instant coffee" } }
{ "type": "action_result", "action_id": "act_1", "content": "..." }
TypeWritten byMeaning
stimulusCallerSomething everyone present perceives: a scene, an event, new material
moderatorServerWhat the moderator says (Simulation API only)
thinkServerWhat a person thinks; no one else perceives it
sayServerWhat a person says; everyone present hears it
actionServerAn action the caller defined in tools, with its arguments
action_resultCallerWhat happened when that action was taken

content is text of 1 to 20,000 characters; a stimulus or an action_result can also carry images, see Images. items has 1 to 2,000 entries, at most 200,000 characters as JSON (image URLs not counted) and at most 20 images; beyond that the request returns 400 invalid_request. A request whose items break the rules below returns 400 invalid_items:

  1. The first item is a stimulus.
  2. Every action is directly followed by its action_result, whose action_id is the action's id. Action ids are unique.
  3. Persona and Group APIs: the last item is a stimulus or an action_result. The Simulation API accepts any last item.
  4. Every persona is a name in personas.
  5. moderator items appear only in the Simulation API, and never first.

When the history approaches the limit, shorten it: replace the earlier part with one opening stimulus that summarizes it, followed by the most recent items.

Images

The content of a stimulus or an action_result can be a list of text and image parts, in order, instead of one string: the package a shopper picks up, an ad, the screen an app shows after a tap.

{
  "type": "stimulus",
  "content": [
    { "type": "text", "text": "In the chiller aisle, Lin picks up an oat milk she has never seen. The front:" },
    { "type": "image", "url": "https://example.com/oat-milk-front.png" }
  ]
}
{
  "type": "action_result",
  "action_id": "act_1",
  "content": [
    { "type": "text", "text": "The screen changes to:" },
    { "type": "image", "url": "data:image/png;base64,iVBORw0KGgo..." }
  ]
}
  • url is an https URL of at most 2,048 characters, or a base64 data URL of a png, jpeg, gif or webp image. A text part is 1 to 20,000 characters; a content has at most 64 parts; items holds at most 20 images.
  • Whoever perceives the item sees the image: everyone sees a stimulus image. In the Group and Simulation APIs, the others see the result of a person's action together with the action. The Simulation API moderator sees images too. think, say and moderator items are text only.
  • The server neither downloads nor stores images; each request passes them to the model as given. Because the caller keeps the history, every request sends all its images again. A URL must stay reachable for the whole simulation: if it cannot be fetched or is not an image, the request returns 400 invalid_image. A data URL travels in every request body, which is limited to 8 MB, so prefer URLs for many or large images.
  • The model counts an image as input tokens, included in usage.input_tokens and charged like text: about 300 to 2,600 tokens per image, depending on its size and detail.

Responses

FieldDescription
idThe request id, also in the x-response-id header. Usage records carry the same id
outputThe new items, in order. At most one action, and only as the last item
stop_reasonWhy the request stopped, see below
usageinput_tokens and output_tokens over all model calls in this request
stop_reasonMeaningNext request's items
end_turnEveryone has reacted; output may be emptyitems + output + a new stimulus. In the Simulation API, items + output is enough
actionThe last output item is an action waiting for its resultitems + output + its action_result
max_itemsThis round reached its limit, see Rounds belowitems + output + a new stimulus, or stop
refusalThe model refused to generateUp to the caller
end_simulationSimulation API: the moderator ended the session; the last item is the closing wordsNone

Rounds

A round starts at a stimulus and lasts until the next one, across requests. In the Simulation API each moderator item also starts a new round. A round holds at most 30 think, say and action items in the Persona API, and 60 for all members together in the Group and Simulation APIs. In the Persona and Group APIs, a request made when the round is already full returns max_items with an empty output. In the Simulation API the moderator speaks next instead, which starts a new round.

Streaming

With "stream": true the response is text/event-stream. Each new item is one item event; a final completed event carries the rest of the response. An item takes a few seconds and a group round can take a minute or two, so user-facing interfaces should stream.

event: item
data: {"type":"say","persona":"Lin","content":"Shall we try the cold brew?"}

event: item
data: {"type":"action","persona":"Zhe","id":"act_1","name":"buy","arguments":{"item":"usual instant coffee"}}

event: completed
data: {"id":"resp_8f3a...","model":"atypica-persona-1","stop_reason":"action","usage":{"input_tokens":4120,"output_tokens":236}}
  • Items are never split or taken back; all item events together equal output.
  • An error after the first item is an error event with the same body as a non-streamed error, and the connection closes. Items already sent are charged.
  • Closing the connection stops generation. To continue, either resend the original items, or append the items received so far and send the next request. When appending, the usual rules still apply: in the Persona and Group APIs the last item must be a stimulus or an action_result, and an action must be followed by its result. In the Simulation API, if the stream stopped after the moderator spoke, the participants react first; if it stopped after a participant spoke, the others in that round do not catch up and the moderator goes on.

Examples

No SDK is needed: a request is plain JSON over HTTPS. Both programs below run as they are with ATYPICA_API_KEY set.

TypeScript: an interview from start to end

Run with npx tsx interview.ts, or node interview.ts on Node 23.6+.

// Run an interview to the end with the Simulation API.
// The caller keeps the items: each request sends all of them, and the output is appended.
const API_KEY = process.env.ATYPICA_API_KEY;
const BASE_URL = process.env.ATYPICA_BASE_URL ?? "https://atypica.ai";

type Item = { type: string; persona?: string; content?: string; id?: string; name?: string };

async function main() {
  const items: Item[] = [
    { type: "stimulus", content: "A quiet interview room. The interviewer and Maya sit down." },
  ];

  for (;;) {
    const res = await fetch(`${BASE_URL}/v1/simulation/responses`, {
      method: "POST",
      headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json" },
      body: JSON.stringify({
        model: "atypica-persona-1",
        format: "interview",
        goal: "Find out how Maya decides what to cook on weeknights, and what would make her buy ready-made meals.",
        personas: [
          {
            name: "Maya",
            profile: "34, nurse on rotating shifts, two kids, cooks most dinners, reads labels.",
          },
        ],
        tools: [{ type: "think" }, { type: "say" }],
        items,
      }),
    });
    const body = await res.json();
    if (!res.ok) throw new Error(`${res.status} ${JSON.stringify(body.error)}`);

    for (const item of body.output) {
      if (item.type === "moderator") console.log(`Interviewer: ${item.content}`);
      if (item.type === "say") console.log(`${item.persona}: ${item.content}`);
    }
    items.push(...body.output);

    if (body.stop_reason === "end_simulation" || body.stop_reason === "refusal") break;
  }
}

main();

Python: stream one person and answer an action (standard library only)

"""Stream one persona's reactions with the Persona API, and answer an action.

Uses only the Python standard library.
"""
import json
import os
import urllib.request

API_KEY = os.environ["ATYPICA_API_KEY"]
BASE_URL = os.environ.get("ATYPICA_BASE_URL", "https://atypica.ai")

tools = [
    {"type": "think"},
    {"type": "say"},
    {
        "type": "action",
        "name": "buy",
        "description": "Put one product in the shopping cart",
        "parameters": {
            "type": "object",
            "required": ["item"],
            "properties": {"item": {"type": "string", "enum": ["new cold brew", "usual instant coffee"]}},
        },
    },
]
items = [
    {
        "type": "stimulus",
        "content": "Saturday afternoon at the supermarket coffee shelf. Lin is out of coffee at home. A new cold brew is on a buy-one-get-one-half-price deal, next to the instant coffee Lin usually buys.",
    }
]


def respond(items):
    """One streamed request. Prints each item as it arrives; returns (new items, stop_reason)."""
    request = urllib.request.Request(
        f"{BASE_URL}/v1/persona/responses",
        data=json.dumps(
            {
                "model": "atypica-persona-1",
                "profile": "Lin, 29, UI designer in Shenzhen. Reads ingredient labels, watches prices.",
                "tools": tools,
                "items": items,
                "stream": True,
            }
        ).encode(),
        headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
    )
    output, event = [], None
    with urllib.request.urlopen(request) as response:
        for raw in response:
            line = raw.decode().rstrip("\n")
            if line.startswith("event: "):
                event = line[len("event: "):]
            elif line.startswith("data: "):
                data = json.loads(line[len("data: "):])
                if event == "item":
                    print(data)
                    output.append(data)
                elif event == "completed":
                    return output, data["stop_reason"]
                elif event == "error":
                    raise RuntimeError(data["error"])
    raise RuntimeError("stream ended without a completed event")


output, stop_reason = respond(items)
items += output
if stop_reason == "action":
    action = output[-1]
    # The caller runs the action in its own world and reports what happened.
    items.append(
        {
            "type": "action_result",
            "action_id": action["id"],
            "content": f"One {action['arguments']['item']} is now in the cart.",
        }
    )
    output, stop_reason = respond(items)
    items += output
print("stop_reason:", stop_reason)

Errors

Errors return { "error": { "code": "...", "message": "..." } }. Once generation has started (400 invalid_image, 402, 500, 503), the body also has the request id and the usage so far: model calls before the error are charged. The other 400 errors and 401 are not charged.

HTTPcodeCause
400invalid_requestThe request is malformed; message names the field
400invalid_itemsitems break the rules in Items
400invalid_toolsAn action's parameters use an unsupported keyword
400invalid_imageAn image cannot be used: its URL cannot be fetched, or it is not an image; message gives the model's reason
401unauthorizedMissing or invalid API key
402insufficient_tokensNot enough tokens, including running out mid-request
500internal_errorGeneration failed
503model_unavailableThe model is temporarily unreachable; retry later