feat(snowflake-cortex): add Snowflake Cortex provider#1902
Merged
rekram1-node merged 1 commit intoMay 30, 2026
Conversation
Contributor
Author
|
CC: @sfc-gh-kkeller |
This was referenced May 29, 2026
Adds the snowflake-cortex provider which exposes Snowflake's Cortex
REST API (OpenAI Chat Completions-compatible endpoint) to opencode.
Provider details:
- npm: @ai-sdk/openai-compatible
- API: https://${SNOWFLAKE_ACCOUNT}.snowflakecomputing.com/api/v2/cortex/v1
- Auth: SNOWFLAKE_ACCOUNT + SNOWFLAKE_CORTEX_PAT (Programmatic Access Token)
Models (11, all with tool_call support):
- Anthropic: claude-opus-4-7 (beta/preview), claude-sonnet-4-6,
claude-sonnet-4-5, claude-haiku-4-5
- OpenAI: openai-gpt-5.4 (beta), openai-gpt-5.2, openai-gpt-5.1,
openai-gpt-5 (beta), openai-gpt-5-mini (beta), openai-gpt-5-nano (beta),
openai-gpt-4.1
Models without tool_call support (deepseek-r1, llama3.1-70b,
snowflake-llama-3.3-70b, mistral-large2) are excluded per Snowflake docs:
"Tool calling is supported for OpenAI and Claude models only."
Preview/not-GA models are marked with status = "beta".
Cost fields are intentionally omitted on all models. The Cortex REST API
is billed in USD (AI_INFERENCE service type) at rates defined in the
Snowflake Service Consumption Table.
Closes anomalyco#1895
7012e98 to
f3466af
Compare
kameshsampath
added a commit
to kameshsampath/opencode
that referenced
this pull request
May 30, 2026
Snowflake Cortex uses a per-account endpoint URL and has two API quirks that require explicit handling: it expects max_completion_tokens instead of max_tokens, and returns 400 "conversation complete" as a normal stop condition rather than a finish_reason. Changes: - custom() loader in provider.ts: resolves baseURL from SNOWFLAKE_ACCOUNT, PAT from SNOWFLAKE_CORTEX_PAT or opencode auth store, fetch interceptor rewrites max_tokens and handles conversation complete - SnowflakeCortexPlugin in packages/core: V2 plugin for the aisdk.sdk hook with the same fetch interceptor; registered before OpenAICompatiblePlugin - providers.ts: dedicated login flow that collects and stores both account identifier and PAT via opencode auth Companion models.dev PR: anomalyco/models.dev#1902 .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
kameshsampath
added a commit
to kameshsampath/opencode
that referenced
this pull request
Jun 3, 2026
Snowflake Cortex uses a per-account endpoint URL and has two API quirks that require explicit handling: it expects max_completion_tokens instead of max_tokens, and returns 400 "conversation complete" as a normal stop condition rather than a finish_reason. Changes: - custom() loader in provider.ts: resolves baseURL from SNOWFLAKE_ACCOUNT, PAT from SNOWFLAKE_CORTEX_PAT or opencode auth store, fetch interceptor rewrites max_tokens and handles conversation complete - SnowflakeCortexPlugin in packages/core: V2 plugin for the aisdk.sdk hook with the same fetch interceptor; registered before OpenAICompatiblePlugin - providers.ts: dedicated login flow that collects and stores both account identifier and PAT via opencode auth Companion models.dev PR: anomalyco/models.dev#1902 .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
snowflake-cortexas a new provider, exposing Snowflake's Cortex REST API through the OpenAI Chat Completions-compatible endpoint.Closes #1895
Provider
npm@ai-sdk/openai-compatibleapihttps://${SNOWFLAKE_ACCOUNT}.snowflakecomputing.com/api/v2/cortex/v1envSNOWFLAKE_ACCOUNT,SNOWFLAKE_CORTEX_PATModels (15)
claude-opus-4-7,claude-sonnet-4-6,claude-sonnet-4-5,claude-haiku-4-5extends anthropic/*+ Snowflake output limitsdeepseek-r1extends deepseek/deepseek-reasonermistral-large2extends mistral/mistral-large-2411openai-gpt-5.4,openai-gpt-5.2,openai-gpt-5.1,openai-gpt-5,openai-gpt-5-mini,openai-gpt-5-nano,openai-gpt-4.1extends openai/*llama3.1-70b,snowflake-llama-3.3-70bCost fields
All cost fields are intentionally omitted. Rates defined in the Snowflake Service Consumption Table.
Test plan
bun validatepasses with no errorsbun validateJSON output)logo.svgfollows project conventions (width="24",fill="currentColor", Snowflake snowflake mark)SNOWFLAKE_ACCOUNT+SNOWFLAKE_CORTEX_PAT