MusePi

Provider endpoint constraints

Provider integrations are not interchangeable just because they speak an OpenAI-shaped HTTP protocol. A request is shaped by four layers at once:

  1. endpoint family: openai-completions, openai-responses, openai-codex-responses, anthropic-messages, etc.
  2. gateway/auth surface: OpenRouter, Vercel AI Gateway, Azure OpenAI, Copilot, Alibaba Coding Plan, Kimi Code, Fireworks/Firepass, and similar hosts
  3. model metadata and compat overrides
  4. request context: tools, images, reasoning mode, stateful session, service tier

Use this page when adding a provider, adding a compat flag, or moving logic out of a provider-specific branch. The goal is to encode endpoint constraints once, at the narrowest layer that actually owns the behavior.

Related references:

Baseline rules

1. Choose the endpoint family first

OpenAI Chat Completions compatible

Preserve these differences instead of treating every host as stock OpenAI:

OpenAI Responses compatible

Responses request shape is its own dialect:

OpenAI Codex Responses

Codex is not plain Responses with a different URL. Keep these as Codex transport policy:

Codex intentionally does not forward caller max-token caps because the backend rejects them.

Anthropic/OpenAI dual-surface providers

Kimi Code and Synthetic can be called as OpenAI-compatible or Anthropic-compatible. The shim may need to:

Do not encode these as one-way provider migrations; they are runtime surface selection decisions.

2. Apply gateway and auth overlays

These constraints sit above the endpoint family. They affect auth, headers, routing, model ids, or usage accounting.

Azure OpenAI

GitHub Copilot

OpenRouter

Vercel AI Gateway

Alibaba Coding Plan

Kimi Code

Fireworks and Firepass

3. Serialize request parameters by dialect

Check these before adding or forwarding a field:

4. Map reasoning and thinking explicitly

Reasoning fields are not interchangeable.

OpenAI-style reasoning_effort

Responses reasoning

OpenRouter reasoning

Z.AI / GLM

Qwen

Anthropic-compatible format

DeepSeek reasoning history

Reasoning plus tool choice

xAI Grok through Responses/SuperGrok

Keep these independent:

Some models reject only one of those fields; do not collapse them into one “Grok mode” branch.

5. Normalize tools and schemas per endpoint

Strict tools

Strict schemas are not a universal capability:

Retry-without-strict should be a compat recovery policy scoped to the current session/provider path.

Responses and Codex custom tools

Responses and Codex both support freeform custom grammar tools for apply_patch. Custom grammar tools do not force request-level parallel_tool_calls; Codex responsesLite separately disables request-level parallel tool calls whenever tools are present. Responses additionally:

Codex applies its own request transformation before sending.

Tool choice

Before emitting tool_choice:

Anthropic through LiteLLM/Bedrock

Mistral / Devstral

Custom tool outputs

Responses/Codex must remember whether a call was custom_tool_call; the paired output must then be custom_tool_call_output, not function_call_output.

MiniMax-compatible streaming arguments

Tool arguments can stream as objects instead of JSON strings. Deep-merge object deltas, then emit one final concat-safe JSON delta.

6. Convert messages and replay history safely

7. Decode streams by provider behavior, not just schema

8. Preserve usage and cost semantics

9. Implement recovery at the right boundary

10. Checklist for a new constraint

Before adding a branch or compat field, answer these in order:

  1. Is this endpoint-family behavior, gateway behavior, model behavior, or request context behavior?
  2. Can it be represented by existing compat metadata?
  3. If not, is a new compat field better than a provider-name branch?
  4. Does the field need provider-level defaults, model-level overrides, or both?
  5. Does it interact with tools, images, reasoning, stateful Responses chains, or service tier?
  6. Can retry happen before visible text/tool calls only?
  7. Does usage accounting still preserve cache reads/writes, billed input, service tier multipliers, and provider-specific counters such as Copilot premiumRequests?