Chat & PRD Generation API
General AI Chat
POST /api/chat
| Field | Type | Required | Description |
|---|---|---|---|
messages | array | Yes | Array of {role, content} message objects |
provider | string | No | Force a specific provider (openai, anthropic, gemini) |
projectId | string | No | Associate with a project for context |
curl -X POST https://app.thig.ai/api/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What sections should a good PRD include?"}
],
"provider": "anthropic"
}'
const res = await fetch('https://app.thig.ai/api/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
messages: [
{ role: 'user', content: 'What sections should a good PRD include?' }
],
provider: 'anthropic'
})
});
const data = await res.json();
{
"role": "assistant",
"content": "Based on your requirements, I'd recommend..."
}
Project Chat
POST /api/projects/{projectId}/chat
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
conversationHistory | array | No | Previous messages for context |
curl -X POST https://app.thig.ai/api/projects/proj_123/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "The app should support offline mode and push notifications"}'
const res = await fetch('https://app.thig.ai/api/projects/proj_123/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'The app should support offline mode and push notifications'
})
});
const data = await res.json();
{
"response": "Great, let me ask about your target users...",
"qaPairId": "qa_123"
}
Streaming Conversation
POST /api/projects/{projectId}/conversation/stream
data: {"type": "progress", "phase": "Analyzing your requirements...", "percent": 15}
data: {"type": "content", "content": "Based on what you've described..."}
data: {"type": "done", "fullContent": "Complete response text..."}
curl -X POST https://app.thig.ai/api/projects/proj_123/conversation/stream \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"message": "Users need to collaborate in real-time"}'
// Note: EventSource only supports GET; use fetch for POST SSE streams
const res = await fetch('https://app.thig.ai/api/projects/proj_123/conversation/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ message: 'Users need to collaborate in real-time' })
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n').filter(l => l.startsWith('data: '));
for (const line of lines) {
const data = JSON.parse(line.slice(6));
if (data.type === 'content') process.stdout.write(data.content);
if (data.type === 'done') console.log('\n--- Complete ---');
}
}
Generate PRD (Non-Streaming)
POST /api/generate-prd
| Field | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | Project to generate PRD for |
style | string | No | PRD style (comprehensive, technical, business, lean, agile) |
regenerate | boolean | No | Force regeneration |
curl -X POST https://app.thig.ai/api/generate-prd \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"projectId": "proj_123", "style": "comprehensive"}'
const res = await fetch('https://app.thig.ai/api/generate-prd', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ projectId: 'proj_123', style: 'comprehensive' })
});
const data = await res.json();
Generate PRD (Streaming)
POST /api/generate-prd/stream
data: {"type": "progress", "phase": "Generating Executive Summary...", "percent": 10}
data: {"type": "content", "content": "# Executive Summary\n\n..."}
data: {"type": "done", "fullContent": "Complete PRD content..."}
data: {"type": "error", "message": "Generation failed", "code": "GENERATION_ERROR"}
curl -N -X POST https://app.thig.ai/api/generate-prd/stream \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"projectId": "proj_123", "style": "technical"}'
const res = await fetch('https://app.thig.ai/api/generate-prd/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ projectId: 'proj_123', style: 'technical' })
});
const reader = res.body.getReader();
const decoder = new TextDecoder();
let fullContent = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n').filter(l => l.startsWith('data: '));
for (const line of lines) {
const data = JSON.parse(line.slice(6));
if (data.type === 'progress') console.log(`${data.percent}% — ${data.phase}`);
if (data.type === 'content') fullContent += data.content;
if (data.type === 'done') console.log('PRD generated:', data.fullContent.length, 'chars');
}
}
Chat Export
GET /api/projects/{projectId}/chat-export
| Parameter | Type | Description |
|---|---|---|
format | string | pdf, csv, or json |
curl -G https://app.thig.ai/api/projects/proj_123/chat-export \
-H "Authorization: Bearer YOUR_API_KEY" \
-d "format=json" \
-o chat-history.json
const res = await fetch('https://app.thig.ai/api/projects/proj_123/chat-export?format=json', {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'chat-history.json';
a.click();