DocumentationAI provider connections

AI provider connections

Use credential-free Webhook Relay AI or store provider API keys and bind them to Webhook Relay functions for ai.generate().

AI provider connections enable bounded, synchronous enrichment inside a Function. Webhook Relay AI uses the platform's managed model and needs no credential. Customer-provider keys are encrypted at rest, write-only through the dashboard and API, and never become values that function code can read.

Supported connection types

Connection typeCredentialAPI used
Webhook Relay AINoneWebhook Relay managed model
OpenAIAPI keyChat Completions
Google GeminiGemini API keygenerateContent
AnthropicAPI keyMessages API
Custom LLMAPI key and HTTPS base URLOpenAI-compatible POST /chat/completions

For a custom connection, enter the API root, for example https://llm.example.com/v1. Webhook Relay appends /chat/completions. The base URL cannot contain embedded credentials, a query or a fragment.

Create and bind a connection

  1. Open Service Connections and choose Webhook Relay AI, OpenAI, Gemini, Anthropic or Custom Chat Completions API.
  2. For Webhook Relay AI, no credential is needed. For a customer provider, paste the server-side API key; a custom provider also needs its HTTPS base URL.
  3. Import an alias in the function, such as require("ai:classifier").
  4. Save the function and use its Connections tab to bind classifier to the provider connection. A missing binding links directly to the filtered Service Connections dialog and returns you to the function after setup.

Enter customer-provider API keys only in that write-only dialog. The account agent can inspect and bind an existing connection, but it never asks for or accepts a credential in chat.

const ai = require("ai:classifier")

const result = ai.generate("Classify this webhook as low, medium, or high risk", {
  system: "Return one lowercase label.",
  maxTokens: 16
})

r.setHeader("X-Risk", result.text.trim())
local ai = require("ai:classifier")

local result = ai.generate("Classify this webhook as low, medium, or high risk", {
  system = "Return one lowercase label.",
  maxTokens = 16
})

r:SetRequestHeader("X-Risk", result.text)

The examples above use a Webhook Relay AI connection, so the model is selected for you. For customer providers, add model (model = in Lua). Example values are gpt-5-mini for OpenAI, gemini-2.5-flash for Gemini, claude-haiku-4-5 for Anthropic, or a model name supported by your custom endpoint.

Limits and delivery behavior

ai.generate(prompt, options) accepts a prompt up to 64 KiB. model is required for customer providers and must be omitted for Webhook Relay AI. system, maxTokens, timeoutMs and jsonSchema are optional for every provider. Temperature accepts 0–2 for OpenAI, Gemini and custom providers, but is not supported by Webhook Relay AI. For Anthropic, the only accepted explicit value is its default, 1; omit the option to use the provider default. Output is capped at 4,096 tokens, timeouts can be 1–30 seconds, responses are capped at 1 MiB, and one function execution can make at most three AI calls.

The helper returns normalized provider, model, text, finish_reason and usage fields. With jsonSchema, it also validates and returns json. OpenAI, Gemini and Anthropic receive their native structured-output setting; for Anthropic, choose a model that supports structured outputs. Anthropic's strict format makes every declared object property present and disallows undeclared properties during generation; the schema supplied by the function is still used unchanged for local validation. Custom Chat Completions endpoints are validated locally because response-format extensions are not portable across OpenAI-compatible providers. Webhook Relay AI receives the schema as a generation instruction and validates the result locally.

Webhook Relay AI usage is charged to the same monthly AI token allowance as the account agent. Function calls add token usage to that shared ledger but do not count as conversational agent turns. The allowance and reset time shown by the account agent therefore already include managed Function enrichment.

AI generation is synchronous enrichment, so do not use it as an unbounded agent loop. Writes to Slack, databases and other destinations should remain outputs, where retries, logs, throttling and response functions continue to apply.

API and MCP fields

Create a standard service connection with one of these service_type values: webhookrelay_ai, openai, gemini, anthropic or custom_llm. webhookrelay_ai accepts no credential fields. REST uses the nested llm_service_connection.api_key and llm_service_connection.base_url fields for customer providers. External MCP clients can use create_service_connection with no key for webhookrelay_ai, or with llm_api_key and llm_base_url for customer providers. Credential-bearing write tools are intentionally not offered to the dashboard account agent, so credentials cannot enter persisted chat history. API keys are omitted or masked on every read surface.

Next steps

Did this page help you?