config.yaml 中添加 AIone 作为提供商:model 字段必须使用 openai/ 前缀(如 openai/claude-sonnet-4-6),因为 AIone 暴露的是 OpenAI 兼容接口 /v1/chat/completions。anthropic/ 或 gemini/ 前缀,LiteLLM 会尝试直连 Anthropic / Google 官方 API,绕过 AIone。imageConfig 等自定义参数。LiteLLM Proxy 默认不会将这些非标准字段转发给上游,需要通过 extra_body 配置。extra_body 中:{
"model": "gemini-image",
"messages": [
{"role": "user", "content": "画一只穿宇航服的猫咪"}
],
"max_tokens": 4096,
"extra_body": {
"image_size": "4K",
"aspect_ratio": "16:9"
}
}imageConfig 格式,两种写法等效:{
"model": "gemini-image",
"messages": [
{"role": "user", "content": "画一只穿宇航服的猫咪"}
],
"max_tokens": 4096,
"extra_body": {
"imageConfig": {
"aspect_ratio": "16:9",
"image_size": "4K"
}
}
}extra_body 指定分辨率:{"extra_body": {"image_size": "4K"}}优先级规则: 如果同时使用了带分辨率后缀的模型名(如 -4k)和image_size参数,参数优先。后缀只在没传image_size时生效。
{
"model": "gemini-image",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "把这张图的背景换成星空"},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQ..."
}
}
]
}
],
"max_tokens": 4096,
"extra_body": {"image_size": "2K"}
}{
"choices": [{
"message": {
"role": "assistant",
"content": "这是模型的文字回复"
}
}]
}{
"choices": [{
"message": {
"role": "assistant",
"content": "这是为你生成的图片:\n\n",
"images": [
{
"type": "image_url",
"index": 0,
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQ...",
"detail": "auto"
}
}
]
}
}]
}| 字段 | 类型 | 说明 |
|---|---|---|
content | string | Markdown 格式的文本 + 图片,符合 OpenAI spec |
images | array | 结构化的图片数据,方便程序提取 |
重要: LiteLLM 的 openai/handler 是纯直通模式,不会自动从content中提取图片。如果你的应用需要程序化处理图片,请使用images字段。
litellm_params 下添加 extra_bodyextra_body 字段内extra_body={} 参数image_size、aspect_ratio、imageConfig 等)必须通过 extra_body 传递。model 字段使用了 openai/ 前缀max_tokens 已设置(建议 4096)content 字段:包含 Markdown 格式的图片()images 字段:包含结构化的 base64 图片数据openai/ handler 不会自动提取图片,请直接读取 images 字段"stream": true,AIone 网关会每 10 秒发送 keepalive 心跳,防止连接被中间网络设备断开。litellm_params.model 中的模型名必须与 AIone 支持的模型 ID 一致GET https://api.nexara.net/v1/models 查看完整列表