---
title: "AI Applications & Agents With Temporal"
description: "Build the most capable AI applications and agents on Temporal's open foundation, powered by durable execution"
canonical: "https://temporal.io/solutions/ai.md"
source: "https://temporal.io/solutions/ai"
---

# Build and run the most capable AI

Orchestrate your workflows, AI apps, and agents across any models, tools, systems, and length of time. Reliably complete complex work at any scale with Durable Execution.

## AI Solutions Coding Agent Prompt

### Coding Agent

```
Install the Temporal CLI and start the dev server in the background.
Set up the hello-world-litellm-python example from github.com/temporalio/ai-cookbook.
Create a .env for my LLM API key and pause for me to fill it in.
Install Python deps with uv, then run the worker in the background and execute the Workflow.
Open localhost:8233 when done.
# Prerequisites: Python 3.10+, uv, LLM provider key
```

### Mac

```
# Install the Temporal CLI 
brew install temporal 

# Start the dev server (runs in this terminal) 
temporal server start-dev 

# In a new terminal: clone and navigate to the example 
git clone https://github.com/temporalio/ai-cookbook.git 
cd ai-cookbook/foundations/hello_world_litellm_python 

# Install dependencies 
uv sync 

# Set your LLM provider key (default model: gemini-2.5-flash-lite) 
export GEMINI_API_KEY=your-key-here 

# Run the worker (runs in this terminal) 
uv run python -m worker 

# In a new terminal: start the workflow 
uv run python -m start_workflow 

# Open the Temporal UI 
open http://localhost:8233
```

### Windows/Linux

```
# Install the Temporal CLI 
curl -sSf https://temporal.download/cli.sh | sh

# Start the dev server (runs in this terminal) 
temporal server start-dev 

# In a new terminal: clone and navigate to the example 
git clone https://github.com/temporalio/ai-cookbook.git 
cd ai-cookbook/foundations/hello_world_litellm_python 

# Install dependencies 
uv sync 

# Set your LLM provider key (default model: gemini-2.5-flash-lite) 
export GEMINI_API_KEY=your-key-here 

# Run the worker (runs in this terminal) 
uv run python -m worker 

# In a new terminal: start the workflow 
uv run python -m start_workflow 

# Open the Temporal UI 
open http://localhost:8233
```

- [Get Started for Free](https://temporal.io/get-cloud)
- [Watch a Demo](#demo)

Logos: Snap, netflix, Cloudflare, Qualtrics, OpenAI, GitLab, Remitly, Coinbase, Brex, Doordash, Deloitte, Bestseller, Retool, Alaska Airlines, datadog, Mythical Games, Lovable AI, Abridge, Hebbia, xy.ai labs

## AI Requires Durable Execution To Run

Every AI team is rebuilding the same abstractions. Long running sessions, state persistence, storage & cost optimization, massive scale, visibility into execution, and resilience to external failures. Temporal handles these for you for one durable runtime.

<div class="grid lg:grid-cols-2 gap-20"><style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'><iframe src='https://www.youtube.com/embed/GEXllEH2XiQ' frameborder='0' allowfullscreen></iframe></div>

<div><h2 class="text s68 none display text-off-white svelte-lrigwr mt-0 md:mt-auto">Powerful Abstractions To Ship Complex AI</h2>

Temporal allows developers to stop building runtime infrastructure and focus on AI business logic with flexibility, reliability, and massive scale built in.

<a role="link" href="https://temporal.io/code-exchange/ai-agent-execution-using-temporal.md" class="button group w-fit primary center ultraviolet svelte-w4bvtf mt-6" disabled="false"><svg width="24" height="24" class="transition-colors group-hover:text-indigo-100" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" data-contentful-entry-id="" data-contentful-field-id=""><path d="M14.1188 3.0675L13.8451 3.9225L8.44509 20.7225L8.17134 21.5775L9.88509 22.1288L10.1588 21.2738L15.5588 4.47375L15.8326 3.61875L14.1188 3.0675ZM16.4288 8.14126L17.0851 8.75625L21.1838 12.6L17.0851 16.4438L16.4288 17.0588L17.6588 18.3713L18.3151 17.7563L23.1151 13.2563L23.8163 12.6L23.1151 11.9438L18.3151 7.44375L17.6588 6.82875L16.4288 8.14126ZM6.34134 6.82875L5.68509 7.44375L0.885088 11.9438L0.183838 12.6L0.885088 13.2563L5.68509 17.7563L6.34134 18.3713L7.57134 17.0588L6.91509 16.4438L2.81634 12.6L6.91509 8.75625L7.57134 8.14126L6.34134 6.82875Z" fill="currentcolor"></path><defs><linearGradient id="mist-066d4613-1d7b-44dd-b675-b369a734a592"><stop offset="0%" stop-color="#34D399"></stop><stop offset="100%" stop-color="#FF6BFF"></stop></linearGradient><linearGradient id="green-gradient-066d4613-1d7b-44dd-b675-b369a734a592"><stop offset="0%" stop-color="#C3FF62"></stop><stop offset="100%" stop-color="#1FF1A5"></stop></linearGradient><linearGradient id="pink-gradient-066d4613-1d7b-44dd-b675-b369a734a592"><stop offset="0%" stop-color="#FF5555"></stop><stop offset="100%" stop-color="#B664FF"></stop></linearGradient><linearGradient id="purple-ultraviolet-gradient-066d4613-1d7b-44dd-b675-b369a734a592"><stop offset="0%" stop-color="#B664FF"></stop><stop offset="100%" stop-color="#444CE7"></stop></linearGradient></defs></svg> View the Project </a>

</div></div>

> We were able to get Retool Agents out in a matter of months and support a really robust experience out the gate with a really small team…It just wouldn’t have been possible without Temporal.
>
> — Lizzie Siegrist, Product Manager, Retool

> We're able to work with the agent again and again. It was really painful to do this without a workflow approach. I think for us, a workflow approach with Temporal was good because in the end, all LLM use cases are workflows.
>
> — Romain Niveau, Senior Engineering Manager, Gorgias

## AI Built On Durable Execution

### Write durable workflows as code

**Workflows-as-code**
Write your AI applications using Temporal's SDKs, which take care of any failure scenario out-of-the-box.

**Orchestration**
Set up workflows to orchestrate interactions across any number of distributed data stores and tools.

**Durable Execution**
Guarantee all executions of all processes run to completion successfully in spite of failures.

### Code for the happy path only

**State handling**
Workflows automatically hold state over long periods of time (even years), so you don’t need state machines.

**Human-in-the-loop**
Easily facilitate human-in-the-loop interactions like validating LLM results or approving agent decisions.

**Self-healing**
Get automatic retries out-of-the-box, and maintain the ability to retry until a probabilistic LLM returns valid data.

### Know what's happening and why

**High scale**
Code parallel tasks and concurrent workflows at incredible scale.

**Easily testable**
Step-debug your AI application’s execution, and test thousands of outcomes using your preferred tools.

**Strong observability**
Inspect and troubleshoot an AI application’s performance, inputs, and outputs from a detailed UI.

## Build On An Open Foundation Of AI Frameworks

Build and monitor with popular agent frameworks and tools. Have an AI tool you're interested in integrating with Temporal? Reach out to [our team](https://temporal.io/partners/ai.md).

- [OpenAI Agents SDK](https://github.com/temporalio/sdk-python/tree/main/temporalio/contrib/openai_agents) — Integration
- [Pydantic AI Temporal Integration](https://ai.pydantic.dev/durable_execution/temporal/) — Integration
- [Trace Temporal Workflows with Langfuse](https://langfuse.com/integrations/frameworks/temporal) — Ecosystem
- [AI SDK by Vercel](https://github.com/temporalio/samples-typescript/tree/main/vercel-ai-sdk) — Integration
- [Braintrust AI Observability](https://www.braintrust.dev/docs/cookbook/recipes/TemporalDeepResearch) — Integration
- [Google ADK](https://adk.dev/integrations/temporal/) — Integration
- [Mastra Agent Framework](https://mastra.ai/guides/deployment/temporal) — Integration
- [Tenuo Integration](https://tenuo.ai/temporal) — Integration
- [Parseable Observability Integration](https://www.parseable.com/docs/ingest-data/ai-agents/temporal) — Integration
- [OpenBox Governance Integration](https://docs.openbox.ai/getting-started/temporal/temporal-101) — Integration
- [Strands Agents Integration](https://docs.temporal.io/develop/python/integrations/strands-agents) — Integration
- [SpringAI Integration](https://docs.temporal.io/develop/java/integrations/spring-ai) — Integration
- [Tuning Engines Integration](https://app.tuningengines.com/docs/orchestration#%E2%80%A6) — Integration
- [xmemory Integration](https://temporal.io/resources/integrations/xmemory-integration.md) — Integration

## AI Cookbook: Hands-on recipes

Step-by-step solutions that show you how to build reliable, production-ready AI systems with Temporal.

### Hello World

Simple example demonstrating how to call an LLM from Temporal using the OpenAI Python API library.

[Learn More](https://docs.temporal.io/ai-cookbook/hello-world-openai-responses-python)

### Basic Agentic Loop with Tool Calling

A basic agentic loop that invokes a dynamic set of tools.

[Learn More](https://docs.temporal.io/ai-cookbook/agentic-loop-tool-call-openai-python)

### Tool calling agent

Build a simple, non-looping agent that gives agency to the LLM to choose tools, and then invokes chosen tools.

[Learn More](https://docs.temporal.io/ai-cookbook/tool-call-openai-python)

## Success story: Replit

Replit migrated their popular coding agent to Temporal to improve reliability and free up time for the Platform team. Temporal orchestrates the Replit Agent control plane layer at massive scale.

[Read the story ›](https://temporal.io/resources/case-studies/replit-uses-temporal-to-power-replit-agent-reliably-at-scale.md)

> Temporal gives us a lot more confidence to build the product and know that it's not going to have lots of edge cases that lead to bad user experiences.
>
> — Connor Brewster, Lead Engineer, Replit

## Temporal use cases in AI

Improve the reliability and development speed of critical AI applications.

### Agents

Orchestrate reliable, long-running, and human-in-the-loop agents. Protect against hallucinations and rate limiting. Scale to millions of agents.

[Learn more](https://temporal.io/ai/agentic-ai.md)

### MCP

Write Durable Tools with Temporal to improve reliability and context awareness. Make reliable long-running calls.

### Inference & RAG

Orchestrate reliable interactions across LLMs and gather data across multiple datastores. Easily schedule document ingestion.

### Context engineering

Orchestrate reliable data engineering pipelines to ensure your agents have the necessary information to create context for making the right decisions.

## Learn more about Temporal for AI

- [Replit uses Temporal to power Replit Agent reliably at scale](https://temporal.io/resources/case-studies/replit-uses-temporal-to-power-replit-agent-reliably-at-scale.md) — Case Study
- [Deep Dive: Beyond Chatbots with Durable MCP](https://pages.temporal.io/webinar-beyond-chatbots-with-durable-mcp.html) — Webinar
- [Learn How to Build AI Agents with Temporal](https://pages.temporal.io/webinar-how-to-build-AI-agents-with-temporal-2025-04-07-on-demand.html) — Webinar
- [Deep-Dive: AI Agent Code Walkthrough with Temporal](https://pages.temporal.io/temporal-ai-agent-live-coding-webinar.html) — Webinar
- [Production-ready agents with the OpenAI Agents SDK + Temporal](https://temporal.io/blog/announcing-openai-agents-sdk-integration.md) — Blog Post
- [How Retool built robust Workflow and Agents products on Temporal](https://temporal.io/resources/case-studies/how-retool-built-robust-workflow-agents-products.md) — Case Study

## Get started today

- [Get Started for Free](https://temporal.io/get-cloud)
- [Talk to an Expert](https://temporal.io/pages/ask-an-expert.md)
