How to Convert Prompt Templates Between AI Providers
The core content of a well-written prompt — the instructions, examples, and constraints — is portable across providers. The structure isn't. Converting a prompt template means changing the JSON wrapper while preserving the instructions inside it.
What changes between providers
Three things change across providers:
1. System prompt placement. OpenAI puts it as a {"role": "system"} message in the messages array. Anthropic uses a top-level system parameter. Gemini uses system_instruction. Converting between these is the most structural change.
2. Role names. OpenAI and Ollama use user and assistant. Gemini uses user and model. Anthropic uses user and assistant.
3. Content structure. OpenAI and Anthropic accept content as a plain string: "content": "text". Gemini requires a parts array: "parts": [{"text": "text"}].
OpenAI to Anthropic conversion
Steps: (1) Extract any {"role": "system"} message and move its content to the top-level system field. (2) Remove the system message from the messages array. (3) Replace the model name. The content structure is the same for both providers.
OpenAI to Gemini conversion
Steps: (1) Extract system messages to system_instruction.parts[0].text. (2) Rename assistant roles to model. (3) Wrap each content string in a parts array: {"parts": [{"text": content}]}. (4) Rename messages to contents.
Testing after conversion
After converting, test with the same set of inputs you used during development. The structural change shouldn't affect output — but models have different defaults and may require minor prompt adjustments to produce equivalent output. If output quality drops, check whether system instructions are being applied (try re-stating key constraints in the first user message if they're not).