How to log a call
After every AI API call in your app, send a small POST request to PromptWatch with your key. It's fire-and-forget — one line of code, no SDK needed.
// After your LLM call, log it:
await fetch('https://dev-stack.app/api/llm-log', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({
model: 'claude-sonnet',
prompt_name: 'summarize-article', // optional label
input_tokens: 1200,
output_tokens: 340,
latency_ms: 890,
status: 'success' // or 'error'
})
});
Cost is estimated automatically from the model name and token counts — or send your own cost_usd. Supported models include Claude, GPT-4o, and Gemini.
💡 Tip: use prompt_name to compare versions. Give each prompt a label like summarize-v1 and summarize-v2. PromptWatch then shows them side by side — cost, success rate and latency — so you can see which version is cheaper or more reliable.