Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Tips for integrating Chat402
# Store in environment variables export CHAT402_API_KEY="pp_your_key_here" # Never commit to git echo "CHAT402_API_KEY=*" >> .gitignore
let totalCost = 0; async function trackedChat(prompt) { const result = await chat(prompt); totalCost += result.cost; console.log(`Session cost: $${totalCost.toFixed(6)}`); return result; }
async function chatWithRetry(prompt, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { return await chat(prompt); } catch (error) { if (error.response?.status === 402) { throw error; // Don't retry payment errors } if (i === maxRetries - 1) throw error; await new Promise(r => setTimeout(r, 1000 * (i + 1))); } } }