Messages
Message types accepted by the Guards API.
Guards follows the OpenAI ChatCompletion message format. Each message object must include a role field that determines its type and which
additional fields are required.
user
A message from the end user.
role "user"content string — the user's input text{ "role": "user", "content": "What is the weather today?" }assistant
A message produced by the AI model.
role "assistant"content string | null — the model's response text; null when tool calls are presenttool_calls array (optional) — tool calls requested by the model. Each item has: id: string — unique call identifiertype:"function"function.name: string — function to callfunction.arguments: string — JSON-encoded arguments
{
"role": "assistant",
"content": "Let me check the weather for you.",
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{"location": "New York"}"
}
}
]
}system
A high-level instruction that shapes the model's behaviour throughout the conversation.
role "system"content string{ "role": "system", "content": "You are a helpful assistant." }developer
A trusted instruction injected by the application developer, distinct from end-user input. Introduced in OpenAI's o-series models.
role "developer"content string{ "role": "developer", "content": "Only answer questions about the weather." }tool
The result of a tool call made by the model.
role "tool"content string — the tool's outputtool_call_id string — the id from the corresponding
assistant tool_calls entry{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "Sunny, 72°F"
}function deprecated
Legacy function-call result. Superseded by the tool role; accepted for backward compatibility only.
role "function"content string — the function's outputname string — the name of the function that was called{
"role": "function",
"name": "get_weather",
"content": "Sunny, 72°F"
}