fix: harden custom image provider compatibility
Maintainer edit: preserve provider-specific size hints for custom image generation endpoints while keeping the default 1K mapping compatible. Clarify the custom provider contract in docs and cover response_format/size overrides in tests.
This commit is contained in:
@@ -23,7 +23,7 @@ The feature is disabled by default. Enable it in `~/.nanobot/config.json`, confi
|
||||
}
|
||||
```
|
||||
|
||||
See [Provider Notes](#provider-notes) for AIHubMix, MiniMax, Gemini, Ollama, StepFun, and Zhipu configuration examples.
|
||||
See [Provider Notes](#provider-notes) for Custom, AIHubMix, MiniMax, Gemini, Ollama, StepFun, and Zhipu configuration examples.
|
||||
|
||||
> [!TIP]
|
||||
> Prefer environment variables for API keys. nanobot resolves `${VAR_NAME}` values from the environment at startup.
|
||||
@@ -86,7 +86,13 @@ Use a model that supports image generation and image editing if you want referen
|
||||
|
||||
### Custom (OpenAI-compatible)
|
||||
|
||||
Any OpenAI-compatible image generation API can be used with the `custom` provider. This includes local Stable Diffusion servers, Replicate, Agnes AI, and similar services that expose the `/v1/images/generations` endpoint.
|
||||
Use the `custom` provider for services that implement the synchronous OpenAI Images API:
|
||||
|
||||
```text
|
||||
POST /v1/images/generations
|
||||
```
|
||||
|
||||
The response must include generated images in `data[].b64_json` or `data[].url`. Native prediction APIs, such as Replicate's `/v1/models/{owner}/{model}/predictions`, are not directly compatible unless you put an OpenAI-compatible gateway in front of them.
|
||||
|
||||
Configure:
|
||||
|
||||
@@ -108,7 +114,15 @@ Configure:
|
||||
}
|
||||
```
|
||||
|
||||
The `apiBase` is required. The provider sends requests to `{apiBase}/images/generations` using the OpenAI Images API format with `response_format: "b64_json"`. The `apiKey` is optional for local or unauthenticated endpoints.
|
||||
The `apiBase` is required. The provider sends requests to `{apiBase}/images/generations` using the OpenAI Images API format with `response_format: "b64_json"`. The `apiKey` is optional for local or unauthenticated endpoints. Reference-image edits are not supported by the generic `custom` provider.
|
||||
|
||||
`extraBody` can adapt provider-specific quirks because it is merged last into the request body. Examples:
|
||||
|
||||
- Agnes AI documents URL responses, so use `"extraBody": {"response_format": "url"}`.
|
||||
- Together AI documents `"response_format": "base64"`, so override the default.
|
||||
- Volcengine Ark Seedream models may require size hints such as `"2K"`, `"3K"`, `"4K"`, or explicit dimensions. Set `tools.imageGeneration.defaultImageSize` or `providers.custom.extraBody.size` to a value supported by the selected model.
|
||||
|
||||
For compatibility with the default nanobot setting, custom maps `defaultImageSize: "1K"` to `1024x1024`. Other explicit size hints are passed through unchanged.
|
||||
|
||||
### AIHubMix
|
||||
|
||||
|
||||
Reference in New Issue
Block a user