Bind API support and preference to the preset's provider and model. Carry the API declaration through factory selection, fallback chains, hot reload and WebUI persistence. Use Copilot endpoint metadata for automatic routing and keep reasoning replay and compaction defaults in provider capability profiles. Consolidate Responses follow-ups from #5906, #5935, #6020, #6051 and #5834; acknowledge equivalent contributions in #6105 and #5863. Co-authored-by: Parman Mohammadalizadeh <prmma23@gmail.com> Co-authored-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com> Co-authored-by: kkkhoo <128304090+kkkhoo@users.noreply.github.com> Co-authored-by: pei711 <199601925+pei711@users.noreply.github.com> Co-authored-by: Steven Huang <134844631+remote-controlled-man@users.noreply.github.com> Co-authored-by: Louis Yue <179701714+selfucker@users.noreply.github.com> Co-authored-by: iuiuiu <92971770+iuiu-py@users.noreply.github.com>
2.6 KiB
2.6 KiB
How to Configure an OpenAI-Compatible Provider in nanobot
nanobot can call OpenAI-compatible model providers by configuring an apiBase,
optional apiKey, and a model preset that references that provider name.
What you will build
- a custom provider entry
- a model preset pointing at that provider
- one successful
nanobot agentrun
When to use this
Use this for local or hosted services that expose OpenAI-compatible endpoints, including internal gateways, local model servers, and provider proxies that are not already named in nanobot.
Install
python -m pip install nanobot-ai
nanobot onboard --wizard
Verify the endpoint responds before debugging nanobot:
curl -sS https://api.example.com/v1/models
Minimal working example
Merge this into ~/.nanobot/config.json:
{
"providers": {
"custom": {
"apiKey": "${CUSTOM_API_KEY}",
"apiBase": "https://api.example.com/v1"
}
},
"modelPresets": {
"Custom": {
"provider": "custom",
"model": "provider-model-name",
"maxTokens": 4096,
"contextWindowTokens": 65536,
"temperature": 0.1
}
},
"agents": {
"defaults": {
"modelPreset": "Custom"
}
}
}
Then run:
nanobot agent -m "Hello!"
Production notes
- Include the version path in
apiBasewhen the service expects/v1. - Use separate provider names for separate endpoints.
- Use a placeholder key such as
EMPTYonly when the endpoint requires a non-empty key but does not validate it. - Leave
apiTypeunset for OpenAI-compatible custom endpoints. - For models requiring Responses, declare
api.supportedApis: ["responses"]in their model preset, or select Responses in the WebUI preset editor.
Security notes
- Keep provider keys in environment variables.
- Treat internal model gateways as sensitive network services.
- Do not point nanobot at untrusted proxy endpoints for private workspaces.
Troubleshooting
- If
curl /modelsfails, fix the provider endpoint before changing nanobot. - If nanobot says the model is unknown, check the model ID expected by the provider.
- If auth fails, confirm whether the provider wants Bearer auth and whether the key is present in the environment that starts nanobot.