Compatible Open AI 406 error

Hello,

I am using OpenAI-compatible API with the endpoint set to [LocalUrl]/v1. My application is running and connecting to Ollama, and it can successfully receive requests from Mattermost. However, I am not receiving the expected response back.

The backend server sends the following response:

{ "id": "bbf9c726-fa1a-4fdf-9320-be7c37ed2e09", "object": "chat.completion", "created": 1755133389, "model": "llama3.1", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! This is a test" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 100, "completion_tokens": 1000, "total_tokens": 1100 } }

However, I am encountering the following error message:

{ "caller": "app/plugin_api.go:980", "error": "error, status code: 406, message: invalid character ‘<’ looking for beginning of value", "level": "error", "msg": "Streaming result to post failed partway", "plugin_id": "mattermost-ai", "timestamp": "2025-08-13 21:02:31.253 -04:00" }

Can someone help me understand why the response is not being processed correctly and explain what this error message indicates?

Hi,

I looked at the error and found the issue. Here’s what’s happening in simple terms:

The problem is with your system is expecting to receive data in JSON format (like a text message), but instead it’s getting HTML (like a webpage). That’s why it’s confused and showing the error.

Do these quick fixes and then let me know

  1. First, test if Ollama is working properly then do Open your browser and go to: [LocalUrl]/v1/models. . than you should see a list of models in text format

  2. If that doesn’t work then restart your Ollama service. Make sure it’s running on the correct port.

  3. Check your Mattermost settings and after that Go to the AI plugin settings. Along with that verify the API URL is exactly: [LocalUrl]/v1. Make sure there are no extra characters or spaces

  4. If still having issues then try changing the endpoint to: [LocalUrl]/api/chat.Some Ollama versions use different paths

This should resolve the connection issue. Let me know if you need help with any of these steps!