camelAI Documentation

Guides

Definitions: reusable agent templates in camelRun v2

Save reusable agent configurations at PUT /v2/definitions/:slug and instantiate agents, sub-agents, and channels from them.

View as Markdown

A definition is a named, reusable agent configuration stored per tenant and addressed by its slug (such as support-triage or code-reviewer). Definitions let you share model settings, instructions, built-in suites, webhook tools, MCP servers, queue modes, dreaming settings, and spend limits across many agents, sub-agents, and inbound channels.

Create or update a definition

Use PUT /v2/definitions/:slug (or client.definitions.upsert(slug, config)):

ts
const def = await client.definitions.upsert("support-triage", {
  model: "azure/gpt-6.2-sol",
  instructions: "Triage incoming customer tickets. Ask clarifying questions when needed.",
  builtins: ["files", "web_search", "human"],
  mcpServers: [
    {
      name: "crm",
      url: "https://app.example.com/mcp",
      auth: { type: "runtime" },
      allowTools: ["lookup_customer", "list_tickets"],
    },
  ],
  queue: { mode: "each", windowMs: 0 },
  spendLimitUsd: 5,
  idleTtlSeconds: 604800,
  dreaming: { enabled: true, idleSeconds: 3600 },
});

Over REST

bash
# Upsert a definition
curl -s -X PUT "https://run.camelai.com/v2/definitions/support-triage" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "azure/gpt-6.2-sol",
    "instructions": "Triage incoming customer tickets.",
    "builtins": ["files", "human"],
    "spendLimitUsd": 5
  }'

# List all definitions
curl -s "https://run.camelai.com/v2/definitions" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY"

# Read one definition
curl -s "https://run.camelai.com/v2/definitions/support-triage" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY"

# Delete a definition
curl -s -X DELETE "https://run.camelai.com/v2/definitions/support-triage" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY"

Create agents from a definition

Pass definition: "<slug>" when upserting an agent. Any field you pass explicitly on the agent overrides the definition's value for that field; omitted fields inherit from the definition.

ts
const agent = await client.agents.upsert(`support-${ticketId}`, {
  definition: "support-triage",
  toolIdentity: {
    subject: user.id,
    context: { ticketId },
  },
  // Optionally override a single field:
  spendLimitUsd: 2,
});
  • When an agent uses a definition and calls a signed MCP server (auth: { type: "runtime" }), the signed JWT automatically includes the definition claim with the slug name.
  • Definitions can also be referenced by delegated child agents (delegate / spawn_agent with definition: "<slug>") and by channels (POST /v2/channels with definition: "<slug>").
  • Updating a definition affects agents created or re-upserted afterward. To update an existing agent with a definition's latest config, call PUT /v2/agents/:key with { definition: "<slug>" }.

All /v2/definitions endpoints require a tenant API key (cr_live_...).