Fix/1758 OpenAI pro responses api
Summary
OpenAI serves the *-pro models only over /v1/responses. Embabel routed them to /v1/chat/completions, so every call returned HTTP 400. No test ever called them, so the build stayed green.
Spring AI has no client for that endpoint (spring-projects/spring-ai#2962, milestone 2.1.x), so this adds an adapter. Fixing the transport surfaced three defects on the same path, all included here.
Fixes #1758
1. Responses API transport
OpenAiResponsesChatModel adapts the OpenAI SDK to Spring AI's ChatModel. Single request/response only: Embabel drives its own tool loop, so background mode, server-side conversation state and remote MCP stay unused. Non-streaming.
The two APIs differ on most of what matters:
| Chat Completions | Responses |
|---|---|
system role message |
instructions field |
response_format.json_schema |
text.format, schema must be named |
tools[].function |
flat FunctionTool |
max_tokens |
max_output_tokens, which reasoning tokens also consume |
finish_reason |
status + incomplete_details.reason |
Transport is declared per model, defaulting to CHAT_COMPLETIONS so existing catalogs keep working:
- name: "gpt5pro"
model_id: "gpt-5-pro"
api_format: "RESPONSES"
Declared, not inferred from the id. GPT-5.6 dropped the -pro suffix one release later: its tiers are Luna/Terra/Sol, and "pro" became a reasoning mode.
2. GPT-5 takes a token limit and nothing else
max_tokens is rejected for its presence alone:
400 Unsupported parameter: 'max_tokens' is not supported with this model.
Use 'max_completion_tokens' instead.
Same for top_p, presence_penalty and frequency_penalty. The converter now sends max_completion_tokens and no sampling parameter at all, warning on whatever it drops.
The refusal is per model, verified live on 2026-08-05: gpt-5, gpt-5-mini, gpt-5-nano, gpt-5.3-chat, gpt-5.5 and the gpt-5.6 tiers refuse all four; gpt-5.1, gpt-5.2 and the gpt-5.4 tiers accept them. Sending none to any keeps a single converter for the family.
StandardOpenAiOptionsConverter is untouched: GPT-4 and OpenAI-compatible providers still get everything, max_tokens included.
Side effect fixed: gen_ai.request.max_tokens had disappeared from traces for the whole GPT-5 family, since ChatModelObservationFilter reads getMaxTokens(). It now falls back to maxCompletionTokens.
3. Failures that looked like success
The Responses API reports refusals, failures and truncation inside a 200. Read only output and a refused call is indistinguishable from a model with nothing to say.
Now raised as NonTransientAiException, which SpringAiRetryPolicy reads to skip a pointless retry:
status: failedandstatus: cancelled- a
refusalcontent part, which arrives ascompletedwith no output text
Truncation is kept rather than raised: status: incomplete returns its partial text with length or content_filter as the finish reason.
4. Dependency alignment
spring-ai-openai 2.0.0 moved openai-java-core to 4.39.1 while the parent BOM still manages openai-java at 4.36.0, putting two releases of one SDK on the classpath. Managed at 4.39.1 in the root pom, to be dropped once the BOM catches up.
5. Catalog: GPT-5.5 and GPT-5.6
The catalog stopped at GPT-5.4. Verified against developers.openai.com on 2026-08-04:
| model | transport | input /1M | output /1M |
|---|---|---|---|
gpt-5.6-sol |
Chat Completions | $5.00 | $30.00 |
gpt-5.6-terra |
Chat Completions | $2.00 | $12.00 |
gpt-5.6-luna |
Chat Completions | $0.20 | $1.20 |
gpt-5.5 |
Chat Completions | $5.00 | $30.00 |
gpt-5.5-pro |
Responses | $30.00 | $180.00 |
gpt-5.5-pro lists Chat Completions as "Not supported": a model released after the fix was written, landing in exactly the case it handles.
Testing
Unit tests cover the adapter's mapping in both directions, catalog parsing, and transport routing through the real bean-registration path. No Spring context, no network.
Integration tests hit the live API, gated on OPENAI_API_KEY and skipped when the project is not entitled to a model:
OpenAiCatalogIT: oneGET /v1/modelsvalidates every catalog id; the five new models each answer over the transport they declare.OpenAiResponsesAdapterIT: structured output and tool calling, the two paths a mocked SDK cannot check.Gpt5SamplingParamsITandGpt5MaxTokensIT: which parameters each model accepts. This is how the per-model split above was established rather than assumed.
All green, including gpt-5.5-pro over Responses. These are excluded from mvn test by the parent POM's **/*IT.java rule and do not run in CI without a key.
Known limitations
- No streaming.
stream()throwsUnsupportedOperationException, which is how the capability is reported absent. - No media. An image-bearing prompt is refused rather than sent as text alone.
- GPT-5.6 long-context pricing is not represented.
PerTokenPricingModelholds one price pair, so cost under-reports very large prompts. reasoning.mode: prois not wired through. Different axis fromapi_format, out of scope here.
Noted, not fixed
A pro model on a two-turn tool loop exceeds the 60s default LLM timeout (108s observed). It then succeeds only on retry, which replays the whole loop: tools called twice, reasoning billed twice. Worked around in the integration test; the default deserves its own issue.
Related PR: #1852
Related PR: #1852
@igordayen Thnaks for the review
Different axes. #1852 fixes #1724, which parameters go into the request. This PR fixes #1758, which endpoint it goes to. gpt-5-pro answers "This model is only supported in v1/responses" whatever parameters you send, so no parameter handling can reach it. The fix is a second transport plus an api_format field to route to it.
Kept deliberately small: 215 added / 22 removed lines across 6 existing files. The rest of src/main is one self-contained new file, reached from a single call site. No new abstraction, no SPI change.
Larger work left to the PR that owns it. The generic capability mechanism belongs in #1585, so none of #1852's files are touched (InstrumentedChatModel.kt, SpringAiLlmMessageSender.kt, UnsupportedRequestParameterRetry.kt), and supports_temperature is unchanged on every pre-existing model.
One point of contact. I stopped sending topP, presencePenalty and frequencyPenalty in Gpt5ChatOptionsConverter. On the default path nothing changes on the wire: LlmOptions defaults all four to null and Spring AI never serialised them. Only an explicit caller differs, and that case is #1724's: #1852 fails fast where I drop and warn. That decision belongs to #1852, not to this PR - I can remove those three lines if you prefer, which makes this PR smaller still.
max_tokens to max_completion_tokens is the one thing I'd keep either way: different error, not a sampling parameter, not covered by #1852.
@azanux thanks for reviewing my review:)
Would be good to have consistency on the LLMOption request basis. Either an exception (fail fast ) or a warning.
Please mark inquiries as "resolved" - thank you
@azanux thanks for reviewing my review:)
Would be good to have consistency on the LLMOption request basis. Either an exception (fail fast ) or a warning.
Please mark inquiries as "resolved" - thank you
@igordayen understood.
If top_p - fail fast vs warning (It's just a temporary trade-off)- is the only blocker here, I'd rather keep and validate this PR for the response fix and let the deeper work happen in #1852, which is still under review.
It reaches beyond OpenAI (InstrumentedChatModel and SpringAiLlmMessageSender sit in embabel-agent-api, on the path shared by every provider), so that's the right place to settle the parameter-handling strategy once and apply it consistently everywhere. Whichever lands first, the other rebases.
What do you think ? do you have other idea