Connect to OpenAI
Connect to OpenAI and use their models for AI-powered apps and automations in Retool.
OpenAI provides advanced AI models for natural language processing, code generation, text analysis, and reasoning tasks. You can create an OpenAI resource so you can build AI-powered apps and workflows that leverage GPT's capabilities for content generation, data analysis, conversational interfaces, and more.
What you can do with OpenAI in Retool
After you create an OpenAI resource in Retool, you can:
- Generate, summarize, classify, and extract information from text using GPT's language models.
- Build conversational, multi-turn chat experiences with context-aware responses.
- Analyze images to generate captions, classify content, extract entities, or answer questions about visual content.
- Generate images from text descriptions using DALL·E.
- Choose between a Retool-managed key or your own OpenAI API key.
Supported models
- Retool-managed key
- Bring your own key
The following models are available with Retool-managed keys:
| Model | Resource queries | Agent support | Assist support |
|---|---|---|---|
| GPT Image 1 | |||
| GPT Image 1 Mini | |||
| GPT Image 1.5 | |||
| GPT Image 2 | |||
| GPT-3.5 Turbo | |||
| GPT-4 | |||
| GPT-4 Turbo | |||
| GPT-4.1 | |||
| GPT-4.1-mini | |||
| GPT-4.1-nano | |||
| GPT-4o | |||
| GPT-4o-mini | |||
| GPT-5 | |||
| GPT-5.1 | |||
| GPT-5.3 Codex | |||
| GPT-5.4 | |||
| GPT-5.5 | |||
| o4-mini |
When you configure an OpenAI resource with your own API key, Retool interacts directly with the OpenAI API. You can use any OpenAI model you have access to through your OpenAI account, including:
- All current and future GPT models
- o-series reasoning models
- Image generation models (DALL·E)
- Embedding models
- Fine-tuned models
Specify the model ID in your queries (e.g., gpt-5.2, gpt-4.1, o3-mini). Refer to OpenAI's model documentation for the complete list of available models and their identifiers.
Before you begin
Before creating an OpenAI resource, you need:
- Retool permissions: Ability to create and manage resources in your Retool organization.
- OpenAI API key (optional): An API key from your OpenAI account if you want to bring your own key. New Retool organizations automatically include an OpenAI resource with a Retool-managed key.
Create an OpenAI resource
Create a resource to connect Retool to OpenAI and configure authentication. Once connected, you can then select it when writing queries to make use of its available models.
Follow these steps to create an OpenAI resource in Retool.
Create a new resource
Navigate to Resources in the main navigation and click Create new > Resource and search for OpenAI. Then, click the OpenAI tile to create a new resource.
Configure connection settings
Specify a name for the resource that identifies it within your organization. Include a description that can provide more context to users and Assist about how to use the resource.
Configure authentication
OpenAI resources support two authentication options: Retool-managed keys or customer-provided keys (Bring Your Own Key).
- Retool-managed
- Bring Your Own Key
Retool organizations include an OpenAI resource with a Retool-managed key by default. This allows you to use GPT models immediately without providing your own API key. Retool maintains a direct relationship with the AI provider and bills you directly for AI usage.
To use a Retool-managed key, set Key Source to Retool Managed.

Retool uses customer-provided keys to interact with OpenAI. You are billed directly by the AI provider for any usage of the resource.
- Set Key Source to Bring Your Own Key.
- Base URL (optional): The OpenAI API endpoint. Default is
https://api.openai.com. Only change this if you're using a custom endpoint or proxy. - API Key: Your OpenAI API key from the OpenAI Platform.
- Organization ID (optional): Your OpenAI organization ID if you belong to multiple organizations.
- Headers (optional): Custom HTTP headers to include with requests. Add headers as key-value pairs if required by your setup.
Retrieve your API key from the API Keys page in your OpenAI account.

Where possible, create dedicated API keys for Retool to best manage and revoke access without disruption. All API keys used with Retool are encrypted and stored securely.
Save the resource
Click Create resource to save your OpenAI resource. The resource is now available for use in apps and workflows.
AI resources do not have a Test connection button. To verify your configuration, create a new app and ask the agent to test the resource for you.
Interact with OpenAI data
Once you've created an OpenAI resource, you can interact with GPT and DALL·E models using Retool.
Retool recommends using the new app builder so you can use natural language to build React-based apps using AI.
- To use OpenAI models in the app builder, reference the resource in the prompt with
@, such as@OpenAI. Refer to the data and functions documentation to learn more. - For classic apps, workflows, and agents, refer to the AI queries documentation to learn how to write a resource query.
Best practices
Follow these best practices to keep your OpenAI usage secure and cost-efficient.
Security
- Rotate credentials regularly: Roll your OpenAI API key periodically from the OpenAI Platform, and immediately if a key is ever exposed.
- Create separate API keys for Retool: Use a dedicated OpenAI API key for Retool so you can revoke or rotate access without disrupting other integrations.
- Use resource environments: Organizations on an Enterprise plan can configure multiple resource environments to maintain separate OpenAI API keys for production, staging, and development.
Manage token usage and cost
- Choose the smallest capable model: Use a faster, cheaper model (e.g. GPT-4.1 Nano) for simple tasks like classification or extraction, and reserve larger models for tasks that need deeper reasoning.
- Set output token limits: Configure a maximum output token limit appropriate to the task to avoid paying for unnecessarily long responses.
- Trim conversation history: For chat use cases, truncate or summarize older messages instead of sending the full history on every request. OpenAI bills for all input tokens, including message history.
- Monitor usage: Track token consumption and spend in the OpenAI Platform usage dashboard to catch unexpected usage spikes early.
Related resources
Create a resource
Learn how to create and manage resources in Retool.
Resource environments
Configure separate credentials for production and non-production environments.
AI models
Learn about Retool-managed and self-managed AI model keys.
Retool community: OpenAI
Community discussions and solutions for OpenAI integrations.
OpenAI API reference
Official OpenAI API documentation.
Azure OpenAI
Connect to GPT models through Azure instead of OpenAI directly.