https://api.morphllm.com/v1.
Throughput runs ~90–200 tok/s depending on model and load. All models support
tools, response_format (JSON mode + JSON schema), structured outputs, logprobs, and reasoning. Per-token rates are on the pricing page and live at /api/models/json.
Quick Start
- Python
- TypeScript
- Vercel AI SDK
- cURL
Tools and Structured Output
reasoning: { effort: "medium" } ("low" / "high"). Reasoning tokens bill as output.
Automatic prefix caching is on for all models, with per-request TTL control. Use Model Router to pick automatically per request.
Service Tiers
GLM-5.2 supports the OpenAIservice_tier parameter.
- A standby request is admitted only while the fleet is under roughly a quarter of its serving capacity. When no region qualifies, you get
429witherror.code: "resource_unavailable"and aRetry-Afterheader. Nothing is generated and nothing is billed. Expect most standby throughput off-peak. - On a 429, retry with exponential backoff. If you need the result now, resend with
service_tier: "default". - The response echoes the tier that served it in a
service_tierfield (on the final usage chunk when streaming). - Streaming, tools, and structured output work the same as
default. - Unknown tier values return
400listing the accepted ones.
default: under load, default requests are served in full while standby is shed in ~200ms.
Standby bills at the standard per-token rates today. Available on GLM-5.2 (morph-glm52-744b); sending it to other models is a no-op.
Pitfalls
Latency worse than expected
Latency worse than expected
TPS numbers are generation throughput, not end-to-end. With 30k tokens of context, prefill dominates first-token wait even with caching. For agent loops, keep a smaller working context with Compact rather than filling the full window.
Tool calls not working
Tool calls not working
These models use OpenAI tool-call shape, not Anthropic
tool_use blocks or Gemini functionDeclarations. Use the OpenAI SDK or @ai-sdk/openai pointed at our base URL.JSON mode returns prose
JSON mode returns prose
Pass
response_format: { type: "json_object" } and say “respond in JSON” in your prompt. For strict shape control: response_format: { type: "json_schema", json_schema: { ... } }.See Also
- Prompt Caching — automatic cached-input discounts, per-request TTL
- Standby Requests — best-effort GLM-5.2 capacity for batch and background work
- Model Router — auto-route between these and frontier models per request
- Compact — shrink context before paying for it
- WarpGrep — code search for retrieval when context is the bottleneck