Livid
392.83D
542.57D
V2EX  ›  Wunder

使用 OpenCode 调用 V2EX AI API 的配置文件例子

  •  
  •   Livid ·
    PRO
    · 13h 1m ago · 664 views

    之前的 OpenCode 配置例子帖子中的配置文件非常 bare bone:

    https://edge.v2ex.com/t/1227634

    所以其实很多 OpenCode 的额外功能会因此没有打开。

    这里是一个我目前测试过的更完整的配置文件例子:

    文件位置 ~/.config/opencode/opencode.jsonc

    内容是目前 V2EX 上能够提供的 3 个 GLM 模型及其能力,其中 GLM 5.3 Flash 能支持图片。

    {
      "$schema": "https://opencode.ai/config.json",
      "disabled_providers": [],
      "provider": {
        "v2ex": {
          "name": "v2ex",
          "npm": "@ai-sdk/openai-compatible",
          "options": {
            "baseURL": "https://edge.v2ex.com/chat/v1"
          },
          "models": {
            "coder": {
              "name": "GLM-5.2",
              "reasoning": true,
              "temperature": true,
              "interleaved": { "field": "reasoning_content" },
              "limit": { "context": 1000000, "output": 131072 },
              "modalities": { "input": ["text"], "output": ["text"] },
              "cost": { "input": 1.4, "output": 4.4, "cache_read": 0.26, "cache_write": 0 },
              "variants": {
                "high": { "reasoningEffort": "high" },
                "max": { "reasoningEffort": "max" }
              }
            },
            "glm-5.3": {
              "name": "GLM-5.3",
              "reasoning": true,
              "temperature": true,
              "interleaved": { "field": "reasoning_content" },
              "limit": { "context": 1048576, "output": 131072 },
              "modalities": { "input": ["text"], "output": ["text"] },
              "cost": { "input": 1.4, "output": 4.4, "cache_read": 0.26, "cache_write": 0 },
              "variants": {
                "low": { "reasoningEffort": "low" },
                "high": { "reasoningEffort": "high" },
                "max": { "reasoningEffort": "max" }
              }
            },
            "glm-5.3-flash": {
              "name": "GLM-5.3-Flash",
              "attachment": true,
              "reasoning": true,
              "temperature": true,
              "interleaved": { "field": "reasoning_content" },
              "limit": { "context": 1048576, "output": 131072 },
              "modalities": { "input": ["text", "image"], "output": ["text"] },
              "cost": { "input": 0.075, "output": 0.25, "cache_read": 0.015, "cache_write": 0 },
              "variants": {
                "low": { "reasoningEffort": "low" },
                "high": { "reasoningEffort": "high" },
                "max": { "reasoningEffort": "max" }
              }
            }
          }
        }
      }
    }
    

    这样配置之后,除了可以看到思考过程,还可以看到 context 占用和费用预估(如果是使用类似官方 API 的话)。

    2 replies    2026-08-30 19:57:18 +08:00
    chanssl
        1
    chanssl  
       11h 1m ago
    感谢 Livid
    waytin
        2
    waytin  
       10h 56m ago
    普通账号现在能有多少额度呀
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   930 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:53 · PVG 06:53 · LAX 15:53 · JFK 18:53
    ♥ Do have faith in what you're doing.