shiftlabs Start free
Menu Agents

Agents

An agent is instructions, a model and tools. A tool is one of your workflows, or a function in the agent's own code.

Define an agent

Deploy an agent with PUT /v1/agents/:agent, from a project with shiftlabs deploy, or from a template on the dashboard's Agents screen. Each deploy adds a version and makes it current.

Agents are on in a new workspace. An admin can turn them off.

shellcurl
# Deploy the agent (developer key). Answers {"name", "version", "warnings"}.
# Deploy each tool's workflow first.
curl -X PUT https://api.shiftlabs.org/v1/agents/billing \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "title": "Billing assistant",
    "instructions": "Answer questions about invoices. Look them up first.",
    "model": "@cf/zai-org/glm-4.7-flash",
    "tools": [{
      "workflow": "lookup-invoice",
      "description": "Look up an invoice by its id.",
      "parameters": {
        "type": "object",
        "properties": {"invoice": {"type": "string"}},
        "required": ["invoice"]
      },
      "approval": "never"
    }]
  }'
  • title

    1 to 80 characters, shown in the dashboard.

  • description

    What the agent does, up to 300 characters, shown in the dashboard's list of agents. Optional.

  • instructions

    What the agent is for and how it works, 1 to 8,000 characters. In a project, file("./x.md") keeps them in a file.

  • model

    A model id from Models, or <provider>/<model> on your own provider key. Default @cf/zai-org/glm-4.7-flash.

  • fallback

    Up to 3 more model ids, tried in order when a request to model fails before it answers. None may be of a lower tier than model. Left out, the platform picks one; [] means none. On your own provider key, only that provider's models, and the platform picks none.

  • providerKey

    The workspace secret holding your API key with the provider of a model on your own provider key, by name. Pro only.

  • maxTurns

    Model turns one message may take, 1 to 20. Default 6.

  • budget

    {conversationUsd, monthlyUsd, endUserDailyUsd}: what the agent may spend, and what each end user may spend with it in a day. See Budgets.

  • access

    {role, members}: who may message the agent. See Access.

  • welcome

    Shown in the dashboard's chat before the first message, up to 500 characters. Optional.

  • suggestions

    Up to 4 first messages, each up to 200 characters, offered in the dashboard's chat. Choosing one sends it.

  • tools

    Up to 16 workflow tools, counting the tools in the agent's code.

  • code

    The codeHash of the agent's code. Every tool in the code joins the agent.

shiftlabs.config.ts
import { agent, file, project, workflowTool } from "shiftlabs";

export default project({
  workflows: { "stripe-refund": "./workflows/stripe-refund.ts" },
  agents: {
    "invoice-assistant": agent({
      title: "Invoice assistant",
      description: "Answers billing questions and issues refunds.",
      instructions: file("./agents/invoice-assistant.md"),
      model: "@cf/zai-org/glm-4.7-flash",
      tools: [
        workflowTool("stripe-refund", {
          description: "Refund an invoice.",
          approval: "always",
        }),
      ],
      budget: { conversationUsd: 0.5, monthlyUsd: 20, endUserDailyUsd: 0.25 },
      access: { role: "developer", members: ["ana@acme.com"] },
      welcome: "Ask me about an invoice.",
      suggestions: ["Why was I charged twice?", "Refund invoice in_123"],
    }),
  },
});

An agent's name is 2 to 48 lowercase letters, digits and hyphens, and starts with a letter. shiftlabs is taken by the helper, and shiftlabs-draft by the workflow editor's AI drafts: PUT /v1/agents/:agent, PUT /v1/agents/:agent/code, a release, a rollback and a promotion that use either return 400.

A bad field, a workflow tool without approval, or a tool whose workflow doesn't exist, returns 400 {"error": "invalid definition", "detail"}. For a model id agents can't use, the detail lists the ones they can. A model your plan doesn't include returns 403 {"error": "plan", "detail"}. A new agent past your plan's limit returns 403 {"error": "quota exceeded", "limit": "agents", "max"}.

Models

Free workspaces use the small models. Pro workspaces use every model below, and models on your own provider key. A model's tier is its answer quality, from 1 to 5. Prices are in US dollars per million tokens. Each response's tokens, at the prices of the model that answered, count toward the agent's budgets and the workspace's model allowance.

Small models, on Free and Pro
ModelTierInputOutput
@cf/google/gemma-4-26b-a4b-it4$0.10$0.30
@cf/ibm-granite/granite-4.0-h-micro1$0.017$0.112
@cf/meta/llama-3.1-8b-instruct-fp8-fast2$0.045$0.384
@cf/meta/llama-3.2-1b-instruct1$0.027$0.201
@cf/meta/llama-3.2-3b-instruct1$0.051$0.335
@cf/mistral/mistral-7b-instruct-v0.1 retired by Workers AI on 2026-05-301$0.11$0.19
@cf/qwen/qwen3-30b-a3b-fp84$0.051$0.335
@cf/zai-org/glm-4.7-flash4$0.06$0.40
Every other model, on Pro
ModelTierInputOutput
@cf/aisingapore/gemma-sea-lion-v4-27b-it3$0.351$0.555
@cf/deepseek-ai/deepseek-r1-distill-qwen-32b3$0.497$4.881
@cf/deepseek-ai/deepseek-v4-flash-0731 cached input $0.0145$0.44$1.32
@cf/deepseek-ai/deepseek-v4-pro-0813 cached input $0.0445$1.32$3.96
@cf/deepseek-ai/deepseek-v4.1-flash-1017 cached input $0.0065$0.30$1.20
@cf/google/gemma-3-12b-it retired by Workers AI on 2026-05-302$0.345$0.556
@cf/meta/llama-2-7b-chat-fp16 retired by Workers AI on 2026-05-301$0.556$6.667
@cf/meta/llama-3-8b-instruct retired by Workers AI on 2026-05-302$0.282$0.827
@cf/meta/llama-3-8b-instruct-awq retired by Workers AI on 2026-05-302$0.123$0.266
@cf/meta/llama-3.1-70b-instruct-fp8-fast3$0.293$2.253
@cf/meta/llama-3.1-8b-instruct retired by Workers AI on 2026-05-302$0.282$0.827
@cf/meta/llama-3.1-8b-instruct-awq retired by Workers AI on 2026-05-302$0.123$0.266
@cf/meta/llama-3.1-8b-instruct-fp82$0.152$0.287
@cf/meta/llama-3.2-11b-vision-instruct2$0.049$0.676
@cf/meta/llama-3.3-70b-instruct-fp8-fast3$0.293$2.253
@cf/meta/llama-4-scout-17b-16e-instruct3$0.27$0.85
@cf/mistralai/mistral-small-3.1-24b-instruct3$0.351$0.555
@cf/moonshotai/kimi-k2.5 cached input $0.10; retired by Workers AI on 2026-05-30; served by @cf/moonshotai/kimi-k2.6 at its price5$0.60$3.00
@cf/moonshotai/kimi-k2.6 cached input $0.165$0.95$4.00
@cf/moonshotai/kimi-k2.7-code cached input $0.194$0.95$4.00
@cf/nvidia/nemotron-3-120b-a12b4$0.50$1.50
@cf/openai/gpt-oss-120b4$0.35$0.75
@cf/openai/gpt-oss-20b4$0.20$0.30
@cf/qwen/qwen2.5-coder-32b-instruct3$0.66$1.00
@cf/qwen/qwen3.8-27b5$0.45$3.20
@cf/qwen/qwq-32b3$0.66$1.00
@cf/zai-org/glm-5.2 cached input $0.265$1.40$4.40
@cf/zai-org/glm-5.3 cached input $0.265$1.40$4.40
@cf/zai-org/glm-5.3-flash cached input $0.035$0.15$0.50
  • Any other model id returns 400, unless it is a model on your own provider key.
  • A fallback must be the same tier as model or higher, so a failing model never lowers the quality of answers. A fallback of a lower tier returns 400.
  • Without fallback, the platform picks one at each deploy: of the models still served at the lowest tier at or above that of model, the one closest in price. For a small model it picks a small model. Once an earlier pick has retired, deploying the same definition picks another and adds a version.
  • When a fallback answers, the conversation's model item names it with "fallback": true, and the dashboard's trace marks it.
  • When Workers AI retires a model, the table above notes the date. A deploy or release naming a model or fallback that retires within 30 days goes ahead, with a sentence for each in warnings that shiftlabs deploy prints. Naming a retired one returns 400, or 409 for a rollback, with its successor or the models still served.
  • After its model retires, a conversation is answered by the successor Workers AI named, else by the agent's first fallback still served, else by a model the platform picks by the rule above. That model's price applies: a Kimi K2.5 conversation now costs Kimi K2.6's. Its budgets run out sooner. Its model items carry "retired", the date, and the dashboard's trace says so. A retired fallback gives way to its successor, or is skipped. Deploy the agent with another model to choose for yourself.
  • In a Free workspace, deploying, releasing or messaging an agent on a Pro model returns 403 {"error": "plan", "detail"}. An agent on a Pro model stops taking messages when its workspace moves back to Free.

Your own provider key

On Pro, an agent can run on another provider's model, on your account with that provider. Your provider bills you for it, and shiftlabs doesn't. Store your API key with the provider as a workspace secret, then name the model <provider>/<model> and the secret providerKey.

shellcurl
# Store the key (admin key). Leave it not readable: no workflow can read it.
curl -X PUT https://api.shiftlabs.org/v1/secrets/OPENAI_API_KEY \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"value": "<your OpenAI API key>"}'

# Deploy the agent on it (developer key).
curl -X PUT https://api.shiftlabs.org/v1/agents/billing \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "title": "Billing assistant",
    "instructions": "Answer questions about invoices.",
    "model": "openai/gpt-4.1-mini",
    "fallback": ["openai/gpt-4.1"],
    "providerKey": "OPENAI_API_KEY"
  }'
  • The provider is one of anthropic, baseten, cerebras, cohere, deepseek, google-ai-studio, google-vertex-ai, grok, groq, mistral, openai, parallel, perplexity and workers-ai. The model is the provider's own name for it, as Cloudflare AI Gateway's OpenAI-compatible endpoint takes it, such as anthropic/claude-sonnet-4-5 or google-ai-studio/gemini-2.5-flash. shiftlabs doesn't check the model: one the provider doesn't serve fails the turn with the provider's error.
  • The request goes from shiftlabs to AI Gateway, then to the provider. Your key is read from the secret for each request, inside shiftlabs, and sent only in that request's Authorization header. It never reaches your workflows, code tools, the model, the transcript, logs, errors or the dashboard. Each use is written to the audit log, on the Audit screen and at /v1/audit, as provider_key with the agent and the model.
  • The secret must not be readable, since a readable secret reaches workflow code. A deploy doesn't check the secret: a message checks it.
  • Your provider bills each response. Its model item reads "byok": true and "costUsd": 0, and the dashboard's trace marks it your key. It counts toward no budget, and toward neither the $2 of model use per month nor model use on your bill. Its tokens count toward the model tokens per 24 hours.
  • A fallback must be another model of the same provider, and is asked on the same key. The platform picks none, and never a model it pays for.
  • Tool calls work as they do on the platform's models. How well a model uses them is up to the model.
  • In a Free workspace, deploying, releasing or messaging an agent on your own key returns 403 {"error": "plan", "detail"}. It stops taking messages when its workspace moves back to Free.
  • A request that can't use the key ends the turn as failed at once, without a fallback or a retry, and costs nothing. Its error item names the secret, never the key. See below.
  • An end user reads only The agent could not answer: the model request failed., without the secret's name.
  • Of each request, AI Gateway keeps what it keeps of the platform's models. See Conversations.

Such an error item reads The agent could not answer: its provider key, the secret OPENAI_API_KEY, and goes on with one of these.

  • isn't in the workspace. An admin must add it, or restore it from the trash.

    No secret has that name, or it is in the trash.

  • can be read by workflow code, which a provider key must not be. An admin must turn off readable on it.

    The secret is readable.

  • has spaces, line breaks or other characters no key has. An admin must set it again.

    The value holds a character no header can carry.

  • was refused by openai. An admin must replace its value.

    The provider answered 401 or 403, or AI Gateway found no key in the request it takes for the provider.

  • is over openai's limits or out of credit. Try again later, or raise the limits with openai.

    The provider answered 429.

Workflow tools

A workflow tool runs one of your workflows. The model's arguments, checked against parameters, are the run's payload. Arguments over 1 MiB as JSON fail the call without starting a run, and the model reads why. In a project, workflowTool(workflow, {...}) defines one.

shiftlabs.config.ts
import { agent, project, workflowTool } from "shiftlabs";
import * as z from "zod";

export default project({
  workflows: { "lookup-invoice": "./workflows/lookup-invoice.ts" },
  agents: {
    billing: agent({
      title: "Billing assistant",
      instructions: "Answer questions about invoices. Look them up first.",
      model: "@cf/zai-org/glm-4.7-flash",
      tools: [
        workflowTool("lookup-invoice", {
          description: "Look up an invoice by its id.",
          parameters: z.object({ invoice: z.string() }),
          approval: "never",
        }),
      ],
    }),
  },
});
  • workflow

    The workflow's name. Deploy the workflow before the agent.

  • description

    When to use the tool, 1 to 1,024 characters. The model chooses tools by it.

  • parameters

    A JSON Schema with "type": "object", up to 8 KB. Left out, it is the workflow's payload schema as of the agent's deploy, or any object when the workflow has none. A payload schema that isn't an object schema, or is over 8 KB, can't stand in: that deploy returns 400 and asks for parameters. In shiftlabs.config.ts, any Standard JSON Schema too, such as a zod 4.2+ schema: shiftlabs deploy sends its JSON Schema.

  • approval

    Required: each workflow tool says whether its calls wait for a person. "never" runs every call at once. "always" holds every call until an admin or approver approves it. {"approvers": ["role:admin", "ana@acme.com"]} holds it for those roles and members only: up to 20, each role:admin, role:approver, role:manager or the email of a member who is an admin or approver when you deploy. A developer never approves. See Who approves. {"approvals": 2} needs that many different members to approve, 1 to 5, alone or with approvers; see Two approvers. A tool without it returns 400, naming the tool and these choices. Versions deployed before it was required keep the "never" they were stored with, and roll back as they were. The stored definition reads "approval": "always" with the tool's approvers and approvals beside it, and a deploy takes that shape too.

  • waitSeconds

    How long a call waits for the run's output, 5 to 300. Default 60.

  • A call starts a run, as run now does. It counts toward runs per 24 hours and runs at once, and it is refused past the spending limit.
  • Only someone who may start runs gets workflow tools: developers, admins and keys that hold run.start. A viewer, or a key whose capabilities leave run.start out, still talks to the agent, and its code tools still run for them, but the conversations they start have no workflow tools. A conversation keeps the tools it started with and goes by the role of its person's latest message. So in one started before they lost run.start, each workflow tool call fails with your role can't start runs from their next message on, and no run starts and no approval is asked for. Until that message the agent goes by their earlier role, also in its answer to an approval decided meanwhile, and a call already waiting for approval runs whenever an approver approves it. Conversations of end users and schedules, and a workflow's step.ask, keep their workflow tools, though a key's scope still limits them, as below.
  • The run is listed with your other runs, with origin agent and origin_ref <agent>/<conversation id>.
  • The model reads Run <id> completed. Output: <JSON>, or the run's error. A run still going after waitSeconds goes on, but its output doesn't reach the conversation.
  • A readable secret's value in a result is replaced by [redacted] before the model or the transcript sees it. A result is cut at 16,000 characters.
  • An API key scoped to some workflows can't give an agent tools outside them. That deploy returns 403.
  • A key scoped to some workflows gets only those workflows' tools, since it may start only their runs. So do the end users it names with person or a chat token, the schedules it adds or changes, and a workflow deployed with it when it asks an agent. The conversations they start have no tools for other workflows, and in an older one that still has them, each call of such a tool fails with this key is limited to other workflows, and no run starts and no approval is asked for. An end user's conversation goes by the key that sent its latest message (a repeat with the same Idempotency-Key doesn't count), so one started before 4 November 2026 gets the key's limit from the key's next message on. A scope that names only agents limits no tool, and the key's other limits don't reach its end users: a key without run.start still gives them every tool its scope allows.
  • A tool that took its workflow's payload schema keeps it until the agent is deployed again. shiftlabs deploy releases a project's workflows and agents together, so they stay in step.

Code tools

A code tool is a function in the agent's own TypeScript, defined with its description and parameters by tool({...}, fn). It has no network, no environment and no secrets. It keeps a SQLite database for each person who talks to the agent.

agents/notes.tools.ts
import { tool, tools } from "shiftlabs";

export default tools({
  "save-note": tool(
    {
      description: "Save a note.",
      parameters: {
        type: "object",
        properties: { text: { type: "string" } },
        required: ["text"],
      },
    },
    ({ text }: { text: string }, { sql }) => {
      sql.exec("CREATE TABLE IF NOT EXISTS notes (at INTEGER, text TEXT)");
      sql.exec("INSERT INTO notes (at, text) VALUES (?, ?)", Date.now(), text);
      return { saved: true };
    },
  ),
  "list-notes": tool(
    { description: "List the latest notes." },
    (_args, { sql }) => {
      sql.exec("CREATE TABLE IF NOT EXISTS notes (at INTEGER, text TEXT)");
      return sql
        .exec("SELECT at, text FROM notes ORDER BY at DESC LIMIT 20")
        .toArray();
    },
  ),
});
shiftlabs.config.ts
import { agent, project } from "shiftlabs";

// shiftlabs deploy uploads the code, then releases the agent with it.
export default project({
  agents: {
    notes: agent({
      title: "Notes",
      instructions: "Save notes people give you; read them back when asked.",
      model: "@cf/zai-org/glm-4.7-flash",
      code: "./agents/notes.tools.ts",
    }),
  },
});
shellcurl
# Upload the code (developer key).
# Answers {"codeHash", "tools", "sizeBytes", "warnings"}.
curl -X PUT https://api.shiftlabs.org/v1/agents/notes/code \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  --data-binary @agents/notes.tools.ts

# Name the hash in the agent's next version. Every tool in the code joins it.
curl -X PUT https://api.shiftlabs.org/v1/agents/notes \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "title": "Notes",
    "instructions": "Save notes people give you; read them back when asked.",
    "model": "@cf/zai-org/glm-4.7-flash",
    "code": "<codeHash>"
  }'
  • description

    When to use the tool, 1 to 1,024 characters. The model chooses tools by it. Required.

  • parameters

    A JSON Schema with "type": "object", up to 8 KB. Default: any object. The upload converts a Standard JSON Schema to JSON Schema.

  • waitSeconds

    How long a call waits for the function, 5 to 300. Default 60.

  • The code is bundled and scanned like a workflow, 512 KiB at most, and a new upload counts toward new versions per 24 hours. Its default export must be tools({...}), with a tool(...) under each name. Names are lowercase letters, digits and hyphens.
  • The upload reads each tool's description and parameters. A tool with no description or no function, a bad name or parameters that aren't an object schema returns 400 {"error": "invalid tool", "detail"}, and detail names the tool. Descriptions and parameters together are at most 256 KiB.
  • The upload loads the code once, with no network, to read them, and so do PUT /v1/agents/:agent and a release that name code. Loading may take 60 seconds: past that, the request returns 503 {"error": "temporarily unavailable"} with a detail and Retry-After: 30. Nothing changed, so the agent's code and current version stay as they were. Send it again.
  • PUT /v1/agents/:agent and a release that name code count toward the 20 deploys a minute, as the upload does. See Rate limits.
  • Nothing changes until a version names the hash in code. Then every tool in the code joins the agent, after its workflow tools. A name can't be both a workflow tool and a code tool. An upload that no version names is dropped after a day.
  • A function gets the model's arguments and {sql, conversation, log}. sql.exec(query, ...bindings) returns a cursor with toArray(), one() and rowsWritten. The model reads the return value as JSON.
  • Each person's database is shared by all their conversations with the agent, and a workflow that asks the agent has one for all its runs. Each end user of your app has their own. It is kept until the workspace is deleted, or until the agent is deleted and erased from the trash. Conversations reaching the end of their period don't erase it.
  • On paid plans, each person's code runs apart from everyone else's. On Free, everyone in a workspace runs an agent version's code together: a value one person's call keeps outside a function can show up in another person's call, and a call that runs out of CPU time restarts the code for all of them. A value kept outside a function lasts only while the code is loaded. Keep data in sql, which is each person's own.
  • A code tool never waits for approval. Calls to other services belong in workflow tools.
  • A person's calls run one at a time. A call still waiting for an earlier one when its waitSeconds pass fails without running.
  • A call gets 2,000 ms of CPU and the tool's waitSeconds. Past either, that call fails and the code restarts. A call cut off by a platform restart is not run again.
  • After 3 calls in the workspace are stopped for CPU time in one UTC day, every code tool call fails without running until 00:00 UTC, with the workspace's agent code was stopped for CPU time 3 times today, so its code tools are off until 00:00 UTC (limit codeStopsPerDay=3). The model reads it and goes on; workflow tools still run. See Limits.

Tool results are data

A tool result can hold text anyone wrote: an email, a ticket, a web page or a record a workflow read. Such text can try to give the model orders. This is called prompt injection.

  • The model gets each tool result between <untrusted_tool_result> tags, with a rule after the agent's instructions: what is inside is data, never instructions. Transcripts, streams and the dashboard show the result without the tags.
  • This makes injection less likely, but no model is proof against it. Give a tool that changes anything, such as a refund, an email or a deploy, "approval": "always", so a person sees every call before it runs. See Approvals.
  • Give the agent only the tools it needs, and put a budget on it.

Conversations

Anyone the agent's access includes can talk to it. A message starts a conversation, and the agent answers in the background. Read the conversation, or stream it to get the answer as it is written.

shellcurl
# Start a conversation (any role).
# Answers 202 {"conversation", "status": "working"}.
curl -X POST https://api.shiftlabs.org/v1/agents/billing/conversations \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"text": "What is the status of invoice in_1QxYzExample?"}'

# Read it until its status is no longer working.
curl https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation> \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"

# Send the next message. Answers 202.
curl -X POST \
  https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation>/messages \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"text": "When was it paid?"}'
  • working

    The agent is calling models and tools.

  • answered

    The agent replied. Send the next message.

  • waiting for approval

    A tool call waits for an approver. See Approvals.

  • stopped at maxTurns

    The model kept asking for tools past maxTurns. Send another message to go on.

  • budget reached

    The conversation spent its budget.conversationUsd. The next message returns 409 {"error": "budget reached"}. Start a new conversation.

  • monthly budget reached

    The agent spent its budget.monthlyUsd for this UTC month. See Budgets.

  • daily budget reached

    The agent answered, and the conversation's end user has now spent the agent's budget.endUserDailyUsd for this UTC day. Their next message, in this conversation or another, returns 429 until the day ends. See Budgets.

  • allowance reached

    The workspace's model allowance ran out during the turn.

  • failed

    A model request failed or sent nothing for 120 seconds, or the turn stopped without an answer. The transcript's error item says why. Send the next message to try again.

  • A message is 1 to 4,000 characters. It can't start with Approval update:, which marks approval answers.
  • A conversation keeps the agent version it started on. Only the person or API key that started it can add to it.
  • A message can carry an Idempotency-Key header, 1 to 255 visible ASCII characters such as a UUID. A repeat with the same key within 24 hours sends the agent nothing and returns the first 202 {"conversation", "status"}, with Idempotent-Replayed: true. The same key with another agent, conversation, person or text returns 409. shiftlabs/client and Python's shiftlabs.client send a key with each message, and send it again after a network error, or a 503 with Retry-After of 5 seconds or less. See API.
  • A workflow's step.ask starts a conversation the workflow owns. Its person is workflow:<name>, its personLabel is workflow <name>, and its run is the run that asked. Nobody can add to it.
  • A model request that sends nothing for 120 seconds, before or during its answer, ends the turn as failed, with an error item saying the model did not respond for 120 s. It isn't retried, and its unfinished answer costs nothing. Text that keeps arriving is never cut off.
  • When shiftlabs briefly fails while it takes in a message, it sends the message to the agent again, at most twice, and the agent gets it once. If it still fails, the request returns 503 with Retry-After: 1: send it again, with the same Idempotency-Key if it had one. A model request that fails because shiftlabs was briefly unavailable is retried twice, 0.5 and 1 second apart. If the last one fails too, the turn ends as failed with the error item The agent could not answer: the platform was briefly unavailable. Send the message again., and the failed requests cost nothing.
  • A turn waits for each tool call at most the tool's waitSeconds. Past it, a workflow tool's run goes on without the conversation, and a code tool's call fails. A helper tool's call fails after 30 seconds, and the model reads <tool> did not finish within 30 s.
  • A turn that stops without an answer ends as failed within about 2 minutes, with the error item The agent stopped without an answer. Send the message again. A message sent while it ends isn't processed and gets the error item Your message wasn't processed. Send it again.
  • One model turn calls at most 10 tools on Free and 50 on Pro. The answer stops at the first call past that, which fails without running, with Tool call limit reached (toolCallsPerTurn 10): this call did not run. The model reads it and goes on. The stopped answer's tokens are estimated from the length of its request and what it wrote, and count toward budgets and the model allowance.
  • GET …/conversations lists your own, newest first, 50 a page (up to 100 with limit) and the next from Next-Before, and with ?person= an end user's. Developers and admins can list everyone's with ?all=1 and read any conversation. Lists leave out the conversations workflows started: ?workflows=1 lists those instead, and ?run=<id> one run's. Reading other people's conversations is written to the audit log. A viewer gets 403 for ?all=1, ?workflows=1 or ?run= and 404 for another person's conversation.
  • An API key limited to some workflows gets 404 for a conversation a workflow it can't reach started. It can't read other people's conversations at all, a schedule's included, because their transcripts and the agent's answers can hold what other workflows returned: ?all=1 returns 403 {"error": "forbidden", "reason": "this key is limited to other agents or workflows"}, and another person's conversation and its stream return 404. It still lists and reads its own, its end users' with ?person=, and with ?workflows=1 or ?run= those its workflows started. Another person's conversation with the helper needs a key without a scope that holds every developer capability, because its tool output was made with that person's access. Lists leave out what the key can't read, so a page can hold fewer than limit with Next-Before set.
  • A conversation reads {id, agent, person, personLabel, run, version, status, startedAt, lastAt, costUsd, busy, turns, maxTurns, budgetUsd, items, approvals, lastEventId}. costUsd is its model use (USD). run is null unless a workflow owns it. budgetUsd is its version's budget.conversationUsd. items is the transcript: user, assistant, model (the model that gave each response, whether it was a fallback, retired when the agent's model had retired, byok when it ran on your own provider key, "finish": "length" when the answer stopped at the model's output limit, its tokens and model use (USD) as costUsd), tool_call, tool_result, approval_update and error. lastEventId is where its stream stands after items.
  • A conversation also reads diagnostics: its latest 20 diagnostics and its latest 5 tools_failed ones, oldest first, each {at, reason, model, toolCalls, toolErrors, toolNames, finish, durationMs, chars, excerpt}. reason is tool_call_limit, model_silent, model_failed, tools_refused, tools_failed or stuck. A failed model request the platform retries has none. model is the model that served the request. toolNames names the first 5 calls, or for a tool round the first 5 that were refused or failed, each cut at 64 characters. finish is how the model ended its answer, null if it never did. durationMs is how long the request took, or for a tool round its longest call. excerpt is the first 1,000 characters of what the model wrote, without its reasoning, or of the calls that failed, with your readable secrets' values replaced. When your secrets couldn't be read, excerpt is "" and toolNames is empty. A chat token doesn't read it.
  • A conversation is erased 7 days after its last message on Free, and 30 days on Pro. See How long conversations are kept. Of each model request, the AI gateway may keep the model, tokens, cost, status, duration and the workspace, agent and conversation ids for up to 30 days, never the prompt or the answer. See Privacy.

End users

An app built on an agent calls it with one API key for all its users. Give that key agent.chat_as, and it names the user each request is for with person. Each person gets their own conversations, their own code tool database and their own message limit.

shellcurl
# Create the app's key (admin key). agent.chat_as is in no role, so list it.
curl -X POST https://api.shiftlabs.org/v1/api-keys \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "name": "billing-app",
    "role": "developer",
    "capabilities": ["agent.chat", "agent.chat_as"],
    "scope": {"agents": ["billing"]}
  }'

# Start a conversation for user_123.
# Answers 202 {"conversation", "status": "working"}.
curl -X POST https://api.shiftlabs.org/v1/agents/billing/conversations \
  -H "authorization: Bearer $APP_KEY" -H "content-type: application/json" \
  -d '{"text": "Where is my refund?", "person": "user_123"}'

# Read it, list user_123's conversations, and send the next message as user_123.
curl \
  "https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation>?person=user_123" \
  -H "authorization: Bearer $APP_KEY"
curl \
  "https://api.shiftlabs.org/v1/agents/billing/conversations?person=user_123" \
  -H "authorization: Bearer $APP_KEY"
curl -X POST \
  https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation>/messages \
  -H "authorization: Bearer $APP_KEY" -H "content-type: application/json" \
  -d '{"text": "Thanks!", "person": "user_123"}'
  • agent.chat_as is in no role. An admin gives it to a developer or admin key by listing it in capabilities, or on the API keys screen under Limit this key → Only when ticked. Members signed in to the dashboard never hold it.
  • person is 1 to 128 letters, digits and _ - . @ : | + =, such as your app's user id. Send it in the body of a POST and as ?person= on a GET. A key without agent.chat_as gets 403 with "capability": "agent.chat_as", and a bad name gets 400.
  • The conversation's person is user:<person>, and its personLabel is the name you sent. Every key in the workspace that names the same person reaches the same conversations, so a new key carries on where an old one stopped.
  • The dashboard and approval notices show an end user as <person> (end user), so ceo@acme.com from your app isn't taken for the member ceo@acme.com.
  • Without person, the key is the person, as before. As user_123, a key can't read or add to its own conversations, a member's, a workflow's or another person's: they return 404.
  • Each person has their own limit of 10 messages a minute, and every person's messages count toward the workspace's limits. The agent's access is checked against the key.
  • A key scoped to some workflows gives the people it names only those workflows' tools: the agent starts no other workflow for them, as the key itself can't. A conversation of theirs from before 4 November 2026 has every tool until the key's next message in it. Its other limits don't reach them.
  • Each person may spend the agent's budget.endUserDailyUsd on model use each UTC day, $0.10 unless the agent says otherwise, all their conversations with it together. Past it, their messages return 429 {"error": "daily budget reached", "detail", "endUserDailyUsd", "resetsAt"} until the day ends. See Budgets.
  • The helper talks only with members and keys, so person on it returns 400.
  • ?person= can't be combined with ?all=1, ?workflows=1 or ?run=: that's 403 without conversation.read_others and 400 with it. Developers and admins see every person's conversations with ?all=1.

Browsers

An API key never goes in a browser. Your server mints a chat token for one person and one agent, and the browser chats with it, from any site. A token lasts at most an hour. With shiftlabs/client, the server mints it with chatTokens.create and the page chats with new Shiftlabs({ chatToken }).

shellcurl
# With the app's key, which holds agent.chat_as.
# Answers 201 {"token", "agent", "person", "expiresAt"}.
curl -X POST https://api.shiftlabs.org/v1/chat-tokens \
  -H "authorization: Bearer $APP_KEY" -H "content-type: application/json" \
  -d '{"agent": "billing", "person": "user_123", "ttl": "15 minutes"}'
chat.ts
const conversations =
  "https://api.shiftlabs.org/v1/agents/billing/conversations";
const headers = {
  authorization: `Bearer ${token}`,
  "content-type": "application/json",
};

// Start a conversation as user_123,
// then read it until its status is no longer working.
const started = await fetch(conversations, {
  method: "POST",
  headers,
  body: JSON.stringify({ text: "Where is my refund?" }),
});
const { conversation } = await started.json();
const reply = await (
  await fetch(`${conversations}/${conversation}`, { headers })
).json();
  • POST /v1/chat-tokens {"agent", "person", "ttl"?} needs a key with agent.chat_as and agent.chat that reaches the agent. ttl is milliseconds or a duration such as "15 minutes", from 1 minute to 1 hour, and an hour by default. The helper has no chat tokens.
  • Send the token as Authorization: Bearer slc_…. It starts, lists, reads, streams and adds to its person's conversations with its agent, and nothing else. Another agent returns 403 with "reason": "this chat token is for another agent", any other route 403, and another person's conversation 404. It never lists everyone's conversations, whatever its key can do.
  • A token reads what its person may see: {id, agent, person, personLabel, status, startedAt, lastAt, busy, items, approvals, lastEventId}. items holds only user and assistant messages and error, what the person is told when the agent couldn't answer, without the model provider's own message. approvals holds only the requests still waiting. Its stream is the same: user, text, approval and status events, and a failed status's error without the provider's message. Tool calls and results, models, model use and budget stay with your key: past the agent's monthly budget a token gets 429 {"error": "monthly budget reached"} and Retry-After, without the amount. Past its person's daily budget it gets 429 {"error": "daily budget reached", "detail"} and Retry-After: detail is a sentence your page can show the person, without any amount. Lists leave out costUsd, version and run.
  • After expiresAt a token returns 401 {"error": "chat token expired"}: mint a new one. A token also stops working once its key is revoked or expires.
  • A page on any site can call these routes with a token: their answers carry Access-Control-Allow-Origin: *, a 429 included. Answers to API keys don't, so a browser can't use a key.
  • One person's tokens make at most 120 requests a minute, and all of a workspace's tokens together 1,200. That's apart from the 1,200 /v1 calls of your keys and the dashboard, so browsers can't slow down your server's calls. Messages also count toward the person's and the workspace's limits.

Stream a conversation

GET …/conversations/:conversation/stream sends the conversation as it happens, as Server-Sent Events: the agent's text as it is written, its tool calls and their results, approvals and status changes. Anyone who can read the conversation can stream it. Each event is an id and one data: line of JSON with a type.

shellcurl
# Send the next message. Answers 202.
curl -X POST \
  https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation>/messages \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"text": "When was it paid?"}'

# Stream the answer.
# -N prints each event as it arrives; the stream ends when the agent is done.
curl -N \
  https://api.shiftlabs.org/v1/agents/billing/conversations/<conversation>/stream \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"
  • text

    {"delta"}: the next piece of the agent's answer.

  • user, approval_update

    {"text", "at"}: a message in, or the platform's approval update.

  • tool_call, tool_result

    As in the transcript: {"id", "name", "arguments", "at"}, then {"id", "name", "isError", "text", "at"}.

  • approval

    {"id", "tool", "status", "requestedAt", "expiresAt", "decidedAt"}: a tool call waits for an approver, or was decided.

  • status

    {"status", "error"?}: the conversation's status. On failed, error says why.

  • A stream starts with your latest message and the answer so far. Then come the approvals whose answer hasn't reached the conversation yet, and its status.
  • It ends after a status other than working: close your client then, or it reconnects for nothing. Reconnecting with that last id while the conversation is at rest gets 204. Open it again after your next message, or once the status is working again, for example after an approval.
  • Reconnect with the last id you got in a Last-Event-ID header, or as ?lastEventId=, and the stream goes on from there without repeating text. A conversation's lastEventId streams what came after its items.
  • A browser's EventSource can't send the authorization header. Read the stream with fetch, or an SSE client that sends headers.
  • A stream also ends after 5 minutes: reconnect to go on. While nothing else happens, a comment line comes every 20 seconds.
  • A conversation takes 10 streams at once. The next one gets 429.
  • Streaming someone else's conversation needs conversation.read_others, and is written to the audit log like a read.
  • A chat token streams only what its person may see: no tool_call, tool_result or approval_update events.

How long conversations are kept

A conversation is erased 7 days after its last message on Free, and 30 days after it on Pro. The agent's answer counts as a message, so a conversation in use isn't cut off. On Enterprise the contract sets the period, up to 365 days: conversationRetentionDays in Limits.

  • Erasing a conversation erases its transcript, trace and diagnostics, and its approval requests. Reading, streaming or messaging it then returns 404, as for a conversation that never existed, and lists leave it out.
  • A conversation still working or waiting for approval is kept until it ends, then for the period after its last message. One whose last message is more than 4 days and 2 hours older than that is erased all the same: that is longer than any approval request waits (72 hours), with the time its answer takes to arrive and a day for the turn, so its status can only be one that was never updated.
  • A conversation goes within the hour after its period ends.
  • Its model use stays counted: toward the model allowance, the agent's monthly model use and budgets, end users' daily budgets and billing.
  • After a move from Pro to Free, conversations already past 7 days are erased with the workspace's next agent message, and at the latest when they reach 30 days. After a move to Pro, every conversation still kept has 30 days.
  • A workflow's step.ask conversations and scheduled messages are kept the same way. Turning agents off doesn't keep conversations longer.
  • What the agent's code stores in each person's database isn't a conversation's: it stays until the agent or the workspace is deleted. Deleting the workspace erases every conversation sooner, and the trash erases a deleted agent's when it erases the agent. See Delete an agent.

Scheduled messages

A schedule can message an agent on a cron. Each tick starts a new conversation with message, and the agent answers in the background as it does for a person.

shiftlabs.config.ts
import { project, schedule } from "shiftlabs";

export default project({
  schedules: {
    "monday-summary": schedule({
      agent: "billing",
      message: "Summarize last week's refunds.",
      cron: "0 9 * * 1",
      timezone: "America/Detroit",
    }),
  },
});
  • The conversation belongs to the schedule: its person is schedule:<name> and its personLabel is schedule <name>. Developers and admins see it with ?all=1, as they see other people's conversations. No one can add messages to it.
  • No one sent the message, so the agent acts for no person: platform tools, which read the workspace as the person talking, refuse, and the built-in helper can't be scheduled. Workflow tools and code tools work as usual, and a tool that needs approval waits for an approver.
  • A schedule a key scoped to some workflows adds or changes gives the agent only those workflows' tools, as that key gets. Once a member or an unscoped key changes it, it gives every tool again; a release that leaves it as it is changes nothing. Trigger now with a key scoped to some workflows returns 403 {"error": "forbidden", "reason": "this key is limited to other workflows"} for a schedule that may start other workflows, such as one a member made.
  • Each message counts like any agent message: toward runs per day, the model allowance and the agent's budgets. A message a limit refuses starts nothing, and the Schedules screen shows why.
  • The agent must exist once the release is in, and adding or changing an agent schedule needs agents turned on and the agent.deploy capability. While agents are off, each tick starts nothing and the Schedules screen shows agents are off in this workspace. The agent's current version answers, on models your plan includes.
  • While the agent is in the trash, each tick starts nothing. The schedule records lastSkipped: "the agent is in the trash" in GET /v1/schedules, and the Schedules screen shows that the last tick was skipped. A restore brings the schedule back with the agent, and erasing the agent erases the schedule.
  • An agent's schedule takes jitter and catchup, and can be paused, resumed and triggered now; it takes no overlap or pauseOnFailure and can't be backfilled. See Schedules and Pause, trigger or backfill a schedule. Each control also needs agent.deploy.
  • message is 1 to 4,000 characters, and can't start with Approval update:.

Budgets

budget caps what the agent spends on model use, in US dollars.

  • conversationUsd

    What one conversation may spend, above 0 and at most 5. Default 0.5.

  • monthlyUsd

    What all the agent's conversations may spend in a UTC month, above 0 and at most 1,000. Optional. Without it, the workspace's model allowance is the only monthly cap.

  • endUserDailyUsd

    What each end user may spend with the agent in a UTC day, all their conversations together, above 0 and at most 100, or null for no cap. Default 0.1, about 200 model responses of 5,000 tokens in and 500 out on the default model, so one visitor of an app that mints chat tokens for anyone can't use up your model credit.

  • A turn that spends conversationUsd stops as budget reached. The conversation's next message returns 409 {"error": "budget reached"}.
  • A turn that spends monthlyUsd stops as monthly budget reached. Until the month ends, every message to the agent returns 429 {"error": "monthly budget reached", "monthlyUsd"} with Retry-After.
  • The current version's monthlyUsd holds for every conversation, whichever version it started on.
  • GET /v1/agents shows each agent's model use (USD) this UTC month as stats.costMonthUsd.
  • An end user is a person your app's key names, or a chat token's. Members, and API keys chatting as themselves, have no daily budget.
  • An end user's turn that reaches endUserDailyUsd goes on to its answer, and the conversation reads daily budget reached. Until the UTC day ends, their next message to the agent, in any conversation, returns 429 {"error": "daily budget reached", "detail", "endUserDailyUsd", "resetsAt"} with Retry-After. resetsAt is the next 00:00 UTC, in milliseconds since the epoch, and detail a sentence for the person. A chat token gets error and detail only.
  • Turns already running when an end user reaches it finish, so they can spend past it by what those turns spend, at most conversationUsd each.
  • The current version's endUserDailyUsd holds for all of an end user's conversations, whichever version each started on. A version deployed without a budget stores the default it was deployed with: 0.1 from 8 November 2026, 0.5 before, until it is deployed again. A version deployed before endUserDailyUsd existed has 0.1.
  • GET /v1/agents shows how many end users reached it this UTC day as stats.endUsersCapped, and when the latest did as stats.endUserCappedAt. The agent's page on the dashboard says so too.
  • Each model response's model use counts to the nearest $0.000001, and budgets, the model allowance and costUsd (model use, USD) add up those amounts exactly.
  • A model response counts once toward monthlyUsd, endUserDailyUsd, costMonthUsd and the model allowance. When shiftlabs briefly fails while counting it, it tries twice more. If those fail too, the response counts only toward conversationUsd.

Access

access says who may message the agent. Without it, every member can, from viewer up.

  • role

    The lowest role that may message the agent: viewer, developer or admin. Without it, only members may.

  • members

    Up to 100 members, by the email they sign in with, who may message the agent whatever their role.

  • Each message is checked against the current version's access, in new conversations and old ones. A message from outside it returns 403 {"error": "forbidden", "reason"}. People keep reading the conversations they started.
  • API keys count by their role.
  • A viewer can message an agent its access includes, but the agent's workflow tools don't start runs for them, and a key scoped to some workflows gets only those workflows' tools. See Workflow tools.
  • GET /v1/agents shows canChat on each agent: whether you may message it. The dashboard shows the chat only to them.

Versions

Each deploy of an agent adds a version, numbered from 1, and makes it current. New conversations start on the current version. The helper isn't deployed: its version is a number that changes whenever its definition does, and the dashboard shows it as built in.

  • GET /v1/agents/:agent/versions lists the newest 50, each with its definition, deployedBy, and deployedByName for an API key.
  • A release makes agent definitions current together with workflow versions. An agent whose definition hasn't changed keeps its version. Rolling back a release makes its agent versions current again.
  • shiftlabs deploy and a template's Deploy each make one release.

Delete an agent

Delete an agent with Delete agent on its page on the dashboard's Agents screen, or with DELETE /v1/agents/:agent. Developers and admins can. The agent moves to the workspace's trash for 7 days, where an admin can restore it.

shellcurl
# Developer key. Answers {"deleted", "stoppedConversations", "withdrawnApprovals", "purgeAt"}.
curl -X DELETE https://api.shiftlabs.org/v1/agents/billing \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"
  • Gone at once

    The agent leaves GET /v1/agents and the Agents screen. Its versions, messages to it and chat tokens for it return 404 {"error": "agent not found"}, as for an agent that doesn't exist, and a workflow's step.ask fails with agent <name> not found. Its conversations list as [], and reading or streaming one returns 404.

  • Turns stop

    A turn in progress, or waiting for approval, ends as failed with the error item The agent was deleted. A step.ask waiting on it fails.

  • Approvals withdrawn

    Its pending approval requests become withdrawn, with the note the agent was deleted and decidedBy the one who deleted it. Nobody is told: no alert email or webhook, and nothing in the conversation. A request already posted to Slack is edited to say it was withdrawn. A request answered but not yet delivered to its conversation never is.

  • Schedules

    Its schedules skip every tick, and the Schedules screen shows the agent is in the trash as why.

  • Model usage

    What it spent stays counted toward the workspace's model allowance for the month. An agent made again under the same name counts that month's model use toward its own monthly budget.

  • Restore

    An admin restores it on the dashboard's Trash screen or with POST /v1/trash/restore and {"kind": "agent", "name"}. Its versions, the current one included, its conversations still within their period, its code with each person's code tool database, and its schedules come back. Withdrawn requests stay withdrawn, and stopped conversations stay failed: a new message goes on.

  • Delete for good

    An admin erases it on the Trash screen or with POST /v1/trash/purge, or it is erased 7 days after the delete. That erases its definition and versions, its code, each person's code tool database, its schedules, its approval requests and its conversations, with their transcripts, traces and diagnostics. The name is free at once. Its model usage stays counted.

  • Deleting needs the agent.deploy capability. A key scoped to other agents can't delete it.
  • The built-in helper can't be deleted: DELETE /v1/agents/shiftlabs returns 400.
  • While the agent is in the trash, its name stays taken. PUT /v1/agents/:agent, PUT /v1/agents/:agent/code and a release that names it return 409 with the item in trash, and shiftlabs deploy exits 7. Restore it, or delete it for good to use the name now. See Trash.
  • The audit log records the delete as agent_delete, with how many conversations stopped and approvals were withdrawn, and a restore or erasure as agent_restore or agent_purge.

Turn agents on or off

Agents are on in a new workspace. An admin turns them off, or on again, in Settings → Agents or with the API. The helper is on wherever agents are.

shellcurl
# Admin key. Answers {"on", "chosen", "override"}.
curl -X PUT https://api.shiftlabs.org/v1/workspace/agents \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"enabled": false}'
  • While agents are off, the agent routes return 404, /v1/approvals lists only workflow runs' requests, a release that names agents returns 400, a workflow's step.ask fails with an error that says so, and the dashboard hides Helper and Agents.
  • Turning agents off keeps agents, conversations and their approvals. Conversations are still erased at the end of their period.
  • GET /v1/me shows features.agents and agentsSwitch {on, chosen, override}. When shiftlabs has set agents on or off for the workspace (override), PUT returns 409. Contact support to change it.
  • Each change is written to the audit log as feature_set.

Limits

Agents count toward the workspace's plan. Model use, the helper's included, counts toward the model allowance.

Agent limits by plan
LimitFreePro
Agents the helper isn't counted325
Model tokens per 24 hours input and output50,0005,000,000
Model use per UTC month$2$2, or $1,000 with model use billed past the $2 included
Modelsthe small modelsevery model, and models on your own provider key
Messages per 24 hours counted apart from runs1,000250,000
Messages a minute30 per workspace, 10 per person or workflow30 per workspace, 10 per person or workflow
Tool calls per model turn1050
Conversations kept after the last message7 days30 days
  • Past the model allowance, a message returns 429 {"error": "quota exceeded", "limit", "max"} with "limit": "modelTokensPerDay" or "modelCentsPerMonth", and Retry-After. Past the month's model use it also carries detail, a sentence naming the amount and when it resets, and resetsAt, the next 00:00 UTC on the 1st in milliseconds, except to a chat token. A turn that uses up the allowance stops as allowance reached.
  • Past the messages per 24 hours, a message returns 429 with "limit": "runsPerDay" and Retry-After. Past the messages a minute, it returns 429 {"error": "rate limited"} with Retry-After: 60.
  • On Free, model use past the $2 a month isn't billed, and messages are refused until the month ends. On Pro, model use past the $2 included each billing month is billed at the model's list price × 1.20, up to your spending limit. Until your subscription includes model credit, Pro's model use stops at $2 a month instead. See Model use.
  • Workflow tool calls are runs, with your plan's run limits. Each code tool call gets 2,000 ms of CPU, and one stopped there counts the CPU time it used. After 3 such stops in a UTC day, code tools pause until 00:00 UTC. A model turn's tool calls past its limit fail without running. See Conversations.
  • On Pro, past the spending limit or while a payment is failing, messages return 429. See Plans and billing. While shiftlabs pauses new runs, they return 503. See Rate limits.

API

Define agents, upload their code and talk to them with the /v1 API.

Routes
RouteMethodMinimum role
/v1/workspace/agents {"enabled"}; {on, chosen, override}PUTadmin
/v1/agents each agent's current version, stats and canChat, the helper first with builtIn: trueGETviewer
/v1/agents/:agent the definition; {name, version, warnings}PUTdeveloper
/v1/agents/:agent {deleted, stoppedConversations, withdrawnApprovals, purgeAt}; moves it to the trash for 7 days with its versions, conversations, code and schedules; see Delete an agentDELETEdeveloper
/v1/agents/:agent/code body: TypeScript whose default export is tools({...}); {codeHash, tools, sizeBytes, warnings}PUTdeveloper
/v1/agents/:agent/versions newest first, 50 at mostGETviewer
/v1/agents/:agent/conversations POST {"text", "person"?}: 202 {conversation, status}, takes an Idempotency-Key; GET your own, ?person= an end user's, ?all=1 everyone's, ?workflows=1 the ones workflows started, ?run= one run's; newest first, 50 a page, ?limit= (up to 100) and ?before= from Next-BeforeGET · POSTviewer
/v1/agents/:agent/conversations/:conversation status, transcript, model use (USD) and approvals; ?person= for an end user'sGETviewer
/v1/agents/:agent/conversations/:conversation/messages {"text", "person"?}: 202 {conversation, status}; takes an Idempotency-KeyPOSTviewer
/v1/agents/:agent/conversations/:conversation/stream Server-Sent Events until the conversation comes to rest; Last-Event-ID or ?lastEventId= resumes, and 204 once there is nothing more; ?person= for an end user'sGETviewer
/v1/chat-tokens {"agent", "person", "ttl"?}: a chat token for one agent and end user, 1 minute to 1 hour; 201 {token, agent, person, expiresAt}POSTdeveloper key with agent.chat_as