Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kommerzienrat
Copy link

@kommerzienrat kommerzienrat commented Dec 13, 2025

  • Added support for OpenAI Responses API in OpenAiHandler, including handling of base URLs and API modes.
  • Introduced utility functions for URL normalization and Azure host detection.
  • Created a new module for handling Responses API requests and streaming responses.
  • Updated OpenAI settings UI to allow users to select between Completions and Responses API modes.
  • Added tests for URL utilities and Responses API functionality.
  • Enhanced error handling for OpenAI API interactions.

Context

It was not possible to use the latest OpenAI (compatible) models no more, e.g. GPT-5.1-codex-max, since the Responses API was not implemented in KiloCode.
Until recently, the Chat Completions API worked, but now throws a 400 error: "The chatCompletion operation does not work with the specified model". Turns out, these new Codex models (GA since Nov 13) only support the Responses API (/openai/v1/responses) now – chat fallback is gone.

Fixes #4364

Implementation

I rewrote all files related to OpenAI and OpenAI compatible calls. We now have an option to select whether the Chat Completions API or Responses API should be chosen for model calls. Since Azure and others started to save model outputs but allow us to disable this "feature", I added a checkbox for output storage. I also added tests and tried make the app more robust.

Here a generated summary:
StaticSettingsService.ts: Hardened static settings parsing—now decodes base64, JSON-parses with safeParse, funnels all failures through logAndThrow, and distinguishes Zod schema errors. This prevents silent misconfigurations and returns clearer errors.
provider-settings.ts: Added schema fields for selecting OpenAI API style (openAiApiMode) and Responses routing (openAiResponsesMode, openAiResponsesStoreEnabled). Required to validate the new UI/handler options.
openai-url-utils.ts (new): Added URL helpers to enforce https, detect Azure hosts, normalize Responses API base URLs (strip /responses, ensure /openai/v1//v1, drop api-version), and extract hosts. Supports correct client construction for Responses mode.
openai-url-utils.spec.ts (new): Covers ensureHttps, host detection, and normalization for Azure/generic providers, including query handling—guards against regressions in URL shaping.
openai-responses-adapter.ts (new): New adapter to decide Responses eligibility, build request bodies from Anthropic-style messages, stream Responses events into ApiStream, normalize usage, and run non-streaming completions. Enables Responses API integration without touching core handler logic.
openai-responses-mode.spec.ts (new): Tests OpenAiHandler decisions for streaming/non-streaming, ensuring Responses mode only triggers when configured, uses the correct client, and propagates store flag.
base-openai-compatible-provider.ts: Introduced Responses support for compatible providers—stores capability/mode flags, decides per-call whether Responses is required, builds Responses request bodies, and streams/completes via the new adapter while preserving legacy completions paths.
openai.ts: Major wiring for Responses API: normalizes base URLs, creates a dedicated Responses client without Azure api-version, computes effective mode (completions vs responses), routes to Responses adapter when needed (including store/max-tokens handling), and keeps Azure-specific query params off Responses calls. Maintains legacy completions behavior otherwise.
OpenAICompatible.tsx: Settings UI now lets users choose API style (Completions vs Responses), toggle Responses store, and auto-disables Azure api-version when Responses is selected; Azure api-version input is gated to Completions mode. Exposes the new settings to match backend expectations.

Screenshots

before after

|
grafik
|
grafik
|

How to Test

Add a recent OpenAI model like GPT-5.1-codex-max. It wouldn't work without this pull request!
Set the provider api style to responses and have fun using the most recent LLMs!

- Added support for OpenAI Responses API in OpenAiHandler, including handling of base URLs and API modes.
- Introduced utility functions for URL normalization and Azure host detection.
- Created a new module for handling Responses API requests and streaming responses.
- Updated OpenAI settings UI to allow users to select between Completions and Responses API modes.
- Added tests for URL utilities and Responses API functionality.
- Enhanced error handling for OpenAI API interactions.
@changeset-bot
Copy link

changeset-bot bot commented Dec 13, 2025

🦋 Changeset detected

Latest commit: 8fb8854

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kevinvandijk kevinvandijk self-requested a review December 15, 2025 13:31
@kevinvandijk kevinvandijk self-assigned this Dec 15, 2025
@mateuszhoffman
Copy link

That would be awesome to have! Can anyone can approve this?

@pedrommone
Copy link

I'm thinking move away from Cursor just because their API is not fully compatible with Azure models. We need that since we rely on Azure.

Is there a way to get this PR approved? We can move ~10 licenses to Kilo due that.

@kommerzienrat kommerzienrat changed the title OpenAI responses api feat: OpenAI responses api Jan 13, 2026
@kevinvandijk
Copy link
Collaborator

Thank you! We'll review this soon. @chrarnoldus could you review this since you're more up to date on this than I am?

@chrarnoldus
Copy link
Collaborator

chrarnoldus commented Jan 14, 2026

I think it should be made a separate provider "OpenAI Responses Compatible" or some such.

If the goal is purely to use Azure, we could also figure out why the "OpenAI" (native) provider with a custom base url doesn't work.

@qbiecom
Copy link
Contributor

qbiecom commented Jan 15, 2026

First major difference is that the API key is in a different header. Example from their docs:

curl -X POST "https://<REDACTED>-uksouth.cognitiveservices.azure.com/openai/responses?api-version=2025-04-01-preview" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AZURE_API_KEY" \
    -d '{
        "messages": [
            {
                "role": "user",
                "content": "I am going to Paris, what should I see?"
            }
        ],
        "max_completion_tokens": 16384,
        "model": "gpt-5.1"
    }'

That's in addition to some of the newer models that only support the responses API (5.1/5.2 codex for example).

@qbiecom
Copy link
Contributor

qbiecom commented Jan 20, 2026

Updating my previous comment - Azure works fine using OpenAI compatible for models that support chat completion, as long as you tick the 'Use Azure' option in Kilo.

It's just that they restrict some of their models to responses API only now.

image

@kommerzienrat
Copy link
Author

Yes, that's why I took on this issue in the first place. And since the responses API is the future, we should include it anyway.

@chrarnoldus
Copy link
Collaborator

We can accept it as a separate provider from Chat Completions.

@mateuszhoffman
Copy link

So... will it be integrated?

@qbiecom
Copy link
Contributor

qbiecom commented Jan 21, 2026

In which case it'll probably be better to close this PR and then create a new one - clone the existing provider and update it for responses, and then name them 'OpenAI Compatible (Chat Completions)' and 'OpenAI Compatible (Responses)'?

@chrarnoldus
Copy link
Collaborator

Closing in favor of #5330, but thanks for the effort @kommerzienrat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants