Deploy a Workflow as an OpenAI Endpoint
Turn any Tensorify workflow into an OpenAI-compatible API endpoint. Any application that works with the OpenAI SDK can connect to your workflow — no custom client code needed.
Uses: Chat Trigger, AI Agent, Return Time: ~10 minutes
The Chat Trigger speaks the OpenAI Chat Completions protocol natively:
- Incoming: The SDK sends a standard
POST /chat/completionsrequest withmessages[] - Translation: The trigger extracts the latest user message, conversation history, and system prompt
- Processing: Your AI Agent (or any logic) generates a response
- Outgoing: The response is wrapped in OpenAI's ChatCompletion format and returned to the SDK
This means your workflow is a drop-in replacement for any OpenAI model in existing applications.
- A Tensorify workspace
- An OpenAI API key (or any LLM provider — Anthropic, Ollama, etc.)
Use the OpenAI Chatbot template or build from scratch:
- Add a Chat Trigger node
- Set Model Name to whatever you want clients to see (e.g.,
my-agent) — this is cosmetic - Add an AI Agent node and configure your LLM provider and system prompt
- Add a Return node
- Wire: Chat Trigger
chat→ AI Agentmessage→ Returninput
Protect your endpoint so only authorized callers can use it. In the Chat Trigger settings:
- Set authType to
tensorify-api-key - Go to Settings → API Keys and create a key if you don't have one
- Callers will use this key as the
api_keyin their OpenAI SDK configuration
Tensorify API Key is the recommended option — no custom secrets to manage. You can also use Bearer Secret for a simple shared token, or None for open endpoints (development only).
Go to Settings → Environment Variables and add your LLM API key:
OPENAI_API_KEYfor OpenAI modelsANTHROPIC_API_KEYfor Anthropic models- Or use a custom provider with any OpenAI-compatible API
Click Deploy in the workflow editor:
- Cloud — Tensorify runs your workflow on managed infrastructure
- CLI — Your workflow runs on your own machine via the CLI runner
After deployment, you'll get an endpoint URL like:
https://triggers.tensorify.io/h/YOUR_HOOK_PATH
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)
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);
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!"}]
}'
For real-time token delivery, enable streaming in two places:
- AI Agent settings → set Streaming to
true - SDK call → set
stream=True
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)
Streaming uses Server-Sent Events (SSE) and delivers tokens as they're generated.
For multi-turn conversations, add a Window Memory node:
- Drag a Window Memory node onto the canvas
- Connect its
memoryoutput to the AI Agent'smemoryinput - Set Session Key to track conversations per user:
{{ 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"},
)
When deployed, the Chat Trigger exposes:
| Route | Purpose |
|---|---|
| POST /chat/completions | Chat completions (main endpoint) |
| GET /models | Lists available models |
Responses follow the standard OpenAI Chat Completion format — returned directly as the HTTP body, exactly as OpenAI SDKs expect.
{
"id": "chatcmpl-a1b2c3d4e5f6",
"object": "chat.completion",
"created": 1719043200,
"model": "my-agent",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 12,
"total_tokens": 37
},
"_tensorify": {
"tool_calls": [],
"iterations": 1
}
}
Key fields:
| Field | Description |
|---|---|
| choices[0].message.content | The agent's text response |
| choices[0].finish_reason | "stop" for normal completion, "length" if max iterations hit |
| usage.total_tokens | Total tokens consumed (prompt + completion) |
| _tensorify.tool_calls | Tensorify-specific: tools called during reasoning |
| _tensorify.iterations | Tensorify-specific: how many reasoning loops ran |
- Chat Trigger Reference — full settings and output reference
- Streaming AI Responses — real-time token delivery with SSE
- Choosing a Trigger — when to use Chat Trigger vs API Trigger vs Webhook
- Self-Host an AI Agent — run on your own machine with local LLMs
- Build a RAG System — add vector search for document Q&A
- Agent Memory — deep dive into memory configuration
- AI Agent Reference — full output format and settings reference
