complext developer docs

Build research‑grade mini‑agents and mini‑apps. This guide covers API/SDK usage, CMS blocks, webhooks, security, and real‑world patterns across bio/chem, professional services, media, finance, energy, healthcare, and education.

Quick start

1) Create an organization

POST /api/orgs
{ "name": "Acme Labs" }

2) Create an agent

POST /api/agents
{
  "orgId": "org_123",
  "name": "Lead Intake",
  "config": {
    "model": "gpt-4o",
    "tools": ["calendar.create", "sheets.append"],
    "system": "Qualify leads and book meetings on the owner's calendar."
  }
}

3) Create a CMS page

POST /api/apps/app_123/routes
{
  "path": "/landing",
  "content": [
    { "type": "hero", "props": { "title": "Welcome", "subtitle": "mini‑agents in days" } },
    { "type": "feature-list", "props": { "items": ["agents", "cms", "deploy"] } }
  ]
}

REST API

Authentication

Authorization: Bearer <api_key>

# Create key (owner only)
POST /api/apps/app_123/keys
{ "name": "server" } → { "key": "sk_live_***" }   // shown once

Agents

# List
GET /api/agents?orgId=org_123

# Chat with an agent
POST /api/agents/agent_123/chat
{
  "messages": [
    { "role": "user", "content": "Summarize this PDF and add action items." }
  ],
  "attachments": [
    { "type": "file", "url": "https://..." }
  ]
}

CMS Routes

PATCH /api/apps/app_123/routes/route_456
{
  "content": [
    { "type": "hero", "props": { "title": "complext", "subtitle": "research‑grade agents" } },
    { "type": "code", "props": { "language": "ts", "body": "console.log('hello');" } }
  ]
}

TypeScript SDK

Install

pnpm add @complext/sdk

Create & chat with an agent

import { complext } from "@complext/sdk";

const client = complext({ apiKey: process.env.COMPLEXT_API_KEY! });

const agent = await client.agents.create({
  orgId: "org_123",
  name: "Research Assistant",
  config: {
    model: "gpt-4o",
    tools: ["web.search", "sheets.append"]
  }
});

const reply = await client.agents.chat(agent.id, {
  messages: [{ role: "user", content: "Draft a one-page summary of CRISPR" }]
});

console.log(reply.text);

Render a CMS page (server)

import type { Block } from "@complext/sdk";

function renderBlock(b: Block) {
  if (b.type === "hero") {
    return /*html*/`

${b.props.title}

${b.props.subtitle}

`; } return ""; }

Webhooks

Events

POST https://yourapp.com/webhooks/complext
X-Complext-Signature: t=..., v1=...

{
  "type": "agent.job.completed",
  "data": { "jobId": "job_123", "status": "succeeded", "output": {...} }
}

Verify signatures (Node)

import crypto from "node:crypto";

export function verify(sigHeader, rawBody, secret) {
  const [tPart, v1Part] = sigHeader.split(","); // t=... , v1=...
  const t = tPart.split("=")[1];
  const v1 = v1Part.split("=")[1];
  const hmac = crypto.createHmac("sha256", secret);
  hmac.update(`${t}.${rawBody}`);
  const digest = hmac.digest("hex");
  return crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(digest));
}

CMS Blocks

Composable JSON blocks for routing, content, and simple app UIs.

Block schema

{
  "type": "hero" | "feature-list" | "code" | "form",
  "props": { "...": "..." }
}

Hero

{
  "type": "hero",
  "props": {
    "title": "Welcome to complext",
    "subtitle": "mini‑agents & mini‑apps in days",
    "cta": { "label": "Contact", "href": "/contact.html" }
  }
}

Feature list

{
  "type": "feature-list",
  "props": {
    "items": ["agents", "cms pages", "deploy"]
  }
}

Code block

{
  "type": "code",
  "props": { "language": "ts", "body": "console.log('hello');" }
}

Agents & tools

Agents run with explicit tool permissions and typed I/O so you can trust outcomes and reproduce runs.

Tool contract

POST /api/tools/register
{
  "name": "calendar.create",
  "input": { "title": "string", "when": "datetime", "attendees": "string[]" },
  "output": { "eventId": "string", "link": "string" },
  "policy": { "orgOnly": true, "rateLimit": "10/m" }
}

Invoke tools (chat)

POST /api/agents/agent_123/chat
{
  "messages": [{ "role": "user", "content": "Book a 30m call with Alex Fri 10am" }],
  "allow": ["calendar.create"]
}

Security & privacy

Local-first + isolation

Sensitive workloads can run on your own machines. For research tasks, we use containerized processors with least‑privilege policies and signed artifacts for traceability.

Data boundaries

Clear org/app boundaries. Secrets stay in tools (not prompts). Tools receive scoped tokens; prompts receive references.

Observability

Every job has a timeline (inputs, tool calls, outputs) so audits and repros are simple. Redaction and PII scrubbing are available per field.

Industry research & sources

A non‑exhaustive starting library to explore AI in different domains. Use these to guide validation, safety, and feasibility checks.

Biology & Chemistry

  • Nature / Science / Cell (general breakthroughs)
  • Nature Biotechnology, Nature Methods
  • Journal of the American Chemical Society (JACS), Angewandte Chemie
  • Bioinformatics, PLOS Computational Biology
  • Topics: protein design, generative chemistry, multi‑omics, lab automation

Healthcare

  • NEJM, Lancet, JAMA
  • NPJ Digital Medicine, Nature Medicine
  • Topics: triage tools, imaging, clinical summarization, workflow copilot safety

Finance

  • Journal of Finance, Management Science, Quantitative Finance
  • Topics: risk modeling, filings RAG, anomaly detection, agentic controllers with human approval

Energy & Climate

  • Joule, Energy & Environmental Science
  • Topics: solar design agents, grid forecasting, maintenance copilots, policy retrieval

Professional Services

  • Law: Harvard Law Review, Stanford Law Review (AI & procedure, privacy, IP)
  • Accounting/Consulting: MIT Sloan Management Review, HBR
  • Topics: document drafting, due diligence, meeting synthesis, expert‑in‑the‑loop QA

Media & Creative

  • ACM TOG (graphics), SIGGRAPH proceedings
  • Topics: content pipelines, rights management, metadata agents, style‑safe generation

Education

  • Computers & Education, IJAIED
  • Topics: mastery learning agents, formative feedback, curriculum planning

Tip: pair literature with small proof‑of‑concept agents. Validate utility, failure modes, and review loops before scaling.

Industry use‑cases (patterns)

Bio/Chem R&D

  • Paper triage agent → weekly briefs
  • Protocol planner → checklist + reagent table
  • ELN summarizer → experiment deltas + next steps

Professional Services

  • Intake → auto‑route to practice area
  • Case brief generator with source links
  • Billing notes cleanup + categorization

Media

  • Asset ingest → captioning + rights metadata
  • Editorial copilot → outlines + fact check queue
  • Audience insights → weekly dashboard + recommendations

Healthcare

  • Visit summary → structured SOAP + tasks
  • Payer policy retrieval → prior auth packets
  • Care navigation → triage scripts (with oversight)

Finance

  • Earnings RAG → deltas + risk highlights
  • Transaction anomaly explanations
  • Policy agent → model governance checklists

Energy

  • PV layout helper + BOM export
  • Lead triage → site visit scheduler
  • Interconnection paperwork assistant

Best practices

Scope small, measure

Define a clear task, success metric, and human approval step. Ship in days, not months.

Typed I/O

Use schemas for tool inputs/outputs. Reject/repair invalid structures and log failures.

Data minimization

Pass only the fields an agent needs. Avoid dumping full records into prompts.

Observability

Retain traces for audit; add redaction where needed. Make repro easy.

FAQ

Can I host locally?

Yes. You can run selected agents and processors on your own hardware with the same abstractions.

How do you handle secrets?

Secrets stay in the tool layer, not prompts. Tools receive scoped tokens; prompts receive references.

What about compliance?

We provide data boundaries, audit trails, and optional PII scrubbing. Add your industry policies on top.