chat
Create a message
Mirrors Anthropic's Messages API so Anthropic SDKs and agents run against Morph models by changing the base URL and API key only — request and response shapes are unchanged. Set stream: true to receive the message as a text/event-stream of Anthropic-style events; the 200 response below documents the non-streaming shape.
post/v1/messages
Request body
Example request
{
"model": "morph-glm52-744b",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Refactor this Express route to use async/await."
}
],
"system": "You are a senior TypeScript engineer. Reply with code only.",
"stream": false,
"temperature": 0
}Response
Message response
Example response
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "router.get(\"/users\", async (req, res) => {\n const users = await db.users.findMany();\n res.json(users);\n});"
}
],
"model": "morph-glm52-744b",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 42,
"output_tokens": 37
}
}