mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

Error 400 'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.

Open rezadev8 opened this issue 2 months ago • 6 comments

🐛 Describe the bug

I got this error :

BadRequestError: 400 'messages' must contain the word 'json' in some form, to use 'response_format' of type 'json_object'.

When i tried to set my own customPrompt.

using typescript.

mem0ai:2.1.38

rezadev8 avatar Oct 09 '25 20:10 rezadev8

Hi @rezadev8 can you describe the problem in details or can you share me how to reproduce this error in details

ron-42 avatar Oct 13 '25 14:10 ron-42

Hey @rezadev8 really sorry for the trouble caused. Can you share code snippet to help you better? Thanks.

parshvadaftari avatar Oct 13 '25 15:10 parshvadaftari

Hi @ron-42 & @parshvadaftari This is my code in TS :

const memory = new Memory({
      llm: {
        provider: 'openai',
        config: {
          apiKey: process.env.OPENAI_API_KEY,
          model: 'gpt-5-nano',
        },
      },
      embedder: {
        provider: 'ollama',
        config: {
          apiKey: 'ollama',
          model: 'my_model',
          url: 'http://localhost:11434',
        },
      },
      vectorStore: {
        provider: 'memory',
        config: {
          collectionName: 'memories',
          dimension: 768,
        },
      },
      historyStore: {
        provider: 'supabase',
        config: {
          supabaseUrl: 'my_url',
          supabaseKey:'my_key',
          tableName: 'memory_history',
        },
      }
    });

This config is works for me . but when I tryed to set customPrompt: 'my prompt' , I got the error I mentioned in the message above.

rezadev8 avatar Oct 13 '25 15:10 rezadev8

Hey @rezadev8 thank you for the response, will be fixing it with new release. Meanwhile you can try adding "json" or "return in json" keyword in the customPrompt which will fix this issue you're facing.

parshvadaftari avatar Oct 14 '25 13:10 parshvadaftari

@parshvadaftari , Is this issue still open, or has it been resolved?

ParagGhatage avatar Nov 12 '25 21:11 ParagGhatage

@parshvadaftari, I think based on @vedant381 commit, this issue should be fixed. Please check and verify.

shubham2345 avatar Nov 13 '25 07:11 shubham2345