Capability · Math agent

Math and data analysis, computed, not guessed.

A chat endpoint that writes and runs Python or R 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 or R 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.

Tools

Python & R, in a sandbox

The agent can call a python tool (numpy, pandas, matplotlib, sympy, scipy — variables persist across calls) and an r tool (base R + ggplot2, a fresh process per call). It loops — write code, run it, read the result — until the answer checks out.
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.
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.
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.
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.
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 region-resident and the PHI gate is enforced per call. Prices include the flat +10% gateway margin and mirror the live /v1/pricing rate card.

RegionProviderModelTierPrice
CHInfomaniakqwen3.5 (397B)General$0.97 / $4.36
EUScalewayqwen3.5 (397B)General$0.71 / $4.28
UKGooglegemini-2-5-flashGeneral$0.33 / $2.75
USTogetherqwen3.5 · glm-5.2General$0.77 / $3.85
Otherreasoning only (no sandbox)No route

Billed as ordinary chat tokens (per 1M in / out, gateway margin included) — 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.

curl
curl https://phi-cloud.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/non_phi
x-phi-tier: non_phi
x-phi-sandbox-figures: 1
# the answer embeds a ```svg figure (Figure 1)

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 across tool calls within a request; each R call is a fresh process, so keep R snippets self-contained.

FAQ

Common questions

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.
Python (numpy, pandas, matplotlib, sympy, scipy) and R (base R + ggplot2). Python variables persist across tool calls within one request; each R call is a fresh process. The agent reaches for them whenever arithmetic, algebra, statistics or data wrangling is involved.
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.
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.
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.

Free to test · Prepaid credits, no subscription · No data retained