Chat Trigger

Deploy an OpenAI-compatible chat endpoint. Any application that uses the OpenAI SDK — Python, Node.js, curl, IDE plugins, chat widgets — connects directly to your workflow.

When to Use

Use Chat Trigger when:

  • You want to deploy an AI chatbot or conversational agent as an API
  • Callers use the OpenAI SDK (or any OpenAI-compatible client)
  • You need streaming (SSE) token-by-token responses
  • You want a simple, purpose-built chat endpoint with minimal configuration

If you need a general-purpose REST API with multiple HTTP methods and custom routing, use API Endpoint instead.

Output

Chat Trigger produces a single chat output handle containing the parsed chat request.

HandleTypeDescription
chatobjectParsed OpenAI chat request — message, history, system prompt, and metadata

The chat object (accessed as {{ chat.* }}) shape:

FieldTypeDescription
messagestringThe latest user message extracted from messages[]
historyarrayAll previous messages in the conversation (everything except the latest user message)
system_promptstringThe system message, if one was provided in messages[]
metadataobjectRequest metadata — model, stream, temperature, requestId, sessionId, headers, and query params

Settings

Protocol

SettingTypeDefaultDescription
model_nametexttensorifyModel name reported in ChatCompletion responses and the /models endpoint. Cosmetic — does not affect which LLM runs.

Authentication

SettingTypeDefaultDescription
authTypeselectnoneAuthentication strategy: none (open), tensorify-api-key (workspace API keys), or bearer-secret (custom token).
secretsecretCustom Bearer token for endpoint authentication. Stored encrypted. Shown when authType is bearer-secret.

Tensorify API Key is the simplest option — callers send Authorization: Bearer tfk_... using a workspace API key from Settings → API Keys. No custom secrets to create or manage.

Bearer Secret lets you set a custom token that callers must provide. Useful when you want a simple shared secret without tying it to a workspace API key.

Behavior

SettingTypeDefaultDescription
responseModeselectuse-workflow-responseuse-workflow-response waits for the Return node and wraps the result as a ChatCompletion. ack-immediately returns an empty ChatCompletion instantly.

Testing

SettingTypeDefaultDescription
mockPayloadcode editor (JSON){ "messages": [{"role": "user", "content": "Hello"}] }Test payload for canvas test runs. Uses OpenAI messages[] format.

Example

Canvas

Build a chatbot with streaming responses:

  1. Drag a Chat Trigger onto the canvas
  2. Set authType to tensorify-api-key
  3. Add an AI Agent node — configure your LLM provider and system prompt, enable Streaming
  4. Add a Return node
  5. Wire: Chat Trigger chat → AI Agent message → Return input
  6. Deploy the workflow

Access chat data in downstream nodes:

{{ chat.message }}
{{ chat.history }}
{{ chat.system_prompt }}
{{ chat.metadata.model }}
{{ chat.metadata.stream }}

Connect with the OpenAI SDK

from openai import OpenAI

client = OpenAI(
    base_url="https://triggers.tensorify.io/h/YOUR_HOOK_PATH",
    api_key="tfk_your_workspace_api_key",
)

response = client.chat.completions.create(
    model="tensorify",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What can you help me with?"},
    ],
)

print(response.choices[0].message.content)

Streaming

response = client.chat.completions.create(
    model="tensorify",
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True,
)

for chunk in response:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

curl

curl -X POST https://triggers.tensorify.io/h/YOUR_HOOK_PATH/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tfk_your_workspace_api_key" \
  -d '{
    "model": "tensorify",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://triggers.tensorify.io/h/YOUR_HOOK_PATH",
  apiKey: "tfk_your_workspace_api_key",
});

const response = await client.chat.completions.create({
  model: "tensorify",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);

Available Routes

When deployed, the Chat Trigger exposes:

| Route | Purpose | |---|---| | POST /chat/completions | Chat completions (main endpoint) | | GET /models | Lists available models |

Session Memory

For multi-turn conversations, add a Window Memory node and set its session key to the request's session header:

{{ chat.metadata.headers['x-tensorify-session-id'] || 'default' }}

Then pass a session ID from the client:

response = client.chat.completions.create(
    model="tensorify",
    messages=[{"role": "user", "content": "Remember, my name is Alice."}],
    extra_headers={"X-Tensorify-Session-Id": "user-alice-123"},
)

Common Gotchas

  • Do not append /chat/completions to the base URL. OpenAI SDKs append it automatically. Set base_url to https://triggers.tensorify.io/h/YOUR_HOOK_PATH — not .../chat/completions.
  • Model name is cosmetic. The model_name setting controls what appears in API responses. It does not select an LLM — your AI Agent node's provider configuration determines which model runs.
  • Streaming requires both sides. Enable streaming in the AI Agent node settings AND pass stream=True in the SDK request.
  • Return node required. When responseMode is use-workflow-response, a Return node must be connected — otherwise the caller's connection hangs until timeout.

See Also

On this page