Use connectors as tools that the LLM can call automatically
Resource Identifier: Use the resource slug (e.g., get-customers, list-users) which is auto-generated from the resource name. Slugs are stable, URL-safe identifiers that won’t break if you rename the resource display name.
Copy
import { createConnectorTool, Agent, openai } from '@runflow-ai/sdk';// Basic connector tool (schema loaded from backend)const getClienteTool = createConnectorTool({ connector: 'api-contabil', // Connector instance slug resource: 'get-customers', // Resource slug description: 'Get customer by ID from accounting API', enableMock: true, // Optional: enables mock mode});// Use with Agentconst agent = new Agent({ name: 'Accounting Agent', instructions: 'You help manage customers in the accounting system.', model: openai('gpt-4o'), tools: { getCliente: getClienteTool, listClientes: createConnectorTool({ connector: 'api-contabil', resource: 'list-customers', // Resource slug }), },});// First execution automatically loads schemas from backendconst result = await agent.process({ message: 'Get customer with ID 123', sessionId: 'session-123', companyId: 'company-456',});
Call connectors programmatically, without agent involvement. Works anywhere: standalone scripts, workflow steps, API handlers.
connector() is a function call, not a client factory. You must pass all 3 arguments (connector slug, resource slug, data) in a single call. It returns a Promise with the result.
The native .connector() step uses template interpolation ({{input.field}}) for parameters. For dynamic logic (conditionals, transformations), use connector() inside a .step() instead.
Connectors automatically resolve path parameters from the resource URL:
Copy
// Resource defined in backend with path: /clientes/{id}/pedidos/{pedidoId}const getClientePedidoTool = createConnectorTool({ connector: 'api-contabil', resource: 'get-customer-order', // Resource slug description: 'Get specific order from a customer',});// Agent automatically extracts path params from contextconst result = await agent.process({ message: 'Get order 456 from customer 123', sessionId: 'session-123', companyId: 'company-456',});// Backend automatically resolves: /clientes/123/pedidos/456