diff --git a/docs/configuration.md b/docs/configuration.md index e63c8f2bf..aa1939a17 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -205,7 +205,7 @@ Tracing covers the providers that go through nanobot's OpenAI-compatible client > - **Step Fun (Mainland China)**: If your API key is from Step Fun's mainland China platform (stepfun.com), set `"apiBase": "https://api.stepfun.com/v1"` in your stepfun provider config. > - **Xiaomi MiMo thinking mode**: MiMo models (e.g. `mimo-v2.5-pro`) default to enabled thinking. Use `agents.defaults.reasoningEffort: "none"` to disable it, or `"low"` / `"medium"` / `"high"` to keep it on. Omitting the field preserves the provider's per-model default. > - **Xiaomi MiMo Token Plan**: If you're on MiMo's token plan, set `"apiBase": "https://token-plan-sgp.xiaomimimo.com/v1"` in your xiaomi_mimo provider config. -> - **Custom OpenAI-compatible providers**: Besides the built-in `custom` provider, any extra key under `providers` can define its own OpenAI-compatible endpoint. For example, `providers.companyProxy.apiBase` plus `modelPresets.primary.provider: "companyProxy"` creates a separate custom provider. Set `apiBase`; set `apiKey` only when the endpoint requires it. +> - **Custom OpenAI-compatible providers**: Besides the built-in `custom` provider, any extra key under `providers` can define its own OpenAI-compatible endpoint. For example, `providers.companyProxy.apiBase` plus `modelPresets.primary.provider: "companyProxy"` creates a separate custom provider. Set `apiBase`; set `apiKey` only when the endpoint requires it. This named-custom path uses the OpenAI-compatible request format only. For Anthropic-compatible proxies, use `providers.anthropic.apiBase` with `provider: "anthropic"`. | Provider | Purpose | Get API Key | |----------|---------|-------------| @@ -859,7 +859,9 @@ Connects directly to any OpenAI-compatible endpoint — llama.cpp, Together AI, > } > ``` > -> In short: **chat-completions-compatible endpoint → `custom`**; **Responses-compatible endpoint → `azure_openai`**. +> Anthropic-compatible endpoints are separate: use `providers.anthropic.apiBase` and set the preset provider to `anthropic`. Arbitrary custom provider names do not use the Anthropic Messages API format. +> +> In short: **chat-completions-compatible endpoint → `custom` or a named custom provider**; **Responses-compatible endpoint → `azure_openai`**; **Anthropic-compatible endpoint → `anthropic` with `apiBase`**. Some OpenAI-compatible gateways expose request-body extensions such as vLLM guided decoding or local sampling controls. Put those under `extraBody`; nanobot merges them into the chat-completions request body after its provider defaults: diff --git a/docs/provider-cookbook.md b/docs/provider-cookbook.md index cfcb240ae..b7c44a12e 100644 --- a/docs/provider-cookbook.md +++ b/docs/provider-cookbook.md @@ -168,6 +168,36 @@ ANTHROPIC_API_KEY="sk-ant-..." nanobot agent -m "Hello!" If you copied a model name such as `anthropic/claude-sonnet-4.5`, that is a gateway-style model path and belongs under `provider: "openrouter"`, not `provider: "anthropic"`. +If you use an Anthropic-compatible proxy, keep the preset provider as `anthropic` and set `providers.anthropic.apiBase`: + +```json +{ + "providers": { + "anthropic": { + "apiKey": "${ANTHROPIC_API_KEY}", + "apiBase": "https://anthropic-proxy.example.com" + } + }, + "modelPresets": { + "primary": { + "label": "Anthropic proxy", + "provider": "anthropic", + "model": "claude-sonnet-4-5", + "maxTokens": 4096, + "contextWindowTokens": 200000, + "temperature": 0.1 + } + }, + "agents": { + "defaults": { + "modelPreset": "primary" + } + } +} +``` + +Do not configure Anthropic-compatible endpoints as arbitrary custom provider names; named custom providers use the OpenAI-compatible request format. + ## Recipe: Custom OpenAI-Compatible Provider This recipe applies to an OpenAI-compatible service that is not a named nanobot provider. @@ -246,7 +276,7 @@ For multiple custom endpoints, do not overload the single `custom` block. Name e } ``` -These custom names behave like direct OpenAI-compatible providers: `apiBase` is required, `apiKey` is optional when the endpoint allows anonymous or placeholder credentials, and `apiType` should be left unset. +These custom names behave like direct OpenAI-compatible providers: `apiBase` is required, `apiKey` is optional when the endpoint allows anonymous or placeholder credentials, and `apiType` should be left unset. They do not support Anthropic-compatible endpoints; use the `anthropic` provider with `apiBase` for that case. ## Recipe: Ollama Local Model diff --git a/docs/providers.md b/docs/providers.md index 32ec2fa40..02760622a 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -121,6 +121,27 @@ Use the model ID exactly as OpenRouter lists it. Anthropic direct uses the native Anthropic provider. Do not use an OpenRouter model ID unless the provider is OpenRouter. +If you use an Anthropic-compatible proxy, keep the provider as `anthropic` and override `apiBase`: + +```json +{ + "providers": { + "anthropic": { + "apiKey": "${ANTHROPIC_API_KEY}", + "apiBase": "https://anthropic-proxy.example.com" + } + }, + "modelPresets": { + "primary": { + "provider": "anthropic", + "model": "claude-sonnet-4-5" + } + } +} +``` + +Arbitrary custom provider names are OpenAI-compatible only; they do not use the Anthropic Messages API request format. + ### OpenAI Direct ```json @@ -215,6 +236,8 @@ If you have more than one custom OpenAI-compatible endpoint, give each endpoint Custom provider keys are treated as direct OpenAI-compatible providers. `apiBase` is required because nanobot cannot know the endpoint URL. `apiKey` is optional for local servers or private proxies that do not require one. Do not set `apiType` on custom provider keys; `apiType` is only for `providers.openai`. +This named custom provider path is not for Anthropic-compatible endpoints. For Anthropic-compatible proxies, use `providers.anthropic.apiBase` and set the preset provider to `anthropic`. + ### Ollama Start Ollama separately, then point nanobot at the OpenAI-compatible endpoint.