Keep Your Database Credentials Secure While Building Powerful AI Agents
OpenAI's new Agent Builder is revolutionizing how businesses create AI-powered workflows with its intuitive drag-and-drop interface. But here's the challenge that every enterprise faces: how do you give your agents access to internal databases without exposing credentials or compromising security?
This is where DreamFactory becomes essential. Instead of sharing database credentials with external platforms or writing custom APIs from scratch, DreamFactory provides a secure, instant REST API layer that sits between your agents and your data—whether it's on-premises, self-hosted, or in a private cloud.
Why DreamFactory + OpenAI Agent Builder?
Security First: Your database credentials never leave your environment. DreamFactory runs in your infrastructure and exposes only controlled API endpoints.
Universal Database Support: Connect to MySQL, PostgreSQL, SQL Server, Oracle, MongoDB, and 20+ other data sources through a single, standardized REST API.
Zero Code Required: DreamFactory and OpenAI Agent Builder are both designed for efficiency, build agents visually while accessing data through auto-generated APIs.
Enterprise-Grade: With DreamFactory you get Role-based access control, API key management, rate limiting, and comprehensive logging out of the box.
Architecture Overview
Here's how the components work together:
Your agent makes API calls to DreamFactory, which handles authentication, authorization, and query execution—all within your secure environment.
Step-by-Step Implementation Guide
Part 1: Set Up DreamFactory
1. Deploy DreamFactory
Choose your deployment method:
- Docker (fastest for testing):
- On-Premises Installation: Download from dreamfactory.com for production environments
- Cloud Deployment: Deploy to AWS, Azure, or Google Cloud in your VPC
2. Connect Your Database
After accessing the DreamFactory admin console:
- Navigate to Services > Create
- Select your database type (e.g., "MySQL" or "PostgreSQL")
- Enter connection details:
- Host: Your database server address
- Database Name: Target database
- Username/Password: Database credentials (stored securely, never exposed)
- Click Save
DreamFactory immediately generates a full REST API for your database with endpoints for all tables.
3. Create an API Key
- Go to Roles and create a new role defining table access permissions
- Navigate to Apps > Create
- Generate an API key for your OpenAI agent
- Set the role to control exactly what data the agent can access
Your API endpoint will look like:
Part 2: Configure OpenAI Agent Builder
1. Create a New Agent Workflow
In OpenAI's Agent Builder:
- Start a new workflow from the canvas
- Add an API connector node (using MCP or custom action)
- Configure the HTTP request settings
2. Set Up the DreamFactory Connection
Configure the API connector with:
- Base URL: https://your-dreamfactory-instance.com/api/v2
- Authentication: API Key (add as header)
- Header Name: X-DreamFactory-API-Key
- Header Value: Your generated API key
3. Build Your First Query
Create a simple data retrieval workflow:
Example: Customer Lookup Agent
- Trigger: User provides customer email
- Action Node: HTTP GET request
- Endpoint: /database/_table/customers
- Query Parameter: filter=(email='${userInput}')
- Response: Format and return customer data
Example: Sales Analytics Agent
- Trigger: User asks "What were our top products last month?"
- Action Node: HTTP GET request
- Endpoint: /database/_proc/get_top_products
- Parameters: {"month": "2025-09", "limit": 10}
- Transform Node: Parse JSON response
- Output: Present results in natural language
Part 3: Common Agent Patterns
Pattern 1: Read-Only Data Assistant
Perfect for customer service agents that need to look up information:
DreamFactory API Example:
Pattern 2: Data Update Agent
For agents that need to modify records:
DreamFactory API Example: PATCH Request to....
Pattern 3: Multi-Source Data Agent
When your agent needs data from multiple systems:
You can connect multiple databases to DreamFactory and give your agent a unified API interface.
Part 4: Security Best Practices
1. Principle of Least Privilege
Create specific roles in DreamFactory for each agent:
- Read-only for lookup agents
- Specific table access only
- Field-level restrictions to hide sensitive data (SSN, passwords)
2. Network Security
- Keep DreamFactory behind your firewall
- Use VPN or private networking to connect OpenAI agents
- Enable IP whitelisting in DreamFactory if possible
3. API Key Management
- Generate unique keys for each agent workflow
- Set expiration dates on keys
- Rotate keys regularly
- Monitor usage through DreamFactory's logging
4. Data Validation
Add validation nodes in your agent workflow:
- Sanitize user inputs before database queries
- Validate data types and formats
- Implement rate limiting
- Add human approval gates for destructive operations
Part 5: Advanced Techniques
Using Stored Procedures
For complex business logic, call database stored procedures through DreamFactory:
This keeps business rules in your database where they belong.
Implementing Caching
DreamFactory supports caching to reduce database load:
- Enable cache in service settings
- Set appropriate TTL for your use case
- Agents get faster responses for repeated queries
Webhooks and Triggers
Use DreamFactory's scripting to trigger actions:
- Send notifications when data changes
- Log all agent interactions
- Validate data before writes
- Implement custom business rules
Part 6: Real-World Use Cases
Customer Service Agent
An agent that helps support staff quickly access customer information:
- Looks up customer account details
- Retrieves order history
- Checks inventory availability
- All without exposing the backend database
Sales Intelligence Agent
Helps sales teams with data-driven insights:
- Analyzes pipeline data
- Identifies at-risk deals
- Suggests upsell opportunities
- Generates custom reports on demand
Inventory Management Agent
Automates warehouse operations:
- Checks stock levels across locations
- Updates inventory counts
- Triggers reorder workflows
- Generates receiving reports
Employee Onboarding Agent
Streamlines HR processes:
- Creates employee records
- Provisions access across systems
- Tracks onboarding progress
- Updates multiple databases transactionally
Testing Your Integration
1. Start Simple
Test with a single read-only query:
Verify the agent can retrieve and display data correctly.
2. Test Error Handling
Intentionally trigger errors:
- Invalid API key
- Malformed queries
- Non-existent tables
Ensure your agent handles errors gracefully.
3. Performance Testing
Monitor response times and optimize:
- Add database indexes for common queries
- Enable DreamFactory caching
- Use pagination for large result sets
4. Troubleshooting
Connection Issues
- Verify DreamFactory is accessible from OpenAI's network
- Check API key is correctly configured in headers
- Review DreamFactory logs for authentication errors
Permission Errors
- Confirm the role assigned to your API key has proper permissions
- Check table-level access in DreamFactory role settings
- Verify field restrictions aren't blocking needed columns
Performance Problems
- Review database query performance
- Enable query logging to identify slow operations
- Consider adding database indexes
- Implement caching for frequently accessed data
Conclusion
By combining OpenAI's Agent Builder with DreamFactory, you get the best of both worlds: powerful AI agents with secure, controlled access to your internal data. Your database credentials stay protected within your infrastructure while your agents gain the ability to interact with real business data.
This architecture scales from simple lookup agents to complex multi-system workflows, all while maintaining enterprise-grade security and governance.
Next Steps
- Deploy DreamFactory in your environment (free trial available)
- Connect one database to start with
- Build a simple agent that queries a single table
- Expand gradually adding more data sources and complex workflows
- Monitor and optimize using DreamFactory's analytics
Your agents will be accessing internal data securely within hours, not weeks.
Resources:
- DreamFactory Documentation: https://guide.dreamfactory.com
- OpenAI Agent Builder Guide: https://platform.openai.com/docs/guides/agents
- API Security Best Practices: Review your organization's security policies
- Community Support: Join DreamFactory's community forums for implementation guidance
Keep your data secure. Keep your agents powerful. Use DreamFactory.