jcode icon indicating copy to clipboard operation
jcode copied to clipboard

Per model api wire type and custom Responses providers

Open buraktamturk opened this issue 4 months ago • 5 comments

Some names providers have three of the following api formats:

OpenAI Responses, OpenAI Chat Completions, Anthropic Messages

For example, qwen3.7-max on OpenCode Go supports only Anthropic endpoint, whereas another model like glm-5.2 works with OpenAI Chat Completions. Ollama works with both OpenAI Responses and OpenAI Chat Completions - however perhaps with the Responses cache hit will be better. SuperGrok or some other providers works better with Responses API because of built in server side tool calling functionality.

Currently named providers only support "OpenAI Chat Completions" format, it is not possible to create custom OpenAI Responses provider or model.

buraktamturk avatar Jul 11 '26 21:07 buraktamturk

Triaged as a medium-priority enhancement requiring provider-routing design work. The request combines three distinct wire protocols with per-model selection, session restore, model switching, auth, tool-call normalization, streaming, and catalog metadata. That is not safe to implement autonomously as a small compatibility flag.

The native openai-api route already supports custom Responses-compatible base URLs, but mixing Responses, Chat Completions, and Anthropic Messages inside one named provider needs an explicit wire-type schema and runtime-routing design. Keeping this open for that decision.

1jehuang avatar Jul 14 '26 04:07 1jehuang

@1jehuang it is not possible to setup a custom named provider with "OpenAI Responses" alone. I think some providers have issues with caching with the chat completions endpoint. Perhaps this issue should be considered again even if the api type is not set per model but per provider.

buraktamturk avatar Jul 18 '26 06:07 buraktamturk

I ran into this while configuring a named provider for GPT-5.6 models on an Azure-hosted endpoint. The endpoint supports the Responses API, but Jcode’s named providers always use Chat Completions, so I cannot use Responses while keeping that provider’s endpoint, API key, model list, and identity separate from other providers.

It might make sense to support a provider-level wire API selector as a smaller first step, without solving per-model protocol selection or Anthropic Messages yet:

[providers.my-gateway]
type = "openai-compatible"
base_url = "https://gateway.example/v1"
api = "responses"
api_key_env = "MY_GATEWAY_API_KEY"
default_model = "gpt-example"

Suggested behavior:

  • Omitting api, or setting api = "chat-completions", preserves the current behavior.
  • Setting api = "responses" sends requests to <base_url>/responses using the Responses request, tool, reasoning, and streaming formats.
  • Model switching and session restore retain the named provider’s selected API format, endpoint, authentication, and model ID.
  • The implementation can reuse Jcode’s existing native Responses request builders and stream parser.
  • Tests cover both the default Chat Completions path and the opt-in Responses path.

This differs from #343 and #374, which allow the native openai-api provider to use a custom Responses base URL. A named provider is still useful when the endpoint needs its own authentication, model catalog, and route identity.

This provider-level scope would address the immediate use case without requiring per-model wire types, provider-specific defaults, pricing changes, or a broader provider-routing redesign.

apierron avatar Jul 21 '26 18:07 apierron

@1jehuang I prepared and validated a focused reference implementation for the provider-level Responses API portion of #475:

• Commit: https://github.com/apierron/jcode/commit/eac5d80228ecfda003a39bbc6afa3094a4d4d837 • Compare: https://github.com/1jehuang/jcode/compare/master…apierron:feat/named-responses-api-475

Named OpenAI-compatible profiles can opt into /v1/responses with api = "responses", while omitted values and chat-completions preserve existing behavior. It reuses Jcode’s Responses builders/parser and covers tools, reasoning, image gating, errors, retries, rollback, forks, and session continuation.

This is intentionally provider-level only. It does not attempt per-model wire selection, Anthropic Messages, or broader routing changes. All affected suites, checks, clippy, and formatting pass.

apierron avatar Jul 21 '26 21:07 apierron

I would even add that we have FOUR different methods - mistral supports conversations. https://docs.mistral.ai/api/endpoint/beta/conversations For now in beta, but still. Sorry for piggy-backing, but I believe we should have one issue which tackle in general different ways to talk to model, with possibility to select which one we have. Why? Because I can't use on azure openai (microsoft foundry) luna with thinking and tools, because that requires responses, not chat/completions.

Image

KhazAkar avatar Aug 25 '26 06:08 KhazAkar