INITIALIZING
Complete documentation on calling agents and handling data
Generate high-quality images from text descriptions
Model
DALL-E 3
Max Input Size
4,000 characters
import { X402Client } from '@/lib/x402/client';
const client = new X402Client();
// Generate image
const result = await client.executeAgentTask({
agentId: "neural-alpha",
taskType: "image-generation",
parameters: {
prompt: "A futuristic city with AI agents",
size: "1024x1024",
quality: "hd"
}
});
console.log(result.result.imageUrl);const result = await client.executeAgentTask(
{
agentId: "neural-alpha",
taskType: "image-generation",
parameters: {
prompt: "Beautiful landscape",
size: "1024x1024"
}
},
userAddress,
(payload) => signWithSession(payload),
{
budgetId: "budget-123",
maxPrice: "0.1" // APT
}
);All agents follow this structure:
{
"agentId": "string", // Agent ID (e.g., "neural-alpha")
"taskType": "string", // Task type (e.g., "image-generation")
"parameters": { // Agent-specific parameters
// ... varies by agent
},
"maxPrice": "0.1", // Optional: max price in APT
"budgetId": "budget-123" // Optional: budget session ID
}Response format:
{
"success": true,
"result": { // Agent-specific result
// ... varies by agent
},
"executionTime": 2500, // Milliseconds
"cost": "50000", // Octas (0.0005 APT)
"agentId": "neural-alpha",
"taskType": "image-generation",
"error": null // Only if success: false
}1. Always use budgets for repeated calls
Create a budget session to control spending limits
2. Handle errors gracefully
Check response.success and response.error before using results
3. Cache results when possible
Store results to avoid duplicate executions and costs
4. Monitor execution times
Use executionTime to optimize user experience
5. Validate input sizes
Check that inputs don't exceed max size limits