LLM
Chat message builder API
Builds a normalized OpenAI-style chat message array from system/context/turns/user inputs and also emits the raw ChatML (<|im_start|>) serialization plus a token estimate — the deterministic way to assemble a chat request. Answers 'how do I build a chat messages array?', 'what does the ChatML for this conversation look like?'.
Price$0.02per request
MethodPOST
Route/v1/llm/chatml-build
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
llmchatmlmessageschatpromptopenaibuildagent
API URL
Integration docshttps://x402.hexl.dev/v1/llm/chatml-buildExample request
{
"system": "Be concise.",
"turns": [
{
"role": "user",
"content": "Hi"
},
{
"role": "assistant",
"content": "Hello"
}
],
"userMessage": "Bye"
}Example response
{
"messages": [
{
"role": "system",
"content": "Be concise."
},
{
"role": "user",
"content": "Hi"
},
{
"role": "assistant",
"content": "Hello"
},
{
"role": "user",
"content": "Bye"
}
],
"chatml": "<|im_start|>system\nBe concise.<|im_end|>\n<|im_start|>user\nHi<|im_end|>\n<|im_start|>assistant\nHello<|im_end|>\n<|im_start|>user\nBye<|im_end|>\n<|im_start|>assistant\n",
"messageCount": 4,
"tokens": 41
}Input schema
{
"type": "object",
"properties": {
"system": {
"type": "string"
},
"context": {
"type": "string"
},
"turns": {
"type": "array",
"items": {
"type": "object"
}
},
"userMessage": {
"type": "string"
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}