BuildBuilt-in toolsCode execution

Code execution

⚠️
Preview — this feature is being built; the design below is the spec.

With the built-in syntic_code_execution tool, the model can write and run code in an isolated container that Syntic hosts. It can analyse spreadsheets, compute statistics, transform files, draw charts and check its own work, then return the answer along with any files it produced. Your systems are never touched.

When to use it

  • Data analysis on uploaded CSV or Excel files.
  • Accurate maths, statistics and date calculations.
  • Producing charts, cleaned data files or converted documents.
  • Running agent skills that ship scripts.

Endpoint and auth

POST https://app.syntic.ai/v1/chat/completions (and Messages), Authorization: Bearer sk_live_....

Tool definition

FieldTypeRequiredDetails
typestringYes"syntic_code_execution"
containerstring or objectNo"auto" (default) creates a fresh container. {"id": "cntr_..."} reuses one from an earlier request so files and installed packages carry over.
filesarray of stringsNoFile ids (purpose: "code_input") copied into /mnt/input/ before the model starts.
max_runsintegerNoCode runs allowed in this request, 1 to 50. Default 20.

The container

PropertyValue
LanguagesPython 3.12 and Bash; common data libraries pre-installed (pandas, numpy, matplotlib, openpyxl, pypdf)
CPU and memory2 vCPU, 4 GB RAM
Disk5 GB
NetworkOff by default. No inbound access. Package installs come from a Syntic mirror.
Run timeout120 seconds per run
LifetimeIdle containers are removed after 30 minutes; any container after 24 hours
Output folderFiles written to /mnt/output/ become Files you can download

Response

{
  "message": {
    "role": "assistant",
    "content": "Average order value rose 8.4% in Q3. The chart is attached.",
    "server_tool_calls": [
      { "id": "srv_03", "type": "syntic_code_execution", "status": "ok", "exit_code": 0, "duration_ms": 2140 }
    ],
    "files": [
      { "id": "file_01JBXK2", "filename": "aov_by_month.png", "bytes": 48211, "source": "code_execution" }
    ]
  },
  "container": { "id": "cntr_01JBXK0", "expires_at": 1791822600 },
  "usage": {
    "prompt_tokens": 3920, "completion_tokens": 410, "total_tokens": 4330,
    "server_tool_use": { "code_execution_seconds": 6 }
  }
}
FieldDescription
message.server_tool_calls[]One entry per run with status, exit_code, duration_ms. Pass include: ["code_execution.code"] in the request to also get the code and its output.
message.files[]Files written to /mnt/output/. Download with GET /v1/files/{id}/content.
container.idSend it back to keep working in the same container.

Streaming

Each run sends server_tool_call deltas with status: "running" and then the result, the same as web search.

Examples

curl https://app.syntic.ai/v1/chat/completions \
  -H "Authorization: Bearer $SYNTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Amara S1.2",
    "stream": false,
    "tools": [{ "type": "syntic_code_execution", "files": ["file_01JBXJZ"] }],
    "messages": [{ "role": "user", "content": "orders.csv is in /mnt/input. Plot average order value by month and tell me the Q3 trend." }]
  }'

Errors

Unified envelope. Code that crashes is not an API error: the model sees the error output and usually fixes its code.

StatuscodeCause
400server_tool_not_supportedThe model cannot use code execution.
404container_not_foundUnknown, expired or another workspace’s container.
404file_not_foundAn id in files does not exist.
403tool_disabledTurned off for your organisation.
429container_limit_reachedToo many live containers for your tier (default 20).
503overloadedNo container capacity right now. Retry after Retry-After.

Pricing

Container time$0.05 per container-hour, billed per second while code runs, minimum 5 seconds per request
TokensCode the model writes and output it reads are normal tokens
Free allowance50 container-hours per month per organisation

Security

  • Each container belongs to one workspace and is never reused across organisations.
  • No network unless your organisation enables an egress allowlist in the Console.
  • Files in a container are deleted with it; files in /mnt/output/ follow Files retention.

Build notes for the platform team

  • Reuse the App Builder sandbox fleet (ab-sandbox) with a separate pool and strict egress rules.
  • Containers are addressed by cntr_ ids mapped to sandboxes; never expose sandbox hostnames.
  • Billing line code_execution per second.
Was this page helpful?