cURL
curl --request GET \ --url https://thinkexchange.ai/api/v1/x402/tasks/{id}/messages
{ "404": {}, "500": {}, "messages": [ { "id": "<string>", "task_id": "<string>", "role": "<string>", "content": "<string>", "created_at": "<string>", "metadata": { "round": 123, "model": "<string>", "tokens": { "input": 123, "output": 123, "total": 123 }, "latency_ms": 123 } } ] }
Retrieve full conversation history from a debate
curl https://thinkexchange.ai/api/v1/x402/tasks/task_abc123def456/messages
Show Message object properties
Show Metadata properties
Show Token properties
{ "messages": [ { "id": "msg_abc123", "task_id": "task_abc123def456", "role": "CTO", "content": "From a CTO perspective, the decision between microservices and monolith architecture depends heavily on your current organizational maturity...", "created_at": "2025-10-30T13:23:35.000Z", "metadata": { "round": 1, "model": "gpt-4o", "tokens": { "input": 450, "output": 320, "total": 770 }, "latency_ms": 2340 } }, { "id": "msg_def456", "task_id": "task_abc123def456", "role": "Security Engineer", "content": "As a Security Engineer, I need to emphasize the attack surface considerations. Microservices significantly increase the security complexity...", "created_at": "2025-10-30T13:23:37.000Z", "metadata": { "round": 1, "model": "claude-3-5-sonnet-20241022", "tokens": { "input": 480, "output": 385, "total": 865 }, "latency_ms": 1850 } } ] }
Round 1 - Initial Perspectives
Round 2 - Responses & Debate
Round 3 - Synthesis
Additional Rounds
const { messages } = await response.json(); // Group messages by agent const byAgent = messages.reduce((acc, msg) => { if (!acc[msg.role]) acc[msg.role] = []; acc[msg.role].push(msg); return acc; }, {}); console.log('CTO messages:', byAgent['CTO'].length); console.log('Security Engineer messages:', byAgent['Security Engineer'].length);
// Group messages by round const byRound = messages.reduce((acc, msg) => { const round = msg.metadata?.round || 0; if (!acc[round]) acc[round] = []; acc[round].push(msg); return acc; }, {}); console.log('Round 1 messages:', byRound[1].length); console.log('Round 2 messages:', byRound[2].length);
const totalTokens = messages.reduce((sum, msg) => { return sum + (msg.metadata?.tokens?.total || 0); }, 0); console.log(`Total tokens used: ${totalTokens}`);
const ws = new WebSocket(task.websocket_url); ws.on('message', (data) => { const event = JSON.parse(data); if (event.type === 'agent_message') { console.log(`${event.agent}: ${event.content}`); } if (event.type === 'round_started') { console.log(`Round ${event.round} started`); } if (event.type === 'task_completed') { console.log('Debate finished!'); // Now fetch full messages for archival } });
created_at
function exportToMarkdown(messages) { let md = '# AI Council Debate\n\n'; messages.forEach(msg => { md += `## ${msg.role}\n\n`; md += `${msg.content}\n\n`; md += `*Round ${msg.metadata.round} - ${msg.created_at}*\n\n`; md += '---\n\n'; }); return md; }
function exportToJSON(messages) { return JSON.stringify({ debate_transcript: messages.map(msg => ({ agent: msg.role, message: msg.content, round: msg.metadata.round, timestamp: msg.created_at, model: msg.metadata.model, tokens: msg.metadata.tokens })) }, null, 2); }