ROCm / ROCm/FastFlowLM

Feature Request: response_format: {"type": "json_object"} support

Open
#554 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.9k
Forks
152
Avg merge
4h 14m
Merged PRs (30d)
11

Description

Description

The OpenAI-compatible /v1/chat/completions endpoint accepts response_format but silently ignores it. There is no error, no warning, and no effect on output — the model returns plain text regardless of the value passed.

Reproduction

Request:

curl -s http://localhost:52625/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemma4-it:e4b",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant that always responds in valid JSON format."},
      {"role": "user", "content": "List 3 programming languages with their type system and year created. Return as a JSON object with a \"languages\" array."}
    ],
    "max_tokens": 300,
    "response_format": {"type": "json_object"}
  }'
Actual response (content):
{
  "languages": 
    {
      "name": "Java",
      "type": "static",
      "year": 1995
    },
    ...
 
}
This JSON object contains a list of...

Expected:

Raw valid JSON, parseable without post-processing (matching OpenAI API behavior when response_format: {"type": "json_object"} is set).

Tests performed

Tests performed :

| response_format value | Result |
| {"type": "json_object"} | ❌ Ignored — markdown-wrapped output|
| {"type": "text"} |❌ Ignored — same behavior as default|
Not set (default) | Same output as above
Passing an unrecognized value also produces no error — the parameter appears to be completely ignored server-side.

Expected behavior

  1. response_format: {"type": "json_object"} should force the model to output valid JSON (no markdown fences, no conversational wrapper).
  2. Invalid/unrecognized response_format values should return a 400 error rather than being silently ignored.
  3. (Optional) Support {"type": "json_schema", "json_schema": {...}} for schema-constrained output, matching the OpenAI Structured Outputs API (https://platform.openai.com/docs/guides/structured-outputs).

Why this matters

  • OpenAI API compatibility: response_format is a core parameter of the OpenAI Chat Completions API. Clients (OpenAI SDK, LangChain, etc.) rely on it for structured parsing.
  • Downstream usage: Any pipeline that expects parseable JSON from the response (tool calling, RAG, data extraction) currently has to implement ad-hoc post-processing (strip code fences, regex-extract JSON blocks), which is fragile and model-dependent.
  • Competitors: llama.cpp (GBNF grammars), Ollama ("format": "json"), vLLM, and LM Studio all support this.

Environment

  • FLM version: v0.9.42
  • Model tested: gemma4-it:e4b
  • OS: Linux
  • Endpoint: POST /v1/chat/completions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the POST /v1/chat/completions endpoint and trace how response_format is parsed or passed into generation; the issue does not name source files or tests. Reproduce the supplied curl request, then verify that json_object returns raw valid JSON and invalid values return HTTP 400, with tests covering the supported formats.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.