Help us shape the future of Go! Take the 2026 Go Developer Survey

modellink

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 23 Imported by: 0

README

ModelLink 官方 Go 客户端,用于获取、校验、缓存和解析版本化的中国 AI 模型与服务商数据。

数据来自 @modellink/data,运行时默认访问国内的 npmmirror。客户端不依赖 Node.js,也不会执行 npm 包中的任何脚本。

安装

go get github.com/goroutined/modellink-go

按需求选择

需求 从哪里开始
读取当前模型目录 examples/basic
计算一次调用的花费 成本计算、examples/cost
检查并更新数据 examples/update
审核并切换指定版本 examples/version-control
修改缓存目录和保留数量 examples/file-cache
查看上次检查/切换状态、监控阶段耗时 状态与操作报告、examples/observability
接入 Redis 或对象存储 自定义缓存
维护 Schema 和生成类型 Schema 与代码生成

大多数应用只需要 New、Load 和 Snapshot 查询方法,不需要了解缓存接口或 Schema 生成过程。

快速开始

package main

import (
    "context"
    "fmt"
    "log"

    modellink "github.com/goroutined/modellink-go"
)

func main() {
    client, err := modellink.New(modellink.Options{})
    if err != nil {
        log.Fatal(err)
    }

    // 本地已有已校验版本时不访问网络;首次使用时下载最新版。
    snapshot, err := client.Load(context.Background())
    if err != nil {
        log.Fatal(err)
    }

    model, ok := snapshot.ProviderModel("deepseek", "deepseek-v4-pro")
    if !ok {
        log.Fatal("model not found")
    }
    fmt.Printf("%s: context=%d\n", model.Name, model.Limit.Context)
}

Snapshot 还提供:

snapshot.Model("deepseek/deepseek-v4-pro")
snapshot.Provider("deepseek")
snapshot.ProviderModel("deepseek", "deepseek-v4-pro")
查询方法 返回内容
Model 研发机构发布的基础模型元数据
Provider 服务商及其完整可调用模型目录
ProviderModel 指定服务商下可调用模型的价格、协议和限制

也可以直接访问完整的强类型目录:

snapshot.Catalog.Models
snapshot.Catalog.Providers
snapshot.Manifest
snapshot.Schema()
snapshot.File(modellink.FileCatalog) // npm 包内经过哈希校验的原始字节

返回的 Snapshot 会在进程内共享,请将其视为只读数据。

成本计算

数据里的价格字段按官方真实规则建模(分时段、输入阶梯、缓存命中与写入、思考模式差价、订阅积分),Snapshot.Cost 把这些解析收敛到 SDK:填服务商、模型、用量和计价时间,直接得到花费。

用量按请求所用协议填写,字段与官方 usage 对象打平,按响应返回的数值直接赋值即可,SDK 内部处理各协议的记账差异(缓存是否计入输入、reasoning 是否计入输出):

// OpenAI Chat Completions,响应 usage 原始 JSON:
//   {"prompt_tokens": 2620000, "completion_tokens": 100000,
//    "prompt_tokens_details": {"cached_tokens": 820000}}
result, ok, err := snapshot.Cost(modellink.CostQuery{
    Provider: "deepseek",
    Model:    "deepseek-flash",
    Usage: modellink.OpenAIChatUsage{
        PromptTokens:       2_620_000,
        CompletionTokens:   100_000,
        PromptCachedTokens: 820_000,
    },
    // DeepSeek 官方高峰窗口排除中国法定节假日,需要注入节假日判定。
    IsCNStatutoryHoliday: func(day time.Time) (bool, error) { return false, nil },
    At:                   requestTime, // 分时判定按数据声明时区换算
})
// result.Currency = CNY; result.TierLabel = "高峰"; result.Total = 4.4328

// Anthropic Messages,响应 usage 原始 JSON:
//   {"input_tokens": 1000000, "cache_creation_input_tokens": 100000,
//    "cache_read_input_tokens": 500000, "output_tokens": 200000}
result, _, _ = snapshot.Cost(modellink.CostQuery{
    Provider: "deepseek",
    Model:    "deepseek-v4-pro",
    Usage: modellink.AnthropicUsage{
        InputTokens:              1_000_000,
        CacheReadInputTokens:     500_000,
        CacheCreationInputTokens: 100_000,
        OutputTokens:             200_000,
    },
    IsCNStatutoryHoliday: func(day time.Time) (bool, error) { return false, nil },
    At:                   requestTime,
})
// result.Currency = CNY; result.TierLabel = "高峰"; result.Total = 14.55

订阅套餐(Token / Coding Plan 等)按积分抵扣的模型同样适用,result.Currency 返回 POINTS、result.Total 是积分数。

内置的 usage 类型:

类型 对应协议 说明
OpenAIChatUsage OpenAI Chat Completions prompt_tokens 含缓存命中;PromptCachedTokens 对应 prompt_tokens_details.cached_tokens
OpenAIResponsesUsage OpenAI Responses 输入含缓存命中、输出含 reasoning;对应两个 details 子对象字段
AnthropicUsage Anthropic Messages input_tokens 不含缓存,cache_read_input_tokens / cache_creation_input_tokens 独立计费
RawUsage 自定义 已经自行拆分用量时直接填写

计算规则:

  • 先匹配 tiers[].when(生效日期区间、时间窗、输入/输出阶梯、上下文档),未命中时回退顶层默认价;输入阶梯按输入总量(含缓存命中与写入)判定;
  • 官方公告的未来调价通过 when.date 生效区间表达:At 落在区间内才使用新价,生效前自动回退当前价;
  • 缓存命中、缓存写入按各自单价计费;数据声明 reasoning 单价时,输出中的 reasoning token 单独计价;
  • Thinking = true 时使用思考模式差价(数据声明 cost_cn.thinking 时);
  • 时间窗支持跨午夜与 24:00 结束,按数据声明时区换算,服务商按请求接收时间计费;
  • 数据声明 holiday = "exclude_cn_statutory" 的窗口必须提供 IsCNStatutoryHoliday 判定函数,缺失时返回错误而不是猜测价格;
  • 模型或价格缺失返回 ok = false;用量缺失、非法(如缓存数超过总输入)或数据无法可靠计价时返回 error。

完整示例见 examples/cost。

Client 功能地图

公开方法分成底层能力、版本组合和加载入口。下载地址、npm tarball 和存储过程都隐藏在 Client 内部:

flowchart BT
    subgraph P["底层能力"]
        ST["Status<br/>读取持久化状态"]
        CV["CurrentVersion<br/>读取当前版本"]
        LC["LoadCached<br/>读取当前缓存"]
        FL["FindLatest<br/>查询 Registry"]
        AV["ActivateVersion<br/>激活已缓存版本"]
    end

    subgraph C["版本组合"]
        LV["LoadVersion<br/>加载指定版本"]
        CL["CheckLatest<br/>检查最新版本"]
        SV["SwitchVersion<br/>切换指定版本"]
    end

    subgraph H["加载入口"]
        LL["LoadLatest<br/>防降级加载最新版"]
        LD["Load<br/>缓存优先加载"]
    end

    CV --> CL
    FL --> CL
    LV --> SV
    AV --> SV
    CL --> LL
    SV --> LL
    LC --> LD
    LL --> LD

返回值遵循固定规则:

  • Status、Current、Find、Check 返回轻量状态。
  • Activate、Switch 执行动作,只返回 error。
  • 只有 Load* 返回 *Snapshot。

完整函数签名:

CurrentVersion(ctx context.Context) (string, error)
Status(ctx context.Context) (modellink.CacheState, error)
FindLatest(ctx context.Context) (string, error)
CheckLatest(ctx context.Context) (modellink.UpdateStatus, error)

ActivateVersion(ctx context.Context, version string) error
SwitchVersion(ctx context.Context, version string) error

LoadCached(ctx context.Context) (*modellink.Snapshot, error)
LoadVersion(ctx context.Context, version string) (*modellink.Snapshot, error)
LoadLatest(ctx context.Context) (*modellink.Snapshot, error)
Load(ctx context.Context) (*modellink.Snapshot, error)
行为对照
方法 Registry 写缓存 修改 current 返回内容
CurrentVersion 否 否 否 当前版本号
Status 否 否 否 持久化检查/切换状态
FindLatest 只查询元数据 写检查记录 否 Registry 最新版本号
CheckLatest 只查询元数据 写检查记录 否 版本比较状态及检查时间、耗时
ActivateVersion 否 写激活元数据 是(版本不同时) error
SwitchVersion 缓存未命中时访问 可能 版本变化时 error
LoadCached 否 否 否 当前 Snapshot
LoadVersion 缓存未命中时访问 可能 否 指定版本 Snapshot
LoadLatest 是 写检查记录,可能安装数据 版本变化时 安全的最新或当前兼容 Snapshot
Load 仅无有效缓存时 可能 可能 当前可用 Snapshot

LoadCached 是本地只读调用,不发生网络阻塞,但 Go 的同步文件读取仍可能产生短暂磁盘等待。

加载与版本控制

检查和切换的持久化状态、阶段耗时见状态与操作报告。

缓存优先

Load 先读取当前有效缓存,不检查更新;只有没有可用缓存时才阻塞调用 LoadLatest:

snapshot, err := client.Load(ctx)
明确要求最新

LoadLatest 每次都会检查 Registry。Registry 较新或当前无版本时切换到最新版本; Registry 暂时落后时保持本地较新版本并产生 WarningRegistryBehind: Registry 最新数据使用未来破坏性 Schema 时,SDK 会先尝试按当前 Go 类型解析其 Core Catalog。解析成功则激活新数据并产生 WarningSchemaSDKOutdated;解析失败且 本地已有可用版本时,返回旧 Snapshot 并产生 WarningSchemaUpdateSkipped。

snapshot, err := client.LoadLatest(ctx)
完全本地启动
snapshot, err := client.LoadCached(ctx)
if errors.Is(err, modellink.ErrNoCachedData) {
    // 使用应用自身随程序发布的 fallback 数据,并在后台调用 LoadLatest。
}
固定版本

LoadVersion 必要时下载并校验指定版本,但不修改 current:

snapshot, err := client.LoadVersion(ctx, "0.1.4")
审核后切换
version, err := client.FindLatest(ctx)
candidate, err := client.LoadVersion(ctx, version)

// 检查 candidate 后,显式激活已经缓存的版本。
err = client.ActivateVersion(ctx, version)
active, err := client.LoadCached(ctx)

简化为一步切换指定版本:

err := client.SwitchVersion(ctx, "0.1.4")

SwitchVersion 是显式操作,因此允许开发者主动升级或降级;自动执行的 LoadLatest 始终禁止降级。

检查最新版本

status, err := client.CheckLatest(ctx)
if err != nil {
    return err
}
if status.UpdateAvailable {
    snapshot, err = client.LoadLatest(ctx)
}
if status.RegistryBehind {
    // Registry 镜像暂时落后,本地版本不会被自动降级。
}

Schema 兼容性提醒

SDK 会在每次加载后,本地比较数据包 manifest.json 中的 Schema 版本与 SHA-256, 不会为此增加网络请求:

  • 未来破坏性 Schema 会先尝试解析。未知字段会被忽略,Core Catalog 仍可更新; 解析成功时产生 WarningSchemaSDKOutdated。
  • 未来破坏性 Schema 解析失败且本地已有兼容缓存时,返回旧缓存并产生 WarningSchemaUpdateSkipped;本地没有兼容缓存时返回 ErrUnsupportedSchema。
  • LoadVersion 和 SwitchVersion 是显式版本操作,遇到旧 Schema 直接返回 ErrUnsupportedSchema;未来 Schema 同样先尝试解析,解析失败时返回错误, 且不会自动替换成其他版本。
  • Schema 哈希不一致但仍可解析时继续返回 Snapshot,并产生非阻断 warning。
  • 仅 npm 数据版本不同、Schema 哈希相同时不会产生 warning。

库默认不主动写日志。Schema 漂移和 Registry 落后等非阻断事件可以通过 OnWarning 接入自己的日志或监控:

client, err := modellink.New(modellink.Options{
    OnWarning: func(warning modellink.Warning) {
        slog.Warn(warning.Message, "code", warning.Code)
    },
})

与 Snapshot 数据本身相关的 warning 也会保留在 Snapshot 中:

snapshot, err := client.Load(ctx)
for _, warning := range snapshot.Warnings() {
    // 写入日志、监控或运维状态页
}

同一个 Client 对同一事件只调用一次 OnWarning,重复或并发调用不会刷屏。数据 Schema 较新时会建议升级 modellink-go;自动更新因未来 Schema 被跳过时会说明 当前继续使用的版本。

缓存与并发

默认缓存目录由 os.UserCacheDir() 决定:

系统 默认目录
Linux $XDG_CACHE_HOME/modellink 或 ~/.cache/modellink
macOS ~/Library/Caches/modellink
Windows %LocalAppData%\\modellink

需要指定共享目录时,创建文件缓存并传给 Client:

cache, err := modellink.NewFileCache(modellink.FileCacheOptions{
    Directory: "/var/cache/my-service/modellink",
})
if err != nil {
    return err
}

client, err := modellink.New(modellink.Options{
    Cache: cache,
})

文件缓存默认保留当前版本和最近一个其他版本,总计最多两个版本。只修改保留数量、 继续使用系统默认目录:

cache, err := modellink.NewFileCache(modellink.FileCacheOptions{
    MaxVersions: 5,
})

同时修改目录和保留数量:

cache, err := modellink.NewFileCache(modellink.FileCacheOptions{
    Directory:   "/var/cache/my-service/modellink",
    MaxVersions: 5,
})

MaxVersions 至少为 2;设置为 -1 可以保留全部历史版本。自动清理只在下载或切换版本时执行, 不会启动后台 goroutine;当前版本和本次操作使用的版本不会被删除。

  • 多个 goroutine 同时请求同一个版本时,只下载一次,其余调用等待同一结果。
  • 多个进程使用同一文件缓存时,通过带超时的系统文件锁共享下载与更新结果。
  • 已有可用缓存时,Load 不等待正在进行的更新。
  • 下载先写入独立临时目录;npm integrity、Manifest SHA-256、Schema 版本和 JSON 解析全部通过后才原子安装。
  • 下载或校验失败不会切换当前版本;若激活已经完成,后续清理或解锁失败不回滚切换。 收到错误时可通过 Status 确认实际持久化结果。
  • 文件锁覆盖查询、下载、校验和激活的完整流程;进程退出后由操作系统自动释放。
  • 调用方取消等待不会取消其他 goroutine 已经共享的下载任务。
自定义缓存

Options 只接收一个 Cache。它同时负责版本化数据存储和共享更新互斥:

type Cache interface {
    CacheStore
    Locker
}

因此 Redis 实现通常只需要配置一次:

client, err := modellink.New(modellink.Options{
    Cache: redisCache,
})

自定义缓存需要实现:

type CacheStore interface {
    Current(ctx context.Context) (string, error)
    Get(ctx context.Context, version string) (*modellink.CacheEntry, error)
    Put(ctx context.Context, entry *modellink.CacheEntry) error
    SetCurrent(ctx context.Context, version string) error
    State(ctx context.Context) (modellink.CacheState, error)
    RecordCheck(ctx context.Context, check modellink.CheckState) error
}

type Locker interface {
    Lock(ctx context.Context, key string) (modellink.Lock, error)
}

Put 必须原子发布完整版本,不能让读取方看到部分文件;找不到数据时返回 modellink.ErrNoCachedData。客户端仍会重新校验 Manifest、文件哈希、Schema 版本并解析 JSON,缓存实现不能绕过数据完整性检查。

自定义 Cache 升级注意:新增 State、RecordCheck 两个必需方法。 State 在新缓存上返回空结构,不返回 ErrNoCachedData;读取失败应返回错误,不能伪造空状态。 RecordCheck 必须按 CheckedAt 保留较新检查,且不能覆盖版本和切换记录。 SetCurrent 必须将当前版本与 LastUpdate 在一次原子事务中更新,并保留 LastCheck; 版本没有变化时,不更新 LastUpdate。记录的 previous 必须是事务内读取到的版本,不能从 Client 内存猜测。 首次激活的 PreviousVersion 为空,显式降级也属于切换。更新时间由缓存实现于事务中产生(UTC)。 Redis 实现可使用 Lua/事务完成比较和合并,不要通过空实现跳过元数据。

FileCache 将以上字段与旧 version 一起保存在 current.json,使用独立的 metadata 文件锁及原子替换。锁遵循调用上下文并最多等待两分钟。旧的只有 version 的文件可直接读取, 首次写入才扩展;历史检查/更新时间保持未知,绝不使用文件修改时间补造。清理历史版本不删除元数据。 不建议新旧 SDK 同时写同一目录:旧 SDK 写入时不知道新字段,可能丢失历史信息。

如果数据和锁位于不同系统,例如对象存储配 Redis 锁,可以组合为一个缓存:

cache, err := modellink.NewCache(objectStore, redisLocker)
if err != nil {
    return err
}
client, err := modellink.New(modellink.Options{Cache: cache})

Redis 锁实现应使用唯一持有者 token 安全解锁,并处理锁租期和续租;不能仅使用 一个无法确认持有者的 SETNX 键。等待锁时必须遵守传入的 context。

默认 Registry:

https://registry.npmmirror.com

可以切换到 npm 官方源或内部镜像:

client, err := modellink.New(modellink.Options{
    Registry: "https://registry.npmjs.org",
})

可选字段

生成类型会保留公开 Schema 的可选性。例如:

model.Temperature == nil                         // 未知
model.Temperature != nil && !*model.Temperature // 明确不支持或固定不可调
model.Temperature != nil && *model.Temperature  // 明确支持调节

不要把缺失字段自动当成 false,也不要根据上下文窗口推导缺失的最大输入或输出长度。

状态与操作报告

持久化状态
字段 含义 持久化/未知值
CacheState.Version 共享缓存当前激活的版本,不代表应用已替换手中 Snapshot 持久化;未激活时为空字符串
LastCheck.CheckedAt 成功查询 Registry 最新版本后的 UTC 时间,无更新也记录 持久化;无已知记录时 LastCheck == nil
LastCheck.LatestVersion / Registry 该次查询得到的版本与查询来源,不保证此刻仍最新 随检查记录持久化
LastUpdate.UpdatedAt 缓存原子切换当前版本时产生的 UTC 时间 持久化;无已知记录时 LastUpdate == nil
LastUpdate.PreviousVersion / CurrentVersion 最近一次实际切换前后的版本;首次激活的前版本为空 随切换记录持久化
UpdateStatus.CheckedAt 本次成功远程检查时间;不表示后续持久化一定成功,须同时检查 error 不单独存储;查询未成功时为零值
UpdateStatus.Duration 本次 CheckLatest 总耗时,包含状态读取和检查记录写入,不含 OnOperation 回调 不持久化
OperationReport.StartedAt / FinishedAt / Duration 本次逻辑操作起止 UTC 时间与总耗时 不持久化;共享任务可能在调用返回后结束
StageReport.Duration 单次阶段排他耗时,同名阶段可能出现多次 不持久化;未执行的阶段不出现
state, err := client.Status(ctx) // 只读取共享缓存,不联网
if err != nil {
    return err
}
fmt.Println("当前激活版本:", state.Version)
if check := state.LastCheck; check != nil {
    fmt.Println("上次成功检查:", check.CheckedAt, check.LatestVersion, check.Registry)
}
if update := state.LastUpdate; update != nil {
    fmt.Println("上次实际切换:", update.UpdatedAt,
        update.PreviousVersion, "->", update.CurrentVersion)
}

这是 SDK/共享缓存的状态,不代表应用已经替换它持有的旧 Snapshot。 记录跨 Client、跨进程、跨重启保留;历史记录为 nil 表示未知。只保存最近一次检查/切换, 不是审计日志。LastCheck.Registry 标识检查来源;多个 Registry 共用缓存时,保留全局最近的 成功检查,而不是每个 Registry 各一条。跨主机的缓存使用方应保持系统时钟同步。

  • 无更新、镜像落后也刷新 LastCheck;纯缓存读取、查询指定版本不刷新。
  • 检查成功但下载/校验失败,LastCheck 保留,LastUpdate 不变。
  • 检查请求失败,旧 LastCheck 保留。检查记录写入失败也返回 error,不声称已持久化; CheckLatest 的返回值仍保留已成功获取的 CheckedAt/LatestVersion,可连同 error 诊断。
  • 同版本激活不刷新 LastUpdate;第一次激活、升级和显式降级才刷新。
  • 激活已原子写入后即使解锁失败,LastUpdate 仍反映真实落盘结果;不能仅凭 error 推导未切换。
  • CheckLatest 直接返回的 UpdateStatus 另含 CheckedAt、Duration,Duration 不包含 OnOperation 回调。

挂载点固定在最新版本解析成功和统一激活入口,便利方法不重复写状态:

flowchart TD
    F[FindLatest] --> R[findLatestCheck]
    C[CheckLatest] --> Q[checkLatest]
    Q --> R
    L[LoadLatest] --> Q
    A[Load 缓存不可用] --> L
    R --> P[RecordCheck 持久化]
    L --> S[switchVersionOperation]
    V[SwitchVersion] --> S
    X[LoadVersion] --> E[加载指定版本 不激活]
    S --> E
    S --> T[activateCachedVersion]
    B[ActivateVersion] --> T
    T --> U[SetCurrent 原子保存版本与 LastUpdate]

CurrentVersion、Status、LoadCached 及缓存命中的 Load 不写事件状态; LoadVersion 只可能安装/清理数据包,不写检查和激活记录。

单次操作报告
client, err := modellink.New(modellink.Options{
    OnOperation: func(report modellink.OperationReport) {
        log.Printf("%s: start=%s end=%s total=%s err=%v",
            report.Operation, report.StartedAt, report.FinishedAt,
            report.Duration, report.Err)
        for _, stage := range report.Stages {
            log.Printf("  %s: %s", stage.Stage, stage.Duration)
        }
    },
})

可运行示例:go run ./examples/observability(会检查 Registry 并加载数据)。 Report 不持久化、不放到 Snapshot,也不改变现有 Load/Switch 返回值。 未设置 OnOperation 时不采集阶段明细。阶段按开始顺序记录,允许重复,缺失表示没有执行。

Stage 范围
resolve Registry 元数据请求及解析,含指定版本查询
lock_wait 缓存锁等待,包括 FileCache 元数据锁
cache_read 缓存数据与状态读取
download 压缩包 HTTP 请求及响应体读取,不含包校验
verify integrity/hash 校验、解包、Schema 版本检查及 JSON 解析
cache_write 数据包和检查元数据写入
activate 激活操作,含原子更新版本与切换记录
prune 历史版本清理
shared_wait 加入同一 Client 已有任务后的等待

嵌套阶段使用排他耗时,例如激活内的验证和锁等待从 activate 中扣除。 总耗时独立测量,含调度和其他未单列开销,不强求等于阶段之和。 自定义 Cache 内部耗时计入其外层 cache_read/cache_write/activate,SDK 不猜测 Redis 内部的网络/验证划分。 download 出现只证明尝试下载;需结合 Err、后续阶段判断结果,不能当作成功标记。

并发与回调时机

公开方法建立逻辑操作记录,内部组合调用不重复生成 Report。 合并任务的发起调用把记录交给后台任务,任务结束、释放锁后产生一次完整报告; 即使发起调用取消等待,后台任务仍会按原有三分钟上限运行并报告真实结果。 后续加入的调用报告自己的 shared_wait(以及加入前已执行的步骤),不会复制实际下载耗时。 因此发起调用收到取消错误时,后续仍可能收到成功的任务报告,不能将它当成“该调用的返回值日志”。

OnOperation 在 Client/缓存锁外执行,可能并发发生,且后台报告可能在 API 返回后到达。 回调应快速、线程安全,不计入该报告的耗时。不提供回调异常恢复;请勿 panic。 不要在回调中无条件再次调用同一个 Client 的公开方法,否则这些方法又会触发回调。 需要完整的逐调用日志、持久审计历史或进程退出时的日志排空时,由应用负责。

候选数据包验证

internal/cmd/verifydata 用一个只监听本机回环地址的临时 npm Registry 验证尚未发布的 @modellink/data tarball。它执行完整客户端链路:解析 Registry 元数据、下载 tarball、 校验外层 integrity、校验 manifest 内部 SHA-256、解码 Go 类型、比较原始 JSON 与强类型 目录、写入临时 FileCache,并确认缓存重载不再访问 Registry。

go run ./internal/cmd/verifydata --tarball /path/to/modellink-data-0.3.2.tgz

也可以先用已发布包填充临时缓存,再把 Registry latest 切到候选包,验证真实升级路径:

go run ./internal/cmd/verifydata \
  --tarball /path/to/modellink-data-0.3.2.tgz \
  --baseline-tarball /path/to/modellink-data-0.3.1.tgz

默认允许同一破坏性 Schema 版本内的 additive 变更,并把 SDK Schema 落后记录为 warning。 需要在发布关键版本前强制候选 Schema 与当前 SDK 内嵌 Schema 完全一致时,添加:

--strict-schema

命令只读取传入的 tarball,不访问真实 npm Registry,不发布包,不修改用户缓存,也不 写入任何仓库文件。--json 可输出机器可读报告。

Schema 与代码生成

当前内嵌 Schema v3,来源于 @modellink/data 0.3.0。客户端只解析当前破坏性 Schema 版本,不提供旧 Schema 数据的回滚读取。 Provider 的可选 Links 提供 Models(模型目录)、Pricing(价格/套餐)、 APIKey(申请和接入指引)、Console(管理后台)。使用前检查 provider.Links != nil 及具体字段是否为 nil;旧数据或未提供的入口保持缺省。原 Doc 文档入口仍保留。

仓库保存了生成依据:

schema/schema.json
schema/schema.lock.json
zz_types_generated.go

schema.lock.json 记录 npm 包版本、Schema 版本、SHA-256 和 ModelLink 源 commit。

更新过程是手动触发的:

# 从 npm 官方源同步最新 Schema 和锁文件
go run ./internal/cmd/schemasync

# 只根据仓库内 Schema 重新生成 Go 类型,不拉取 ModelLink 数据
go generate ./...

go test ./...

也可以同步指定版本或指定 Registry:

go run ./internal/cmd/schemasync -version 0.1.3
go run ./internal/cmd/schemasync -registry https://registry.npmmirror.com

CI 会强制检查已提交 Schema 与生成代码是否一致。npm 最新数据包中的 Schema 版本或内容发生变化时只给出提示,不阻止 Pull Request;仅模型数据更新不会触发提示:

go run ./internal/cmd/schemacheck

当前客户端支持的破坏性 Schema 版本由 modellink.SupportedSchemaVersion 表示。 自动更新遇到更高版本时会先尝试解析最新 JSON:解析成功则使用新数据并产生 WarningSchemaSDKOutdated;解析失败则保留当前兼容缓存并产生 WarningSchemaUpdateSkipped。没有兼容缓存或显式加载不兼容版本时返回 modellink.ErrUnsupportedSchema。

仓库结构

根目录保持单一的 modellink package,外部项目始终只需要一个 import。文件按职责 拆分,目录并不代表额外的公共子包:

client.go              Client、Options 和公共版本结构
client_api.go          完整公开 Client API 与语义注释
client_load.go         缓存读取、固定版本和激活实现
client_update.go       Registry 查询、防降级和并发协调
snapshot.go            Model、Provider、ProviderModel 查询
warning.go             Schema 兼容性警告与版本方向判断

cache.go               Cache、CacheStore 和 Locker 接口
cache_file.go          默认文件缓存和原子读写
cache_file_lock.go     跨进程文件锁
cache_file_prune.go    缓存版本清理

schema.go              内嵌 Schema 和版本元数据
types_custom.go        手写的特殊 JSON 类型
zz_types_generated.go  Schema 自动生成类型,请勿手工修改

internal/artifact/     npm 下载、integrity 和文件哈希校验
internal/cmd/          Schema 同步、生成、检查和候选包验证命令
examples/              可直接运行的使用示例
schema/                生成依据和版本锁文件

修改公开数据类型时,应先更新 ModelLink 的 schema.json,然后同步 Schema 并重新运行 go generate ./...,不要直接编辑 zz_types_generated.go。

数据来源

License

MIT

Documentation

Overview

Package modellink downloads, verifies, caches and parses the versioned ModelLink catalog for Go applications.

The zero-value Options use the domestic npmmirror registry and a shared, cross-platform file cache:

client, err := modellink.New(modellink.Options{})
snapshot, err := client.Load(ctx)
model, ok := snapshot.ProviderModel("deepseek", "deepseek-v4-pro")

Load prefers the active verified cache and only calls LoadLatest when no usable cache exists. LoadCached never accesses the registry; LoadLatest always checks it and prevents automatic downgrade. LoadVersion reads an explicit version without activating it, while SwitchVersion deliberately changes the active version. Use NewFileCache to customize local retention, or implement Cache to connect Redis or another shared backend. Compatibility warnings are available from Snapshot.Warnings and Options.OnWarning. Status reads persistent check and activation history from the cache. FindLatest and CheckLatest persist successful checks without activating data. Options.OnOperation optionally receives exclusive stage timings.

Index

Constants

View Source
const SupportedSchemaVersion = 3

Variables

View Source
var (
	ErrNoCachedData      = errors.New("modellink: no cached data")
	ErrUnsupportedSchema = errors.New("modellink: unsupported schema version")
	ErrLockTimeout       = errors.New("modellink: cache lock timeout")
)

Functions

func Schema

func Schema() []byte

Types

type AnthropicUsage added in v0.5.0

type AnthropicUsage struct {
	InputTokens              int64 `json:"input_tokens"`
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int64 `json:"cache_read_input_tokens"`
	OutputTokens             int64 `json:"output_tokens"`
}

AnthropicUsage mirrors the usage object of the Anthropic Messages API. InputTokens excludes cached input; cache reads and writes are separate.

func (*AnthropicUsage) UnmarshalJSON added in v0.5.0

func (usage *AnthropicUsage) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the official Messages usage object.

type Cache

type Cache interface {
	CacheStore
	Locker
}

Cache combines storage and update coordination. Most users only configure this interface; the smaller interfaces allow advanced backend composition.

func NewCache

func NewCache(store CacheStore, locker Locker) (Cache, error)

NewCache combines a store and locker into one Cache.

type CacheEntry

type CacheEntry struct {
	Version string
	Files   map[DataFile][]byte
}

CacheEntry is one immutable, versioned ModelLink data package. Files contain the verified JSON bytes published in @modellink/data.

type CachePruner

type CachePruner interface {
	Prune(ctx context.Context, protected ...string) error
}

CachePruner is an optional cache capability used after successful package operations. Custom caches may omit it and manage retention independently.

type CacheState added in v0.3.0

type CacheState struct {
	// Version is the shared active pointer, not the version of an application's
	// previously loaded Snapshot. Empty means no version has been activated.
	Version    string       `json:"version,omitempty"`
	LastCheck  *CheckState  `json:"last_check,omitempty"`
	LastUpdate *UpdateState `json:"last_update,omitempty"`
}

CacheState survives process restarts. Nil records mean no known event. Version uses the legacy current.json field for backwards-readable storage.

type CacheStore

type CacheStore interface {
	Current(ctx context.Context) (string, error)
	Get(ctx context.Context, version string) (*CacheEntry, error)
	Put(ctx context.Context, entry *CacheEntry) error
	// SetCurrent must atomically update Version and LastUpdate, preserving
	// LastCheck. Same-version activation must preserve LastUpdate. Implementations
	// coordinate metadata writes internally (callers can hold version locks).
	SetCurrent(ctx context.Context, version string) error
	// State returns durable metadata; a new cache returns an empty state.
	State(ctx context.Context) (CacheState, error)
	// RecordCheck merges a successful latest lookup without overwriting activation.
	// Older CheckedAt values must not replace newer records.
	RecordCheck(ctx context.Context, check CheckState) error
}

CacheStore persists versioned packages and the currently active version. Put must publish an entry atomically: readers must never observe partial data.

type Catalog

type Catalog struct {
	// Models corresponds to the JSON schema field "models".
	Models Models `json:"models"`

	// Providers corresponds to the JSON schema field "providers".
	Providers Providers `json:"providers"`
}

type CheckState added in v0.3.0

type CheckState struct {
	// CheckedAt is the UTC time of a successful latest lookup, even if unchanged.
	CheckedAt time.Time `json:"checked_at"`
	// LatestVersion is what Registry returned at CheckedAt, not a live value.
	LatestVersion string `json:"latest_version"`
	Registry      string `json:"registry"`
}

CheckState records a successful latest lookup, not a successful download.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client loads verified, versioned ModelLink snapshots.

func New

func New(options Options) (*Client, error)

New creates a ModelLink client.

func (*Client) ActivateVersion

func (client *Client) ActivateVersion(ctx context.Context, version string) (err error)

ActivateVersion makes an already cached version active without accessing the registry. It returns ErrNoCachedData when that version is not cached.

func (*Client) CheckLatest

func (client *Client) CheckLatest(ctx context.Context) (status UpdateStatus, err error)

CheckLatest compares the active local version with the registry latest version without downloading data or activating a version. Successful checks are persisted in cache metadata.

func (*Client) CurrentVersion

func (client *Client) CurrentVersion(ctx context.Context) (versionResult string, err error)

CurrentVersion returns the active local version without accessing the registry. It returns ErrNoCachedData when no version has been activated.

func (*Client) FindLatest

func (client *Client) FindLatest(ctx context.Context) (versionResult string, err error)

FindLatest queries the registry for its latest package version. It does not download data or change the active version. It persists a successful check.

func (*Client) Load

func (client *Client) Load(ctx context.Context) (result *Snapshot, err error)

Load returns the active verified cache without checking the registry. When no valid cache is available, it blocks while loading the safe latest version.

func (*Client) LoadCached

func (client *Client) LoadCached(ctx context.Context) (result *Snapshot, err error)

LoadCached returns the active verified local snapshot without accessing the registry. It returns ErrNoCachedData when no version has been activated.

func (*Client) LoadLatest

func (client *Client) LoadLatest(ctx context.Context) (result *Snapshot, err error)

LoadLatest checks the registry, prevents automatic downgrade, activates the safe latest version and returns the active verified snapshot.

func (*Client) LoadVersion

func (client *Client) LoadVersion(ctx context.Context, version string) (result *Snapshot, err error)

LoadVersion returns a verified explicit version without changing the active version. It downloads and caches the version when necessary.

func (*Client) Status added in v0.3.0

func (client *Client) Status(ctx context.Context) (state CacheState, err error)

Status reads persistent shared-cache metadata without querying the registry.

func (*Client) SwitchVersion

func (client *Client) SwitchVersion(ctx context.Context, version string) (err error)

SwitchVersion loads and activates an explicit version. This deliberate operation permits both upgrades and downgrades.

type CostCurrency added in v0.5.0

type CostCurrency string

CostCurrency identifies the unit a CostResult is expressed in.

const (
	// CostCNY means the result is in Chinese yuan per the cost_cn field.
	CostCNY CostCurrency = "CNY"
	// CostPoints means the result is in plan points per cost_points.
	CostPoints CostCurrency = "POINTS"
	// CostUSD means the result is in US dollars per the cost field.
	CostUSD CostCurrency = "USD"
)

type CostQuery added in v0.5.0

type CostQuery struct {
	Provider string
	Model    string

	// Usage carries the provider-reported usage. Pick the type matching the
	// protocol of the request.
	Usage CostUsage

	// Thinking selects the dedicated thinking-mode prices (cost_cn.thinking)
	// when the selected tier declares them.
	Thinking bool

	// At is the billing moment for time-window tiers, interpreted in the
	// timezone declared by the data. Providers bill by server receive time, so
	// pass that moment when available. Required whenever a matching price has
	// time-window tiers.
	At time.Time

	// IsCNStatutoryHoliday reports whether a calendar day in the declared
	// timezone is a Chinese statutory holiday. It is required when a matching
	// price window excludes holidays (holiday = "exclude_cn_statutory"); without
	// it the price is unknown and Cost returns an error instead of guessing.
	IsCNStatutoryHoliday func(day time.Time) (bool, error)
}

CostQuery describes one billable request.

type CostResult added in v0.5.0

type CostResult struct {
	// Currency is CNY, POINTS or USD.
	Currency CostCurrency
	// Total is the full price of the request in the currency above.
	Total float64
	// InputCost covers uncached input tokens.
	InputCost float64
	// CachedInputCost covers cache-hit input tokens.
	CachedInputCost float64
	// CacheWriteCost covers cache-write input tokens when the data prices them.
	CacheWriteCost float64
	// OutputCost covers generated tokens, including any separately priced
	// reasoning tokens.
	OutputCost float64
	// TierLabel names the matched tier, or the top-level fallback label such
	// as 闲时. Empty when the data has no label.
	TierLabel string
	// PerTokens is the token unit the prices refer to: 1,000,000 for CNY and
	// USD prices, or the per_tokens declared by cost_points.
	PerTokens int64
}

CostResult is the computed price of one request.

type CostUsage added in v0.5.0

type CostUsage interface {
	// contains filtered or unexported methods
}

CostUsage is the usage of one billable request, expressed with the same fields as the protocol that produced it. Pick the type matching the API you called and copy the usage object from the provider response; ModelLink normalizes the accounting differences (whether cached tokens are included in the input count, whether reasoning tokens are included in the output count) before pricing.

type DataFile

type DataFile string

DataFile identifies a JSON file published in @modellink/data.

const (
	FileAPI      DataFile = "api.json"
	FileModels   DataFile = "models.json"
	FileCatalog  DataFile = "catalog.json"
	FileSchema   DataFile = "schema.json"
	FileManifest DataFile = "manifest.json"
)

type FileCache

type FileCache struct {
	// contains filtered or unexported fields
}

FileCache is the default persistent cache. It uses atomic filesystem updates and kernel-backed file locks, so independent processes can safely share it.

func NewFileCache

func NewFileCache(options FileCacheOptions) (*FileCache, error)

NewFileCache creates a filesystem cache. Zero options use the same defaults as New(Options{}).

func (*FileCache) Current

func (cache *FileCache) Current(ctx context.Context) (string, error)

func (*FileCache) Directory

func (cache *FileCache) Directory() string

Directory returns the absolute cache directory.

func (*FileCache) Get

func (cache *FileCache) Get(ctx context.Context, version string) (*CacheEntry, error)

func (*FileCache) Lock

func (cache *FileCache) Lock(ctx context.Context, key string) (Lock, error)

func (*FileCache) Prune

func (cache *FileCache) Prune(ctx context.Context, protected ...string) error

Prune removes old immutable versions while preserving the active version and every version named in protected. Busy versions are serialized by their version lock before removal.

func (*FileCache) Put

func (cache *FileCache) Put(ctx context.Context, entry *CacheEntry) error

func (*FileCache) RecordCheck added in v0.3.0

func (cache *FileCache) RecordCheck(ctx context.Context, check CheckState) error

func (*FileCache) SetCurrent

func (cache *FileCache) SetCurrent(ctx context.Context, version string) error

func (*FileCache) State added in v0.3.0

func (cache *FileCache) State(ctx context.Context) (CacheState, error)

State reads an atomic metadata snapshot, including old version-only files.

type FileCacheOptions

type FileCacheOptions struct {
	// Directory is the cache root. Empty uses os.UserCacheDir()/modellink.
	Directory string
	// MaxVersions is the total number of versions to retain. Zero defaults to
	// two; -1 disables automatic cleanup. Positive values must be at least two.
	MaxVersions int
}

FileCacheOptions configures the default filesystem cache.

type Interleaved

type Interleaved struct {
	Field string
}

func (Interleaved) MarshalJSON

func (value Interleaved) MarshalJSON() ([]byte, error)

func (*Interleaved) UnmarshalJSON

func (value *Interleaved) UnmarshalJSON(data []byte) error

type JSONValue

type JSONValue interface{}

type Lock

type Lock interface {
	Unlock() error
}

Lock is an acquired cache lock.

type Locker

type Locker interface {
	Lock(ctx context.Context, key string) (Lock, error)
}

Locker coordinates a complete update operation across all clients sharing a cache. Implementations must honor cancellation while waiting for a lock.

type Manifest

type Manifest struct {
	// Files corresponds to the JSON schema field "files".
	Files ManifestFiles `json:"files"`

	// GeneratedAt corresponds to the JSON schema field "generated_at".
	GeneratedAt time.Time `json:"generated_at"`

	// SchemaVersion corresponds to the JSON schema field "schema_version".
	SchemaVersion int `json:"schema_version"`

	// Source corresponds to the JSON schema field "source".
	Source ManifestSource `json:"source"`

	// Version corresponds to the JSON schema field "version".
	Version string `json:"version"`
}

type ManifestFile

type ManifestFile struct {
	// SHA256 corresponds to the JSON schema field "sha256".
	SHA256 string `json:"sha256"`

	// Size corresponds to the JSON schema field "size".
	Size int `json:"size"`
}

type ManifestFiles

type ManifestFiles struct {
	// APIJSON corresponds to the JSON schema field "api.json".
	APIJSON ManifestFile `json:"api.json"`

	// CatalogJSON corresponds to the JSON schema field "catalog.json".
	CatalogJSON ManifestFile `json:"catalog.json"`

	// ModelsJSON corresponds to the JSON schema field "models.json".
	ModelsJSON ManifestFile `json:"models.json"`

	// SchemaJSON corresponds to the JSON schema field "schema.json".
	SchemaJSON ManifestFile `json:"schema.json"`
}

type ManifestSource

type ManifestSource struct {
	// Repository corresponds to the JSON schema field "repository".
	Repository string `json:"repository"`

	// Revision corresponds to the JSON schema field "revision".
	Revision string `json:"revision"`
}

type ModelMetadata

type ModelMetadata struct {
	// Whether attachments are supported. Missing on optional metadata means unknown.
	Attachment *bool `json:"attachment,omitempty"`

	// Benchmarks corresponds to the JSON schema field "benchmarks".
	Benchmarks []ModelMetadataBenchmarksElem `json:"benchmarks,omitempty"`

	// Description corresponds to the JSON schema field "description".
	Description string `json:"description"`

	// Family corresponds to the JSON schema field "family".
	Family *ModelMetadataFamily `json:"family,omitempty"`

	// ID corresponds to the JSON schema field "id".
	ID string `json:"id"`

	// Knowledge corresponds to the JSON schema field "knowledge".
	Knowledge *string `json:"knowledge,omitempty"`

	// LastUpdated corresponds to the JSON schema field "last_updated".
	LastUpdated *string `json:"last_updated,omitempty"`

	// License corresponds to the JSON schema field "license".
	License *string `json:"license,omitempty"`

	// Token limits published for the base model.
	Limit *ModelMetadataLimit `json:"limit,omitempty"`

	// Links corresponds to the JSON schema field "links".
	Links []ModelMetadataLinksElem `json:"links,omitempty"`

	// Input and output modalities exposed by this model endpoint.
	Modalities *ModelMetadataModalities `json:"modalities,omitempty"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// OpenWeights corresponds to the JSON schema field "open_weights".
	OpenWeights *bool `json:"open_weights,omitempty"`

	// Whether reasoning is supported. Missing means unknown; false means explicitly
	// unsupported.
	Reasoning *bool `json:"reasoning,omitempty"`

	// ReleaseDate corresponds to the JSON schema field "release_date".
	ReleaseDate *string `json:"release_date,omitempty"`

	// Series corresponds to the JSON schema field "series".
	Series *string `json:"series,omitempty"`

	// Whether structured output is supported. Missing means unknown; false means
	// explicitly unsupported.
	StructuredOutput *bool `json:"structured_output,omitempty"`

	// Whether temperature is explicitly adjustable. Missing means unknown; false
	// means fixed or unsupported.
	Temperature *bool `json:"temperature,omitempty"`

	// Whether tool calling is supported. Missing means unknown; false means
	// explicitly unsupported.
	ToolCall *bool `json:"tool_call,omitempty"`

	// Weights corresponds to the JSON schema field "weights".
	Weights []ModelMetadataWeightsElem `json:"weights,omitempty"`
}

type ModelMetadataBenchmarksElem

type ModelMetadataBenchmarksElem struct {
	// Dataset corresponds to the JSON schema field "dataset".
	Dataset *string `json:"dataset,omitempty"`

	// Date corresponds to the JSON schema field "date".
	Date *string `json:"date,omitempty"`

	// Harness corresponds to the JSON schema field "harness".
	Harness *string `json:"harness,omitempty"`

	// Metric corresponds to the JSON schema field "metric".
	Metric *string `json:"metric,omitempty"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// Score corresponds to the JSON schema field "score".
	Score interface{} `json:"score"`

	// Source corresponds to the JSON schema field "source".
	Source *string `json:"source,omitempty"`

	// Variant corresponds to the JSON schema field "variant".
	Variant *string `json:"variant,omitempty"`

	// Version corresponds to the JSON schema field "version".
	Version *string `json:"version,omitempty"`
}

type ModelMetadataFamily

type ModelMetadataFamily string
const ModelMetadataFamilyAgi ModelMetadataFamily = "agi"
const ModelMetadataFamilyAllam ModelMetadataFamily = "allam"
const ModelMetadataFamilyAllenai ModelMetadataFamily = "allenai"
const ModelMetadataFamilyAlpha ModelMetadataFamily = "alpha"
const ModelMetadataFamilyAura ModelMetadataFamily = "aura"
const ModelMetadataFamilyAuto ModelMetadataFamily = "auto"
const ModelMetadataFamilyBaichuan ModelMetadataFamily = "baichuan"
const ModelMetadataFamilyBart ModelMetadataFamily = "bart"
const ModelMetadataFamilyBge ModelMetadataFamily = "bge"
const ModelMetadataFamilyBigPickle ModelMetadataFamily = "big-pickle"
const ModelMetadataFamilyCanopylabs ModelMetadataFamily = "canopylabs"
const ModelMetadataFamilyChutesai ModelMetadataFamily = "chutesai"
const ModelMetadataFamilyClaude ModelMetadataFamily = "claude"
const ModelMetadataFamilyClaudeFable ModelMetadataFamily = "claude-fable"
const ModelMetadataFamilyClaudeHaiku ModelMetadataFamily = "claude-haiku"
const ModelMetadataFamilyClaudeOpus ModelMetadataFamily = "claude-opus"
const ModelMetadataFamilyClaudeSonnet ModelMetadataFamily = "claude-sonnet"
const ModelMetadataFamilyCodestral ModelMetadataFamily = "codestral"
const ModelMetadataFamilyCodestralEmbed ModelMetadataFamily = "codestral-embed"
const ModelMetadataFamilyCogito ModelMetadataFamily = "cogito"
const ModelMetadataFamilyCohereEmbed ModelMetadataFamily = "cohere-embed"
const ModelMetadataFamilyCommand ModelMetadataFamily = "command"
const ModelMetadataFamilyCommandA ModelMetadataFamily = "command-a"
const ModelMetadataFamilyCommandLight ModelMetadataFamily = "command-light"
const ModelMetadataFamilyCommandR ModelMetadataFamily = "command-r"
const ModelMetadataFamilyDallE ModelMetadataFamily = "dall-e"
const ModelMetadataFamilyDeepseek ModelMetadataFamily = "deepseek"
const ModelMetadataFamilyDeepseekFlash ModelMetadataFamily = "deepseek-flash"
const ModelMetadataFamilyDeepseekFlashFree ModelMetadataFamily = "deepseek-flash-free"
const ModelMetadataFamilyDeepseekFlashThink ModelMetadataFamily = "deepseek-flash-think"
const ModelMetadataFamilyDeepseekThinking ModelMetadataFamily = "deepseek-thinking"
const ModelMetadataFamilyDevstral ModelMetadataFamily = "devstral"
const ModelMetadataFamilyDiscolm ModelMetadataFamily = "discolm"
const ModelMetadataFamilyDistilbert ModelMetadataFamily = "distilbert"
const ModelMetadataFamilyDoubaoSeed ModelMetadataFamily = "doubao-seed"
const ModelMetadataFamilyDreamMachine ModelMetadataFamily = "dream-machine"
const ModelMetadataFamilyDreamshaper ModelMetadataFamily = "dreamshaper"
const ModelMetadataFamilyElephant ModelMetadataFamily = "elephant"
const ModelMetadataFamilyElevenlabs ModelMetadataFamily = "elevenlabs"
const ModelMetadataFamilyErnie ModelMetadataFamily = "ernie"
const ModelMetadataFamilyFalcon ModelMetadataFamily = "falcon"
const ModelMetadataFamilyFlux ModelMetadataFamily = "flux"
const ModelMetadataFamilyFugu ModelMetadataFamily = "fugu"
const ModelMetadataFamilyGemini ModelMetadataFamily = "gemini"
const ModelMetadataFamilyGeminiEmbedding ModelMetadataFamily = "gemini-embedding"
const ModelMetadataFamilyGeminiFlash ModelMetadataFamily = "gemini-flash"
const ModelMetadataFamilyGeminiFlashLite ModelMetadataFamily = "gemini-flash-lite"
const ModelMetadataFamilyGeminiPro ModelMetadataFamily = "gemini-pro"
const ModelMetadataFamilyGemma ModelMetadataFamily = "gemma"
const ModelMetadataFamilyGlm ModelMetadataFamily = "glm"
const ModelMetadataFamilyGlmAir ModelMetadataFamily = "glm-air"
const ModelMetadataFamilyGlmFlash ModelMetadataFamily = "glm-flash"
const ModelMetadataFamilyGlmFree ModelMetadataFamily = "glm-free"
const ModelMetadataFamilyGlmZ ModelMetadataFamily = "glm-z"
const ModelMetadataFamilyGlmv ModelMetadataFamily = "glmv"
const ModelMetadataFamilyGpt ModelMetadataFamily = "gpt"
const ModelMetadataFamilyGptCodex ModelMetadataFamily = "gpt-codex"
const ModelMetadataFamilyGptCodexMini ModelMetadataFamily = "gpt-codex-mini"
const ModelMetadataFamilyGptCodexSpark ModelMetadataFamily = "gpt-codex-spark"
const ModelMetadataFamilyGptImage ModelMetadataFamily = "gpt-image"
const ModelMetadataFamilyGptLuna ModelMetadataFamily = "gpt-luna"
const ModelMetadataFamilyGptMini ModelMetadataFamily = "gpt-mini"
const ModelMetadataFamilyGptNano ModelMetadataFamily = "gpt-nano"
const ModelMetadataFamilyGptOss ModelMetadataFamily = "gpt-oss"
const ModelMetadataFamilyGptPro ModelMetadataFamily = "gpt-pro"
const ModelMetadataFamilyGptSol ModelMetadataFamily = "gpt-sol"
const ModelMetadataFamilyGptTerra ModelMetadataFamily = "gpt-terra"
const ModelMetadataFamilyGranite ModelMetadataFamily = "granite"
const ModelMetadataFamilyGrok ModelMetadataFamily = "grok"
const ModelMetadataFamilyGrokBeta ModelMetadataFamily = "grok-beta"
const ModelMetadataFamilyGrokBuild ModelMetadataFamily = "grok-build"
const ModelMetadataFamilyGrokVision ModelMetadataFamily = "grok-vision"
const ModelMetadataFamilyGroq ModelMetadataFamily = "groq"
const ModelMetadataFamilyHermes ModelMetadataFamily = "hermes"
const ModelMetadataFamilyHunyuan ModelMetadataFamily = "hunyuan"
const ModelMetadataFamilyHy ModelMetadataFamily = "Hy"
const ModelMetadataFamilyHy3 ModelMetadataFamily = "hy3"
const ModelMetadataFamilyHy3Free ModelMetadataFamily = "hy3-free"
const ModelMetadataFamilyIdeogram ModelMetadataFamily = "ideogram"
const ModelMetadataFamilyImagen ModelMetadataFamily = "imagen"
const ModelMetadataFamilyIndictrans ModelMetadataFamily = "indictrans"
const ModelMetadataFamilyIntellect ModelMetadataFamily = "intellect"
const ModelMetadataFamilyInternS ModelMetadataFamily = "intern-s"
const ModelMetadataFamilyInternvl ModelMetadataFamily = "internvl"
const ModelMetadataFamilyJais ModelMetadataFamily = "jais"
const ModelMetadataFamilyJamba ModelMetadataFamily = "jamba"
const ModelMetadataFamilyJoyai ModelMetadataFamily = "joyai"
const ModelMetadataFamilyKatCoder ModelMetadataFamily = "kat-coder"
const ModelMetadataFamilyKimi ModelMetadataFamily = "kimi"
const ModelMetadataFamilyKimiFree ModelMetadataFamily = "kimi-free"
const ModelMetadataFamilyKimiK2 ModelMetadataFamily = "kimi-k2"
const ModelMetadataFamilyKimiK3 ModelMetadataFamily = "kimi-k3"
const ModelMetadataFamilyKimiThinking ModelMetadataFamily = "kimi-thinking"
const ModelMetadataFamilyLaguna ModelMetadataFamily = "laguna"
const ModelMetadataFamilyLagunaS ModelMetadataFamily = "laguna-s"
const ModelMetadataFamilyLing ModelMetadataFamily = "ling"
const ModelMetadataFamilyLingFlashFree ModelMetadataFamily = "ling-flash-free"
const ModelMetadataFamilyLiquid ModelMetadataFamily = "liquid"
const ModelMetadataFamilyLlama ModelMetadataFamily = "llama"
const ModelMetadataFamilyLlava ModelMetadataFamily = "llava"
const ModelMetadataFamilyLongcat ModelMetadataFamily = "longcat"
const ModelMetadataFamilyLucid ModelMetadataFamily = "lucid"
const ModelMetadataFamilyLyria ModelMetadataFamily = "lyria"
const ModelMetadataFamilyM2M ModelMetadataFamily = "m2m"
const ModelMetadataFamilyMagistral ModelMetadataFamily = "magistral"
const ModelMetadataFamilyMagistralMedium ModelMetadataFamily = "magistral-medium"
const ModelMetadataFamilyMagistralSmall ModelMetadataFamily = "magistral-small"
const ModelMetadataFamilyMai ModelMetadataFamily = "mai"
const ModelMetadataFamilyMelotts ModelMetadataFamily = "melotts"
const ModelMetadataFamilyMercury ModelMetadataFamily = "mercury"
const ModelMetadataFamilyMimo ModelMetadataFamily = "mimo"
const ModelMetadataFamilyMimoFlashFree ModelMetadataFamily = "mimo-flash-free"
const ModelMetadataFamilyMimoOmni ModelMetadataFamily = "mimo-omni"
const ModelMetadataFamilyMimoOmniFree ModelMetadataFamily = "mimo-omni-free"
const ModelMetadataFamilyMimoPro ModelMetadataFamily = "mimo-pro"
const ModelMetadataFamilyMimoProFree ModelMetadataFamily = "mimo-pro-free"
const ModelMetadataFamilyMimoV25 ModelMetadataFamily = "mimo-v2.5"
const ModelMetadataFamilyMimoV25Free ModelMetadataFamily = "mimo-v2.5-free"
const ModelMetadataFamilyMimoV25Pro ModelMetadataFamily = "mimo-v2.5-pro"
const ModelMetadataFamilyMimoV26Flash ModelMetadataFamily = "mimo-v2.6-flash"
const ModelMetadataFamilyMimoV26Pro ModelMetadataFamily = "mimo-v2.6-pro"
const ModelMetadataFamilyMimoV2Omni ModelMetadataFamily = "mimo-v2-omni"
const ModelMetadataFamilyMimoV2Pro ModelMetadataFamily = "mimo-v2-pro"
const ModelMetadataFamilyMinimax ModelMetadataFamily = "minimax"
const ModelMetadataFamilyMinimaxFree ModelMetadataFamily = "minimax-free"
const ModelMetadataFamilyMinimaxM2 ModelMetadataFamily = "minimax-m2"
const ModelMetadataFamilyMinimaxM21 ModelMetadataFamily = "minimax-m2.1"
const ModelMetadataFamilyMinimaxM25 ModelMetadataFamily = "minimax-m2.5"
const ModelMetadataFamilyMinimaxM27 ModelMetadataFamily = "minimax-m2.7"
const ModelMetadataFamilyMinimaxM3 ModelMetadataFamily = "minimax-m3"
const ModelMetadataFamilyMinimaxM3Free ModelMetadataFamily = "minimax-m3-free"
const ModelMetadataFamilyMinistral ModelMetadataFamily = "ministral"
const ModelMetadataFamilyMistral ModelMetadataFamily = "mistral"
const ModelMetadataFamilyMistralEmbed ModelMetadataFamily = "mistral-embed"
const ModelMetadataFamilyMistralLarge ModelMetadataFamily = "mistral-large"
const ModelMetadataFamilyMistralMedium ModelMetadataFamily = "mistral-medium"
const ModelMetadataFamilyMistralNemo ModelMetadataFamily = "mistral-nemo"
const ModelMetadataFamilyMistralSmall ModelMetadataFamily = "mistral-small"
const ModelMetadataFamilyMixtral ModelMetadataFamily = "mixtral"
const ModelMetadataFamilyMmPoly ModelMetadataFamily = "mm-poly"
const ModelMetadataFamilyModelRouter ModelMetadataFamily = "model-router"
const ModelMetadataFamilyMorph ModelMetadataFamily = "morph"
const ModelMetadataFamilyMuse ModelMetadataFamily = "muse"
const ModelMetadataFamilyNanoBanana ModelMetadataFamily = "nano-banana"
const ModelMetadataFamilyNemoretriever ModelMetadataFamily = "nemoretriever"
const ModelMetadataFamilyNemotron ModelMetadataFamily = "nemotron"
const ModelMetadataFamilyNemotronFree ModelMetadataFamily = "nemotron-free"
const ModelMetadataFamilyNeuralChat ModelMetadataFamily = "neural-chat"
const ModelMetadataFamilyNexN2 ModelMetadataFamily = "nex-n2"
const ModelMetadataFamilyNorth ModelMetadataFamily = "north"
const ModelMetadataFamilyNorthFree ModelMetadataFamily = "north-free"
const ModelMetadataFamilyNousresearch ModelMetadataFamily = "nousresearch"
const ModelMetadataFamilyNova ModelMetadataFamily = "nova"
const ModelMetadataFamilyNovaLite ModelMetadataFamily = "nova-lite"
const ModelMetadataFamilyNovaMicro ModelMetadataFamily = "nova-micro"
const ModelMetadataFamilyNovaPro ModelMetadataFamily = "nova-pro"
const ModelMetadataFamilyO ModelMetadataFamily = "o"
const ModelMetadataFamilyOMini ModelMetadataFamily = "o-mini"
const ModelMetadataFamilyOPro ModelMetadataFamily = "o-pro"
const ModelMetadataFamilyOpenchat ModelMetadataFamily = "openchat"
const ModelMetadataFamilyOpengvlab ModelMetadataFamily = "opengvlab"
const ModelMetadataFamilyOpenpangu ModelMetadataFamily = "openpangu"
const ModelMetadataFamilyOrnith ModelMetadataFamily = "ornith"
const ModelMetadataFamilyOsmosis ModelMetadataFamily = "osmosis"
const ModelMetadataFamilyOswe ModelMetadataFamily = "oswe"
const ModelMetadataFamilyPalmyra ModelMetadataFamily = "palmyra"
const ModelMetadataFamilyPangu ModelMetadataFamily = "pangu"
const ModelMetadataFamilyParakeet ModelMetadataFamily = "parakeet"
const ModelMetadataFamilyPhi ModelMetadataFamily = "phi"
const ModelMetadataFamilyPhoenix ModelMetadataFamily = "phoenix"
const ModelMetadataFamilyPixtral ModelMetadataFamily = "pixtral"
const ModelMetadataFamilyPlamo ModelMetadataFamily = "plamo"
const ModelMetadataFamilyPony ModelMetadataFamily = "pony"
const ModelMetadataFamilyQvq ModelMetadataFamily = "qvq"
const ModelMetadataFamilyQwen ModelMetadataFamily = "qwen"
const ModelMetadataFamilyQwen35 ModelMetadataFamily = "qwen3.5"
const ModelMetadataFamilyQwen36 ModelMetadataFamily = "qwen3.6"
const ModelMetadataFamilyQwen37Flash ModelMetadataFamily = "qwen3.7-flash"
const ModelMetadataFamilyQwen37Max ModelMetadataFamily = "qwen3.7-max"
const ModelMetadataFamilyQwen37Plus ModelMetadataFamily = "qwen3.7-plus"
const ModelMetadataFamilyQwen38Max ModelMetadataFamily = "qwen3.8-max"
const ModelMetadataFamilyQwenFree ModelMetadataFamily = "qwen-free"
const ModelMetadataFamilyQwerky ModelMetadataFamily = "qwerky"
const ModelMetadataFamilyRay ModelMetadataFamily = "ray"
const ModelMetadataFamilyRecraft ModelMetadataFamily = "recraft"
const ModelMetadataFamilyRednote ModelMetadataFamily = "rednote"
const ModelMetadataFamilyReka ModelMetadataFamily = "reka"
const ModelMetadataFamilyResnet ModelMetadataFamily = "resnet"
const ModelMetadataFamilyRing ModelMetadataFamily = "ring"
const ModelMetadataFamilyRing1TFree ModelMetadataFamily = "ring-1t-free"
const ModelMetadataFamilyRnj ModelMetadataFamily = "rnj"
const ModelMetadataFamilyRunway ModelMetadataFamily = "runway"
const ModelMetadataFamilySarvam ModelMetadataFamily = "sarvam"
const ModelMetadataFamilySeed ModelMetadataFamily = "seed"
const ModelMetadataFamilySensenova ModelMetadataFamily = "sensenova"
const ModelMetadataFamilySherlock ModelMetadataFamily = "sherlock"
const ModelMetadataFamilySkywork ModelMetadataFamily = "skywork"
const ModelMetadataFamilySmartTurn ModelMetadataFamily = "smart-turn"
const ModelMetadataFamilySolar ModelMetadataFamily = "solar"
const ModelMetadataFamilySolarMini ModelMetadataFamily = "solar-mini"
const ModelMetadataFamilySolarPro ModelMetadataFamily = "solar-pro"
const ModelMetadataFamilySonar ModelMetadataFamily = "sonar"
const ModelMetadataFamilySonarDeepResearch ModelMetadataFamily = "sonar-deep-research"
const ModelMetadataFamilySonarPro ModelMetadataFamily = "sonar-pro"
const ModelMetadataFamilySonarReasoning ModelMetadataFamily = "sonar-reasoning"
const ModelMetadataFamilySora ModelMetadataFamily = "sora"
const ModelMetadataFamilySourceful ModelMetadataFamily = "sourceful"
const ModelMetadataFamilySparkX2 ModelMetadataFamily = "spark-x2"
const ModelMetadataFamilySqlcoder ModelMetadataFamily = "sqlcoder"
const ModelMetadataFamilyStableDiffusion ModelMetadataFamily = "stable-diffusion"
const ModelMetadataFamilyStarling ModelMetadataFamily = "starling"
const ModelMetadataFamilyStep ModelMetadataFamily = "step"
const ModelMetadataFamilyTako ModelMetadataFamily = "tako"
const ModelMetadataFamilyTextEmbedding ModelMetadataFamily = "text-embedding"
const ModelMetadataFamilyTitan ModelMetadataFamily = "titan"
const ModelMetadataFamilyTitanEmbed ModelMetadataFamily = "titan-embed"
const ModelMetadataFamilyTngtech ModelMetadataFamily = "tngtech"
const ModelMetadataFamilyTopazlabs ModelMetadataFamily = "topazlabs"
const ModelMetadataFamilyTrinity ModelMetadataFamily = "trinity"
const ModelMetadataFamilyTrinityMini ModelMetadataFamily = "trinity-mini"
const ModelMetadataFamilyTstars ModelMetadataFamily = "tstars"
const ModelMetadataFamilyUnaCybertron ModelMetadataFamily = "una-cybertron"
const ModelMetadataFamilyUnsloth ModelMetadataFamily = "unsloth"
const ModelMetadataFamilyV0 ModelMetadataFamily = "v0"
const ModelMetadataFamilyVenice ModelMetadataFamily = "venice"
const ModelMetadataFamilyVeo ModelMetadataFamily = "veo"
const ModelMetadataFamilyVoxtral ModelMetadataFamily = "voxtral"
const ModelMetadataFamilyVoyage ModelMetadataFamily = "voyage"
const ModelMetadataFamilyWhisper ModelMetadataFamily = "whisper"
const ModelMetadataFamilyYi ModelMetadataFamily = "yi"
const ModelMetadataFamilyZephyr ModelMetadataFamily = "zephyr"

type ModelMetadataLimit

type ModelMetadataLimit struct {
	// Maximum context window in tokens.
	Context int `json:"context"`

	// Maximum input length in tokens when separately documented.
	Input *int `json:"input,omitempty"`

	// Maximum output length in tokens when documented.
	Output *int `json:"output,omitempty"`
}

Token limits published for the base model.

type ModelMetadataLinksElem

type ModelMetadataLinksElem struct {
	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type *ModelMetadataLinksElemType `json:"type,omitempty"`

	// URL corresponds to the JSON schema field "url".
	URL string `json:"url"`
}

type ModelMetadataLinksElemType

type ModelMetadataLinksElemType string
const ModelMetadataLinksElemTypeAnnouncement ModelMetadataLinksElemType = "announcement"
const ModelMetadataLinksElemTypeBlog ModelMetadataLinksElemType = "blog"
const ModelMetadataLinksElemTypeDocs ModelMetadataLinksElemType = "docs"
const ModelMetadataLinksElemTypeLicense ModelMetadataLinksElemType = "license"
const ModelMetadataLinksElemTypeModelCard ModelMetadataLinksElemType = "model_card"
const ModelMetadataLinksElemTypeOther ModelMetadataLinksElemType = "other"
const ModelMetadataLinksElemTypePaper ModelMetadataLinksElemType = "paper"
const ModelMetadataLinksElemTypeWeights ModelMetadataLinksElemType = "weights"

type ModelMetadataModalities

type ModelMetadataModalities struct {
	// Input modalities accepted by the model.
	Input []ModelMetadataModalitiesInputElem `json:"input"`

	// Output modalities produced by the model.
	Output []ModelMetadataModalitiesOutputElem `json:"output"`
}

Input and output modalities exposed by this model endpoint.

type ModelMetadataModalitiesInputElem

type ModelMetadataModalitiesInputElem string
const ModelMetadataModalitiesInputElemAudio ModelMetadataModalitiesInputElem = "audio"
const ModelMetadataModalitiesInputElemImage ModelMetadataModalitiesInputElem = "image"
const ModelMetadataModalitiesInputElemPdf ModelMetadataModalitiesInputElem = "pdf"
const ModelMetadataModalitiesInputElemText ModelMetadataModalitiesInputElem = "text"
const ModelMetadataModalitiesInputElemVideo ModelMetadataModalitiesInputElem = "video"

type ModelMetadataModalitiesOutputElem

type ModelMetadataModalitiesOutputElem string
const ModelMetadataModalitiesOutputElemAudio ModelMetadataModalitiesOutputElem = "audio"
const ModelMetadataModalitiesOutputElemImage ModelMetadataModalitiesOutputElem = "image"
const ModelMetadataModalitiesOutputElemPdf ModelMetadataModalitiesOutputElem = "pdf"
const ModelMetadataModalitiesOutputElemText ModelMetadataModalitiesOutputElem = "text"
const ModelMetadataModalitiesOutputElemVideo ModelMetadataModalitiesOutputElem = "video"

type ModelMetadataWeightsElem

type ModelMetadataWeightsElem struct {
	// Format corresponds to the JSON schema field "format".
	Format *string `json:"format,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Quantization corresponds to the JSON schema field "quantization".
	Quantization *string `json:"quantization,omitempty"`

	// URL corresponds to the JSON schema field "url".
	URL string `json:"url"`
}

type Models

type Models map[string]ModelMetadata

type OpenAIChatUsage added in v0.5.0

type OpenAIChatUsage struct {
	PromptTokens       int64 `json:"prompt_tokens"`
	CompletionTokens   int64 `json:"completion_tokens"`
	PromptCachedTokens int64 `json:"-"`
}

OpenAIChatUsage mirrors the usage object of OpenAI-compatible chat completions. PromptTokens includes cache hits; PromptCachedTokens is the cached_tokens part reported in prompt_tokens_details.

func (*OpenAIChatUsage) UnmarshalJSON added in v0.5.0

func (usage *OpenAIChatUsage) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the official chat-completions usage object.

type OpenAIResponsesUsage added in v0.5.0

type OpenAIResponsesUsage struct {
	InputTokens           int64 `json:"input_tokens"`
	OutputTokens          int64 `json:"output_tokens"`
	InputCachedTokens     int64 `json:"-"` // input_tokens_details.cached_tokens
	OutputReasoningTokens int64 `json:"-"` // output_tokens_details.reasoning_tokens
}

OpenAIResponsesUsage mirrors the usage object of the OpenAI Responses API. InputTokens includes cache hits; OutputTokens includes reasoning tokens.

func (*OpenAIResponsesUsage) UnmarshalJSON added in v0.5.0

func (usage *OpenAIResponsesUsage) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts the official Responses usage object.

type Operation added in v0.3.0

type Operation string

Operation identifies the public entry point that initiated a logical task.

const (
	OperationCurrentVersion  Operation = "current_version"
	OperationStatus          Operation = "status"
	OperationFindLatest      Operation = "find_latest"
	OperationCheckLatest     Operation = "check_latest"
	OperationActivateVersion Operation = "activate_version"
	OperationSwitchVersion   Operation = "switch_version"
	OperationLoadCached      Operation = "load_cached"
	OperationLoadVersion     Operation = "load_version"
	OperationLoadLatest      Operation = "load_latest"
	OperationLoad            Operation = "load"
)

type OperationReport added in v0.3.0

type OperationReport struct {
	Operation Operation
	// StartedAt and FinishedAt are UTC wall-clock timestamps.
	StartedAt  time.Time
	FinishedAt time.Time
	// Duration includes unclassified overhead but excludes the report callback.
	// It need not equal the sum of the exclusive stage durations.
	Duration time.Duration
	Stages   []StageReport
	Err      error
}

OperationReport measures a logical operation. A joined caller reports only its own shared_wait; the original task reports its work even if its caller cancels. Err is the operation error; applications should apply their usual redaction policy before exporting error messages to external log systems. Reports are not persisted. Callbacks run outside client/cache locks, may run concurrently, and may arrive after the initiating API call has returned.

type Options

type Options struct {
	// Registry is an npm-compatible registry URL. Empty uses npmmirror.
	Registry string
	// Cache stores and coordinates packages. Empty uses the default FileCache.
	Cache Cache
	// OnWarning receives each distinct non-fatal warning once per Client. Nil
	// keeps the client silent; warnings remain available from Snapshot.Warnings.
	OnWarning func(Warning)
	// OnOperation receives completed logical operations outside cache/client
	// locks. Calls can be concurrent; keep the handler short and concurrency-safe.
	// Shared tasks may report after the API returns. Nil disables stage collection.
	OnOperation func(OperationReport)
}

Options configures a Client. Its zero value uses npmmirror and the default cross-platform file cache.

type Protocol

type Protocol string
const ProtocolAnthropicCompatible Protocol = "anthropic-compatible"
const ProtocolOpenaiCompatible Protocol = "openai-compatible"
const ProtocolOpenaiResponses Protocol = "openai-responses"

type Provider

type Provider struct {
	// Base API URL for the default endpoint.
	API *string `json:"api,omitempty"`

	// Purchasable credit packages published for users in China.
	CreditPackagesCN []ProviderCreditPackagesCNElem `json:"credit_packages_cn,omitempty"`

	// Legacy single credit package summary retained for Schema v3 readers.
	CreditsCN *ProviderCreditsCN `json:"credits_cn,omitempty"`

	// Doc corresponds to the JSON schema field "doc".
	Doc string `json:"doc"`

	// All protocol-specific endpoints exposed by this provider.
	Endpoints []ProviderEndpoint `json:"endpoints,omitempty"`

	// Env corresponds to the JSON schema field "env".
	Env []string `json:"env"`

	// ID corresponds to the JSON schema field "id".
	ID string `json:"id"`

	// Purpose-specific official links for integrating with this provider.
	Links *ProviderLinks `json:"links,omitempty"`

	// Models corresponds to the JSON schema field "models".
	Models ProviderModels `json:"models"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// NPM corresponds to the JSON schema field "npm".
	NPM string `json:"npm"`

	// Subscription plans published for users in China.
	PlansCN []ProviderPlansCNElem `json:"plans_cn,omitempty"`

	// Default protocol used by this provider.
	Protocol ProviderProtocol `json:"protocol"`
}

type ProviderCreditPackagesCNElem added in v0.5.0

type ProviderCreditPackagesCNElem struct {
	// Cny corresponds to the JSON schema field "cny".
	Cny float64 `json:"cny"`

	// Points corresponds to the JSON schema field "points".
	Points int `json:"points"`

	// ValidDays corresponds to the JSON schema field "valid_days".
	ValidDays *int `json:"valid_days,omitempty"`
}

type ProviderCreditsCN

type ProviderCreditsCN struct {
	// Cny corresponds to the JSON schema field "cny".
	Cny float64 `json:"cny"`

	// Points corresponds to the JSON schema field "points".
	Points int `json:"points"`

	// ValidDays corresponds to the JSON schema field "valid_days".
	ValidDays *int `json:"valid_days,omitempty"`
}

Legacy single credit package summary retained for Schema v3 readers.

type ProviderEndpoint

type ProviderEndpoint struct {
	// Base API URL for this endpoint.
	API string `json:"api"`

	// Marks the endpoint represented by the provider-level protocol and API fields.
	Default *bool `json:"default,omitempty"`

	// Stable endpoint ID referenced by provider models.
	ID string `json:"id"`

	// Protocol corresponds to the JSON schema field "protocol".
	Protocol Protocol `json:"protocol"`
}

A protocol-specific API endpoint exposed by a provider.

type ProviderLinks struct {
	// Official instructions for applying for and configuring an API key.
	APIKey *string `json:"api_key,omitempty"`

	// Official console used to manage API keys and the provider account.
	Console *string `json:"console,omitempty"`

	// Official catalog of models available from this provider.
	Models *string `json:"models,omitempty"`

	// Official pricing, subscription plan, or purchase page.
	Pricing *string `json:"pricing,omitempty"`
}

Purpose-specific official links for integrating with this provider.

type ProviderModel

type ProviderModel struct {
	// Whether attachments are supported. Missing on optional metadata means unknown.
	Attachment bool `json:"attachment"`

	// Prices in USD per million tokens.
	Cost *ProviderModelCost `json:"cost,omitempty"`

	// Prices in CNY per million tokens.
	CostCN *ProviderModelCostCN `json:"cost_cn,omitempty"`

	// Plan point consumption per the number of tokens declared by per_tokens.
	CostPoints *ProviderModelCostPoints `json:"cost_points,omitempty"`

	// Description corresponds to the JSON schema field "description".
	Description string `json:"description"`

	// Doc corresponds to the JSON schema field "doc".
	Doc *string `json:"doc,omitempty"`

	// Provider endpoint IDs enabled for this model; missing means the provider
	// default endpoint.
	Endpoints []string `json:"endpoints,omitempty"`

	// Experimental corresponds to the JSON schema field "experimental".
	Experimental *ProviderModelExperimental `json:"experimental,omitempty"`

	// Family corresponds to the JSON schema field "family".
	Family *ProviderModelFamily `json:"family,omitempty"`

	// ID corresponds to the JSON schema field "id".
	ID string `json:"id"`

	// Whether reasoning content is returned alongside output, optionally naming its
	// response field.
	Interleaved *Interleaved `json:"interleaved,omitempty"`

	// Knowledge corresponds to the JSON schema field "knowledge".
	Knowledge *string `json:"knowledge,omitempty"`

	// LastUpdated corresponds to the JSON schema field "last_updated".
	LastUpdated string `json:"last_updated"`

	// Token limits exposed by this provider model endpoint.
	Limit ProviderModelLimit `json:"limit"`

	// Input and output modalities exposed by this model endpoint.
	Modalities ProviderModelModalities `json:"modalities"`

	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// OpenWeights corresponds to the JSON schema field "open_weights".
	OpenWeights bool `json:"open_weights"`

	// Provider corresponds to the JSON schema field "provider".
	Provider *ProviderModelProvider `json:"provider,omitempty"`

	// Whether reasoning is supported. Missing means unknown; false means explicitly
	// unsupported.
	Reasoning *bool `json:"reasoning,omitempty"`

	// Provider-specific controls for enabling or configuring reasoning.
	ReasoningOptions []ReasoningOption `json:"reasoning_options,omitempty"`

	// ReleaseDate corresponds to the JSON schema field "release_date".
	ReleaseDate string `json:"release_date"`

	// Series corresponds to the JSON schema field "series".
	Series *string `json:"series,omitempty"`

	// Status corresponds to the JSON schema field "status".
	Status *ProviderModelStatus `json:"status,omitempty"`

	// Whether structured output is supported. Missing means unknown; false means
	// explicitly unsupported.
	StructuredOutput *bool `json:"structured_output,omitempty"`

	// Whether temperature is explicitly adjustable. Missing means unknown; false
	// means fixed or unsupported.
	Temperature *bool `json:"temperature,omitempty"`

	// Whether tool calling is supported. Missing means unknown; false means
	// explicitly unsupported.
	ToolCall *bool `json:"tool_call,omitempty"`
}

type ProviderModelCost

type ProviderModelCost struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// ContextOver200K corresponds to the JSON schema field "context_over_200k".
	ContextOver200K *ProviderModelCostContextOver200K `json:"context_over_200k,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`

	// Tiers corresponds to the JSON schema field "tiers".
	Tiers []ProviderModelCostTiersElem `json:"tiers,omitempty"`
}

Prices in USD per million tokens.

type ProviderModelCostCN

type ProviderModelCostCN struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// ContextOver200K corresponds to the JSON schema field "context_over_200k".
	ContextOver200K *ProviderModelCostCNContextOver200K `json:"context_over_200k,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`

	// Thinking corresponds to the JSON schema field "thinking".
	Thinking *ProviderModelCostCNThinking `json:"thinking,omitempty"`

	// Tiers corresponds to the JSON schema field "tiers".
	Tiers []ProviderModelCostCNTiersElem `json:"tiers,omitempty"`
}

Prices in CNY per million tokens.

type ProviderModelCostCNContextOver200K

type ProviderModelCostCNContextOver200K struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`

	// Thinking corresponds to the JSON schema field "thinking".
	Thinking *ProviderModelCostCNContextOver200KThinking `json:"thinking,omitempty"`
}

type ProviderModelCostCNContextOver200KThinking

type ProviderModelCostCNContextOver200KThinking struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`
}

type ProviderModelCostCNThinking

type ProviderModelCostCNThinking struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`
}

type ProviderModelCostCNTiersElem

type ProviderModelCostCNTiersElem struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`

	// Thinking corresponds to the JSON schema field "thinking".
	Thinking *ProviderModelCostCNTiersElemThinking `json:"thinking,omitempty"`

	// When corresponds to the JSON schema field "when".
	When ProviderModelCostCNTiersElemWhen `json:"when"`
}

type ProviderModelCostCNTiersElemThinking

type ProviderModelCostCNTiersElemThinking struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`
}

type ProviderModelCostCNTiersElemWhen added in v0.4.0

type ProviderModelCostCNTiersElemWhen struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostCNTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostCNTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostCNTiersElemWhen_1Output `json:"output,omitempty"`

	// Size corresponds to the JSON schema field "size".
	Size *int `json:"size,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostCNTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostCNTiersElemWhen_0 added in v0.4.0

type ProviderModelCostCNTiersElemWhen_0 struct {
	// Size corresponds to the JSON schema field "size".
	Size int `json:"size"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostCNTiersElemWhen_1 added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1 struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostCNTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostCNTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostCNTiersElemWhen_1Output `json:"output,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostCNTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostCNTiersElemWhen_1Date added in v0.5.0

type ProviderModelCostCNTiersElemWhen_1Date struct {
	// From corresponds to the JSON schema field "from".
	From *string `json:"from,omitempty"`

	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone,omitempty"`

	// To corresponds to the JSON schema field "to".
	To *string `json:"to,omitempty"`
}

type ProviderModelCostCNTiersElemWhen_1Input added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1Input struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostCNTiersElemWhen_1Output added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1Output struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostCNTiersElemWhen_1Time added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1Time struct {
	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone"`

	// Windows corresponds to the JSON schema field "windows".
	Windows []ProviderModelCostCNTiersElemWhen_1TimeWindowsElem `json:"windows"`
}

type ProviderModelCostCNTiersElemWhen_1TimeWindowsElem added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1TimeWindowsElem struct {
	// Days corresponds to the JSON schema field "days".
	Days []ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem `json:"days"`

	// End corresponds to the JSON schema field "end".
	End string `json:"end"`

	// Excludes this window on China statutory holidays; callers provide the holiday
	// resolver.
	Holiday *string `json:"holiday,omitempty"`

	// Start corresponds to the JSON schema field "start".
	Start string `json:"start"`
}

type ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem added in v0.4.0

type ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem string
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemFriday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "friday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemMonday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "monday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemSaturday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "saturday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemSunday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "sunday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemThursday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "thursday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemTuesday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "tuesday"
const ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElemWednesday ProviderModelCostCNTiersElemWhen_1TimeWindowsElemDaysElem = "wednesday"

type ProviderModelCostContextOver200K

type ProviderModelCostContextOver200K struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`
}

type ProviderModelCostPoints

type ProviderModelCostPoints struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// PerTokens corresponds to the JSON schema field "per_tokens".
	PerTokens int `json:"per_tokens"`

	// Tiers corresponds to the JSON schema field "tiers".
	Tiers []ProviderModelCostPointsTiersElem `json:"tiers,omitempty"`
}

Plan point consumption per the number of tokens declared by per_tokens.

type ProviderModelCostPointsTiersElem

type ProviderModelCostPointsTiersElem struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// When corresponds to the JSON schema field "when".
	When ProviderModelCostPointsTiersElemWhen `json:"when"`
}

type ProviderModelCostPointsTiersElemWhen added in v0.4.0

type ProviderModelCostPointsTiersElemWhen struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostPointsTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostPointsTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostPointsTiersElemWhen_1Output `json:"output,omitempty"`

	// Size corresponds to the JSON schema field "size".
	Size *int `json:"size,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostPointsTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostPointsTiersElemWhen_0 added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_0 struct {
	// Size corresponds to the JSON schema field "size".
	Size int `json:"size"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostPointsTiersElemWhen_1 added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1 struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostPointsTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostPointsTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostPointsTiersElemWhen_1Output `json:"output,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostPointsTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostPointsTiersElemWhen_1Date added in v0.5.0

type ProviderModelCostPointsTiersElemWhen_1Date struct {
	// From corresponds to the JSON schema field "from".
	From *string `json:"from,omitempty"`

	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone,omitempty"`

	// To corresponds to the JSON schema field "to".
	To *string `json:"to,omitempty"`
}

type ProviderModelCostPointsTiersElemWhen_1Input added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1Input struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostPointsTiersElemWhen_1Output added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1Output struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostPointsTiersElemWhen_1Time added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1Time struct {
	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone"`

	// Windows corresponds to the JSON schema field "windows".
	Windows []ProviderModelCostPointsTiersElemWhen_1TimeWindowsElem `json:"windows"`
}

type ProviderModelCostPointsTiersElemWhen_1TimeWindowsElem added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1TimeWindowsElem struct {
	// Days corresponds to the JSON schema field "days".
	Days []ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem `json:"days"`

	// End corresponds to the JSON schema field "end".
	End string `json:"end"`

	// Excludes this window on China statutory holidays; callers provide the holiday
	// resolver.
	Holiday *string `json:"holiday,omitempty"`

	// Start corresponds to the JSON schema field "start".
	Start string `json:"start"`
}

type ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem added in v0.4.0

type ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem string
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemFriday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "friday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemMonday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "monday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemSaturday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "saturday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemSunday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "sunday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemThursday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "thursday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemTuesday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "tuesday"
const ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElemWednesday ProviderModelCostPointsTiersElemWhen_1TimeWindowsElemDaysElem = "wednesday"

type ProviderModelCostTiersElem

type ProviderModelCostTiersElem struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`

	// When corresponds to the JSON schema field "when".
	When ProviderModelCostTiersElemWhen `json:"when"`
}

type ProviderModelCostTiersElemWhen added in v0.4.0

type ProviderModelCostTiersElemWhen struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostTiersElemWhen_1Output `json:"output,omitempty"`

	// Size corresponds to the JSON schema field "size".
	Size *int `json:"size,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostTiersElemWhen_0 added in v0.4.0

type ProviderModelCostTiersElemWhen_0 struct {
	// Size corresponds to the JSON schema field "size".
	Size int `json:"size"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostTiersElemWhen_1 added in v0.4.0

type ProviderModelCostTiersElemWhen_1 struct {
	// Date corresponds to the JSON schema field "date".
	Date *ProviderModelCostTiersElemWhen_1Date `json:"date,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input *ProviderModelCostTiersElemWhen_1Input `json:"input,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output *ProviderModelCostTiersElemWhen_1Output `json:"output,omitempty"`

	// Time corresponds to the JSON schema field "time".
	Time *ProviderModelCostTiersElemWhen_1Time `json:"time,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ProviderModelCostTiersElemWhen_1Date added in v0.5.0

type ProviderModelCostTiersElemWhen_1Date struct {
	// From corresponds to the JSON schema field "from".
	From *string `json:"from,omitempty"`

	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone,omitempty"`

	// To corresponds to the JSON schema field "to".
	To *string `json:"to,omitempty"`
}

type ProviderModelCostTiersElemWhen_1Input added in v0.4.0

type ProviderModelCostTiersElemWhen_1Input struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostTiersElemWhen_1Output added in v0.4.0

type ProviderModelCostTiersElemWhen_1Output struct {
	// Gt corresponds to the JSON schema field "gt".
	Gt *int `json:"gt,omitempty"`

	// Gte corresponds to the JSON schema field "gte".
	Gte *int `json:"gte,omitempty"`

	// Lt corresponds to the JSON schema field "lt".
	Lt *int `json:"lt,omitempty"`

	// Lte corresponds to the JSON schema field "lte".
	Lte *int `json:"lte,omitempty"`
}

type ProviderModelCostTiersElemWhen_1Time added in v0.4.0

type ProviderModelCostTiersElemWhen_1Time struct {
	// Timezone corresponds to the JSON schema field "timezone".
	Timezone string `json:"timezone"`

	// Windows corresponds to the JSON schema field "windows".
	Windows []ProviderModelCostTiersElemWhen_1TimeWindowsElem `json:"windows"`
}

type ProviderModelCostTiersElemWhen_1TimeWindowsElem added in v0.4.0

type ProviderModelCostTiersElemWhen_1TimeWindowsElem struct {
	// Days corresponds to the JSON schema field "days".
	Days []ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem `json:"days"`

	// End corresponds to the JSON schema field "end".
	End string `json:"end"`

	// Excludes this window on China statutory holidays; callers provide the holiday
	// resolver.
	Holiday *string `json:"holiday,omitempty"`

	// Start corresponds to the JSON schema field "start".
	Start string `json:"start"`
}

type ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem added in v0.4.0

type ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem string
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemFriday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "friday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemMonday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "monday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemSaturday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "saturday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemSunday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "sunday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemThursday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "thursday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemTuesday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "tuesday"
const ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElemWednesday ProviderModelCostTiersElemWhen_1TimeWindowsElemDaysElem = "wednesday"

type ProviderModelExperimental

type ProviderModelExperimental struct {
	// Modes corresponds to the JSON schema field "modes".
	Modes ProviderModelExperimentalModes `json:"modes,omitempty"`
}

type ProviderModelExperimentalModes

type ProviderModelExperimentalModes map[string]struct {
	// Cost corresponds to the JSON schema field "cost".
	Cost *ProviderModelExperimentalModesValueCost `json:"cost,omitempty"`

	// CostCN corresponds to the JSON schema field "cost_cn".
	CostCN *ProviderModelExperimentalModesValueCostCN `json:"cost_cn,omitempty"`

	// Provider corresponds to the JSON schema field "provider".
	Provider *ProviderModelExperimentalModesValueProvider `json:"provider,omitempty"`
}

type ProviderModelExperimentalModesValueCost

type ProviderModelExperimentalModesValueCost struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`
}

type ProviderModelExperimentalModesValueCostCN

type ProviderModelExperimentalModesValueCostCN struct {
	// CacheRead corresponds to the JSON schema field "cache_read".
	CacheRead *float64 `json:"cache_read,omitempty"`

	// CacheWrite corresponds to the JSON schema field "cache_write".
	CacheWrite *float64 `json:"cache_write,omitempty"`

	// Input corresponds to the JSON schema field "input".
	Input float64 `json:"input"`

	// InputAudio corresponds to the JSON schema field "input_audio".
	InputAudio *float64 `json:"input_audio,omitempty"`

	// Label corresponds to the JSON schema field "label".
	Label *string `json:"label,omitempty"`

	// Output corresponds to the JSON schema field "output".
	Output float64 `json:"output"`

	// OutputAudio corresponds to the JSON schema field "output_audio".
	OutputAudio *float64 `json:"output_audio,omitempty"`

	// Reasoning corresponds to the JSON schema field "reasoning".
	Reasoning *float64 `json:"reasoning,omitempty"`
}

type ProviderModelExperimentalModesValueProvider

type ProviderModelExperimentalModesValueProvider struct {
	// Body corresponds to the JSON schema field "body".
	Body ProviderModelExperimentalModesValueProviderBody `json:"body,omitempty"`

	// Headers corresponds to the JSON schema field "headers".
	Headers ProviderModelExperimentalModesValueProviderHeaders `json:"headers,omitempty"`
}

type ProviderModelExperimentalModesValueProviderBody

type ProviderModelExperimentalModesValueProviderBody map[string]JSONValue

type ProviderModelExperimentalModesValueProviderHeaders

type ProviderModelExperimentalModesValueProviderHeaders map[string]string

type ProviderModelFamily

type ProviderModelFamily string
const ProviderModelFamilyAgi ProviderModelFamily = "agi"
const ProviderModelFamilyAllam ProviderModelFamily = "allam"
const ProviderModelFamilyAllenai ProviderModelFamily = "allenai"
const ProviderModelFamilyAlpha ProviderModelFamily = "alpha"
const ProviderModelFamilyAura ProviderModelFamily = "aura"
const ProviderModelFamilyAuto ProviderModelFamily = "auto"
const ProviderModelFamilyBaichuan ProviderModelFamily = "baichuan"
const ProviderModelFamilyBart ProviderModelFamily = "bart"
const ProviderModelFamilyBge ProviderModelFamily = "bge"
const ProviderModelFamilyBigPickle ProviderModelFamily = "big-pickle"
const ProviderModelFamilyCanopylabs ProviderModelFamily = "canopylabs"
const ProviderModelFamilyChutesai ProviderModelFamily = "chutesai"
const ProviderModelFamilyClaude ProviderModelFamily = "claude"
const ProviderModelFamilyClaudeFable ProviderModelFamily = "claude-fable"
const ProviderModelFamilyClaudeHaiku ProviderModelFamily = "claude-haiku"
const ProviderModelFamilyClaudeOpus ProviderModelFamily = "claude-opus"
const ProviderModelFamilyClaudeSonnet ProviderModelFamily = "claude-sonnet"
const ProviderModelFamilyCodestral ProviderModelFamily = "codestral"
const ProviderModelFamilyCodestralEmbed ProviderModelFamily = "codestral-embed"
const ProviderModelFamilyCogito ProviderModelFamily = "cogito"
const ProviderModelFamilyCohereEmbed ProviderModelFamily = "cohere-embed"
const ProviderModelFamilyCommand ProviderModelFamily = "command"
const ProviderModelFamilyCommandA ProviderModelFamily = "command-a"
const ProviderModelFamilyCommandLight ProviderModelFamily = "command-light"
const ProviderModelFamilyCommandR ProviderModelFamily = "command-r"
const ProviderModelFamilyDallE ProviderModelFamily = "dall-e"
const ProviderModelFamilyDeepseek ProviderModelFamily = "deepseek"
const ProviderModelFamilyDeepseekFlash ProviderModelFamily = "deepseek-flash"
const ProviderModelFamilyDeepseekFlashFree ProviderModelFamily = "deepseek-flash-free"
const ProviderModelFamilyDeepseekFlashThink ProviderModelFamily = "deepseek-flash-think"
const ProviderModelFamilyDeepseekThinking ProviderModelFamily = "deepseek-thinking"
const ProviderModelFamilyDevstral ProviderModelFamily = "devstral"
const ProviderModelFamilyDiscolm ProviderModelFamily = "discolm"
const ProviderModelFamilyDistilbert ProviderModelFamily = "distilbert"
const ProviderModelFamilyDoubaoSeed ProviderModelFamily = "doubao-seed"
const ProviderModelFamilyDreamMachine ProviderModelFamily = "dream-machine"
const ProviderModelFamilyDreamshaper ProviderModelFamily = "dreamshaper"
const ProviderModelFamilyElephant ProviderModelFamily = "elephant"
const ProviderModelFamilyElevenlabs ProviderModelFamily = "elevenlabs"
const ProviderModelFamilyErnie ProviderModelFamily = "ernie"
const ProviderModelFamilyFalcon ProviderModelFamily = "falcon"
const ProviderModelFamilyFlux ProviderModelFamily = "flux"
const ProviderModelFamilyFugu ProviderModelFamily = "fugu"
const ProviderModelFamilyGemini ProviderModelFamily = "gemini"
const ProviderModelFamilyGeminiEmbedding ProviderModelFamily = "gemini-embedding"
const ProviderModelFamilyGeminiFlash ProviderModelFamily = "gemini-flash"
const ProviderModelFamilyGeminiFlashLite ProviderModelFamily = "gemini-flash-lite"
const ProviderModelFamilyGeminiPro ProviderModelFamily = "gemini-pro"
const ProviderModelFamilyGemma ProviderModelFamily = "gemma"
const ProviderModelFamilyGlm ProviderModelFamily = "glm"
const ProviderModelFamilyGlmAir ProviderModelFamily = "glm-air"
const ProviderModelFamilyGlmFlash ProviderModelFamily = "glm-flash"
const ProviderModelFamilyGlmFree ProviderModelFamily = "glm-free"
const ProviderModelFamilyGlmZ ProviderModelFamily = "glm-z"
const ProviderModelFamilyGlmv ProviderModelFamily = "glmv"
const ProviderModelFamilyGpt ProviderModelFamily = "gpt"
const ProviderModelFamilyGptCodex ProviderModelFamily = "gpt-codex"
const ProviderModelFamilyGptCodexMini ProviderModelFamily = "gpt-codex-mini"
const ProviderModelFamilyGptCodexSpark ProviderModelFamily = "gpt-codex-spark"
const ProviderModelFamilyGptImage ProviderModelFamily = "gpt-image"
const ProviderModelFamilyGptLuna ProviderModelFamily = "gpt-luna"
const ProviderModelFamilyGptMini ProviderModelFamily = "gpt-mini"
const ProviderModelFamilyGptNano ProviderModelFamily = "gpt-nano"
const ProviderModelFamilyGptOss ProviderModelFamily = "gpt-oss"
const ProviderModelFamilyGptPro ProviderModelFamily = "gpt-pro"
const ProviderModelFamilyGptSol ProviderModelFamily = "gpt-sol"
const ProviderModelFamilyGptTerra ProviderModelFamily = "gpt-terra"
const ProviderModelFamilyGranite ProviderModelFamily = "granite"
const ProviderModelFamilyGrok ProviderModelFamily = "grok"
const ProviderModelFamilyGrokBeta ProviderModelFamily = "grok-beta"
const ProviderModelFamilyGrokBuild ProviderModelFamily = "grok-build"
const ProviderModelFamilyGrokVision ProviderModelFamily = "grok-vision"
const ProviderModelFamilyGroq ProviderModelFamily = "groq"
const ProviderModelFamilyHermes ProviderModelFamily = "hermes"
const ProviderModelFamilyHunyuan ProviderModelFamily = "hunyuan"
const ProviderModelFamilyHy ProviderModelFamily = "Hy"
const ProviderModelFamilyHy3 ProviderModelFamily = "hy3"
const ProviderModelFamilyHy3Free ProviderModelFamily = "hy3-free"
const ProviderModelFamilyIdeogram ProviderModelFamily = "ideogram"
const ProviderModelFamilyImagen ProviderModelFamily = "imagen"
const ProviderModelFamilyIndictrans ProviderModelFamily = "indictrans"
const ProviderModelFamilyIntellect ProviderModelFamily = "intellect"
const ProviderModelFamilyInternS ProviderModelFamily = "intern-s"
const ProviderModelFamilyInternvl ProviderModelFamily = "internvl"
const ProviderModelFamilyJais ProviderModelFamily = "jais"
const ProviderModelFamilyJamba ProviderModelFamily = "jamba"
const ProviderModelFamilyJoyai ProviderModelFamily = "joyai"
const ProviderModelFamilyKatCoder ProviderModelFamily = "kat-coder"
const ProviderModelFamilyKimi ProviderModelFamily = "kimi"
const ProviderModelFamilyKimiFree ProviderModelFamily = "kimi-free"
const ProviderModelFamilyKimiK2 ProviderModelFamily = "kimi-k2"
const ProviderModelFamilyKimiK3 ProviderModelFamily = "kimi-k3"
const ProviderModelFamilyKimiThinking ProviderModelFamily = "kimi-thinking"
const ProviderModelFamilyLaguna ProviderModelFamily = "laguna"
const ProviderModelFamilyLagunaS ProviderModelFamily = "laguna-s"
const ProviderModelFamilyLing ProviderModelFamily = "ling"
const ProviderModelFamilyLingFlashFree ProviderModelFamily = "ling-flash-free"
const ProviderModelFamilyLiquid ProviderModelFamily = "liquid"
const ProviderModelFamilyLlama ProviderModelFamily = "llama"
const ProviderModelFamilyLlava ProviderModelFamily = "llava"
const ProviderModelFamilyLongcat ProviderModelFamily = "longcat"
const ProviderModelFamilyLucid ProviderModelFamily = "lucid"
const ProviderModelFamilyLyria ProviderModelFamily = "lyria"
const ProviderModelFamilyM2M ProviderModelFamily = "m2m"
const ProviderModelFamilyMagistral ProviderModelFamily = "magistral"
const ProviderModelFamilyMagistralMedium ProviderModelFamily = "magistral-medium"
const ProviderModelFamilyMagistralSmall ProviderModelFamily = "magistral-small"
const ProviderModelFamilyMai ProviderModelFamily = "mai"
const ProviderModelFamilyMelotts ProviderModelFamily = "melotts"
const ProviderModelFamilyMercury ProviderModelFamily = "mercury"
const ProviderModelFamilyMimo ProviderModelFamily = "mimo"
const ProviderModelFamilyMimoFlashFree ProviderModelFamily = "mimo-flash-free"
const ProviderModelFamilyMimoOmni ProviderModelFamily = "mimo-omni"
const ProviderModelFamilyMimoOmniFree ProviderModelFamily = "mimo-omni-free"
const ProviderModelFamilyMimoPro ProviderModelFamily = "mimo-pro"
const ProviderModelFamilyMimoProFree ProviderModelFamily = "mimo-pro-free"
const ProviderModelFamilyMimoV25 ProviderModelFamily = "mimo-v2.5"
const ProviderModelFamilyMimoV25Free ProviderModelFamily = "mimo-v2.5-free"
const ProviderModelFamilyMimoV25Pro ProviderModelFamily = "mimo-v2.5-pro"
const ProviderModelFamilyMimoV26Flash ProviderModelFamily = "mimo-v2.6-flash"
const ProviderModelFamilyMimoV26Pro ProviderModelFamily = "mimo-v2.6-pro"
const ProviderModelFamilyMimoV2Omni ProviderModelFamily = "mimo-v2-omni"
const ProviderModelFamilyMimoV2Pro ProviderModelFamily = "mimo-v2-pro"
const ProviderModelFamilyMinimax ProviderModelFamily = "minimax"
const ProviderModelFamilyMinimaxFree ProviderModelFamily = "minimax-free"
const ProviderModelFamilyMinimaxM2 ProviderModelFamily = "minimax-m2"
const ProviderModelFamilyMinimaxM21 ProviderModelFamily = "minimax-m2.1"
const ProviderModelFamilyMinimaxM25 ProviderModelFamily = "minimax-m2.5"
const ProviderModelFamilyMinimaxM27 ProviderModelFamily = "minimax-m2.7"
const ProviderModelFamilyMinimaxM3 ProviderModelFamily = "minimax-m3"
const ProviderModelFamilyMinimaxM3Free ProviderModelFamily = "minimax-m3-free"
const ProviderModelFamilyMinistral ProviderModelFamily = "ministral"
const ProviderModelFamilyMistral ProviderModelFamily = "mistral"
const ProviderModelFamilyMistralEmbed ProviderModelFamily = "mistral-embed"
const ProviderModelFamilyMistralLarge ProviderModelFamily = "mistral-large"
const ProviderModelFamilyMistralMedium ProviderModelFamily = "mistral-medium"
const ProviderModelFamilyMistralNemo ProviderModelFamily = "mistral-nemo"
const ProviderModelFamilyMistralSmall ProviderModelFamily = "mistral-small"
const ProviderModelFamilyMixtral ProviderModelFamily = "mixtral"
const ProviderModelFamilyMmPoly ProviderModelFamily = "mm-poly"
const ProviderModelFamilyModelRouter ProviderModelFamily = "model-router"
const ProviderModelFamilyMorph ProviderModelFamily = "morph"
const ProviderModelFamilyMuse ProviderModelFamily = "muse"
const ProviderModelFamilyNanoBanana ProviderModelFamily = "nano-banana"
const ProviderModelFamilyNemoretriever ProviderModelFamily = "nemoretriever"
const ProviderModelFamilyNemotron ProviderModelFamily = "nemotron"
const ProviderModelFamilyNemotronFree ProviderModelFamily = "nemotron-free"
const ProviderModelFamilyNeuralChat ProviderModelFamily = "neural-chat"
const ProviderModelFamilyNexN2 ProviderModelFamily = "nex-n2"
const ProviderModelFamilyNorth ProviderModelFamily = "north"
const ProviderModelFamilyNorthFree ProviderModelFamily = "north-free"
const ProviderModelFamilyNousresearch ProviderModelFamily = "nousresearch"
const ProviderModelFamilyNova ProviderModelFamily = "nova"
const ProviderModelFamilyNovaLite ProviderModelFamily = "nova-lite"
const ProviderModelFamilyNovaMicro ProviderModelFamily = "nova-micro"
const ProviderModelFamilyNovaPro ProviderModelFamily = "nova-pro"
const ProviderModelFamilyO ProviderModelFamily = "o"
const ProviderModelFamilyOMini ProviderModelFamily = "o-mini"
const ProviderModelFamilyOPro ProviderModelFamily = "o-pro"
const ProviderModelFamilyOpenchat ProviderModelFamily = "openchat"
const ProviderModelFamilyOpengvlab ProviderModelFamily = "opengvlab"
const ProviderModelFamilyOpenpangu ProviderModelFamily = "openpangu"
const ProviderModelFamilyOrnith ProviderModelFamily = "ornith"
const ProviderModelFamilyOsmosis ProviderModelFamily = "osmosis"
const ProviderModelFamilyOswe ProviderModelFamily = "oswe"
const ProviderModelFamilyPalmyra ProviderModelFamily = "palmyra"
const ProviderModelFamilyPangu ProviderModelFamily = "pangu"
const ProviderModelFamilyParakeet ProviderModelFamily = "parakeet"
const ProviderModelFamilyPhi ProviderModelFamily = "phi"
const ProviderModelFamilyPhoenix ProviderModelFamily = "phoenix"
const ProviderModelFamilyPixtral ProviderModelFamily = "pixtral"
const ProviderModelFamilyPlamo ProviderModelFamily = "plamo"
const ProviderModelFamilyPony ProviderModelFamily = "pony"
const ProviderModelFamilyQvq ProviderModelFamily = "qvq"
const ProviderModelFamilyQwen ProviderModelFamily = "qwen"
const ProviderModelFamilyQwen35 ProviderModelFamily = "qwen3.5"
const ProviderModelFamilyQwen36 ProviderModelFamily = "qwen3.6"
const ProviderModelFamilyQwen37Flash ProviderModelFamily = "qwen3.7-flash"
const ProviderModelFamilyQwen37Max ProviderModelFamily = "qwen3.7-max"
const ProviderModelFamilyQwen37Plus ProviderModelFamily = "qwen3.7-plus"
const ProviderModelFamilyQwen38Max ProviderModelFamily = "qwen3.8-max"
const ProviderModelFamilyQwenFree ProviderModelFamily = "qwen-free"
const ProviderModelFamilyQwerky ProviderModelFamily = "qwerky"
const ProviderModelFamilyRay ProviderModelFamily = "ray"
const ProviderModelFamilyRecraft ProviderModelFamily = "recraft"
const ProviderModelFamilyRednote ProviderModelFamily = "rednote"
const ProviderModelFamilyReka ProviderModelFamily = "reka"
const ProviderModelFamilyResnet ProviderModelFamily = "resnet"
const ProviderModelFamilyRing ProviderModelFamily = "ring"
const ProviderModelFamilyRing1TFree ProviderModelFamily = "ring-1t-free"
const ProviderModelFamilyRnj ProviderModelFamily = "rnj"
const ProviderModelFamilyRunway ProviderModelFamily = "runway"
const ProviderModelFamilySarvam ProviderModelFamily = "sarvam"
const ProviderModelFamilySeed ProviderModelFamily = "seed"
const ProviderModelFamilySensenova ProviderModelFamily = "sensenova"
const ProviderModelFamilySherlock ProviderModelFamily = "sherlock"
const ProviderModelFamilySkywork ProviderModelFamily = "skywork"
const ProviderModelFamilySmartTurn ProviderModelFamily = "smart-turn"
const ProviderModelFamilySolar ProviderModelFamily = "solar"
const ProviderModelFamilySolarMini ProviderModelFamily = "solar-mini"
const ProviderModelFamilySolarPro ProviderModelFamily = "solar-pro"
const ProviderModelFamilySonar ProviderModelFamily = "sonar"
const ProviderModelFamilySonarDeepResearch ProviderModelFamily = "sonar-deep-research"
const ProviderModelFamilySonarPro ProviderModelFamily = "sonar-pro"
const ProviderModelFamilySonarReasoning ProviderModelFamily = "sonar-reasoning"
const ProviderModelFamilySora ProviderModelFamily = "sora"
const ProviderModelFamilySourceful ProviderModelFamily = "sourceful"
const ProviderModelFamilySparkX2 ProviderModelFamily = "spark-x2"
const ProviderModelFamilySqlcoder ProviderModelFamily = "sqlcoder"
const ProviderModelFamilyStableDiffusion ProviderModelFamily = "stable-diffusion"
const ProviderModelFamilyStarling ProviderModelFamily = "starling"
const ProviderModelFamilyStep ProviderModelFamily = "step"
const ProviderModelFamilyTako ProviderModelFamily = "tako"
const ProviderModelFamilyTextEmbedding ProviderModelFamily = "text-embedding"
const ProviderModelFamilyTitan ProviderModelFamily = "titan"
const ProviderModelFamilyTitanEmbed ProviderModelFamily = "titan-embed"
const ProviderModelFamilyTngtech ProviderModelFamily = "tngtech"
const ProviderModelFamilyTopazlabs ProviderModelFamily = "topazlabs"
const ProviderModelFamilyTrinity ProviderModelFamily = "trinity"
const ProviderModelFamilyTrinityMini ProviderModelFamily = "trinity-mini"
const ProviderModelFamilyTstars ProviderModelFamily = "tstars"
const ProviderModelFamilyUnaCybertron ProviderModelFamily = "una-cybertron"
const ProviderModelFamilyUnsloth ProviderModelFamily = "unsloth"
const ProviderModelFamilyV0 ProviderModelFamily = "v0"
const ProviderModelFamilyVenice ProviderModelFamily = "venice"
const ProviderModelFamilyVeo ProviderModelFamily = "veo"
const ProviderModelFamilyVoxtral ProviderModelFamily = "voxtral"
const ProviderModelFamilyVoyage ProviderModelFamily = "voyage"
const ProviderModelFamilyWhisper ProviderModelFamily = "whisper"
const ProviderModelFamilyYi ProviderModelFamily = "yi"
const ProviderModelFamilyZephyr ProviderModelFamily = "zephyr"

type ProviderModelInterleaved_1

type ProviderModelInterleaved_1 struct {
	// Field corresponds to the JSON schema field "field".
	Field ProviderModelInterleaved_1Field `json:"field"`
}

type ProviderModelInterleaved_1Field

type ProviderModelInterleaved_1Field string
const ProviderModelInterleaved_1FieldReasoningContent ProviderModelInterleaved_1Field = "reasoning_content"
const ProviderModelInterleaved_1FieldReasoningDetails ProviderModelInterleaved_1Field = "reasoning_details"

type ProviderModelLimit

type ProviderModelLimit struct {
	// Maximum context window in tokens.
	Context int `json:"context"`

	// Maximum input length in tokens when separately documented.
	Input *int `json:"input,omitempty"`

	// Maximum output length in tokens when documented.
	Output *int `json:"output,omitempty"`
}

Token limits exposed by this provider model endpoint.

type ProviderModelModalities

type ProviderModelModalities struct {
	// Input modalities accepted by the model.
	Input []ProviderModelModalitiesInputElem `json:"input"`

	// Output modalities produced by the model.
	Output []ProviderModelModalitiesOutputElem `json:"output"`
}

Input and output modalities exposed by this model endpoint.

type ProviderModelModalitiesInputElem

type ProviderModelModalitiesInputElem string
const ProviderModelModalitiesInputElemAudio ProviderModelModalitiesInputElem = "audio"
const ProviderModelModalitiesInputElemImage ProviderModelModalitiesInputElem = "image"
const ProviderModelModalitiesInputElemPdf ProviderModelModalitiesInputElem = "pdf"
const ProviderModelModalitiesInputElemText ProviderModelModalitiesInputElem = "text"
const ProviderModelModalitiesInputElemVideo ProviderModelModalitiesInputElem = "video"

type ProviderModelModalitiesOutputElem

type ProviderModelModalitiesOutputElem string
const ProviderModelModalitiesOutputElemAudio ProviderModelModalitiesOutputElem = "audio"
const ProviderModelModalitiesOutputElemImage ProviderModelModalitiesOutputElem = "image"
const ProviderModelModalitiesOutputElemPdf ProviderModelModalitiesOutputElem = "pdf"
const ProviderModelModalitiesOutputElemText ProviderModelModalitiesOutputElem = "text"
const ProviderModelModalitiesOutputElemVideo ProviderModelModalitiesOutputElem = "video"

type ProviderModelProvider

type ProviderModelProvider struct {
	// API corresponds to the JSON schema field "api".
	API *string `json:"api,omitempty"`

	// Body corresponds to the JSON schema field "body".
	Body ProviderModelProviderBody `json:"body,omitempty"`

	// Headers corresponds to the JSON schema field "headers".
	Headers ProviderModelProviderHeaders `json:"headers,omitempty"`

	// NPM corresponds to the JSON schema field "npm".
	NPM *string `json:"npm,omitempty"`

	// Shape corresponds to the JSON schema field "shape".
	Shape *ProviderModelProviderShape `json:"shape,omitempty"`
}

type ProviderModelProviderBody

type ProviderModelProviderBody map[string]JSONValue

type ProviderModelProviderHeaders

type ProviderModelProviderHeaders map[string]string

type ProviderModelProviderShape

type ProviderModelProviderShape string
const ProviderModelProviderShapeCompletions ProviderModelProviderShape = "completions"
const ProviderModelProviderShapeResponses ProviderModelProviderShape = "responses"

type ProviderModelStatus

type ProviderModelStatus string
const ProviderModelStatusAlpha ProviderModelStatus = "alpha"
const ProviderModelStatusBeta ProviderModelStatus = "beta"
const ProviderModelStatusDeprecated ProviderModelStatus = "deprecated"

type ProviderModels

type ProviderModels map[string]ProviderModel

type ProviderPlansCNElem

type ProviderPlansCNElem struct {
	// Name corresponds to the JSON schema field "name".
	Name string `json:"name"`

	// PriceMonth corresponds to the JSON schema field "price_month".
	PriceMonth float64 `json:"price_month"`

	// QuotaWindows corresponds to the JSON schema field "quota_windows".
	QuotaWindows []string `json:"quota_windows,omitempty"`

	// Usage corresponds to the JSON schema field "usage".
	Usage *string `json:"usage,omitempty"`
}

type ProviderProtocol

type ProviderProtocol string
const ProviderProtocolAnthropicCompatible ProviderProtocol = "anthropic-compatible"
const ProviderProtocolOpenaiCompatible ProviderProtocol = "openai-compatible"
const ProviderProtocolOpenaiResponses ProviderProtocol = "openai-responses"

type Providers

type Providers map[string]Provider

type RawUsage added in v0.5.0

type RawUsage struct {
	UncachedInput   int64
	CacheReadInput  int64
	CacheWriteInput int64
	OutputTokens    int64
	ReasoningOutput int64
}

RawUsage bills an explicitly decomposed request when none of the protocol helpers fits, for example after aggregating usage yourself.

type ReasoningOption

type ReasoningOption struct {
	// Default reasoning effort when the provider documents one.
	Default interface{} `json:"default,omitempty"`

	// Provider endpoint IDs where this reasoning control applies.
	Endpoints []string `json:"endpoints,omitempty"`

	// Request body field used by this reasoning control.
	Field *string `json:"field,omitempty"`

	// Maximum reasoning token budget.
	Max *int `json:"max,omitempty"`

	// Minimum reasoning token budget; -1 may represent automatic allocation.
	Min *int `json:"min,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`

	// Supported reasoning effort values; JSON null disables reasoning when supported.
	Values []interface{} `json:"values,omitempty"`
}

Provider-specific reasoning control; type discriminates toggle, effort and token-budget forms.

type ReasoningOption_0

type ReasoningOption_0 struct {
	// Provider endpoint IDs where this reasoning control applies.
	Endpoints []string `json:"endpoints,omitempty"`

	// Request body field used by this reasoning control.
	Field *string `json:"field,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type ReasoningOption_1

type ReasoningOption_1 struct {
	// Default reasoning effort when the provider documents one.
	Default interface{} `json:"default,omitempty"`

	// Provider endpoint IDs where this reasoning control applies.
	Endpoints []string `json:"endpoints,omitempty"`

	// Request body field used by this reasoning control.
	Field *string `json:"field,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`

	// Supported reasoning effort values; JSON null disables reasoning when supported.
	Values []interface{} `json:"values"`
}

type ReasoningOption_1Default_0

type ReasoningOption_1Default_0 string
const ReasoningOption_1Default_0_High ReasoningOption_1Default_0 = "high"
const ReasoningOption_1Default_0_Low ReasoningOption_1Default_0 = "low"
const ReasoningOption_1Default_0_Max ReasoningOption_1Default_0 = "max"
const ReasoningOption_1Default_0_Medium ReasoningOption_1Default_0 = "medium"
const ReasoningOption_1Default_0_Minimal ReasoningOption_1Default_0 = "minimal"
const ReasoningOption_1Default_0_None ReasoningOption_1Default_0 = "none"
const ReasoningOption_1Default_0_Xhigh ReasoningOption_1Default_0 = "xhigh"

type ReasoningOption_1ValuesElem_0

type ReasoningOption_1ValuesElem_0 string
const ReasoningOption_1ValuesElem_0_High ReasoningOption_1ValuesElem_0 = "high"
const ReasoningOption_1ValuesElem_0_Low ReasoningOption_1ValuesElem_0 = "low"
const ReasoningOption_1ValuesElem_0_Max ReasoningOption_1ValuesElem_0 = "max"
const ReasoningOption_1ValuesElem_0_Medium ReasoningOption_1ValuesElem_0 = "medium"
const ReasoningOption_1ValuesElem_0_Minimal ReasoningOption_1ValuesElem_0 = "minimal"
const ReasoningOption_1ValuesElem_0_None ReasoningOption_1ValuesElem_0 = "none"
const ReasoningOption_1ValuesElem_0_Xhigh ReasoningOption_1ValuesElem_0 = "xhigh"

type ReasoningOption_2

type ReasoningOption_2 struct {
	// Provider endpoint IDs where this reasoning control applies.
	Endpoints []string `json:"endpoints,omitempty"`

	// Request body field used by this reasoning control.
	Field *string `json:"field,omitempty"`

	// Maximum reasoning token budget.
	Max *int `json:"max,omitempty"`

	// Minimum reasoning token budget; -1 may represent automatic allocation.
	Min *int `json:"min,omitempty"`

	// Type corresponds to the JSON schema field "type".
	Type string `json:"type"`
}

type SchemaMetadata

type SchemaMetadata struct {
	Package        string `json:"package"`
	PackageVersion string `json:"package_version"`
	SchemaVersion  int    `json:"schema_version"`
	SchemaSHA256   string `json:"schema_sha256"`
	SourceRevision string `json:"source_revision"`
}

func SchemaInfo

func SchemaInfo() SchemaMetadata

type Snapshot

type Snapshot struct {
	Manifest Manifest
	Catalog  Catalog
	// contains filtered or unexported fields
}

Snapshot is one immutable, verified ModelLink catalog version.

func (*Snapshot) Cost added in v0.5.0

func (snapshot *Snapshot) Cost(query CostQuery) (CostResult, bool, error)

Cost prices one request against the snapshot data. It returns ok = false when the provider model is missing or has no price data. It returns an error when price data exists but cannot be applied reliably, for example a missing billing time or holiday resolver; in that case no price should be assumed.

func (*Snapshot) File

func (snapshot *Snapshot) File(name DataFile) ([]byte, bool)

File returns a copy of a verified raw JSON file.

func (*Snapshot) Model

func (snapshot *Snapshot) Model(id string) (ModelMetadata, bool)

Model returns canonical base-model metadata by its globally unique ID.

func (*Snapshot) Provider

func (snapshot *Snapshot) Provider(id string) (Provider, bool)

Provider returns a provider and all of its callable models.

func (*Snapshot) ProviderModel

func (snapshot *Snapshot) ProviderModel(
	providerID string,
	modelID string,
) (ProviderModel, bool)

ProviderModel returns one concrete model offered by a provider. modelID is the provider's callable model identifier.

func (*Snapshot) Schema

func (snapshot *Snapshot) Schema() []byte

Schema returns a copy of the schema published with this snapshot.

func (*Snapshot) Warnings

func (snapshot *Snapshot) Warnings() []Warning

Warnings returns a copy of the non-fatal compatibility warnings found while loading this snapshot.

type Stage added in v0.3.0

type Stage string

Stage identifies one measured phase of an operation. A phase may occur more than once; an absent phase was not executed by this operation.

const (
	StageLockWait   Stage = "lock_wait"
	StageResolve    Stage = "resolve"
	StageCacheRead  Stage = "cache_read"
	StageDownload   Stage = "download"
	StageVerify     Stage = "verify"
	StageCacheWrite Stage = "cache_write"
	StageActivate   Stage = "activate"
	StagePrune      Stage = "prune"
	StageSharedWait Stage = "shared_wait"
)

type StageReport added in v0.3.0

type StageReport struct {
	Stage    Stage
	Duration time.Duration
}

StageReport measures one phase, excluding time attributed to nested phases. Reports are ordered by phase start time, not aggregated by Stage.

type UpdateState added in v0.3.0

type UpdateState struct {
	// UpdatedAt is set in the cache activation transaction, only on version change.
	UpdatedAt time.Time `json:"updated_at"`
	// PreviousVersion is empty for the first activation.
	PreviousVersion string `json:"previous_version"`
	CurrentVersion  string `json:"current_version"`
}

UpdateState records the last actual change of the shared active pointer.

type UpdateStatus

type UpdateStatus struct {
	CurrentVersion  string
	LatestVersion   string
	UpdateAvailable bool
	RegistryBehind  bool
	// CheckedAt is the UTC successful lookup time, or zero if lookup failed.
	// It may be populated alongside an error if persisting the check failed.
	CheckedAt time.Time
	// Duration covers CheckLatest including metadata persistence, excluding the
	// OnOperation callback. It is not persisted in CacheState.
	Duration time.Duration
}

UpdateStatus compares the active snapshot with the registry latest version.

type Warning

type Warning struct {
	Code    WarningCode
	Message string

	DataPackageVersion     string
	DataSchemaVersion      int
	DataSchemaSHA256       string
	EmbeddedPackageVersion string
	EmbeddedSchemaVersion  int
	EmbeddedSchemaSHA256   string
	CurrentVersion         string
	RegistryVersion        string
}

Warning describes an actionable, non-fatal compatibility condition.

type WarningCode

type WarningCode string

WarningCode identifies a non-fatal condition found while loading data.

const (
	// WarningSchemaSDKOutdated means the loaded data uses a newer Schema than
	// the one used to generate this SDK's public Go types.
	WarningSchemaSDKOutdated WarningCode = "schema_sdk_outdated"
	// WarningSchemaDataOutdated means the loaded data uses an older Schema than
	// the one embedded in this SDK.
	WarningSchemaDataOutdated WarningCode = "schema_data_outdated"
	// WarningSchemaMismatch means the two Schema hashes differ but their package
	// versions do not establish which copy is newer.
	WarningSchemaMismatch WarningCode = "schema_mismatch"
	// WarningRegistryBehind means the registry latest version is older than the
	// active local version and automatic downgrade was prevented.
	WarningRegistryBehind WarningCode = "registry_behind"
	// WarningSchemaUpdateSkipped means a future Schema package could not be
	// decoded, so LoadLatest retained the active compatible snapshot instead.
	WarningSchemaUpdateSkipped WarningCode = "schema_update_skipped"
)

Directories

Path Synopsis
examples
basic command
cost command
file-cache command
observability command
update command
version-control command
internal
atomicfile
Package atomicfile writes files through a same-directory temporary file and atomically replaces the destination where the operating system supports it.
Package atomicfile writes files through a same-directory temporary file and atomically replaces the destination where the operating system supports it.
cmd/schemacheck command
cmd/schemagen command
cmd/schemasync command
cmd/verifydata command
trace
Package trace measures exclusive stage durations without exposing SDK types to the artifact transport.
Package trace measures exclusive stage durations without exposing SDK types to the artifact transport.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL