Overview
Integrate OpenAI’s GPT-4 models for advanced conversational AI capabilities. This guide covers setting up the AI connection, configuring via YAML, and using it in conversations.Step 1: Create the AI Connection
Get Your OpenAI API Key
- Visit OpenAI Platform
- Sign in or create an account
- Navigate to API Keys
- Click Create new secret key
- Copy and save your API key securely
Keep your API key secure. Never commit it to version control or share it publicly.
Add Connection in AgentFlow
- Go to Admin Dashboard → AI Models
- Click Add Model
-
Fill in the basic information:
- Name:
OpenAI GPT-4.1 - Model ID:
openai-gpt-4.1 - Description:
Direct integration with OpenAI GPT-4.1 for advanced conversational AI
- Name:
-
Configure the API settings:
- Endpoint:
https://api.openai.com/v1/chat/completions - Method:
POST
- Endpoint:
-
Add headers:
-
Configure request schema:
-
Set response path:
choices[0].message.content - Click Save to create the connection
Step 2: Import Configuration via YAML
Manual YAML Configuration
Create a file namedopenai-gpt-config.yaml:
Import the YAML Configuration
- Go to Admin Dashboard → AI Models
- Click Import Model
- Upload your
openai-gpt-config.yamlfile - Review the configuration
- Enter your OpenAI API key in the secure field
- Click Import
YAML imports automatically configure message formatting and presets, saving you time!
Step 3: Assign to a Group
- Go to Admin Dashboard → Groups
- Select or create a group (e.g., “Marketing Team”)
- Click Manage Models
- Select your OpenAI GPT-4.1 model
- Click Save
Step 4: Use in Chat
Start a Conversation
- Navigate to the Chat interface
- Click New Conversation
- Select OpenAI GPT-4.1 from the model dropdown
- Start chatting!
Example Prompts
Advanced Configuration
Streaming Responses
To enable streaming for real-time responses:Custom System Prompts
Override the default system prompt per conversation:Temperature Control
Adjust creativity vs consistency:- 0.0-0.3: Focused, deterministic responses
- 0.4-0.7: Balanced creativity
- 0.8-1.0: Maximum creativity
Troubleshooting
Authentication Errors
Invalid API Key
Invalid API Key
Verify your API key is correct and has not expired. Generate a new key if needed.
Rate Limit Exceeded
Rate Limit Exceeded
Check your OpenAI usage limits and upgrade your plan if necessary.
Insufficient Quota
Insufficient Quota
Add credits to your OpenAI account or check billing settings.
Response Issues
- Empty responses: Check your max_tokens setting
- Timeout errors: Increase timeout value in advanced settings
- Formatting issues: Verify response_path is correct
Cost Optimization
Token Management
Monitor and optimize token usage:- Set appropriate
max_tokenslimits - Use shorter system prompts when possible
- Implement conversation history trimming
- Track usage in Analytics Dashboard
Model Selection
Choose the right model for your use case:- GPT-4.1 Turbo: Best for complex reasoning
- GPT-4.1: Balanced performance
- GPT-3.5 Turbo: Cost-effective for simple tasks