Vibe Coding with Replit -- May 14, 2026

How to Use Replit to Build a Tool That Calls an AI API

By Arjita SethiMay 14, 20265 min read
Direct Answer

Build an AI-powered tool in Replit by asking Claude to write a backend route that calls your chosen AI API (Anthropic, OpenAI, etc.) with a system prompt and user input, and returns the AI-generated response to your frontend. Store your AI API key in Replit Secrets. The typical pattern: user submits a form, your Express backend calls the AI API with the user's input, and displays the AI-generated response on the result page.

What an AI-Powered Tool Does

An AI-powered tool takes input from a user, sends it to an AI API along with a system prompt that defines what the AI should do with it, receives the AI-generated response, and displays or uses that response. The AI API does the intelligence work. Your Replit app is the interface that connects the user to the AI.

Examples: a tool that takes a meeting transcript and returns action items, a tool that takes a job description and generates tailored interview prep, a tool that takes a product description and generates a sales page, a tool that takes a URL and returns a summary.

The key design decision: what is your system prompt? The system prompt defines what the AI does with the user's input. A well-designed system prompt produces consistent, useful output. A vague system prompt produces variable results. Spend more time on the system prompt than on any other part of the tool.

The Build Prompt for Claude

"Build an AI-powered tool in my Replit Express app. The tool should: show a form at / with a text input called [input_name] and a submit button. When submitted, POST to /api/generate. The /api/generate route should call the Anthropic API using my API key stored in process.env.ANTHROPIC_API_KEY with this system prompt: [your system prompt]. Pass the user's input as the user message. Return the AI response as JSON. Display the response on a /result page."

Frequently Asked Questions

How do I build a tool that calls an AI API in Replit?
Ask Claude to write a backend route that calls your chosen AI API with a system prompt and user input. Store the API key in Replit Secrets. The route receives user input, calls the API, and returns the AI-generated response.
Which AI API should I use in my Replit tool?
Anthropic (Claude) for nuanced writing, analysis, and complex reasoning. OpenAI (GPT) for the largest plugin ecosystem. Choose based on the specific task your tool performs.
What is a system prompt for an AI-powered tool?
A system prompt is the instruction that tells the AI what to do with the user's input. For a meeting summary tool: "You receive meeting transcripts. Extract action items, key decisions, and follow-ups in a structured list." The system prompt defines the tool's behavior.
How much do AI API calls cost?
Claude and GPT charge per token (roughly per word). For most small tools, the cost is very low -- a few cents per request at typical usage volumes. Check current Anthropic and OpenAI pricing for specific models.
Can I build a tool that combines AI generation with database storage?
Yes -- this is the most useful pattern. AI generates content, the database stores the result, and the user can access their previous results. Ask Claude to add both components.
Build With AI

Build AI-Powered Tools

Channel 1 at Build with AI covers building real AI tools from scratch.

Join Channel 1