From 0b48e2518fbfb15ed6a20f1dc9cc3af63620c2a2 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 15 Mar 2026 16:11:40 +0100 Subject: [PATCH] docs: clarify compat flags for openai-compatible local servers closes #2177 --- packages/ai/README.md | 23 +++++++++++++++++++++++ packages/coding-agent/docs/models.md | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/packages/ai/README.md b/packages/ai/README.md index c339b234..f3ca38bd 100644 --- a/packages/ai/README.md +++ b/packages/ai/README.md @@ -729,6 +729,29 @@ const response = await stream(ollamaModel, context, { }); ``` +Some OpenAI-compatible servers do not understand the `developer` role used for reasoning-capable models. For those providers, set `compat.supportsDeveloperRole` to `false` so the system prompt is sent as a `system` message instead. If the server also does not support `reasoning_effort`, set `compat.supportsReasoningEffort` to `false` too. + +This commonly applies to Ollama, vLLM, SGLang, and similar OpenAI-compatible servers. You can set `compat` at the provider level or per model. + +```typescript +const ollamaReasoningModel: Model<'openai-completions'> = { + id: 'gpt-oss:20b', + name: 'GPT-OSS 20B (Ollama)', + api: 'openai-completions', + provider: 'ollama', + baseUrl: 'http://localhost:11434/v1', + reasoning: true, + input: ['text'], + cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, + contextWindow: 131072, + maxTokens: 32000, + compat: { + supportsDeveloperRole: false, + supportsReasoningEffort: false, + } +}; +``` + ### OpenAI Compatibility Settings The `openai-completions` API is implemented by many providers with minor differences. By default, the library auto-detects compatibility settings based on `baseUrl` for a small set of known OpenAI-compatible providers (Cerebras, xAI, Chutes, DeepSeek, zAi, OpenCode, etc.). For custom proxies or unknown endpoints, you can override these settings via the `compat` field. For `openai-responses` models, the compat field only supports Responses-specific flags. diff --git a/packages/coding-agent/docs/models.md b/packages/coding-agent/docs/models.md index 713850dd..ab56794e 100644 --- a/packages/coding-agent/docs/models.md +++ b/packages/coding-agent/docs/models.md @@ -35,6 +35,32 @@ For local models (Ollama, LM Studio, vLLM), only `id` is required per model: The `apiKey` is required but Ollama ignores it, so any value works. +Some OpenAI-compatible servers do not understand the `developer` role used for reasoning-capable models. For those providers, set `compat.supportsDeveloperRole` to `false` so pi sends the system prompt as a `system` message instead. If the server also does not support `reasoning_effort`, set `compat.supportsReasoningEffort` to `false` too. + +You can set `compat` at the provider level to apply to all models, or at the model level to override a specific model. This commonly applies to Ollama, vLLM, SGLang, and similar OpenAI-compatible servers. + +```json +{ + "providers": { + "ollama": { + "baseUrl": "http://localhost:11434/v1", + "api": "openai-completions", + "apiKey": "ollama", + "compat": { + "supportsDeveloperRole": false, + "supportsReasoningEffort": false + }, + "models": [ + { + "id": "gpt-oss:20b", + "reasoning": true + } + ] + } + } +} +``` + ## Full Example Override defaults when you need specific values: