Docs / Strand / connectors/ai-openai

OpenAI Connector

Send prompts to OpenAI GPT models and receive completions from your Strand workflows. Use this connector for classification, summarization, content generation, data extraction, and any task that benefits from a large language model.

Direction: Read / Write | Type: ai.openai

Prerequisites

You need an OpenAI API key:

  1. Go to platform.openai.com/api-keys
  2. Click Create new secret key
  3. Copy the key (it starts with sk-)
  4. Optionally note your Organization ID from platform.openai.com/account/organization if you need billing attribution

Connector Setup

Create an OpenAI connector from the Connectors page.

Configuration Fields

Field Required Default Description
Name Yes - Friendly name (e.g., "GPT-4o Production")
API Key Yes - OpenAI API key (encrypted at rest)
Model No gpt-4o-mini Default model for all nodes using this connector
Temperature No 0.7 Response randomness (0--2). Lower = more deterministic
Max Tokens No 1000 Maximum response tokens (1--128,000)
Organization ID No - OpenAI organization ID for billing attribution
Timeout No 120 Request timeout in seconds (10--600). Increase for reasoning models

Operations

Chat Completion

Generate a chat completion response from an OpenAI model. This is the single operation exposed by the connector.

Operation ID: chat

The prompt is sent as a user message. If System Instructions are configured on the node, they are sent as the system message preceding the prompt.

Models

Model Best for
gpt-4o-mini Fast, cost-effective for most tasks (default)
gpt-4o Higher capability for complex reasoning
gpt-4.1 Latest flagship model with improved instruction following
gpt-4.1-mini Balanced cost and capability
gpt-4.1-nano Fastest and cheapest in the 4.1 family
o1 Advanced reasoning with chain-of-thought
o1-mini Lightweight reasoning
o3-mini Cost-effective reasoning
gpt-4-turbo Large context window tasks
gpt-3.5-turbo Legacy, lowest cost

You can use any valid OpenAI model name, including fine-tuned models.

Tip: Reasoning models (o1, o3-mini) can take significantly longer to respond. Increase the Timeout to 300--600 seconds when using them.

Node Configuration

When you drag an OpenAI connector node onto the canvas, these fields are available in the node inspector. They apply to this specific node and override connector-level defaults where noted.

Field Required Default Description
Prompt Yes `{{ payload \ tojson }}` Prompt sent to the model. Supports Jinja2 templates
System Instructions No - Markdown instructions that set the model's persona and behavior
Model No connector default Override the model for this node only
Temperature No connector default Override temperature (0 = deterministic, 2 = most creative)
Max Tokens No connector default Override maximum response tokens
Timeout No connector default Override request timeout in seconds (10--600)
Max Retries No 2 Retries on transient errors such as rate limits and server errors (0--5)
MCP Servers No - MCP server connectors to attach as tools for this call
Memory Enabled No false Persist conversation history across workflow runs
Memory TTL No 3600 Seconds to retain history (60--2,592,000). Resets on each access
Memory Max Messages No 20 Maximum messages kept in memory. Oldest are trimmed first (2--100)

Output

A successful chat completion returns:

json

{
  "response": "The analysis shows three key trends...",
  "model": "gpt-4o-mini",
  "provider": "openai",
  "usage": {
    "prompt_tokens": 150,
    "completion_tokens": 89,
    "total_tokens": 239
  }
}

When memory is enabled, the output includes "memory_enabled": true. When MCP tools are called, the output includes an "mcp_tools_called" array. If retries occurred, a "retries" count is included.

Access the response in downstream nodes:

jinja2

{{ steps.NODE_ID.output_payload.response }}
{{ steps.NODE_ID.output_payload.usage.total_tokens }}

Example Workflow

Classify incoming support tickets and route them:

  1. HTTP Trigger receives a webhook with { "ticket_body": "...", "ticket_id": "..." }
  2. OpenAI node classifies the ticket:
  1. Router node branches on {{ steps.classify.output_payload.response }}:

Retries

The node automatically retries on transient errors -- rate limits (429), server errors (5xx), timeouts, and connection failures. Retries use exponential backoff with jitter and respect Retry-After headers from OpenAI. Non-retryable errors (invalid API key, bad request) fail immediately.

Conversation Memory

Toggle Memory Enabled on and the node will remember every exchange across workflow runs. Each node gets its own isolated, account-scoped memory that is securely persisted across runs. See AI Connectors for full details on memory behavior, TTL, trimming, and when to enable it.

MCP Tool Access

AI nodes can call external tools via MCP servers. Add one or more MCP server connectors to the MCP Servers field and the model will have access to those tools during its response.

Errors

Error Meaning
OpenAI API key is required API key not configured on the connector
Invalid OpenAI API key Key is incorrect or revoked. Generate a new one
Rate limit exceeded Too many requests. The node will retry automatically
Request timeout The model took too long. Increase the timeout setting
Model not found The specified model name is not valid for your account