Build and deploy web apps programmatically. Send a text prompt, get back a live URL.
Base URL: https://codebase.design (production) or http://localhost:3001 (dev)
curl -X POST https://codebase.design/api/agent/build \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"prompt": "Build a landing page for a coffee shop called Bean Scene"}'Response:
{
"projectId": "mls8miby",
"url": "https://codebase.design/api/preview/mls8miby/",
"files": ["index.html", "styles.css", "app.js"],
"summary": "Built a landing page with hero section, menu grid, and contact form.",
"model": "d4f",
"buildTimeMs": 30476
}The url is a live preview — open it in a browser or give it to your user immediately.
This document describes the AI builder Agent API: prompts, builds, files, previews, and build status. It is separate from product/support chat.
Header (recommended):
Authorization: Bearer YOUR_API_KEY
Body (alternative):
{ "prompt": "...", "apiKey": "YOUR_API_KEY" }Query param (alternative):
/api/agent/build?apiKey=YOUR_API_KEY
In dev mode (AGENT_API_KEYS env not set), auth is disabled — all requests are accepted.
Build a complete web project from a text prompt. This is a synchronous endpoint — the request blocks until the build finishes (typically 20-60 seconds depending on complexity and model).
| Field | Type | Required | Description |
|---|---|---|---|
prompt |
string | Yes | What to build. Be as specific as you want — the more detail, the better the output. |
model |
string | No | Model ID to use for the build. Defaults to d4f (Codebase Auto). See Models for discovery. |
userId |
string | No | Identifier for the end user (for project organization). Defaults to "agent". |
{
"projectId": "string",
"url": "string",
"files": ["string"],
"summary": "string",
"model": "string",
"buildTimeMs": 0,
"warning": "string (optional)"
}| Field | Type | Description |
|---|---|---|
projectId |
string | Unique project identifier. Use this to reference the project later. |
url |
string | Live preview URL. Opens in any browser. Served as static files. |
files |
string[] | List of files created (relative paths, e.g. "index.html", "styles.css"). |
summary |
string | Human-readable summary of what was built. |
model |
string | The model that was actually used. |
buildTimeMs |
number | Build duration in milliseconds. |
warning |
string? | Present only if a non-fatal error occurred during build. The project may still be usable. |
400 Bad Request — Missing or empty prompt:
{ "error": "Missing required field: prompt" }401 Unauthorized — Invalid or missing API key (production only):
{ "error": "Invalid or missing API key" }500 Internal Server Error — Build failed:
{ "error": "Build failed: <reason>" }curl -X POST http://localhost:3001/api/agent/build \
-H "Content-Type: application/json" \
-d '{"prompt": "Hello world page"}'curl -X POST http://localhost:3001/api/agent/build \
-H "Content-Type: application/json" \
-d '{
"prompt": "Build a portfolio site for a photographer named Alex Chen. Include a hero with a fullscreen image, a grid gallery section with lightbox, an about section, and a contact form. Use dark theme with gold accents.",
"model": "claude-sonnet-4-6"
}'import requests
resp = requests.post(
"https://codebase.design/api/agent/build",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"prompt": "Build a todo app with local storage persistence",
"model": "d4f"
},
timeout=120 # builds can take up to 60s
)
result = resp.json()
print(f"Live at: {result['url']}")
print(f"Files: {result['files']}")
print(f"Built in {result['buildTimeMs']}ms")const resp = await fetch("https://codebase.design/api/agent/build", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
prompt: "Build a weather dashboard that shows a 5-day forecast with animated weather icons",
model: "d4f"
})
});
const { projectId, url, files, summary, buildTimeMs } = await resp.json();
console.log(`Project ${projectId} live at ${url} (${buildTimeMs}ms)`);Health check. Use this to verify the API is reachable and check configuration.
{
"status": "ok",
"authRequired": true,
"defaultModel": "d4f",
"timestamp": "2026-02-18T16:17:29.532Z"
}| Field | Type | Description |
|---|---|---|
status |
string | Always "ok" if the server is running. |
authRequired |
boolean | true if API keys are configured (production). false in dev mode. |
defaultModel |
string | The model used when model is not specified in build requests. |
timestamp |
string | Server time (ISO 8601). |
List all registered AI models. Use this authenticated endpoint to discover valid
model values and check current provider availability.
{
"models": [
{
"id": "d4f",
"name": "Codebase Auto",
"provider": "codebase",
"providerName": "Codebase",
"available": true,
"description": "In-house DeepSeek V4 Flash — fast smart-routed default and our lowest-cost option."
}
],
"defaultModel": "d4f"
}Only models with "available": true can be used for builds.
The default model is d4f (Codebase Auto). q27fp8 (Codebase Qwen 3.8)
is the other in-house, low-cost option. Provider availability and the wider
catalog change over time, so clients must discover models from the authenticated
GET /api/v1/models endpoint instead of embedding a static list.
Every build creates a static web project with:
index.html— entry point (always present)styles.css— stylesheetsapp.js/script.js— JavaScript (if interactive)- Additional files as needed (images, data files, etc.)
The build agent writes production-quality HTML/CSS/JS with:
- Local font stacks or bundled font files (distinctive typography, never generic)
- Cohesive color palettes
- CSS animations and transitions
- Responsive/mobile-first design
- Clean semantic HTML
The project is served as static files at the returned url. No server-side rendering, no build step — just open the URL.
The url in the response points to the project's index.html:
https://codebase.design/api/preview/{projectId}/
You can also access individual files:
https://codebase.design/api/preview/{projectId}/styles.css
https://codebase.design/api/preview/{projectId}/app.js
Preview URLs are persistent — they stay live as long as the server is running.
Builds typically complete in 20-60 seconds depending on:
- Prompt complexity (simple page vs full app)
- Model speed (MiniMax Fast ~20s, Claude Opus ~60s)
- Number of files generated
Set your HTTP client timeout to at least 120 seconds to be safe.
No rate limits are currently enforced. Be reasonable — each build consumes LLM tokens and server resources. If you need high-throughput access, reach out.
If your agent framework uses tool/function definitions, register Codebase as:
{
"name": "codebase_build",
"description": "Build and deploy a web application from a text description. Returns a live URL. Use this when the user wants a website, web app, landing page, dashboard, or any browser-based project.",
"parameters": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "Detailed description of what to build. Include specifics about layout, colors, features, and content."
},
"model": {
"type": "string",
"description": "Optional model ID. Defaults to d4f (Codebase Auto). Discover current IDs with GET /api/v1/models."
}
},
"required": ["prompt"]
}
}async function codebase_build({ prompt, model }) {
const resp = await fetch("https://codebase.design/api/agent/build", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.CODEBASE_API_KEY}`
},
body: JSON.stringify({ prompt, model })
});
if (!resp.ok) {
const err = await resp.json();
throw new Error(err.error || "Build failed");
}
const result = await resp.json();
return `Website built and deployed!\n\nLive URL: ${result.url}\nFiles: ${result.files.join(", ")}\nBuild time: ${(result.buildTimeMs / 1000).toFixed(1)}s\n\n${result.summary}`;
}When your agent constructs the prompt, more detail = better output:
Weak: "make a website"
Strong: "Build a landing page for a SaaS product called 'DataFlow'. Hero section with gradient background, product screenshot mockup, three feature cards with icons, pricing table with 3 tiers, FAQ accordion, and footer with social links. Use Inter font, blue-purple gradient theme, glassmorphism effects."
The build agent handles all implementation details (file structure, responsive design, animations) — your prompt just needs to describe what to build.
| HTTP Status | Meaning | Action |
|---|---|---|
| 200 | Build succeeded | Use the url and files from response |
200 + warning |
Build succeeded with issues | Project is usable but may have problems. Check warning field. |
| 400 | Bad request (missing prompt) | Fix your request body |
| 401 | Auth failed | Check your API key |
| 500 | Build crashed | Retry with a simpler prompt or different model. If persistent, the server may be down. |
Retry logic: if you get a 500, wait 5 seconds and retry once. If it fails again, try a different model or simplify the prompt.