
Getting Started
1
Pick a Reflex
Choose one of the eleven defaults (listed below) and pass its name as
model, like jailbreak.2
Send your text
Call
predict with the text you want classified — morph.reflex.predict() in the SDK, or POST /v1/reflex/predict raw. Max input is 65,536 tokens.3
Read the prediction
The SDK hands you the answer directly — read it off the result object:
label, confidence, and selected are SDK conveniences derived from classes. The raw /v1/reflex/predict response below has no label field — it returns only classes, each with a selected boolean, and you pick the winner yourself.The default Reflexes
Eleven Reflexes ship ready to use. Pass themodel name in your request.
The response
Every Reflex returns the same raw wire shape over HTTP (the SDK maps it to the camelCase result fields in Read the prediction):
In this raw response the predicted label is whichever class has
"selected": true — there’s no separate label field. The SDK derives label, confidence, and selected for you from classes, so in code you read result.label instead of scanning the array.
To run several Reflexes over one text in a single request, pass models (an array) instead of model — see Classify against multiple models.
- single_label (every default Reflex except
domain): scores are a softmax that sums to 1. At most one class is selected, the highest scorer above its threshold. - multi_label (e.g.
domain): scores are independent, each 0–1 with no sum constraint. Zero or more classes can be selected.
Label every turn in your traces
The way most agents run Reflexes: send your agent’s traces to Morph and name the Reflexes to run. Morph classifies every turn async, off your request path, with no call wired into each turn. Need a label inline in a single request? Callpredict directly (below).
1
Initialize tracing
Call
morphTracing once at startup. Your OpenAI / Anthropic / LangChain calls are traced automatically after that.2
Wrap a turn with the Reflexes to run
begin() a turn, name the Reflexes per role, and finish() it.3
Read the labels
Classification rides the trace export, adding nothing to your latency. Labeled turns appear in the Traces dashboard, and in code via
morph.traces.list() — each turn carries its labels under reflexResults. See list traced turns for the response shape.Tracing is async:
morph.traces.list() reads labels back after they land. For a label inline in your request instead, call morph.reflex.predict() (below) and read result.label on the spot.Use it in your agent loop
Sometimes you need the label inline, to block or route before the turn proceeds. Callpredict and act on result.selected on the spot:
result.label from difficulty, branch on domain, or alert when stuck-in-a-loop flips to looping.
Improve your agent with one prompt
Your agent’s failure modes are already in its history — the frustrated users, the jailbreak attempts, the turns where it looped. Replay that history through Morph tracing and Reflexes label every turn asynchronously — evals ride the async batch tier, $0.0005 per classification — storing the labels on the traces where the dashboard and API read them back. A coding agent can do the rest: find the hits, root-cause them, and open PRs against the causes. Already tracing? The Morph MCP gives your agentlist_reflexes, reflex_summary, and get_reflex_traces as tools, so “how did the canary do in production?” is a one-line prompt — see the quickstart. The prompt below is for the cold start: no tracing yet, failures still buried in your own logs.
From your agent’s repo, paste this into Claude Code, Cursor, or whatever agent you use. It’s self-contained — the SDK calls, the read-back endpoint, and the full Reflex catalog are inline, so your agent never has to leave the terminal:
Prompt: find and fix your agent's failures
GET /v1/reflex/traces, and once the instrumentation PR merges, new turns label themselves. The next run skips the replay and starts from live traces.
Errors
Failed requests return a non-2xx status with an OpenAI-shapederror object:
model or text field (400), an invalid API key (401), a model name that doesn’t exist (404 model_not_found), or a model that hasn’t finished training (409 model_not_ready). Get a key from your dashboard.
Pricing
Reflexes are priced per event, where one classification is one event. Realtime calls hit/v1/reflex/predict and return in around 90ms. Everything else — the sync and async batch APIs and trace evals — bills at the batch rate. Rates step down once you pass 1M events in a billing month.
Train a Custom Reflex
When the defaults don’t match your categories, train your own in one API call. Bring labeled examples, let Morph synthesize a dataset from a description, or hand it unlabeled text to sort. A small Reflex trains in about 30 seconds. Prefer to do it from a UI? Open the Reflex dashboard to train from a description in the agent chat (“Vibecode a Reflex”), then test your model and follow live training stats there.Train a Custom Reflex
Send labeled examples, get a trained classifier. Full API: create, poll, predict, manage jobs.
Batch classification
Classify up to 300 rows inline, or 10,000 offline. Sync and async batch APIs.
Label Morph traces automatically
Tracing with Morph? Pass
evals on a begin() turn and Morph labels every turn for you, off your request path.Use as a Langfuse evaluator
Traces in Langfuse? Plug a Reflex in as a categorical LLM-as-a-judge to label them.