Repository navigation
Conversation
Add an Ark provider that extends openai-compatible with Volcengine defaults: region-based base URL, thinking budget, and prompt cache key via the X-Ark-Prompt-Id header. - providers/ark.ts: provider definition with Ark base URL and model list - providers/index.ts: export the Ark provider - package.json: export ./providers/ark subpath - test/provider/ark.test.ts: construction and header forwarding tests
There was a problem hiding this comment.
Thanks for splitting this out of #63471. There are a few things to sort out before this can merge.
I couldn't run it end to end. tsc -b in packages/core fails with Cannot find module '@opencode/ai/providers/ark', since that module only comes with #63481, and discovery needs real Ark keys. The existing variant tests pass.
Public API: this adds new provider IDs to the native mapping (byteplus, volcengine, volcengine-coding-plan), a new byteplus provider icon, and new environment-variable fallbacks (ARK_API_KEY, VOLCENGINE_API_KEY, ARK_CODING_PLAN_API_KEY, BYTEPLUS_API_KEY). It also changes how the model list is built for about 18 existing providers (see below). Nothing is removed, but the model lists of those existing providers would change.
Main concerns:
- The scope goes beyond what #63480 describes. That issue says the generic
GET /modelsdiscovery plugin and the local catalog should be discussed separately. This PR still addsplugin/provider/ark.ts, which is that generic discovery plugin, andark/models.ts, which exportsOpenAICompatibleModels. The plugin runs for DeepSeek, Groq, Mistral, MiniMax, Moonshot, Zhipu, SiliconFlow, Fireworks, Novita, Perplexity, NVIDIA and Cerebras as well as Ark (details inline). - It depends on #63481 to compile. The description's "35/35 typecheck pass" can't be true for this branch on its own, and the dependency PR number is still a placeholder. It may be simpler to land this together with, or after, #63481.
byteplusisn't in models.dev. The aisdk-native mapping, the discovery entry and the icon have no effect for BytePlus until abytepluscatalog entry exists there. Onlyvolcengineandvolcengine-coding-planare in models.dev today.
I'd suggest cutting this PR down to the Ark-only wiring: the aisdk-native mapping, the builtin import, the arkChat variant and the icon. Live model discovery can then be proposed separately, if it's wanted.
Related: #63481
| baseURL: "https://ark.ap-southeast.bytepluses.com/api/v3", | ||
| env: ["BYTEPLUS_API_KEY"], | ||
| }, | ||
| // MiniMax |
There was a problem hiding this comment.
From here down, the plugin covers providers that have nothing to do with Ark: MiniMax, DeepSeek, Groq, Fireworks, SiliconFlow, Moonshot, Zhipu, Novita, Perplexity, Mistral, NVIDIA and Cerebras. When any of their keys is set, the transform calls evt.add, which replaces that provider's whole models.dev model list with whatever GET /models returns. Catalog models that the endpoint doesn't list disappear. Anything the endpoint does list (Groq's Whisper, TTS and guard models, Ark's embedding, image and video models) shows up as a chat model. This is the generic discovery plugin that #63480 said would be discussed separately. Could it be limited to the Ark IDs, or left out of this PR?
| cost: previous ? previous.cost : [{ input: Money.USDPerMillionTokens.zero, output: Money.USDPerMillionTokens.zero, cache: { read: Money.USDPerMillionTokens.zero, write: Money.USDPerMillionTokens.zero } }], | ||
| status: previous?.status ?? "active", | ||
| enabled: previous?.enabled ?? true, | ||
| limit: previous?.limit ?? { context: 0, output: 0 }, |
There was a problem hiding this comment.
A model returned by /models that has no catalog template is added with limit: { context: 0, output: 0 }, zero cost, tools: true and text-only input. A zero context limit will likely break compaction and context accounting, and it will mislead users about cost. A missing template would be better skipped, or at least given defaults that aren't zero.
| ["@opencode/ai/providers/azure/messages", () => import("@opencode/ai/providers/azure/messages")], | ||
| ["@opencode/ai/providers/baseten", () => import("@opencode/ai/providers/baseten")], | ||
| ["@opencode/ai/providers/baseten/decisions", () => import("@opencode/ai/providers/baseten/decisions")], | ||
| ["@opencode/ai/providers/ark", () => import("@opencode/ai/providers/ark")], |
There was a problem hiding this comment.
@opencode/ai/providers/ark doesn't exist on this branch or on dev, so tsc -b in packages/core fails here with TS2307. This needs #63481 to land first, or the two PRs need to land together.
Register the Ark provider in the core wiring: - aisdk-native.ts: map Ark provider IDs to the AI SDK - ark/models.ts: Ark model definitions - plugin/provider/ark.ts: Ark provider plugin (config, fetch, models) - variant.ts: Ark variant handling - provider.ts: export the Ark provider - ui: BytePlus provider icon and sprite entry
Per review feedback on anomalyco#63482, the generic GET /models discovery plugin (plugin/provider/ark.ts) and its model template helper (ark/models.ts) are out of scope for this PR — they affect 13 providers beyond Ark and should be proposed separately per issue anomalyco#63480. Remove: - plugin/provider/ark.ts: the generic OpenAI-compatible discovery plugin - ark/models.ts: the OpenAICompatibleModels merge helper - plugin/provider.ts: the ArkPlugin import and registration Keep: - aisdk-native.ts: Ark provider ID mappings (volcengine, byteplus, etc.) - variant.ts: Ark variant handling - provider.ts: builtin import for @opencode/ai/providers/ark - ui: BytePlus provider icon and sprite entry
e746ca1 to
c574989
Compare
There was a problem hiding this comment.
The new commits address all three earlier points: the generic discovery plugin and ark/models.ts are gone, and @opencode/ai/providers/ark now resolves. tsc -b in packages/core passes, as do the new Ark provider tests (5) and the variant and aisdk-native tests (40). I couldn't send real requests to Ark without credentials.
Public API: this adds the @opencode/ai/providers/ark export and the Ark namespace in @opencode/ai, plus a new byteplus provider icon. volcengine and volcengine-coding-plan models from models.dev are now routed through the Ark package instead of plain openai-compatible, so the request shape gains Ark's thinking switch. It's backwards compatible: nothing existing is removed.
One thing to settle: this branch now contains the #63481 commit as well, so the two PRs overlap. Whichever merges first, the other will need to be rebased or closed.
Issue for this PR
Closes #63480
Type of change
What does this PR do?
Register the Ark provider in the core wiring so it appears in the provider list and model catalog.
aisdk-native.ts: map Ark provider IDs (volcengine, volcengine-coding-plan, byteplus) to the AI SDKvariant.ts: Ark variant handling (arkChat)provider.ts: register@opencode/ai/providers/arkas a builtin providerNote:
byteplusis not yet in models.dev, so the icon and mapping have no effect for BytePlus until a catalog entry is added upstream. Onlyvolcengineandvolcengine-coding-planare in models.dev today.Depends on #63481 — this branch is rebased on top of
feat/ark-provider-coreand will not compile without it.The generic
GET /modelsdiscovery plugin that was previously in this PR has been removed. It affected 13 providers beyond Ark and should be proposed separately per issue #63480.How did you verify your code works?
bun turbo typecheck— 35/35 packages pass (on the rebased branch that includes feat(ai): add BytePlus/Volcengine Ark provider #63481)Checklist
Added by the opencode bot (AI-generated).
Related: #63481
Public API: adds @opencode/ai/providers/ark export and routes volcengine/volcengine-coding-plan through it (backwards compatible)