camelAI Documentation

Guides

Stateless runs and decisions in camelRun v2

Run one-shot prompts at POST /v2/runs and classify inputs into calibrated choices at POST /v2/decisions without creating an agent.

View as Markdown

Use stateless endpoints when you want a single answer without persisting an agent, conversation history, or repository.

One-shot stateless runs (POST /v2/runs)

POST /v2/runs runs a model loop (up to maxSteps, default 10, maximum 25), optionally calling HTTP webhook tools and validating outputSchema, then settles usage to your tenant and returns a RunRecord with agentId: null.

ts
const run = await client.runs.create<{ sentiment: string; topics: string[] }>({
  model: "openrouter/meta/muse-ember",
  instructions: "Extract sentiment and up to 3 topics from the review.",
  input: "Fast shipping and sturdy build, though setup docs could be clearer.",
  outputSchema: {
    type: "object",
    properties: {
      sentiment: { type: "string", enum: ["positive", "neutral", "negative"] },
      topics: { type: "array", items: { type: "string" } },
    },
    required: ["sentiment", "topics"],
  },
});

console.log(run.output);
console.log(run.usage);

Over REST

bash
curl -s -X POST "https://run.camelai.com/v2/runs" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/meta/muse-ember",
    "instructions": "Summarize in one sentence.",
    "input": "camelRun v2 runs durable agents on Durable Objects with CamelFS Git-backed repos."
  }'

Request fields

FieldTypeRequiredDescription
inputstringYesPrompt text for the run
modelstringNoModel ID (defaults to the runtime default)
instructionsstringNoSystem instructions
outputSchemaobject | nullNoJSON Schema for output (invalid JSON returns 422 output_schema_invalid)
toolsCustomToolSpec[]NoHTTP webhook tools (each tool must provide a url; local WebSocket tools are not used in stateless runs)
maxStepsnumberNoMaximum model/tool steps, clamped to 1..25 (default 10)

Response shape

json
{
  "id": "run_...",
  "agentId": null,
  "status": "completed",
  "text": "...",
  "output": null,
  "batchedInto": null,
  "inputs": [],
  "toolCalls": [],
  "filesChanged": [],
  "usage": {
    "inputTokens": 42,
    "outputTokens": 18,
    "costUsd": 0.0000132,
    "vmMs": 0
  },
  "error": null
}

Decision classifier (POST /v2/decisions)

POST /v2/decisions classifies text into exactly one of your allowed choices and returns calibrated probability scores summing to 1.0, the winning choice, its confidence, and costUsd.

ts
const result = await client.decisions.decide({
  input: "Can you refund invoice #8821? The card was charged twice.",
  choices: ["billing", "technical", "account", "spam"] as const,
  instructions: "Classify the support ticket by department.",
  model: "openrouter/meta/muse-ember",
});

console.log(result);
// {
//   choice: "billing",
//   confidence: 0.96,
//   scores: { billing: 0.96, technical: 0.02, account: 0.015, spam: 0.005 },
//   costUsd: 0.000021
// }

Over REST

bash
curl -s -X POST "https://run.camelai.com/v2/decisions" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Our CI build fails with ECONNREFUSED on port 5432.",
    "choices": ["billing", "technical", "spam"],
    "instructions": "Classify the incoming ticket."
  }'
FieldTypeRequiredDescription
inputstringYesNon-empty text to classify
choicesstring[]YesNon-empty list of allowed labels
instructionsstringNoCustom classification instructions
modelstringNoModel ID (defaults to openrouter/typesafe/jev-1.14, TypeSafe Jev 1.14)

Both POST /v2/runs and POST /v2/decisions require a tenant API key (cr_live_...).