Skip to content

头像 API

按风格与标识生成头像。同一 style 与同一标识始终对应同一张图,可直接写入 <img src>

  • devimg(图即头像):支持中文首字(如「张三」),可开关文字、形状与背景色
  • 开源接入:卡通、几何、像素等 50 余种风格(DiceBear、Jdenticon、Minidenticons)
  • 默认 SVG;需要位图时使用 .webp / .png 后缀(单边上限 1024)

三方风格许可见 头像许可。使用规范见 使用规范

在线试玩

128px · devimg · 张三

variant=gradienttext=1
/avatar/devimg/%E5%BC%A0%E4%B8%89/128?variant=gradient&text=1
快捷示例
https://cdn.devimg.cn/avatar/devimg/%E5%BC%A0%E4%B8%89/128?variant=gradient&text=1

GET /avatar/:style/:seed/:size

路径参数

参数说明
style风格 slug,见下方目录或 GET /avatar/styles
seed标识(姓名或用户名);相同 style + seed 生成相同头像
size边长,16–4000(SVG);栅格化上限 1024

路径可附加 .webp.png

示例

html
<img src="https://cdn.devimg.cn/avatar/devimg/张三/128" alt="张三" width="128" height="128" />
<img src="https://cdn.devimg.cn/avatar/lorelei/Luna/128" alt="Luna" width="128" height="128" />
<img src="https://cdn.devimg.cn/avatar/devimg/Luna/128?text=0" alt="pattern" width="128" height="128" />
<img src="https://cdn.devimg.cn/avatar/devimg/张三/128?bg=6366f1&fg=ffffff" alt="brand" width="128" height="128" />
<img src="https://cdn.devimg.cn/avatar/devimg/张三/128?shape=square" alt="square" width="128" height="128" />
<img src="https://cdn.devimg.cn/avatar/devimg/张三/128.webp" alt="webp" width="128" height="128" />

devimg Query

参数说明
text1 显示首字(默认),0 不显示
variantgradient / mesh / pattern
shapecircle(默认)/ square
bg / fg背景色 / 字色,6 位 hex,不含 #
pattern纹理 id(variant=pattern 或风格 devimg-pattern
formatwebp / png;也可使用路径后缀

其他风格的可用 query 以 GET /avatar/styles 中该条目的 queryParams 为准。

响应头

  • SVG:Content-Type: image/svg+xml
  • Cache-Control: public, max-age=31536000, immutable
  • 栅格输出限流 60 次/分钟/IP

风格目录

GET /avatar/styles 返回全部风格(含 enginelicenseprovider)。GET /avatar/patterns 返回图即纹理 id。

图即风格(节选)

名称style说明
图即头像devimg中文首字 / 渐变底,可配 bg fg
几何弧环devimg-geo同心弧环
纹理头像devimg-patternCSS 纹理底
曼陀罗devimg-mandala算法 SVG
玻璃拟态devimg-glass半透明叠层

devimg-gradientdevimg-meshdevimg-initialsdevimg 的别名。

开源接入(节选)

各风格独立许可,详见 头像许可

名称style来源
圆环ringsDiceBear
卡通人像loreleiDiceBear
经典矢量avataaarsDiceBear
像素小人pixel-artDiceBear
拉丁缩写initialsDiceBear
对称图标jdenticonJdenticon
极简矩阵minidenticonMinidenticons

完整列表以 GET /avatar/styles 为准。


从 DiceBear 迁移

路径形式为 /avatar/{style}/{seed}/{size}。Query 参数与 DiceBear 官方 API 不完全相同,请以本页与 /avatar/styles 为准。

码形占位(伪 QR / 条码)见 码形占位 API,与头像风格 devimg-matrix 用途不同:前者为独立码形占位并带 X-DevImage-Pseudo-Code 响应头。

devimg · 图即 — 国内开发者占位图 CDN