mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:13:19 +08:00
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。 Made-with: Cursor
1.8 KiB
1.8 KiB
Gateway image.generate Contract
This document describes the Python gateway method image.generate.
Method
- Name:
image.generate - Handler:
oclaw/interfaces/gateway/server_methods/image.py
Input Params
prompt(required, non-empty string)provider(optional, non-empty string)size(optional, non-empty string)quality(optional, non-empty string)idempotencyKey(optional, non-empty string; used asrequestIdwhen provided)
Behavior
- If
context.image_generateexists, it is used as the primary backend hook. - Otherwise, the handler falls back to
extensions/image-generation-core/api.py::generate_image. - Provider resolution uses:
context.image_generation_providersfirst- then
context.get_runtime_snapshot()["image_generation_providers"](if available)
- Provider selection order:
- explicit
providerparam context.config.image.defaultProvider- first matched entry in
context.config.image.providerPriority - first available capable provider
- explicit
- Capability filter:
- providers are considered image-capable when any of the following is true:
capabilities.image_generation == truecapabilitieslist containsimage/image_generationkindisimage/image_generation- provider exposes callable
generate
- providers are considered image-capable when any of the following is true:
Error Semantics
INVALID_REQUEST:- missing/blank
prompt - invalid optional parameter types/empty strings
- missing/blank
NOT_FOUND:- explicit
provideris not registered
- explicit
UNAVAILABLE:- runtime/image backend failure
Success Payload (normalized)
Success responses include normalized fields:
ok: truestatus: "succeeded"requestId: stringprovider: stringmodel: string | nullprompt: string
Provider-specific fields are preserved and merged into the payload.