Integrations in workflow code
Call AI, HTTP, MCP, Postgres and bound provider operations through the workflow context.
Integrations
ctx.integrations declares four ports. Everything else is added per workspace.
| Operation | Does |
|---|---|
ctx.integrations.ai.generateText({ prompt, system?, model?, reasoningEffort? }) | Returns { text }. model is one of AI_TEXT_MODELS and reasoningEffort is low, medium or high; omit either for the platform's default. |
ctx.integrations.ai.generateText({ messages, system?, model?, reasoningEffort? }) | Continues a conversation without tools. Returns the text, and the message to append for the next turn. |
ctx.integrations.ai.generateText({ messages, tools, toolChoice?, model?, reasoningEffort? }) | One turn of an agent loop. Returns text, or the tool calls the model chose. Models in AI_TEXT_MODELS_WITHOUT_FORCED_TOOL_CHOICE refuse a toolChoice other than auto. |
ctx.integrations.ai.generateImage({ prompt, model?, aspectRatio? }) | Returns { imageUrl } for one image. model is one of AI_IMAGE_MODELS; aspectRatio is 1:1 (default), 16:9 or 9:16. |
ctx.integrations.ai.generateVideo({ prompt, model?, aspectRatio?, durationSeconds?, resolution? }) | Returns { videoUrl } for one clip, after a minute or more. model is one of AI_VIDEO_MODELS; resolution is 720p or 1080p. |
ctx.integrations.http.get({ url, headers?, query? }) | Returns { status, headers, body }, with body typed unknown — narrow it with a guard. |
ctx.integrations.http.post({ url, body?, headers? }) | The write verbs, alongside put and patch. Uncertainty on a patch is never retried automatically. |
ctx.integrations.mcp.read({ url, toolName, toolProps?, headers? }) | Calls a read-only tool on an MCP server you name. Returns { structuredContent, content }, both unknown. |
ctx.integrations.mcp.write({ url, toolName, toolProps?, headers? }) | Calls a tool that may change remote state. Uncertainty here is never retried automatically. |
ctx.integrations.postgres.query({ sql, params?, maxRows? }) | One parameterized statement in a read-only transaction. Returns { rows, rowCount, truncated }; a write is refused. |
ctx.integrations.gmail.fetchEmails(…)Search the mailbox with a Gmail query.Those four are what the SDK itself declares. Every other provider operation arrives as a binding: binding an operation writes your workspace's integrations.generated.d.ts, which augments WorkflowIntegrations with that provider's member — so what a workflow can reach depends on what the workspace has bound and the owner has connected, not on what TypeScript would otherwise let you type.
The ai, http and mcp ports are credential-free, and postgres runs against the owner's stored connection, whose password your source never receives. Never read environment variables or credential values in workflow code: take settings from ctx.config, stored secrets from ctx.secrets, and everything else from a port.
Every http and mcp request names its destination in the source: an origin written as a literal, a whole URL from one ctx.config or ctx.secrets value, or — to answer whoever sent a delivery — the address that delivery carried in ctx.input, in which case the request may carry no workflow secret. An agent loop counts every model turn and every tool call against the run's call budget, so cap the turns and validate each call's arguments before you use them.
Access and provider constraints
An available port does not bypass the destination's authentication. HTTP and MCP calls still need any credentials, permissions and provider plan required by their destination. The hosted runtime must be able to reach the endpoint; private-network-only services are not automatically reachable.
Optional AI calls happen during a run and can vary their outputs or incur runtime AI usage. Keep them distinct from the account's weekly building allowance. Model turns and tool calls count against the run's call budget, so bound an agent loop rather than assuming unlimited execution.
An image or video comes back as a public, unguessable link that is deleted after 30 days, so send or post it as it is: embed an image in an HTML email with an img tag and link a video rather than attaching it. Leave the image and video settings out unless the owner asks for a shape, length or resolution; a combination the chosen model cannot render, such as a square Veo clip or a 720p Kling clip, is refused before anything is generated. One run makes at most five videos.