Integration Guides

OpenAI-Compatible API System Prompt: How Backends Handle It

ROIBest AI

How do you set a system prompt on an OpenAI-compatible API?

On any OpenAI-compatible Chat Completions endpoint, the system prompt is the first message in the messages array with "role": "system". The server, not your client, decides what happens to it next: OpenAI's own reasoning models treat it as a developer instruction, Claude's compatibility layer moves it into a top-level system field, and local servers such as vLLM, Ollama or LM Studio pass it through the model's chat template. That last step is where most "my system prompt is ignored" bugs come from.

from openai import OpenAI

client = OpenAI(base_url="https://your-endpoint/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="your-model-id",
    messages=[
        {"role": "system", "content": "You are a support agent. Reply in English, max 80 words."},
        {"role": "user", "content": "How do I reset my password?"},
    ],
)

The rest of this guide explains the three places a system prompt can live, how major backends handle each one, and how to check that yours is actually applied. Behaviour described here was checked against provider documentation on 30 November 2026.

Three ways to send instructions

Method

Where it goes

Supported by

{"role": "system"} message

First item in messages (Chat Completions)

Practically every OpenAI-compatible server

{"role": "developer"} message

Same position; OpenAI's newer name for instructions

OpenAI, and providers that copied it; not all local servers

instructions parameter

Top-level field in the Responses API (POST /v1/responses)

OpenAI and servers that implement the Responses API

Use the system role for portability. It is the one form every compatible server understands. Switch to developer only when a specific OpenAI model requires it, and to instructions only when you are already on the Responses API.

How different backends treat the system prompt

OpenAI

For OpenAI's reasoning models, instructions are meant to be sent as developer messages, and the platform treats system messages as developer messages for those models. Older chat models accept system directly. In practice, sending system works on both; the difference matters mainly when you read OpenAI's docs and see developer in examples.

Claude through the OpenAI SDK

Anthropic's OpenAI SDK compatibility layer hoists all system and developer messages, wherever they appear in the conversation, joins them with a single newline, and sends the result as Claude's top-level system field before every message. Two consequences:

  • A system message inserted in the middle of a chat does not act "from that point on"; it is merged into the opening instructions.
  • Prompt caching and other Claude-only features are not available through this layer, so very long system prompts cost full price on every call. See using the OpenAI SDK with Claude for what else is dropped.

Local servers: vLLM, Ollama, LM Studio, llama.cpp

Local servers turn the messages array into one prompt string using the model's chat template. The system prompt only works if that template has a slot for it.

  • Templates with a system slot (most instruct models today): the system text is placed in its own block, and it behaves as expected.
  • Templates without a system slot: depending on the template, the server merges the system text into the first user turn, drops it, or rejects the request with an error such as "System role not supported". Some templates also require strictly alternating user/assistant turns after the system message.
  • Ollama defaults: a model's Modelfile can define a default SYSTEM prompt. Sending your own system message in the request replaces that default for the call.

If you serve models yourself, our guide to self-hosted OpenAI-compatible APIs covers how vLLM and similar engines load chat templates.

Gateways and proxies

Gateways that translate between providers usually forward system as-is or map it to the target provider's equivalent. Some add their own system text (safety notices, routing hints) in front of yours. If behaviour differs between a gateway and the provider's direct API, compare the raw request in the gateway's logs. Our LLM API gateway article lists what to check.

Five rules for system prompts that survive a provider switch

  1. Send exactly one system message, first. Multiple or mid-conversation system messages are handled differently by each backend.
  2. Keep it a plain string. Some compatible servers do not accept an array of content parts in a system message. Use a string unless you know the server supports parts.
  3. Do not rely on developer outside OpenAI. If a local server returns 400 or seems to ignore it, send the same text as system.
  4. Repeat critical constraints in the user turn for small models. Small open models weight the latest user message heavily; a short reminder such as "answer in JSON" next to the question improves compliance.
  5. Treat the system prompt as tokens you pay for. It is sent on every request. Trim examples you do not need, and use the provider's native caching where available.

How to verify your system prompt is applied

  • Ask a probe question. Put a harmless, checkable rule in the system prompt ("Begin every reply with OK:") and confirm the reply starts with it.
  • Read the token count. usage.prompt_tokens should grow by roughly the length of your system text. If it does not, the server dropped it.
  • Render the template. On vLLM or Hugging Face tooling, apply the chat template to your messages and inspect the final prompt string.
  • Check the role order in errors. A 400 that mentions roles or alternation usually means the template rejected your system message's position.

Troubleshooting

Symptom

Likely cause

Fix

Model ignores the system prompt

Chat template has no system slot, or small model favours user turn

Use an instruct model with a system slot; restate key rules in the user message

400 error mentioning developer

Server does not support the developer role

Send system instead

400 error about roles alternating

Template requires user/assistant alternation

Keep one system message, then strictly alternate turns

Mid-chat system message has no effect

Backend merges all system messages into the opening instructions

Put rules in the first system message or the latest user turn

Behaviour differs via gateway

Gateway adds or rewrites system text

Inspect raw requests; disable gateway prompt injection

For a wider list of fields that "compatible" servers handle differently, see OpenAI compatibility issues.

FAQ

What is the system prompt in an OpenAI-compatible API?

It is a message with "role": "system" placed first in the messages array. It sets instructions, tone and constraints for the whole conversation.

Is developer the same as system?

For OpenAI's newer models they serve the same purpose, and developer is the preferred name. Other compatible servers may not recognise developer, so system is the safer choice.

Can I put a system message in the middle of a conversation?

The API accepts it, but backends differ. Claude's compatibility layer merges it into the opening system field, and many local templates do not support it. Put persistent rules in the first message.

Why does my local model ignore the system prompt?

Usually the model's chat template has no system slot, or the model is too small to follow it reliably. Choose an instruct model whose template supports system messages, and repeat key constraints in the user turn.

Does the system prompt count toward token usage?

Yes. It is part of the input on every request and is billed or counted against the context window like any other input token.

Summary

Send the system prompt as one system message at the start of messages; that works on every OpenAI-compatible server. Remember that each backend transforms it: OpenAI may treat it as developer, Claude hoists it into a top-level field, and local servers depend on the chat template. Verify with a probe rule and the token count, and you will know your instructions are really reaching the model.