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.
The Ark route builds the expected Chat Completions request through model(). The added tests and a tsc type check pass, but I couldn't check it against a real Ark endpoint (no credentials). Two things in the code are worth fixing before merge; see the inline comments.
Public API: this adds the @opencode/ai/providers/ark subpath export, an Ark namespace in @opencode/ai/providers (id "ark", configure, provider, model, chat, route/routes, types Config/Settings/ChatOptionsInput), and API key lookup from ARK_API_KEY, BYTEPLUS_API_KEY and ARK_CODING_PLAN_API_KEY. All of it is new, so nothing existing breaks.
The description doesn't match the code:
- There is one fixed
cn-beijingbase URL, not a region-based one, so BytePlus users get the wrong default endpoint unless they passbaseURL. thinkingis an on/off switch, not a budget.- Prompt caching sends the OpenAI body field
prompt_cache_key. Nothing sends anX-Ark-Prompt-Idheader.
Please update the description or the code so they match. As the split from #63471 intended, nothing in core uses this provider yet: it isn't registered in packages/core/src/provider.ts.
| reasoningField: "reasoning_content", | ||
| maxTokensField: "max_tokens", | ||
| }, | ||
| capabilities: { tools: { strict: false }, promptCacheKey: true }, |
There was a problem hiding this comment.
promptCacheKey: true makes the OpenAI Chat protocol put prompt_cache_key in the request body. I saw "prompt_cache_key":"sess1" in the compiled body. It doesn't send the X-Ark-Prompt-Id header described in the PR. Does Ark's /chat/completions accept prompt_cache_key? If Ark's caching is keyed by a header, it should be added as a header (like x-grok-conv-id in xai.ts) rather than enabling the body field.
chat() builds the model without the compatibility and capability settings that model() sets, so the two exported entry points behave differently. I compiled the same request through both: chat("m") sends max_completion_tokens instead of max_tokens, doesn't read reasoning_content from the stream, and leaves tools strict. Could both use one model factory, the way moonshot.ts does with model: chat, chat?
chat() was building the model without the compatibility and capabilities settings that model() set, so the two entry points behaved differently: chat() sent max_completion_tokens instead of max_tokens, did not read reasoning_content from the stream, and left tools strict. Share one factory function, the way moonshot.ts does with model: chat, chat.
There was a problem hiding this comment.
Both earlier points are addressed. chat() and model() now share one factory, and I confirmed they compile the same request body with the same settings. Ark's current Chat API reference lists prompt_cache_key as a body field, so the prompt cache handling is fine. The Ark tests and tsc on packages/ai pass. I couldn't test against a real Ark endpoint (no credentials).
Public API: unchanged since the last review. The PR adds the @opencode/ai/providers/ark export and the Ark namespace, which is backwards compatible. Nothing new to flag.
Issue for this PR
Closes #63480
Type of change
What does this PR do?
Add an Ark provider that extends
openai-compatiblewith Volcengine-specific defaults.https://ark.cn-beijing.volces.com/api/v3). The model catalog'sapi.base_urlwins over this default. BytePlus (overseas) users need to passbaseURLsince their endpoint ishttps://ark.ap-southeast.bytepluses.com/api/v3.thinking: An on/off switch ({ type: "enabled" | "disabled" }) for Ark's deep-reasoning mode, sent in the request body. This is not a budget — it controls whether deep reasoning is forced on or off.autois documented but rejected by most models, so it is never sent.reasoning_content: The streaming response field that carries the reasoning trace (set viacompatibility.reasoningField).promptCacheKey: true: Ark's implicit caching is automatic for supported models. The optionalprompt_cache_keybody field improves routing affinity for requests sharing the same prefix — it does not control whether caching is enabled. This is confirmed in the Ark context cache docs.tools.strict: false: Ark does not support strict tool mode.ARK_API_KEY,BYTEPLUS_API_KEY, andARK_CODING_PLAN_API_KEY.Files:
providers/ark.ts,providers/index.tsexport,package.jsonsubpath export, and construction/header tests.How did you verify your code works?
bun turbo typecheck— 35/35 packages passbunx biome check— zero new warnings over dev baselineChecklist
Added by the opencode bot (AI-generated).
Public API: adds the
@opencode/ai/providers/arkexport andArkprovider namespace, readingARK_API_KEY/BYTEPLUS_API_KEY/ARK_CODING_PLAN_API_KEY(backwards compatible)