image_fast
Generate images quickly using Flux Schnell for AI agents, balancing speed and cost at $0.002 per image with customizable dimensions.
Instructions
Generate an image quickly using Flux Schnell (faster, cheaper) ($0.002)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| width | No | ||
| height | No |
Implementation Reference
- index.js:18-18 (registration)Registration of the 'image_fast' tool within the TOOLS array.
{ name: 'image_fast', description: 'Generate an image quickly using Flux Schnell (faster, cheaper)', inputSchema: { type: 'object', properties: { prompt: { type: 'string' }, width: { type: 'number', default: 1024 }, height: { type: 'number', default: 1024 } }, required: ['prompt'] }, endpoint: '/image/fast', price: '$0.002' }, - index.js:50-79 (handler)The 'callTool' function serves as the generic handler for all registered tools, including 'image_fast', by making HTTP requests to the IteraTools API.
async function callTool(endpoint, params) { const fetch = (await import('node-fetch')).default; const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method); const url = isGet ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}` : `${BASE_URL}${endpoint}`; const res = await fetch(url, { method: isGet ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: isGet ? undefined : JSON.stringify(params), }); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { data = { raw: text }; } if (!res.ok) { if (res.status === 402) { throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`); } throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`); } return data; }