Agent Runtime Contract
The Invariants
Auth and Identification
The Happy Path
// Agent code — complete runtime
const res = await fetch('https://credit-api.floelabs.xyz/v1/proxy/fetch', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.FLOE_API_KEY}`,
'Content-Type': 'application/json',
// Recommended: send a fresh UUID per logical attempt so 502/timeout
// retries replay the original response instead of paying twice.
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
url: 'https://api.some-x402-service.com/premium/analyze',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ prompt: 'hello' }),
}),
});
if (res.ok) {
const costUsdc = res.headers.get('X-Floe-Cost-USDC'); // raw 6-decimal USDC string
return { data: await res.json(), costUsdc };
}Request and Response Headers
Header
Required
Purpose
Header
When
Purpose
Error Handling Matrix
The Retry Golden Rule
What To Do When Blocked
Further Reading
Last updated
