Skip to content

Capability · Math agent

Math and data analysis, computed, not guessed.

A chat endpoint that writes and runs Python, R or SQL in a region-pinned, network-isolated sandbox to compute and verify — then returns charts as inspectable SVG and diagrams as Mermaid, never opaque raster images.

POST /v1/math/chat/completions

What you get

Built for regulated workloads

Point any OpenAI SDK at /v1/math/chat/completions and ask in plain language. It is the chat endpoint with two differences: a system prompt tuned for careful, step-by-step math and data analysis, and a code sandbox switched on by default — so the model writes and runs Python, R or SQL to compute and verify instead of guessing, then hands back the answer with charts as inspectable SVG and diagrams as Mermaid. Set X-Region per request; the sandbox runs in your jurisdiction.

01 · Tools

Python, R & SQL, in a sandbox

The agent can call a python tool (numpy, pandas, matplotlib, sympy, scipy — variables persist across calls), an r tool (base R + ggplot2, a fresh process per call) and a sql tool (DuckDB — tables you CREATE persist across calls, and it can query CSV/Parquet). It loops — write code, run it, read the result — until the answer checks out.

02 · Verify

Compute, don’t hallucinate

Arithmetic, algebra, statistics and data wrangling are executed, not guessed. The model double-checks each step against real output and states the final answer exactly, preferring closed forms over approximations.

03 · Charts

Figures as inspectable SVG

matplotlib and ggplot2 figures are captured as SVG and stitched into the answer as fenced ```svg blocks (“Figure N”) — XML you can inspect, diff and restyle, never a base64 image. The x-phi-sandbox-figures header counts what was captured.

04 · Diagrams

Diagrams as Mermaid

Flowcharts and sequence, ER, Gantt and state diagrams come back as ```mermaid blocks rather than images — text the caller renders or edits. The dashboard chat renders both SVG figures and Mermaid inline.

05 · Residency

Region-pinned & ephemeral

One network-isolated sandbox per request, pinned to your region and torn down when the answer returns. CH/EU/UK execute in the EU boundary, US in the FedRAMP boundary — code never runs out-of-region, and nothing is persisted.

06 · PHI

General traffic only

Code execution is general-traffic only — an X-PHI:true math call returns phi_blocked until the sandbox BAA lands. For PHI, use plain reasoning on the standard chat endpoint in CH and EU.

Availability & pricing

Where it runs, what it costs

Every route is pinned to a region, PHI stays on resident hosts, and the PHI gate is enforced per call. Prices mirror the live /v1/pricing rate card.

RegionProviderModelTierPrice
CHInfomaniakqwen3.5 (397B)General$1.64 / $7.36
EUScalewayqwen3.5 (397B)General$1.15 / $6.90
UKGooglegemini-3-1-flash-liteGeneral$0.42 / $2.50
USTogetherdeepseek-v4-flashGeneral$0.23 / $0.47
USTogetherglm-5.2General$2.33 / $7.33
Other—reasoning only (no sandbox)No route—

Billed as ordinary chat tokens (per 1M in / out) — you pay for the model that answers; the sandbox is included. Code execution is general-traffic only (X-PHI:true → phi_blocked) and runs only where a compliant in-region sandbox exists — Switzerland, the EU, the UK and the US. Pin any code-capable model, or let the region default decide. Full rate card at /pricing.

Try it

A real call, end to end

Ask in plain language; the agent writes and runs the code in your region, then hands back the result with an inspectable figure.

Sandbox & residency

  • Code runs in an ephemeral, network-isolated container pinned to your region — one sandbox per request, torn down when the answer is returned.
  • CH, EU and UK execute in the EU compliance boundary; US executes in the US (FedRAMP) boundary. The sandbox never runs out-of-region.
  • Regions with no compliant sandbox (everywhere outside CH/EU/UK/US) degrade to plain step-by-step reasoning — the call still answers, it just does not run code.
  • General traffic only: X-PHI:true returns phi_blocked until the sandbox BAA lands. No code, input or output is persisted by the proxy.

Good to know

  • · Same OpenAI chat shape as /v1/chat/completions — only the math-tuned default system prompt and on-by-default code execution differ. Disable per request with code_execution:false.
  • · Streaming is disabled on this route (the loop must inspect tool calls), so the response is buffered.
  • · Python keeps variables and SQL keeps its DuckDB tables across tool calls within a request; each R call is a fresh process, so keep R snippets self-contained.
curl
curl https://cloudsitus.com/api/v1/math/chat/completions \
  -H "Authorization: Bearer $PHI_API_KEY" \
  -H "X-Region: EU" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.5",
    "messages": [
      {"role": "user", "content": "Fit a linear model to this data and plot it with ggplot2."}
    ]
  }'
response
x-phi-routed: scaleway-qwen3-5-397b/EU/general
x-phi-tier: non_phi
x-phi-sandbox-figures: 1
# the answer embeds a ```svg figure (Figure 1)
Is the math agent a different model?
No. It is the same region-resident chat models (qwen3.5, glm-5.2, Gemma-4, Claude…) with a math-tuned system prompt and code execution turned on. Pick a model the normal way, or let the region default decide.
What can the sandbox run?
Python (numpy, pandas, matplotlib, sympy, scipy), R (base R + ggplot2) and SQL (DuckDB). Python variables and DuckDB tables persist across tool calls within one request; each R call is a fresh process. DuckDB can query CSV/Parquet the python tool writes to the workspace, so you can wrangle in pandas and join in SQL. The agent reaches for them whenever arithmetic, algebra, statistics, relational queries or data wrangling is involved.
How do charts and diagrams come back?
matplotlib and ggplot2 figures are captured as SVG and stitched into the answer as fenced ```svg blocks (“Figure N”) — XML you can inspect and restyle, not a raster image — while flowcharts and sequence/ER/Gantt diagrams come back as ```mermaid. The x-phi-sandbox-figures header counts what was captured, and the dashboard chat renders both inline.
Can I run code on PHI?
Not yet. Code execution is general-traffic only — an X-PHI:true math request returns phi_blocked — because the sandbox BAA is not in place. PHI reasoning (without code) is available on the standard chat endpoint in CH and EU.
What happens in a region without a sandbox?
The endpoint still answers, degrading to a single plain reasoning call (no tools). Code execution requires a compliant in-region sandbox; today that is Switzerland, the EU, the UK and the US. Elsewhere you get step-by-step reasoning, just no executed code.

Ready when you are

Put math agent in production — without giving up your data.

Spin up a key in minutes. The residency and PHI posture above arrives unchanged.

Prepaid credits from $10 · No subscription · No data retained