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.
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.
Public APIs — call a template directly (no instance)
For connector templates with authRequired = false (public APIs imported via OpenAPI, like JSONPlaceholder, public REST endpoints, etc.), you can skip the instance step entirely and pass the template slug as the first argument. The resolver tries an instance match first and transparently falls back to the template when no instance exists.
import { connector } from '@runflow-ai/sdk';// Template slug (no instance created)const todo = await connector( 'jsonplaceholder', // template slug — no `-prod` instance needed 'get-todo', { id: 1 });
This works for both connector(...) and createConnectorTool({ connector: 'slug', ... }). The shortcut only kicks in when the template has no auth — anything requiring a credential still needs an instance.
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:
// 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