🤖 AI Prompt Builder
Build and format AI prompts with variables, templates, and API-specific output for OpenAI, Anthropic, and Google Gemini
About this tool
Writing prompts for different AI providers means dealing with different JSON schemas — OpenAI expects messages with roles, Anthropic separates system from messages, and Gemini uses contents with parts. This tool lets you write a single template with {{double-brace variables}}, fill in the values, and get the correctly-formatted API request body for your chosen provider.
Example: a template like Write a {{tone}} summary of {{article}} with tone=concise and article=quantum computing produces Write a concise summary of quantum computing, then wraps it in the OpenAI Chat, Anthropic Messages, or Gemini format ready to paste into your code.
The token counter gives a rough estimate (approximately 4 characters per token for English text) — useful for staying within model context limits and estimating API costs.
FAQ
How accurate is the token counter? ›
The counter uses a rough heuristic of 4 characters per token, which works well for English prose. For exact token counts, use the provider official tokenizer (tiktoken for OpenAI, claude-tokenizer for Anthropic). The estimate is typically within 10-20% of the real count for English text and is useful for budget planning and context window checks.
Can I use nested variables or conditional logic? ›
This tool supports simple text variables with the {{name}} syntax. For advanced templating with conditionals and loops (like Handlebars or Jinja), you would need a full template engine. Most AI prompt use cases are well served by simple variable substitution — the complexity lives in the prompt instructions, not the template logic.
Why does the output format differ between providers? ›
Each AI provider has its own API schema. OpenAI uses an array of message objects with role/content pairs; Anthropic separates the system prompt into its own top-level field; Gemini nests content inside parts arrays within contents. This tool handles the structural differences so your filled template always produces valid API JSON for the selected provider.
What is the system prompt field for? ›
A system prompt sets the assistant behavior, tone, and constraints (e.g. "You are a JSON-only API" or "Answer in Spanish"). In OpenAI it becomes a message with role "system"; in Anthropic it goes into the top-level system field; in Gemini it becomes system_instruction. Leave it empty if you only need user messages.