API
sympy.ai exposes its verified math agent over an Anthropic-compatible Messages API. If you already use the Anthropic SDK, point its base_url at sympy.ai and use a sympy.ai API key — the request and response shapes match POST /v1/messages.
Authentication
Create an API key on your dashboard (shown once). Send it in the x-api-key header (or Authorization: Bearer mv_…). Usage is billed against your plan's token balance.
curl
curl https://api.sympy.ai/v1/messages \
-H "x-api-key: $SYMPY_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "sympy-solve",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "Integrate x^2 from 0 to 1" }
]
}'Anthropic SDK (Python)
from anthropic import Anthropic
client = Anthropic(
api_key="mv_your_key",
base_url="https://api.sympy.ai",
)
message = client.messages.create(
model="sympy-solve",
max_tokens=1024,
messages=[{"role": "user", "content": "Integrate x^2 from 0 to 1"}],
)
print(message.content[0].text)Anthropic SDK (TypeScript)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "mv_your_key",
baseURL: "https://api.sympy.ai",
});
const message = await client.messages.create({
model: "sympy-solve",
max_tokens: 1024,
messages: [{ role: "user", content: "Integrate x^2 from 0 to 1" }],
});
console.log(message.content[0].text);Response
A standard Anthropic message object. The answer is a single text block; usage reports input/output tokens.
{
"id": "msg_…",
"type": "message",
"role": "assistant",
"model": "sympy-solve",
"content": [{ "type": "text", "text": "The integral equals 1/3." }],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": { "input_tokens": 812, "output_tokens": 143 }
}Streaming
Set "stream": true to receive the Anthropic SSE sequence — message_start → content_block_start → content_block_delta → content_block_stop → message_delta → message_stop. The Anthropic SDK's streaming helpers consume it unchanged.
Models
Any model string is accepted; names signalling a stronger tier (containing pro, opus, reasoner, r1) route to the higher-effort verification pipeline, all others to the fast pipeline.
Errors & limits
Errors use the Anthropic envelope { "type": "error", "error": { "type", "message" } }: authentication_error (401), invalid_request_error (400), rate_limit_error (429, with retry-after), and billing_error (403) when your token balance is exhausted. Per-key rate limits follow your plan.