# Luw.ai Studio API (v1)

> Call Luw.ai Studio's AI design agent from the OpenAI SDKs to build and change a project: lay out rooms, add doors, windows and stairs, furnish and paint. Run long turns in the background, cap the credits a turn spends, open every change as a version in the Studio, embed the project in your page, and read or write its scene directly.

## Overview

The Luw.ai Studio API lets your code ask Luw.ai Studio's AI design agent to work on a project. It is OpenAI-compatible: it speaks the OpenAI Responses and Chat Completions formats, so the OpenAI SDKs and the AI SDK's OpenAI provider call it the way they call a reasoning model. Each request is one **turn** on one project: the agent changes the 3D scene, answers in text, and saves what it changed as a version of the project.

The base URL is:

```text
https://studio.luw.ai/api/v1
```

> AI-generated concept, not for construction or renovation. Get a licensed architect or engineer's review and permits first. The agent designs concepts: it never says whether a real wall, column or beam can be removed, and never calls a design structurally sound, code-compliant or permit-ready. See the [Terms of Use](https://app.luw.ai/docs/terms#section-6-2).

This page is also available as Markdown at [/developers/api.md](https://studio.luw.ai/developers/api.md), for agents and tools that read docs.

## Before you start

- **An API key.** Create one on app.luw.ai's [API & MCP](https://app.luw.ai/dashboard/api) page (in the Studio: the account menu › **API keys**). Keys look like `sk-…`. One key works everywhere: Luw.ai's REST API, the Luw.ai MCP server and this Studio API.
- **A project id, or none.** A turn works on a Studio project that the key's account can edit. The Studio shows the open project's id under Settings › Preferences › **Luw.ai API**, such as `luw-1252130` (the number alone works too). Leave it out and the API makes a new project for the turn; see [Name the project](https://studio.luw.ai/developers/api#project).
- **Credits.** Turns use the key owner's own Luw.ai credits, the same credits the Studio chat uses. See [Credits](https://studio.luw.ai/developers/api#credits).

The examples read the key and the project id from two environment variables:

```bash
export LUW_API_KEY="sk-your_key"
export LUW_PROJECT_ID="luw-1252130"
```

Install the SDK for your language:

**Python**

```bash
pip install openai
```

**TypeScript**

```bash
npm install openai
```

**AI SDK**

```bash
npm install ai @ai-sdk/openai
```

The TypeScript examples are ES modules with top-level `await`: save one as `example.ts` and run it with `npx tsx example.ts`.

## Run a turn

Point the client at the base URL with your key, name the project in `metadata.project_id`, and send what you want done:

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

response = client.responses.create(
    model="luw-architect",
    metadata={
        "project_id": os.environ["LUW_PROJECT_ID"],
        "commit_message": "Add a bedroom off the hallway",
    },
    input="Add a 4 m × 3 m bedroom off the hallway with a window facing the garden.",
)

print(response.output_text)
print((response.metadata or {}).get("luw_version_url"))
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const response = await client.responses.create({
  model: "luw-architect",
  metadata: {
    project_id: process.env.LUW_PROJECT_ID!,
    commit_message: "Add a bedroom off the hallway",
  },
  input: "Add a 4 m × 3 m bedroom off the hallway with a window facing the garden.",
});

console.log(response.output_text); // the reply
console.log(response.metadata?.luw_version_url); // the saved version in the Studio
```

**AI SDK**

```ts
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const luw = createOpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
  headers: { "X-Luw-Project": process.env.LUW_PROJECT_ID! },
});

const result = await generateText({
  model: luw("luw-architect"),
  prompt: "Add a 4 m × 3 m bedroom off the hallway with a window facing the garden.",
  maxRetries: 0,
});

console.log(result.text);
```

**curl**

```bash
curl https://studio.luw.ai/api/v1/responses \
  -H "Authorization: Bearer $LUW_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Luw-Project: $LUW_PROJECT_ID" \
  -d '{
    "model": "luw-architect",
    "input": "Add a 4 m × 3 m bedroom off the hallway with a window facing the garden.",
    "metadata": { "commit_message": "Add a bedroom off the hallway" }
  }'
```

With the AI SDK, always pass `maxRetries: 0`: it retries by status code, and a retried turn could change the scene twice. The OpenAI SDKs already obey the API's `x-should-retry: false` header.

If the project is open in a Studio tab, the tab shows the changes as the agent saves them.

## Models

The agent runs on one of two engines, as in the Studio chat: **Symphony**, the most capable, and **Aria**, faster and lighter on credits.

| Model | Engine | Thinking | Accounts |
| --- | --- | --- | --- |
| `luw-architect` | Symphony | Medium, unless the request sets `reasoning.effort` | Paid |
| `luw-architect-low` | Symphony | Low | Paid |
| `luw-architect-medium` | Symphony | Medium | Paid |
| `luw-architect-high` | Symphony | High | Paid |
| `luw-architect-pro` | Symphony | Extra high | Paid |
| `luw-architect-aria` | Aria | Medium, unless the request sets `reasoning.effort` | All |

- The Symphony models also answer without the `luw-` prefix: `architect`, `architect-low`, `architect-medium`, `architect-high` and `architect-pro`. `GET /v1/models` lists every id.
- The Symphony models are for paid accounts, as Symphony is in the Studio chat; on a free account they answer `403 upgrade_required`. `luw-architect-aria` works on every account.
- `reasoning.effort` takes `minimal` (read as low), `low`, `medium`, `high` and, on Symphony, `pro` (Extra high). Only `luw-architect` and `luw-architect-aria` read it; the ids with an effort in their name ignore it.
- A small edit usually uses 1–3 credits. A furnished two-storey villa at medium effort used about 14 credits on Symphony and about 7 on Aria.

## Name the project

A turn works on the project named, in this order, by the `X-Luw-Project` header, `metadata.project_id`, or the project of `previous_response_id`. Both `1252130` and `luw-1252130` work. The header suits clients that set default headers, such as the AI SDK.

- No project named: the API makes a new one, named from the start of the request, and the turn works there. `metadata.luw_project_id` is its id: send it, or `previous_response_id`, to carry on in it. A retry with the same `Idempotency-Key` carries on in the project its first try made, never a second one.
- A project that doesn't exist or that the key's account can't edit: `404 project_not_found`.
- `POST /v1/scenes` makes an empty project, or one from a scene, without running a turn; see [Scenes](https://studio.luw.ai/developers/api#scenes).

## What a turn returns

- **The reply** is `output_text`, plain text that can include Markdown.
- **The reasoning** comes as `reasoning` items (`reasoning_content` in Chat Completions): the agent's thinking, summarised, and one bold line per step it took, such as **Create room ×3, Add door**.
- **The version.** A turn that changed the scene saves it as one version of the project, named by `metadata.commit_message` (or, without one, "API: " and the start of the input). The response reports it as `metadata.luw_version`, `luw_version_label` and `luw_version_url`; the link opens the project in the Studio with its version history on that version. The scene as it was before the turn is kept too, so the history can always go back. A turn that changed nothing saves no version.
- **The credits** the turn used are in `metadata.luw_credits_used`, and the project in `metadata.luw_project_id`. The metadata you sent comes back as well.
- **The links.** Every turn answer (created, polled, streamed or a chat completion) carries the project's links: `metadata.luw_share_url`, its page at studio.luw.ai, `luw_embed_url`, the same page for an iframe, and `luw_thumbnail_url`, its current cover (`null` until the Studio has made one). See [Embed and share](https://studio.luw.ai/developers/api#embed).
- **The picture.** A turn that changed the scene ends with a picture of it, the cover the Studio itself would take: `metadata.luw_preview_url`, a link on Luw.ai's CDN. It also becomes the project's cover, so `luw_thumbnail_url` and the Studio's project list show it. A turn that changed nothing, or whose picture couldn't be taken, has no `luw_preview_url`.

```json
{
  "id": "resp_8f3K…",
  "object": "response",
  "created_at": 1762500000,
  "status": "completed",
  "model": "luw-architect-high",
  "output": [
    {
      "type": "reasoning",
      "id": "rs_…",
      "summary": [{ "type": "summary_text", "text": "**Create room, Add window** …" }]
    },
    {
      "type": "message",
      "id": "msg_…",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Added a 4 × 3 m bedroom off the hallway …",
          "annotations": [
            {
              "type": "url_citation",
              "url": "https://studio.luw.ai/?project=1252130&version=88812",
              "title": "Add a bedroom off the hallway",
              "start_index": 120,
              "end_index": 120
            }
          ]
        }
      ]
    }
  ],
  "output_text": "Added a 4 × 3 m bedroom off the hallway …",
  "error": null,
  "incomplete_details": null,
  "usage": { "input_tokens": 41210, "output_tokens": 3180, "total_tokens": 44390 },
  "metadata": {
    "project_id": "1252130",
    "commit_message": "Add a bedroom off the hallway",
    "luw_project_id": "1252130",
    "luw_version": "88812",
    "luw_version_label": "Add a bedroom off the hallway",
    "luw_version_url": "https://studio.luw.ai/?project=1252130&version=88812",
    "luw_credits_used": "3",
    "luw_share_url": "https://studio.luw.ai/s/k3Jd9xQ2mPa7Lw0e",
    "luw_embed_url": "https://studio.luw.ai/s/k3Jd9xQ2mPa7Lw0e?embed=1",
    "luw_thumbnail_url": "https://i.luvicdn.com/luwai/…/studio-thumb-1762500041000.webp",
    "luw_preview_url": "https://i.luvicdn.com/luwai/…/studio-thumb-1762500041000.webp"
  }
}
```

`status` is one of `in_progress`, `completed`, `incomplete`, `failed` and `cancelled`. An `incomplete` turn stopped early and kept what it finished; `incomplete_details.reason` says why: `max_credits` (your cap), `balance` (the account ran out of credits) or `time_limit`.

## Continue a conversation

- **Responses** turns start fresh unless they send `previous_response_id`, the id of an earlier turn on the same project; the agent then carries on from it. If the agent needs more information, it asks in its reply, and you answer the same way.
- **Chat Completions** turns always start fresh. Only the **last user message** is the request; `system` and `developer` messages become this turn's instructions.
- Use `instructions` (Responses) for guidance that applies to this turn only.

## Stream a turn

Send `stream: true` to follow a turn as it works. The answer is a `text/event-stream` of the OpenAI Responses events, each with a `sequence_number`: `response.created` and `response.in_progress`; `response.output_item.added` and `.done`; `response.reasoning_summary_part.added` and `response.reasoning_summary_text.delta`; `response.content_part.added`, `response.output_text.delta` and `response.output_text.annotation.added`; and last `response.completed`, `response.incomplete` or `response.failed`. A `: keepalive` comment comes every 10 seconds.

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

stream = client.responses.create(
    model="luw-architect",
    stream=True,
    metadata={"project_id": os.environ["LUW_PROJECT_ID"]},
    input="Furnish the living room.",
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    elif event.type == "response.completed":
        print()
        print((event.response.metadata or {}).get("luw_version_url"))
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const stream = await client.responses.create({
  model: "luw-architect",
  stream: true,
  metadata: { project_id: process.env.LUW_PROJECT_ID! },
  input: "Furnish the living room.",
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") process.stdout.write(event.delta);
  if (event.type === "response.completed") {
    console.log("\n", event.response.metadata?.luw_version_url);
  }
}
```

Without `stream`, the headers still come back within 15 seconds, then a space every 10 seconds while the turn works, then the JSON. The SDKs and `JSON.parse` skip the leading spaces.

## Run long turns in the background

A request without `background` follows its turn for up to 13 minutes. The agent stops starting new steps at 12 minutes and the turn ends `incomplete` with `time_limit`; a turn still in the middle of a step at 13 minutes answers `status: "in_progress"` for you to poll (a stream ends with an `error` event, `turn_still_running`). Closing the connection stops a turn that isn't in the background: the work so far is kept and the credits it used are charged.

Send big jobs, such as a whole house from a floor plan, with `background: true`. The request answers `in_progress` at once, and the turn runs to its end with nobody connected, for up to 45 minutes.

**Python**

```python
import time

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

turn = client.responses.create(
    model="luw-architect-high",
    background=True,
    metadata={"project_id": os.environ["LUW_PROJECT_ID"]},
    input="Build a two-bedroom ground floor with an open kitchen.",
)

while turn.status == "in_progress":
    time.sleep(10)
    turn = client.responses.retrieve(turn.id)

print(turn.status, turn.output_text)

# To stop it before it ends:
# client.responses.cancel(turn.id)
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

let turn = await client.responses.create({
  model: "luw-architect-high",
  background: true,
  metadata: { project_id: process.env.LUW_PROJECT_ID! },
  input: "Build a two-bedroom ground floor with an open kitchen.",
});

while (turn.status === "in_progress") {
  await new Promise((resolve) => setTimeout(resolve, 10_000));
  turn = await client.responses.retrieve(turn.id);
}

console.log(turn.status, turn.output_text);

// To stop it before it ends:
// await client.responses.cancel(turn.id);
```

- `GET /v1/responses/{id}` reads a turn while it runs and after it ends. Any key whose account can edit the project can read its turns.
- `POST /v1/responses/{id}/cancel` stops a turn at its next step and returns it as it ended. Changes already made stay saved and the credits used stay charged. Cancelling a turn that already ended returns it as it was. Only the account that started a turn can cancel it; anyone else gets `404 turn_not_found`, as for a turn that doesn't exist.

## Retry safely

A turn changes the scene and spends credits, so a retry after a dropped connection must not start a second one. Send an `Idempotency-Key` header with a value you make, such as a UUID, and keep it with the request:

**Python**

```python
import uuid

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

key = str(uuid.uuid4())  # reuse it only to retry this request
turn = client.responses.create(
    model="luw-architect-high",
    background=True,
    metadata={"project_id": os.environ["LUW_PROJECT_ID"]},
    input="Add a covered porch along the front of the house.",
    extra_headers={"Idempotency-Key": key},
)
print(turn.id, turn.status)
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const key = crypto.randomUUID(); // reuse it only to retry this request
const turn = await client.responses.create(
  {
    model: "luw-architect-high",
    background: true,
    metadata: { project_id: process.env.LUW_PROJECT_ID! },
    input: "Add a covered porch along the front of the house.",
  },
  { headers: { "Idempotency-Key": key } },
);
console.log(turn.id, turn.status);
```

- The same request with the same key returns the turn the first one started, as it stands now, with the header `Idempotent-Replayed: true`. Nothing new runs.
- A key is kept for 24 hours, for your account and the project the request names. The same key with a different request answers `409 idempotency_mismatch`.
- The key is 1 to 255 printable ASCII characters; anything else answers `400 invalid_input`.

## See the agent's tool calls

By default a turn shows one reasoning line per step, not the tools behind it. Ask for each tool call, with its arguments and result, with `include` (Responses only):

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const response = await client.responses.create({
  model: "luw-architect",
  // Luw's own include value, so it isn't in the SDK's types.
  include: ["luw.tool_calls" as OpenAI.Responses.ResponseIncludable],
  metadata: { project_id: process.env.LUW_PROJECT_ID! },
  input: "Furnish the living room.",
});

for (const item of response.output) {
  if (item.type === "mcp_call") console.log(item.name, item.arguments, item.output ?? item.error);
}
```

Each call is an `mcp_call` output item with `server_label: "luw"`, in the order the agent made them: `arguments` and `output` are JSON strings, and a call that failed has `error` and `status: "failed"`. They are kept only for a turn that asked for them with `include`, and `GET /v1/responses/{id}` returns them for that turn.

## Cap the credits a turn spends

Set `metadata.luw_max_credits` to the most credits one turn may spend. Like every metadata value, it is a string:

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

response = client.responses.create(
    model="luw-architect",
    metadata={"project_id": os.environ["LUW_PROJECT_ID"], "luw_max_credits": "20"},
    input="Furnish every bedroom.",
)

if response.status == "incomplete":
    print(response.incomplete_details.reason)  # "max_credits"
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const response = await client.responses.create({
  model: "luw-architect",
  metadata: { project_id: process.env.LUW_PROJECT_ID!, luw_max_credits: "20" },
  input: "Furnish every bedroom.",
});

if (response.status === "incomplete") {
  console.log(response.incomplete_details?.reason); // "max_credits"
}
```

- At the cap the turn stops starting new work and ends `incomplete` with `incomplete_details.reason: "max_credits"` (Chat Completions: `finish_reason: "length"`). What it finished is kept and saved as a version.
- Work already under way finishes, so a turn can end a little above the cap.
- A value that isn't a number above 0 answers `400 invalid_input` naming `metadata.luw_max_credits`, so a turn never runs uncapped by mistake. Without a cap there is no limit per turn.
- A photoreal render the agent makes (see [Pictures and renders](https://studio.luw.ai/developers/api#pictures)) is billed apart, 1 credit each, outside the cap.

## Pictures and renders

- **The agent looks at its work.** Its `view_scene` tool renders the 3D model from a viewpoint it picks (outside, from above, a floor's plan, a room from inside) and shows it the picture, so after a build it can compare what it built with the request and fix what is off. Looking is free: the pictures are part of the turn's own use, at most 12 a turn, and they are not kept.
- **A render, when you ask for one.** When the request asks for a render, a photo or a visualization, the agent takes a frame of the model and renders it with Luw.ai Render, as the Studio chat does: 1 credit from your account each, billed as a Luw.ai Render, outside `luw_max_credits`. Its link is in the `render_view` call's output (`renderUrl`, see [the tool calls](https://studio.luw.ai/developers/api#tool-calls)). A render still being made when the turn moves on says so there; the agent never makes it twice.
- **The turn's picture** is `metadata.luw_preview_url` (see [What a turn returns](https://studio.luw.ai/developers/api#results)).
- **The 3D model** of any scene is `GET /v1/scenes/{id}/glb` (see [Scenes](https://studio.luw.ai/developers/api#scenes)).

## Images and PDFs

A floor plan, a sketch or a photo can go in the request as `input_image` (an https link or a data URI) and a PDF as `input_file` (`file_data` or `file_url`):

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const response = await client.responses.create({
  model: "luw-architect-high",
  background: true,
  metadata: { project_id: process.env.LUW_PROJECT_ID! },
  input: [
    {
      role: "user",
      content: [
        { type: "input_text", text: "Build the ground floor from this plan." },
        { type: "input_image", image_url: "https://example.com/plan.png", detail: "high" },
      ],
    },
  ],
});
```

A request holds at most 10 parts and 32,000 characters of text, and its body at most 4.5 MB, inline pictures included.

## Chat Completions

`POST /v1/chat/completions` runs the same turn for clients that only speak Chat Completions:

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

completion = client.chat.completions.create(
    model="luw-architect-aria",
    messages=[{"role": "user", "content": "Add a pantry next to the kitchen."}],
    extra_headers={"X-Luw-Project": os.environ["LUW_PROJECT_ID"]},
)

print(completion.choices[0].message.content)
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

const completion = await client.chat.completions.create(
  {
    model: "luw-architect-aria",
    messages: [{ role: "user", content: "Add a pantry next to the kitchen." }],
  },
  { headers: { "X-Luw-Project": process.env.LUW_PROJECT_ID! } },
);

console.log(completion.choices[0]?.message.content);
```

- `choices[0].message.content` is the reply and `reasoning_content` the reasoning lines; `annotations` carry the version link, and `metadata` the same `luw_*` values as a Responses turn.
- `finish_reason` is `"stop"`, or `"length"` when the turn stopped at a credit cap or ran out of credits.
- With `stream: true` the answer is `chat.completion.chunk`s with `delta.reasoning_content` and `delta.content`, the version link on the last chunk, a usage chunk when `stream_options.include_usage` is set, and `data: [DONE]` at the end.
- The `id` is `chatcmpl-…`; the same turn can be read as `resp_…` with the same suffix.
- Chat Completions has no background mode: closing the connection stops the turn.

## Embed and share

You never build a project's links yourself: every turn answer carries them in its metadata, and [Scenes](https://studio.luw.ai/developers/api#scenes) lists them for every project. Put `luw_embed_url` in an iframe to show the project in 3D in your own page:

```html
<iframe
  src="https://studio.luw.ai/s/k3Jd9xQ2mPa7Lw0e?embed=1"
  width="960" height="600" style="border: 0" allow="fullscreen"></iframe>
```

- The links are the project's own share link, and the API never turns sharing on: a project nobody has shared yet shows "This project isn't shared" until its owner turns it on in the Studio (**Share** › **Anyone with the link can view**). Then the same links show the project, with no new link to send.
- The owner can turn sharing off, or reset the link, at any time; the old link then shows that the project is not shared.
- `luw_thumbnail_url` is the project's cover, a picture for your list or link card: the one the Studio made the last time the project was open, or the picture of the last turn that changed it.

## Scenes

Read and write a project's 3D scene directly, without a turn. These take the same key, rate limit and errors as the rest of the API, and use no credits.

| Request | Answer |
| --- | --- |
| `GET /v1/scenes?limit=20&page=1` | The key owner's projects, newest first: `{object: "list", data, has_more, next_page}`. Each is `{id, name, updated_at, thumbnail_url, share_url, embed_url, shared}`; `shared` says whether its link is on. `limit` goes up to 100. |
| `GET /v1/scenes/{id}` | `{id, name, scene, sha256, updated_at}`: `scene` is the scene as a JSON object (`null` for a project never saved), `sha256` names this scene for a safe replace. |
| `PUT /v1/scenes/{id}` | Body `{scene, base_sha256?}`: replaces the scene with a Studio scene (`luwFormat: "luw-1"`, as `GET` gives it) and answers the project's card with its new `sha256`. With `base_sha256`, only if the scene is still that one, else `409 scene_changed`. The scene before is kept in the project's history, the new one as an API version, and an open Studio tab shows it. |
| `POST /v1/scenes` | Body `{name?, scene?}`: a new project, empty or holding the scene, answered `201` with its card. |
| `GET /v1/scenes/{id}/glb` | The scene as a GLB, the Studio's own Export GLB (with its concept notice). `202` with `Retry-After: 5` and `{object: "scene.glb", status: "baking", sha256}` while it is made, then `307` to the file on Luw.ai's CDN. Each scene is made once: ask again after a change and a new file is made. An empty project is `409 scene_empty`; a failed export is `422 export_failed` once, and the next request tries again. |
| `GET /v1/scenes/{id}/files` | What the project made, as its Studio gallery keeps it (renders, videos, pictures, 3D models), and its cover, newest first: `{object: "list", data}`, each `{id, kind, url, thumbnail_url, label, created_at}`. `kind` is the gallery's (`render`, `video`, `snapshot`, `picture`, `model`, …) or `cover`; `label` is the prompt it was made from. |

Ids are a project id with or without `luw-`. A project the key can't open (or, for `PUT`, edit) is `404 project_not_found`. Dates are Unix seconds. A `PUT` body is a request like any other, at most 4.5 MB.

**Python**

```python
import os
import requests

API = "https://studio.luw.ai/api/v1"
auth = {"Authorization": f"Bearer {os.environ['LUW_API_KEY']}"}

projects = requests.get(f"{API}/scenes", headers=auth).json()["data"]
project = projects[0]
print(project["name"], project["embed_url"])

current = requests.get(f"{API}/scenes/{project['id']}", headers=auth).json()
scene = current["scene"]
# … change the scene …
saved = requests.put(
    f"{API}/scenes/{project['id']}",
    headers=auth,
    json={"scene": scene, "base_sha256": current["sha256"]},
)
print(saved.status_code)  # 409 when the scene changed since it was read
```

**TypeScript**

```ts
const API = "https://studio.luw.ai/api/v1";
const auth = { Authorization: `Bearer ${process.env.LUW_API_KEY}` };

const { data: projects } = await (await fetch(`${API}/scenes`, { headers: auth })).json();
const project = projects[0];

const current = await (await fetch(`${API}/scenes/${project.id}`, { headers: auth })).json();
// … change current.scene …
const saved = await fetch(`${API}/scenes/${project.id}`, {
  method: "PUT",
  headers: { ...auth, "Content-Type": "application/json" },
  body: JSON.stringify({ scene: current.scene, base_sha256: current.sha256 }),
});
console.log(saved.status); // 409 when the scene changed since it was read
```

**curl**

```bash
curl https://studio.luw.ai/api/v1/scenes/$LUW_PROJECT_ID/files \
  -H "Authorization: Bearer $LUW_API_KEY"
```

## Automations and webhooks

An automation is a request to this API that Luw.ai keeps and sends for you: a saved instruction on one project, started by an event your tools post to its webhook, by a schedule (every day or every week at a time, in your time zone) or by **Run now**. Make them at [studio.luw.ai/automations](https://studio.luw.ai/automations), from the account menu or a project's card. Each run is one background turn (see [Run long turns in the background](https://studio.luw.ai/developers/api#background)) with its own conversation: it is billed, capped, saved as a version and cancelled exactly as a turn you send yourself.

- **Limits you set, checked before each run:** credits a run (the turn's `luw_max_credits`, 20 to start with), credits a day in your time zone (100), runs an hour (6) and minutes a run (15; a run still going then is cancelled at its next step, its work kept). A run counts its renders too, 1 credit each.
- **It pauses itself** when the day's budget is used (it goes on the next day), when the account has too few credits, when its project is gone or no longer yours to edit, when Symphony is picked on a plan without it, or after three failed runs in a row. You get one Studio notification when it pauses; turning it back on is one switch.
- **One run at a time on a project,** in the order the events came. A run waits up to 30 minutes for the project to be free (another turn or chat working on it), then fails.
- **Pause everything** on the page turns every automation off; runs in progress stop at their next step.
- Aria works with any credits; Symphony is on paid plans, as everywhere in the API. Automations are made and changed only while signed in to the Studio, never with an API key.

### Send an event

POST JSON (an object or a list, at most 64 KB) to the automation's webhook address, which the page shows with a ready curl test. Add `X-Luw-Event-Id` with your own id for the event: the same id within 24 hours runs once, so a tool that retries is safe. Without it, the same body within ten minutes runs once.

| Answer | Means |
| --- | --- |
| `202` `{"status": "queued", "run_id": "arun_…"}` | A run is on its way. |
| `200` `{"status": "duplicate", "run_id": …}` | This event ran already; nothing new runs. |
| `200` `{"status": "skipped", "reason": "filter"}` | The event didn't pass the automation's filter. |
| `401` `unsigned` · `bad_signature` · `stale_timestamp` · `bad_key` | Not signed, signed with another secret, a timestamp more than 5 minutes off, or a wrong key in the address. |
| `400` `invalid_json` · `413` `too_large` | The body is not JSON, or larger than 64 KB. |
| `404` | No automation at this address (deleted, or one that runs on a schedule). |
| `409` `paused` | The automation is off or paused itself; `reason` says why. |
| `429` `rate_limited` | Its runs an hour are used, or more than 60 requests came in a minute; wait (`Retry-After`). |

### Sign the request

Every automation has a secret (`lwsec_…`), shown on the page when you ask for it and replaced with **Make a new secret** (the old one stops at once). Sign each request with it: `X-Luw-Timestamp` is the time in Unix seconds and `X-Luw-Signature` is `v1=` and the hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the secret. A request more than 5 minutes off is refused, so a copied request can't be sent again later.

**curl**

```bash
SECRET="lwsec_…"
BODY='{"sheet":"Rooms","name":"Study","width":3.2,"length":2.8}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
curl -X POST "$LUW_AUTOMATION_URL" \
  -H "Content-Type: application/json" \
  -H "X-Luw-Event-Id: row-17" \
  -H "X-Luw-Timestamp: $TS" \
  -H "X-Luw-Signature: v1=$SIG" \
  -d "$BODY"
```

**Python**

```python
import hashlib, hmac, json, os, time, requests

body = json.dumps({"sheet": "Rooms", "name": "Study", "width": 3.2, "length": 2.8})
ts = str(int(time.time()))
sig = hmac.new(os.environ["LUW_AUTOMATION_SECRET"].encode(), f"{ts}.{body}".encode(), hashlib.sha256).hexdigest()
requests.post(
    os.environ["LUW_AUTOMATION_URL"],
    data=body,
    headers={"Content-Type": "application/json", "X-Luw-Event-Id": "row-17",
             "X-Luw-Timestamp": ts, "X-Luw-Signature": f"v1={sig}"},
    timeout=10,
)
```

**TypeScript**

```ts
import { createHmac } from "node:crypto";

const body = JSON.stringify({ sheet: "Rooms", name: "Study", width: 3.2, length: 2.8 });
const ts = Math.floor(Date.now() / 1000).toString();
const sig = createHmac("sha256", process.env.LUW_AUTOMATION_SECRET!).update(`${ts}.${body}`).digest("hex");

await fetch(process.env.LUW_AUTOMATION_URL!, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Luw-Event-Id": "row-17",
    "X-Luw-Timestamp": ts,
    "X-Luw-Signature": `v1=${sig}`,
  },
  body,
});
```

**For tools that can't sign,** choose *Secret in the address* on the automation: its webhook then also takes `?key=<secret>`. Anyone who sees that address can start a run, so keep it private, and sign wherever the tool allows it. An automation set to signing never takes the key in the address.

### Run only on some events

A filter is up to five conditions, each a field of the event and the text it must equal: `sheet` equals `Rooms`, or `row.type` (a field inside another) equals `bath`. All of them must hold; a number or true/false compares as it is written (`3`, `true`). There are no expressions. Other events answer `skipped` and cost nothing.

### What the agent is told

The run's message is your saved instruction, then the event's JSON between two marker lines that carry an id nobody outside can guess. The agent is told that the event is untrusted data from outside Luw.ai: it reads it for the values your instruction asks for and never follows instructions written inside it, so a form answer that says "delete every wall" changes nothing your instruction didn't ask for. Only the instruction commands it. A scheduled run has no event, only the instruction. Nobody can answer the agent's questions during a run, so it does what it can and says why when it can't.

### Get the result

Each run is in **All runs** on the page with its status, credits, the agent's answer and a link that opens the version it made (`/?project=<id>&version=<id>`). A Studio notification tells you when a run ends (you can turn it off). You can also give an https address: when a run ends, its result is POSTed there, signed the same way with the same secret (`X-Luw-Timestamp`, `X-Luw-Signature`, and `X-Luw-Event-Id` set to `<run id>.result`):

```json
{
  "type": "automation.run.finished",
  "automation": { "id": 42, "name": "New sheet row adds a room" },
  "run": {
    "id": "arun_…",
    "trigger": "webhook",
    "status": "completed",
    "credits_used": 9,
    "error": null,
    "created_at": "2026-11-25T09:00:00Z",
    "finished_at": "2026-11-25T09:03:10Z"
  },
  "event_id": "row-17",
  "project": { "id": 1252130, "url": "https://studio.luw.ai/?project=1252130" },
  "version": { "id": 5531, "url": "https://studio.luw.ai/?project=1252130&version=5531" },
  "reply": "Added the study, 3.2 x 2.8 m, next to the living room.",
  "picture_url": "https://i.luvicdn.com/…"
}
```

- Check the signature before you trust a result, as above: the HMAC of `<X-Luw-Timestamp>.<raw body>` with your secret.
- The address must be public https: Luw.ai refuses private, loopback and link-local addresses (also when a name resolves to one), never follows a redirect, waits 5 s to connect and 10 s for an answer, and tries three times (after a minute, then five). Answer `2xx` to take it.
- The result never carries the event itself.

> An automation spends your credits while you are away. Keep its limits small until it does what you expect, sign your events, and keep the secret on your server, never in a web page.

## Parameters the agent ignores or refuses

The agent brings its own tools and answers in text, so these answer `400 unsupported_parameter`, naming the parameter: `tools`, `tool_choice`, `conversation`, `prompt`, a JSON `text.format` or `response_format`, `n` above 1, and a `temperature` other than null. Unknown fields are refused the same way. `store: true` is accepted and ignored: every turn is kept.

## Errors

Don't retry a failed turn automatically: it may already have changed the scene. Every error carries `x-should-retry: false`, which the OpenAI SDKs obey, except a rate limit (`429`), for which nothing ran. A non-streamed Responses turn that fails after it started answers `200` with `status: "failed"` and an `error` object.

A refused request answers with an HTTP status and an `error` object in the OpenAI shape:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "model_not_found",
    "message": "Unknown model. Use luw-architect, luw-architect-low, luw-architect-medium, luw-architect-high, luw-architect-pro or luw-architect-aria.",
    "param": "model",
    "doc_url": "https://studio.luw.ai/developers/api#errors"
  }
}
```

`type` is the class of error, `code` the reason, and `param` the field or header at fault (or `null`). Branch on `code`.

| Status | type | code | When |
| --- | --- | --- | --- |
| 400 | `invalid_request_error` | `invalid_input` | The body isn't JSON, an input part or file can't be read, `metadata.luw_max_credits` isn't a number above 0, the `Idempotency-Key` header is malformed, or a scene isn't a Studio scene. `param` names the field or header. |
| 400 | `invalid_request_error` | `unsupported_parameter` | A parameter the agent can't honour (see above). `param` names it. |
| 400 | `invalid_request_error` | `content_policy` | The request can't run under Luw.ai's usage policy. Nothing runs and nothing is charged. |
| 401 | `authentication_error` | `invalid_api_key` | The key is missing, unknown or revoked. |
| 402 | `insufficient_quota` | `insufficient_quota` | The key's account hasn't enough credits to start a turn. |
| 403 | `invalid_request_error` | `upgrade_required` | The model needs a paid account (the Symphony models). |
| 404 | `invalid_request_error` | `turn_not_found` | The response or `previous_response_id` doesn't exist or you can't read it, or you cancelled a turn someone else started. |
| 404 | `invalid_request_error` | `project_not_found` | The project doesn't exist or the key can't edit it (for reading a scene: can't open it). |
| 404 | `invalid_request_error` | `file_not_found` | The file doesn't exist or the key can't read it. |
| 404 | `invalid_request_error` | `model_not_found` | The model isn't one of the agent's. |
| 409 | `conflict_error` | `turn_in_progress` | A turn is already running on the project. `error.response_id` is that turn, for you to poll. |
| 409 | `conflict_error` | `scene_changed` | `PUT /v1/scenes/{id}` with a `base_sha256` that is no longer the project's scene. Read it again, then replace it. |
| 409 | `conflict_error` | `scene_empty` | `GET /v1/scenes/{id}/glb` on a project with no scene yet. |
| 409 | `idempotency_error` | `idempotency_mismatch` | The `Idempotency-Key` was already used with a different request. |
| 422 | `invalid_request_error` | `export_failed` | The scene's GLB couldn't be made. The message says why; the next request tries again. |
| 429 | `rate_limit_error` | `rate_limit_exceeded` | Too many requests with this key. Wait the `Retry-After` seconds, then send it again. |
| 500 | `api_error` | `internal_error` | Something failed on Luw.ai's side. The message names the request id. |
| 503 | `server_error` | `executor_unavailable` | The API can't run turns right now, for example during a deploy. Try again later. |

A failed turn's `error.code` can also be `turn_interrupted` (the service restarted during the turn; what it had done is saved and charged).

**Python**

```python
import os
from openai import APIStatusError, OpenAI

client = OpenAI(
    api_key=os.environ["LUW_API_KEY"],
    base_url="https://studio.luw.ai/api/v1",
)

try:
    client.responses.create(
        model="luw-architect",
        metadata={"project_id": os.environ["LUW_PROJECT_ID"], "luw_max_credits": "0"},
        input="Add a bedroom.",
    )
except APIStatusError as error:
    print(error.status_code, error.code, error.param)  # 400 invalid_input metadata.luw_max_credits
```

**TypeScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LUW_API_KEY,
  baseURL: "https://studio.luw.ai/api/v1",
});

try {
  await client.responses.create({
    model: "luw-architect",
    metadata: { project_id: process.env.LUW_PROJECT_ID!, luw_max_credits: "0" },
    input: "Add a bedroom.",
  });
} catch (error) {
  if (!(error instanceof OpenAI.APIError)) throw error;
  console.log(error.status, error.code, error.param); // 400 invalid_input metadata.luw_max_credits
}
```

### Request ids

Every answer carries a `Request-Id` header; quote it when you contact support. A turn's reply also carries `x-request-id`, the same value as its response id; every other answer, each error included, carries the `Request-Id` value there. The OpenAI SDKs give it as `response._request_id`, and on an error as `error.request_id` (Python) or `error.requestID` (TypeScript).

## Rate limits and limits

| Limit | Value |
| --- | --- |
| Requests per key | 300 a minute. Over it: `429` with `Retry-After`. |
| Running turns | One per project (`409 turn_in_progress`), five per account (`429`). |
| A turn without `background` | 13 minutes; it stops starting new steps at 12 (`incomplete`, `time_limit`). |
| A background turn | 45 minutes, then `incomplete` with `time_limit`. |
| Steps in one turn | 150 model calls. |
| A request | 10 input parts, 32,000 characters of text, a 4.5 MB body. |

Every answer counts against the key's budget and carries the IETF rate-limit fields, for example `RateLimit-Policy: "credential";q=300;w=60` and `RateLimit: "credential";r=287;t=41` (requests left, and seconds until the window resets).

## Credits

- Turns are billed at the Studio chat's rate, from the key owner's own Luw.ai credits.
- Any credits on the account work, as they do in the Studio chat.
- Credits are charged as the turn runs, after each model call, so a turn that stops early (a cap, a cancel, no credits left) is charged only for what it did. Each turn is rounded up to a whole credit on its own.
- The agent's own pictures (`view_scene`), the turn's picture and GLB exports are free. A render you ask for is 1 credit, billed as a Luw.ai Render, outside `luw_max_credits`.
- A turn that would start with too few credits answers `402 insufficient_quota`; one that runs out midway ends `incomplete` with `balance`, its work saved. [Plans and credit packs](https://app.luw.ai/pricing) top the account up.

## Keys and security

- Keys are made and deleted on app.luw.ai's [API & MCP](https://app.luw.ai/dashboard/api) page. They look like `sk-…`, and the same key works for Luw.ai's REST API, the Luw.ai MCP server and the Studio API.
- A key acts as your account: it can work on every project you can edit and spends your credits. Deleting it there stops it; a turn it started stops at its next step.
- Call the API from your server or your own machine. Never put a key in a web page or an app other people download.

## Terms

> AI-generated concept, not for construction or renovation. Get a licensed architect or engineer's review and permits first. Whatever the agent builds through the API is an AI design concept, made by software, not by an architect or an engineer. Use of the API falls under the Luw.ai [Terms of Use](https://app.luw.ai/docs/terms) and [Privacy Policy](https://app.luw.ai/docs/privacy).
