o3-mini does not format text using the API. Formulas and code come without formatting in the form of text and it is impossible to work with it.
I mean, I expect latex for formulas and ``` for code.
Hi @rus1243mor and welcome to the community!
Have you tried specifying that you would like code formatting in your prompt? According to the docs:
âŚinclude the string
Formatting re-enabled
on the first line of yourdeveloper
message.
can you please tell me if this code is correct or better in another way?
âmessagesâ => [
[
âroleâ => âsystemâ,
âcontentâ => âAnswer in markdown, latex, etc. format. Use headings (#, *, `, ``, ```, $, etc.), frame code blocks with quotation marks, etc., where necessary.â
],
[
âroleâ => âuserâ,
âcontentâ => $prompt
],
],
As the link states, just add âFormatting re-enabledâ as the very first thing in your prompt. And then follow that up with the rest of your prompt.
The solution is to add the phrase âFormatting re-enabledâ before the query for Models (o1 and o3):
$history[] = [
'role' => 'user',
// 'content' => $prompt_query, // Do not use this
'content' => "Formatting re-enabled " . $prompt_query,
];
Are you sure? Maybe:
'messages' => [
[
"role" => "system", // developer ???
"content" => "Formatting re-enabled"
],
[
"role" => "user",
"content" => $prompt
],
],
Yes, in the developer role. Here is a quick example I just tried out:
curl "https://api.openai.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "o3-mini-2025-01-31",
"messages": [
{
"role": "developer",
"content": "Formatting re-enabled"
},
{
"role": "user",
"content": "Output Python code that sorts an array of integers."
}
]
}'
On the output I get:
```python
def main():
....
Still, this instruction is not enough for formulas, for example. I expanded it a bit.:
âFormatting re-enabled. Answer in latex if it is a formula, in markdown if it is a code: #, *, backticks, $, etc. Use headings, frame code blocks with quotation marks, etc., where necessary.â
suuure
The code you mentioned is not working. My code is working fine. They also mentioned this sentence in the documentation as the very first thing in your prompt.
also this not working for me
"messages": [
{
"role": "developer",
"content": "Formatting re-enabled"
},
{
"role": "user",
"content": "Output Python code that sorts an array of integers."
}
]
Also, I couldnât find any documentation mentioning the âroleâ: âdeveloperâ. I donât believe there is a role named âdeveloperâ.
Great! Did it work ok for you with your expanded prompt for latex?
Yes, latex formulas are unformatted, as I wanted.