Resolving the "LLM route only supports llm chat type requests" error

TL;DR

How do I resolve the “LLM route only supports llm chat type requests” error?

Add the required Content-Type: application/json header so that Kong Gateway can correctly interpret the payload format.

Sending the correct Content-Type header

This error occurs when sending an incorrect content-type header to Kong Gateway. Some utilities, such as curl, default to using Content-Type: application/x-www-form-urlencoded. To address the issue, ensure you are sending the header as Content-Type: application/json.

curl -X POST https://mygateway/api/v1 \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "Why is the sky blue?"
      }
    ]
  }'

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!