AI resource queries
Learn how to create AI resource queries to generate text, analyze images, and process documents in Retool.
You're viewing documentation for classic apps, which use Retool's original app editor. The AI app builder is the recommended way to build apps and where Retool focuses new development.
AI resource queries let you leverage AI models from providers like OpenAI, Anthropic, Google, and others to generate text, analyze images, create chat experiences, and process documents in your Retool apps and workflows.
Create an AI resource query
To use AI resource queries, first create an AI provider resource (OpenAI, Anthropic, Google AI, etc.) in your Retool organization. Then create queries against that resource.

Apps
- Open the Code panel.
- Click + to add a new query.
- Select your AI resource (e.g., OpenAI, Anthropic).
- Choose an action type.
Workflows
- Add a Resource query block.
- Select your AI resource.
- Choose an action type.
Text actions
Process and generate text content using AI models' language understanding capabilities.
| Action | Description |
|---|---|
| Generate text | Create original text content based on your prompt. Use for content generation, creative writing, code generation, and general-purpose text tasks. |
| Summarize text | Condense long-form content into concise summaries. Specify the input text and desired summary format. |
| Classify text | Categorize text into predefined categories. Provide the text to classify and the possible categories. |
| Extract entity from text | Extract specific information from unstructured text. Define what entities or data points to extract (names, dates, amounts, etc.). |
Supported models
Text actions are available for use with the following AI providers and models.
- Amazon Bedrock
- Anthropic
- Google Vertex AI
- OpenAI
- Retool
- Amazon Bedrock Model
- Claude 4.5 Haiku (Bedrock)
- Claude 4.5 Opus (Bedrock)
- Claude 4.5 Sonnet (Bedrock)
- Claude 4.6 Opus (Bedrock)
- Claude 4.6 Sonnet (Bedrock)
- Claude 4.7 Opus (Bedrock)
- Claude 4.8 Opus (Bedrock)
- Claude Fable 5.1 (Bedrock)
- Claude Fable 5.2 (Bedrock)
- Claude Opus 5 (Bedrock)
- Claude Opus 5.5 (Bedrock)
- Claude Sonnet 5 (Bedrock)
- Claude Sonnet 5.5 (Bedrock)
- Claude Fable 5
- Claude Fable 5.1
- Claude Fable 5.2
- Claude Haiku 4.5
- Claude Opus 4.5
- Claude Opus 4.6
- Claude Opus 4.7
- Claude Opus 4.8
- Claude Opus 5
- Claude Opus 5.5
- Claude Sonnet 4.5
- Claude Sonnet 4.6
- Claude Sonnet 5
- Claude Sonnet 5.5
- Gemini 2.0 Flash
- Gemini 2.5 Flash
- Gemini 2.5 Pro
- Gemini 3 Flash (Preview)
- Gemini 3.1 Flash-Lite (Preview)
- Gemini 3.1 Pro (Preview)
- Gemini 3.5 Flash
- Gemini 3.6 Flash
- Gemini 3.8 Flash
- Gemini 4 Argon
- Gemini 4 Carbon
- Gemini 4 Hydrogen
- Gemini 2.5 Flash
- Gemini 2.5 Pro
- Gemini 3 Flash (Preview)
- Gemini 3.1 Flash-Lite (Preview)
- Gemini 3.1 Pro (Preview)
- Gemini 3.5 Flash
- Gemini 3.8 Flash
- Gemini 4 Argon
- Gemini 4 Carbon
- Gemini 4 Hydrogen
- GPT 4.1
- GPT 4.1 Mini
- GPT 5
- GPT 5 Mini
- GPT 5 Nano
- GPT 5.1
- GPT 5.2
- GPT 5.3 Codex
- GPT 5.4
- GPT 5.4 Mini
- GPT 5.4 Nano
- GPT 5.5
- GPT 5.6 Luna
- GPT 5.6 Sol
- GPT 5.6 Terra
- GPT 6 Astra
- GPT 6 Luna
- GPT 6 Sol
- GPT 6.1 Sol
- GPT 6.1 Terra
- GPT 6.2 Astra
- GPT 6.2 Sol
- GPT-4o
- GPT-4o Mini
- OpenAI o3
- Retool Mini
- Retool Power
Generate text
You can create original text content using the Generate text action. Provide a prompt with instructions, and the AI model generates text based on your requirements. Use this for content generation, creative writing, code generation, and general-purpose text tasks.
Example: Content generation
Create a query that generates product descriptions:
You are a marketing copywriter. Write engaging, concise product descriptions that highlight key features and benefits.
Write a product description for: {{ productNameInput.value }}
Key features:
{{ productFeaturesTextarea.value }}
The AI model generates marketing copy based on your input. Display the result in a Text component or Rich Text Editor.
Summarize text
You can condense long-form content into concise summaries using the Summarize text action. Provide the text to summarize and optionally specify the desired summary format or length in your prompt.
Example: Customer feedback analysis
Create a query that summarizes customer feedback:
You are a customer insights analyst. Create concise summaries that capture sentiment and key themes.
Summarize this feedback in 2-3 sentences:
{{ feedbackTextarea.value }}
Use with a Textarea component for input and display the summary in a Text component.
Classify text
You can categorize text into predefined categories using the Classify text action. Provide the text to classify and specify the possible categories in your prompt. The model returns which category best matches the input. This is useful for customer support routing, sentiment analysis, and content moderation.
Example: Support ticket routing
Create a query that categorizes support tickets:
Classify support tickets into one of these categories based on the issue described.
Ticket: {{ ticketText.value }}
Categories: Technical Issue, Billing Question, Feature Request, Account Access
The response includes a category property at {{ query.data.category }} with the selected classification. Use this to route tickets automatically.
Extract entity from text
You can extract specific information from unstructured text using the Extract entity from text action. Define what entities or data points to extract in your prompt (names, dates, amounts, email addresses, etc.), and the model returns structured data from the text.
Example: Invoice data extraction
Create a query that extracts structured data from invoices:
Extract information from invoice text and return as JSON with these fields: invoice_number, date, vendor_name, total_amount, line_items.
Extract data from this invoice:
{{ invoiceText.value }}
The response returns structured data at {{ query.data }}. Display results in a Table component or use in subsequent queries.
Chat actions
Generate conversational responses based on message history and context. Build chatbots, virtual assistants, and interactive AI experiences.
| Action | Description |
|---|---|
| Generate chat response | Create contextual responses in multi-turn conversations. The AI model considers previous messages to maintain conversation flow. |
Supported models
Chat actions are available for use with the following AI providers and models.
- Amazon Bedrock
- Anthropic
- Google Vertex AI
- OpenAI
- Retool
- Amazon Bedrock Model
- Claude 4.5 Haiku (Bedrock)
- Claude 4.5 Opus (Bedrock)
- Claude 4.5 Sonnet (Bedrock)
- Claude 4.6 Opus (Bedrock)
- Claude 4.6 Sonnet (Bedrock)
- Claude 4.7 Opus (Bedrock)
- Claude 4.8 Opus (Bedrock)
- Claude Fable 5.1 (Bedrock)
- Claude Fable 5.2 (Bedrock)
- Claude Opus 5 (Bedrock)
- Claude Opus 5.5 (Bedrock)
- Claude Sonnet 5 (Bedrock)
- Claude Sonnet 5.5 (Bedrock)
- Claude Fable 5
- Claude Fable 5.1
- Claude Fable 5.2
- Claude Haiku 4.5
- Claude Opus 4.5
- Claude Opus 4.6
- Claude Opus 4.7
- Claude Opus 4.8
- Claude Opus 5
- Claude Opus 5.5
- Claude Sonnet 4.5
- Claude Sonnet 4.6
- Claude Sonnet 5
- Claude Sonnet 5.5
- Gemini 2.0 Flash
- Gemini 2.5 Flash
- Gemini 2.5 Pro
- Gemini 3 Flash (Preview)
- Gemini 3.1 Flash-Lite (Preview)
- Gemini 3.1 Pro (Preview)
- Gemini 3.5 Flash
- Gemini 3.6 Flash
- Gemini 3.8 Flash
- Gemini 4 Argon
- Gemini 4 Carbon
- Gemini 4 Hydrogen
- Gemini 2.5 Flash
- Gemini 2.5 Pro
- Gemini 3 Flash (Preview)
- Gemini 3.1 Flash-Lite (Preview)
- Gemini 3.1 Pro (Preview)
- Gemini 3.5 Flash
- Gemini 3.8 Flash
- Gemini 4 Argon
- Gemini 4 Carbon
- Gemini 4 Hydrogen
- GPT 4.1
- GPT 4.1 Mini
- GPT 5
- GPT 5 Mini
- GPT 5 Nano
- GPT 5.1
- GPT 5.2
- GPT 5.3 Codex
- GPT 5.4
- GPT 5.4 Mini
- GPT 5.4 Nano
- GPT 5.5
- GPT 5.6 Luna
- GPT 5.6 Sol
- GPT 5.6 Terra
- GPT 6 Astra
- GPT 6 Luna
- GPT 6 Sol
- GPT 6.1 Sol
- GPT 6.1 Terra
- GPT 6.2 Astra
- GPT 6.2 Sol
- GPT-4o
- GPT-4o Mini
- OpenAI o3
- Retool Mini
- Retool Power
Generate chat response
You can create contextual responses in multi-turn conversations using the Generate chat response action. Provide the conversation history as an array of messages, and the AI model generates responses that maintain conversation flow and context.
Example: Customer support chatbot
Use the LLM Chat component to create interactive chat experiences:
- Add an LLM Chat component to your canvas
- A resource query is automatically created with message history configured
- Optionally configure a system message to define the chatbot's behavior:
You are a helpful customer support agent. Answer questions about our products and services. Be friendly and professional.
The component handles message history automatically. Access the full conversation at {{ chat1.messageHistory }}.
For workflows, use a resource query block and provide the conversation history explicitly.