API reference
Use the Model API to write with Taste-1. Use the Engine API to create worlds, run scenarios and read results. Each API accepts its own Bearer key.
Model API · Engine API · Service status
Model API v1
Create a key in API keys and save it as AW_API_KEY in your shell environment. Use https://alignworlds.com/v1 as the base URL in a compatible chat completions client. A request id is available in the x-request-id response header.
List available models
GET /v1/models
List the models available to the caller.
Request and response
curl --fail-with-body \
"https://alignworlds.com/v1/models" \
-H "Authorization: Bearer $AW_API_KEY"{
"object": "list",
"data": [
{
"id": "taste-1",
"object": "model",
"created": 1795651200,
"owned_by": "alignworlds"
}
]
}Error status codes: 401, 503.
Get a model
GET /v1/models/{model}
Read a model’s public id, creation timestamp and owner. An unknown or inaccessible id returns 404.
Request and response
model- path · Public model id · required
curl --fail-with-body \
"https://alignworlds.com/v1/models/taste-1" \
-H "Authorization: Bearer $AW_API_KEY"{
"id": "taste-1",
"object": "model",
"created": 1795651200,
"owned_by": "alignworlds"
}Error status codes: 401, 404, 503.
Create a chat completion
POST /v1/chat/completions
Send a writing request or a conversation with previous replies. The response contains one or more text choices. Streamed responses deliver incremental choices and finish with data: [DONE].
Request and response
model- body · taste-1 · required
messages- body · Send user and assistant text. Put writing instructions in the user message. System and developer messages are unsupported for Taste-1. Up to 256 messages and 80,000 total characters. · required
max_completion_tokens- body · Positive integer up to 4,096. max_tokens is also accepted.
n- body · Number of choices, 1–4. Default 1.
temperature- body · Number from 0 to 2.
top_p- body · Number from 0 to 1.
stop- body · A string or up to four strings, each 1–100 characters.
stream- body · Boolean. Set true for server-sent events.
stream_options.include_usage- body · Boolean. Include a final usage event before [DONE].
think- body · Boolean. Request the optional Think mode when available.
curl --fail-with-body -X POST \
"https://alignworlds.com/v1/chat/completions" \
-H "Authorization: Bearer $AW_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary '{
"model": "taste-1",
"messages": [
{
"role": "user",
"content": "Write one line inviting a neighbor to breakfast."
}
],
"max_completion_tokens": 24
}'{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1796313600,
"model": "taste-1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Come by for coffee and warm rolls.",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21
}
}Error status codes: 400, 401, 402, 403, 404, 413, 429, 502, 503, 504.
Stream a chat completion
POST /v1/chat/completions
Read each data event as it arrives. Append delta.content to the draft. With include_usage enabled, the last JSON event contains usage and an empty choices array. A successful stream ends with [DONE].
Request and response
model- body · taste-1 · required
messages- body · Send user and assistant text. Put writing instructions in the user message. System and developer messages are unsupported for Taste-1. Up to 256 messages and 80,000 total characters. · required
max_completion_tokens- body · Positive integer up to 4,096. max_tokens is also accepted.
n- body · Number of choices, 1–4. Default 1.
temperature- body · Number from 0 to 2.
top_p- body · Number from 0 to 1.
stop- body · A string or up to four strings, each 1–100 characters.
stream- body · Boolean. Set true for server-sent events.
stream_options.include_usage- body · Boolean. Include a final usage event before [DONE].
think- body · Boolean. Request the optional Think mode when available.
curl --fail-with-body --no-buffer -X POST \
"https://alignworlds.com/v1/chat/completions" \
-H "Authorization: Bearer $AW_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary '{
"model": "taste-1",
"messages": [
{
"role": "user",
"content": "Write one line inviting a neighbor to breakfast."
}
],
"max_completion_tokens": 24,
"stream": true,
"stream_options": {
"include_usage": true
}
}'data: {"id":"chatcmpl-example","object":"chat.completion.chunk","created":1796313600,"model":"taste-1","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null,"logprobs":null}],"usage":null}
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","created":1796313600,"model":"taste-1","choices":[{"index":0,"delta":{"content":"Come by for breakfast."},"finish_reason":null,"logprobs":null}],"usage":null}
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","created":1796313600,"model":"taste-1","choices":[{"index":0,"delta":{},"finish_reason":"stop","logprobs":null}],"usage":null}
data: {"id":"chatcmpl-example","object":"chat.completion.chunk","created":1796313600,"model":"taste-1","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":5,"total_tokens":17}}
data: [DONE]If an error arrives after the first chunk, the connection closes without [DONE]. Keep the partial text separate from completed replies. A timeout event looks like this.
data: {"error":{"message":"The model took too long to respond. Try again.","type":"server_error","param":null,"code":"upstream_timeout"}}Error status codes: 400, 401, 402, 403, 404, 413, 429, 502, 503, 504.
Terrarium Engine API v1
Request an organization engine key from hello@alignworlds.com. Store it as ENGINE_API_KEY and send requests to https://api.alignworlds.com/api/v1. Use your own run id for RUN_ID, a completed step number for STEP, and a fresh unique value for REQUEST_ID when creating or forking a run.
Start with Validate a scenario, then Estimate run cost. Create a run starts billable work. Each example is independent. Response excerpts show selected fields. The OpenAPI schema includes every response field and nested type. This reference uses engine release 0.4.5.
The examples keep steps and model choices inside the scenario so you can reuse the same document for validation, estimation and creation. To change just one run, pass steps or the model roles you want to override alongside scenario. The top-level values take precedence for those fields.
Scenario and run settings
- scenario
- Define the world, its people and a clock. Give each person a name, starting place and persona. A persona can include goals and information private to that person.
- models
- Omit this optional object to keep the scenario’s model settings. The agents field selects the default participant model. The people map overrides it for named participants. The world_engine and perception fields select the models that advance the world and describe what each person observes. Optional reviewers check those outputs. Choose IDs available to your workspace. The model API’s list is separate.
- compaction
- Set tokens to the history threshold for summarization and keep to the number of recent replies to preserve. An explicit null disables summarization.
- changes
- When forking, identify an existing place or person by name and provide the state changes to apply at that checkpoint. The original run keeps its history.
Read your account
GET /api/v1/account
Check the organization for this engine key, its balance in cents, run count and total charges in US dollars.
Request and response
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/account" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"id": "8",
"name": "Example organization",
"balance_cents": 1000,
"runs": 4,
"cost_usd": 0.1
}Error status codes: 400, 401, 403, 404, 422.
Read organization spend
GET /api/v1/cost
Group costs by model. Pass since as an ISO 8601 timestamp to choose the start of the period. The default is the last 30 days. If the report times out, read aggregate charges from your account or use the cost endpoint for a single run.
Request and response
since- query · string | null
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/cost?since=2026-12-01T00:00:00Z" \
-H "Authorization: Bearer $ENGINE_API_KEY"[
{
"model": "gemini-3.5-flash-lite",
"calls": 3,
"runs": 1,
"cost_usd": 0.001
}
]Error status codes: 400, 401, 403, 404, 422.
Validate a scenario
POST /api/v1/scenarios/validate
Check a scenario before submitting it. A 200 response can contain valid: false. Follow the error location to the field that needs a change.
Request and response
scenario- body · object · required
steps- body · integer | null
seed- body · integer | null
models- body · Models
compaction- body · Compaction | null
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/scenarios/validate" \
-H "Authorization: Bearer $ENGINE_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary '{
"scenario": {
"world": {
"name": "Corner shop"
},
"people": [
{
"name": "Ada",
"place": "Corner shop",
"persona": "Open the shop for the morning."
}
],
"clock": {
"start": "2026-12-03T09:00:00",
"step_minutes": 15
},
"steps": 2,
"models": {
"agents": "gemini-3.5-flash-lite",
"perception": "gemini-3.5-flash-lite",
"world_engine": "gemini-3.5-flash-lite",
"reviewer": null
}
}
}'{
"valid": true,
"errors": []
}Error status codes: 400, 401, 403, 404, 422.
Create a run
POST /api/v1/runs
Queue a scenario against your organization’s credit. Set cap_cents to pause when recorded costs pass the threshold. Calls are chargeable even if the current step stops before it completes, so the total can exceed the cap. Set a new Idempotency-Key for each new run and reuse it when retrying that request.
Request and response
idempotency-key- header · string | null
scenario- body · object · required
steps- body · integer | null
seed- body · integer | null
models- body · Models
compaction- body · Compaction | null
name- body · string | null
tags- body · string[], default []
cap_cents- body · integer | null
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs" \
-H "Authorization: Bearer $ENGINE_API_KEY" \
-H "Idempotency-Key: ${REQUEST_ID}" \
-H 'Content-Type: application/json' \
--data-binary '{
"name": "Morning at the shop",
"tags": [
"shop-pilot"
],
"scenario": {
"world": {
"name": "Corner shop"
},
"people": [
{
"name": "Ada",
"place": "Corner shop",
"persona": "Open the shop for the morning."
}
],
"clock": {
"start": "2026-12-03T09:00:00",
"step_minutes": 15
},
"steps": 2,
"models": {
"agents": "gemini-3.5-flash-lite",
"perception": "gemini-3.5-flash-lite",
"world_engine": "gemini-3.5-flash-lite",
"reviewer": null
}
},
"cap_cents": 5
}'{
"id": "42",
"name": "Morning at the shop",
"status": "queued",
"step": 0,
"steps": 2,
"cap_cents": 5
}Error status codes: 400, 401, 402, 403, 404, 409, 422.
List runs
GET /api/v1/runs
Filter your organization’s runs by name, status or tag. Results are newest first. Pass next_cursor as cursor to read the next page.
Request and response
status- query · queued | running | paused | done | failed | cancelled | null
tag- query · string | null
name- query · string | null
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs?tag=shop-pilot&limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
Estimate run cost
POST /api/v1/runs/estimate
Estimate US-dollar charges using recent completed runs. The estimate excludes any model in unpriced. The example has no priced model, so zero is only a subtotal. An estimate of $0.03 with an empty unpriced list covers every model, although the final charge can differ.
Request and response
scenario- body · object · required
steps- body · integer | null
seed- body · integer | null
models- body · Models
compaction- body · Compaction | null
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs/estimate" \
-H "Authorization: Bearer $ENGINE_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary '{
"scenario": {
"world": {
"name": "Corner shop"
},
"people": [
{
"name": "Ada",
"place": "Corner shop",
"persona": "Open the shop for the morning."
}
],
"clock": {
"start": "2026-12-03T09:00:00",
"step_minutes": 15
},
"steps": 2,
"models": {
"agents": "gemini-3.5-flash-lite",
"perception": "gemini-3.5-flash-lite",
"world_engine": "gemini-3.5-flash-lite",
"reviewer": null
}
}
}'{
"steps": 2,
"people": 1,
"cost_usd": 0,
"unpriced": [
"gemini-3.5-flash-lite"
]
}Error status codes: 400, 401, 403, 404, 422.
Get a run
GET /api/v1/runs/{run}
Check the current status, committed step count, cost and last failure. The id belongs to the organization that created the run.
Request and response
run- path · string · required
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"id": "42",
"name": "Morning at the shop",
"status": "done",
"step": 2,
"steps": 2,
"cap_cents": 5
}Error status codes: 400, 401, 403, 404, 422.
Pause a run
POST /api/v1/runs/{run}/pause
Pause a queued or running run. A worker may take up to 15 seconds to stop the step in progress. Its last committed step is retained.
Request and response
run- path · string · required
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/pause" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"id": "42",
"name": "Morning at the shop",
"status": "paused",
"step": 0,
"steps": 2,
"cap_cents": 5
}Error status codes: 400, 401, 403, 404, 409, 422.
Resume a run
POST /api/v1/runs/{run}/resume
Continue a paused or failed run from its last committed step. Pass a higher cap_cents if the run paused for cost. The cap applies to cumulative cost, including completed calls from an interrupted step. Replaying that step can add charges. Your organization must have a positive balance.
Request and response
run- path · string · required
cap_cents- body · integer | null
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/resume" \
-H "Authorization: Bearer $ENGINE_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary '{
"cap_cents": 5
}'{
"id": "42",
"name": "Morning at the shop",
"status": "queued",
"step": 0,
"steps": 2,
"cap_cents": 5
}Error status codes: 400, 401, 402, 403, 404, 409, 422.
Cancel a run
POST /api/v1/runs/{run}/cancel
Permanently stop a queued, running, paused or failed run. A cancelled run cannot be resumed. Use pause if you plan to continue.
Request and response
run- path · string · required
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/cancel" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"id": "42",
"name": "Morning at the shop",
"status": "cancelled",
"step": 0,
"steps": 2,
"cap_cents": 5
}Error status codes: 400, 401, 403, 404, 409, 422.
Fork from a checkpoint
POST /api/v1/runs/{run}/fork
Create a new run from a completed step. Supply a seed or changes to explore a different outcome. The parent’s records stay available.
Request and response
run- path · string · required
idempotency-key- header · string | null
step- body · integer, greater than 0 · required
changes- body · Change[], default []
scenario- body · object | null
steps- body · integer | null
seed- body · integer | null
models- body · Models | null
compaction- body · Compaction | null
name- body · string | null
tags- body · string[] | null
cap_cents- body · integer | null
curl --fail-with-body -X POST \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/fork" \
-H "Authorization: Bearer $ENGINE_API_KEY" \
-H "Idempotency-Key: ${REQUEST_ID}" \
-H 'Content-Type: application/json' \
--data-binary '{
"step": 1,
"name": "Morning at the shop, second trial",
"seed": 2,
"cap_cents": 5
}'{
"id": "43",
"status": "queued",
"forked_from": "42",
"forked_at_step": 1
}Error status codes: 400, 401, 402, 403, 404, 409, 422.
Get a step’s state
GET /api/v1/runs/{run}/steps/{step}
Read the world and people after a completed step. Step numbers start at one.
Request and response
step- path · integer · required
run- path · string · required
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/steps/${STEP}" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"run": "42",
"step": 1,
"seconds": 2.8,
"state": {
"step": 1
}
}Error status codes: 400, 401, 403, 404, 422.
Get a step’s log
GET /api/v1/runs/{run}/steps/{step}/log
Read the events recorded at each place during the step.
Request and response
step- path · integer · required
run- path · string · required
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/steps/${STEP}/log" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"run": "42",
"step": 1,
"places": {
"Corner shop": []
}
}Error status codes: 400, 401, 403, 404, 422.
List turns
GET /api/v1/runs/{run}/turns
Read decisions and actions in order. Use include=world to see the people and world after each turn. Here the first turn of step 0 records the shopkeeper’s perception and action. Its ordinal matches the turn field in the perceptions collection.
Request and response
run- path · string · required
step- query · integer | null
person- query · string | null
place- query · string | null
include- query · string | null
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/turns?step=0&include=world&limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [
{
"run": "42",
"step": 0,
"ordinal": 1,
"person": "Ada",
"place": "Corner shop",
"action": "I unlock the front door of the shop, turn on the interior lights, and flip the hanging sign from Closed to Open.",
"world": {
"name": "Corner shop"
}
}
],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
List conversations
GET /api/v1/runs/{run}/conversations
Read participants, places and exchanged lines. A run with no conversations returns an empty page.
Request and response
run- path · string · required
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/conversations?limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
List perceptions
GET /api/v1/runs/{run}/perceptions
Read what a person was told about the world, including what they perceived during conversations.
Request and response
run- path · string · required
person- query · string | null
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/perceptions?person=Ada&limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [
{
"run": "42",
"step": 0,
"turn": 1,
"person": "Ada",
"text": "The corner shop stands before you, and Thursday morning has begun."
}
],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
List probe answers
GET /api/v1/runs/{run}/probes
Read the answers to questions scheduled in the scenario. Filter by person or pass a cursor.
Request and response
run- path · string · required
person- query · string | null
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/probes?person=Ada&limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
List run calls
GET /api/v1/runs/{run}/calls
Inspect your run’s model calls, token counts, duration and cost. Use full=true when you also need the request and response. Those records can contain your scenario content.
Request and response
run- path · string · required
role- query · agent | perception | world_engine | review | perception_review | probe | compaction | null
model- query · string | null
step- query · integer | null
person- query · string | null
full- query · boolean, default false
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/calls?limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [
{
"run": "42",
"role": "agent",
"person": "Ada",
"step": 1
}
],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
List failed attempts
GET /api/v1/runs/{run}/failures
Read failed calls newest first. Each record identifies the step, model, attempt and error.
Request and response
run- path · string · required
step- query · integer | null
cursor- query · string | null
limit- query · integer, min 1, max 1000, default 100
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/failures?limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
Get run cost
GET /api/v1/runs/{run}/cost
Inspect token usage and cost in US dollars for all calls, grouped by role, model and step. Run-level charges are available on the run record.
Request and response
run- path · string · required
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/cost" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"run": "42",
"total": {
"calls": 3,
"cost_usd": 0.001
}
}Error status codes: 400, 401, 403, 404, 422.
Follow run events
GET /api/v1/runs/{run}/events
Receive server-sent turn, probe, step and status events. On reconnect send the last event id in Last-Event-ID or after. The stream closes when a run finishes or is cancelled.
Request and response
run- path · string · required
after- query · string, default ""
last-event-id- header · string, default ""
curl --fail-with-body --no-buffer \
"https://api.alignworlds.com/api/v1/runs/${RUN_ID}/events" \
-H "Authorization: Bearer $ENGINE_API_KEY"id: 1.0.1
event: step
data: {"run":"42","step":1,"cost_usd":0.001}Error status codes: 400, 401, 403, 404, 422.
Export training records
GET /api/v1/training
Read world-engine turns as training records for your organization. Repeat run to select several run ids.
Request and response
model- query · string | null
run- query · string[] | null
cursor- query · string | null
limit- query · integer, min 1, max 100, default 20
curl --fail-with-body \
"https://api.alignworlds.com/api/v1/training?run=$RUN_ID&limit=10" \
-H "Authorization: Bearer $ENGINE_API_KEY"{
"data": [
{
"run": "42",
"step": 1,
"place": "Corner shop"
}
],
"next_cursor": null
}Error status codes: 400, 401, 403, 404, 422.
Service status
These endpoints report engine availability and accept requests without a key.
Check service health
GET /health
Read the engine service version and build identifier. This endpoint is public.
Request and response
curl --fail-with-body \
"https://api.alignworlds.com/health"{
"status": "ok",
"version": "0.4.5",
"commit": null
}Error status codes: none specified.
Check readiness
GET /ready
Check whether the service accepts requests. A draining instance returns 503. This endpoint is public.
Request and response
curl --fail-with-body \
"https://api.alignworlds.com/ready"{
"status": "ready",
"version": "0.4.5",
"commit": null
}Error status codes: 503.