Skip to main content
Directus includes built-in AI integration capabilities, allowing you to leverage large language models from multiple providers for content generation, data processing, and intelligent automation.

Supported AI Providers

Directus supports the following AI providers out of the box:
  • OpenAI - GPT-4, GPT-5 series models
  • Anthropic - Claude models (Haiku, Sonnet, Opus)
  • Google - Gemini models
  • OpenAI-Compatible - Custom endpoints compatible with OpenAI API

Configuration

OpenAI

Anthropic

Google

OpenAI-Compatible Provider

Available Models

Directus includes definitions for popular AI models with their capabilities and pricing:

OpenAI Models

  • gpt-4o-mini - Fast, cost-effective (128k context)
  • gpt-4.1-nano - Entry-level GPT-4.1 (1M context)
  • gpt-4.1-mini - Balanced GPT-4.1 (1M context)
  • gpt-4.1 - Full GPT-4.1 (1M context)
  • gpt-5-nano - Entry-level GPT-5 with reasoning (400k context)
  • gpt-5-mini - Balanced GPT-5 with reasoning (400k context)
  • gpt-5 - Standard GPT-5 with reasoning (400k context)
  • gpt-5.2 - Latest GPT-5 with reasoning (400k context)
  • gpt-5.2-pro - Premium GPT-5 with reasoning (400k context)

Anthropic Models

  • claude-haiku-4-5 - Fast, cost-effective (200k context)
  • claude-sonnet-4-5 - Balanced with reasoning (200k context)
  • claude-opus-4-5 - Most capable with reasoning (200k context)

Google Models

  • gemini-2.5-flash - Fast, cost-effective (1M context)
  • gemini-2.5-pro - Balanced (1M context)
  • gemini-3-flash-preview - Next-gen flash (1M context)
  • gemini-3-pro-preview - Next-gen pro (1M context)

Model Capabilities

Each model definition includes:
Example:

Using AI in Flows

AI can be integrated into flows for automated content processing:

AI Operation Example

AI Tools

Directus AI supports tool calling for structured outputs:

Available System Tools

  • items - Read/write collection items
  • files - Access file metadata
  • folders - Manage file folders
  • assets - Work with uploaded assets
  • flows - Interact with flows
  • trigger-flow - Execute flows
  • operations - Flow operations
  • schema - Database schema info
  • collections - Collection metadata
  • fields - Field definitions
  • relations - Relationship metadata

Tool Approval Modes

  • always - AI can use tools without confirmation
  • ask - Require user approval before tool execution
  • disabled - Tools not available to AI

File Attachments

Models with attachment: true support image and file inputs:

Reasoning Models

Models with reasoning: true support chain-of-thought:
Reasoning models:
  • Think step-by-step before responding
  • Provide explanation of their reasoning
  • Better at complex analysis and problem-solving
  • Higher cost and latency

Context Management

Context Limits

Each model has a maximum context window:

Prompt Optimization

Cost Tracking

Track AI usage and costs:

Custom Models

Define custom models for OpenAI-compatible APIs:

Streaming Responses

Stream AI responses for better UX:

Error Handling

Best Practices

Use faster, cheaper models (mini/nano) for simple tasks. Reserve premium models (opus/pro) for complex reasoning.
Keep prompts concise and only include necessary context to reduce costs and latency.
Set up rate limits to prevent runaway API costs from automated flows.
Cache frequently requested AI generations to reduce API calls.
Track token usage and costs, especially in production environments.