---
title: "AI Agent Code Execution API"
description: "Replit offers sandboxed code execution so LLM agents can run untrusted generated code, contrasting a stateless model (like Bard's implicit code execution for math) with a stateful, session-long project environment (like ChatGPT)."
url: "https://swe.quest/articles/ai-agent-code-execution-api-8f63888d403b81a8"
canonical: "https://replit.com/blog/ai-agents-code-execution"
source: "Replit"
published: "2023-09-19"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 4
tags: ["ai-agents","sandboxing","llms","serverless","python"]
---

# AI Agent Code Execution API

A post on [Replit](https://swe.quest/sources/replit.md), published 2023-09-19, 4 min read, Announcement. Original: [https://replit.com/blog/ai-agents-code-execution](https://replit.com/blog/ai-agents-code-execution)

## Summary

Replit offers sandboxed code execution so LLM agents can run untrusted generated code, contrasting a stateless model (like Bard's implicit code execution for math) with a stateful, session-long project environment (like ChatGPT). The stateless option is a forkable API server on Replit Autoscale Deployments, using the omegajail unprivileged container sandbox with a customizable Docker image, handling requests in as little as 100ms and integrating with OpenAI function calling via the replit-code-exec package. A stateful prototype using a full Repl as sandbox was tried and then discontinued, with code-exec recommended for most use cases.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Sandboxing & isolation](https://swe.quest/tags/sandboxing.md) (Security)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- OpenAI function calling
- Docker images ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))

## Keywords

Replit, replit-code-exec, omegajail, Replit Autoscale Deployments, OpenAI function calling, GPT-4, open-interpreter

## Related posts

- [Building Ghostwriter Chat](https://swe.quest/articles/building-ghostwriter-chat-cdc3d6aa03870bc4.md): Replit · 2023-03-27 · Easy · 5 min read · AI for coding, LLMs, Developer tools
  Ghostwriter Chat embeds an LLM-powered assistant directly in the Replit IDE, using file context, chat history and program output so users never copy-paste into a separate tool.
- [Build Your Own AI-Driven Code Analysis Chatbot for Developers with the GenAI Stack](https://swe.quest/articles/build-your-own-ai-driven-code-analysis-chatbot-for-developers-with-the-genai-062f35bb279ec41b.md): Docker · 2024-06-06 · Medium · 10 min read · RAG & retrieval, LLMs, AI for coding, Containers, Python
  Code Explorer, a winning Docker AI/ML Hackathon project, is a RAG chatbot that answers questions about a local codebase by parsing source files, chunking them with LangChain's RecursiveCharacterTextSplitter (5000 characters with 500 overlap), and storing embeddings in a Neo4j vector store.
- [Ghostwriter AI & Complete Code Beta](https://swe.quest/articles/ghostwriter-ai-complete-code-beta-eb4c500f5fc252eb.md): Replit · 2022-09-08 · Medium · 9 min read · AI for coding, Inference & serving, LLMs, Developer tools
  Replit's Ghostwriter adds AI code completion, generation, transformation, explanation and semantic search to its IDE, with Complete Code starting in closed beta.
- [ToolGrad: Efficient tool-use dataset generation with textual "gradients"](https://swe.quest/articles/toolgrad-efficient-tool-use-dataset-generation-with-textual-gradients-6d6804c563cc5125.md): Google Research · 2026-09-10 · Hard · 6 min read · Model training, AI agents, LLMs, Evaluation
  ToolGrad generates synthetic tool-use training data answer-first: it builds a verified API chain iteratively, then has an LLM write the matching user query, instead of inventing a query and searching for a solution with a DFS agent as ToolBench and ToolACE do.
- [Run Claude Code Locally with Docker Model Runner](https://swe.quest/articles/run-claude-code-locally-with-docker-model-runner-73b35fcd9b678964.md): Docker · 2026-01-26 · Medium · 4 min read · AI for coding, Inference & serving, LLMs, Developer tools
  Claude Code can run against local models by pointing its ANTHROPIC\_BASE\_URL environment variable at Docker Model Runner, which exposes an Anthropic-compatible API on localhost:12434.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
