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.
| Endpoint | Simulates |
|---|---|
| /v1/persona/responses | One person |
| /v1/group/responses | Several people who see and hear each other |
| /v1/simulation/responses | An 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.
- 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)
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.ai
Quick Start
One request to the Persona API:
curl https://atypica.ai/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
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.
| Field | Type | Description |
|---|---|---|
| model | string | Required. Only atypica-persona-1 |
| profile | string | Required. Who this person is, 1 to 20,000 characters |
| tools | array | Required. What this person can do, see Tools |
| items | array | Required. The history so far, see Items |
| stream | boolean | Optional. true streams the response, see Streaming |
Group API
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." }
]
}| Field | Type | Description |
|---|---|---|
| personas | array | Required. 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
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." }
]
}| Field | Type | Description |
|---|---|---|
| format | string | Required. 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 |
| goal | string | Required. What this session has to find out, 1 to 4,000 characters. The session ends when it can be answered |
| guide | string | Optional. 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 |
| personas | array | Required. 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; notthink,say,wait,__proto__,constructororprototype.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'sname. Anything outside the keywords below returns 400invalid_tools, including every$keyword,anyOf/oneOf/allOf,pattern,format,constanddefault.
| Field type | Allowed keywords |
|---|---|
| any | type (one string), description, enum |
| object | properties, required, additionalProperties (only false) |
| array | items (required), minItems, maxItems |
| string | minLength, maxLength |
| number, integer | minimum, maximum |
| boolean | none |
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": "..." }| Type | Written by | Meaning |
|---|---|---|
| stimulus | Caller | Something everyone present perceives: a scene, an event, new material |
| moderator | Server | What the moderator says (Simulation API only) |
| think | Server | What a person thinks; no one else perceives it |
| say | Server | What a person says; everyone present hears it |
| action | Server | An action the caller defined in tools, with its arguments |
| action_result | Caller | What 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:
- The first item is a
stimulus. - Every
actionis directly followed by itsaction_result, whoseaction_idis the action'sid. Action ids are unique. - Persona and Group APIs: the last item is a
stimulusor anaction_result. The Simulation API accepts any last item. - Every
personais a name inpersonas. moderatoritems 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..." }
]
}urlis 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; acontenthas at most 64 parts;itemsholds 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,sayandmoderatoritems 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_tokensand charged like text: about 300 to 2,600 tokens per image, depending on its size and detail.
Responses
| Field | Description |
|---|---|
| id | The request id, also in the x-response-id header. Usage records carry the same id |
| output | The new items, in order. At most one action, and only as the last item |
| stop_reason | Why the request stopped, see below |
| usage | input_tokens and output_tokens over all model calls in this request |
| stop_reason | Meaning | Next request's items |
|---|---|---|
| end_turn | Everyone has reacted; output may be empty | items + output + a new stimulus. In the Simulation API, items + output is enough |
| action | The last output item is an action waiting for its result | items + output + its action_result |
| max_items | This round reached its limit, see Rounds below | items + output + a new stimulus, or stop |
| refusal | The model refused to generate | Up to the caller |
| end_simulation | Simulation API: the moderator ended the session; the last item is the closing words | None |
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
errorevent 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 astimulusor anaction_result, and anactionmust 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.
| HTTP | code | Cause |
|---|---|---|
| 400 | invalid_request | The request is malformed; message names the field |
| 400 | invalid_items | items break the rules in Items |
| 400 | invalid_tools | An action's parameters use an unsupported keyword |
| 400 | invalid_image | An image cannot be used: its URL cannot be fetched, or it is not an image; message gives the model's reason |
| 401 | unauthorized | Missing or invalid API key |
| 402 | insufficient_tokens | Not enough tokens, including running out mid-request |
| 500 | internal_error | Generation failed |
| 503 | model_unavailable | The model is temporarily unreachable; retry later |