Skip to content

feat(snowflake-cortex): add Snowflake Cortex provider#1902

Merged
rekram1-node merged 1 commit into
anomalyco:devfrom
kameshsampath:feat/provider/snowflake-cortex
May 30, 2026
Merged

feat(snowflake-cortex): add Snowflake Cortex provider#1902
rekram1-node merged 1 commit into
anomalyco:devfrom
kameshsampath:feat/provider/snowflake-cortex

Conversation

@kameshsampath

@kameshsampath kameshsampath commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds snowflake-cortex as a new provider, exposing Snowflake's Cortex REST API through the OpenAI Chat Completions-compatible endpoint.

Closes #1895

Provider

Field Value
npm @ai-sdk/openai-compatible
api https://${SNOWFLAKE_ACCOUNT}.snowflakecomputing.com/api/v2/cortex/v1
env SNOWFLAKE_ACCOUNT, SNOWFLAKE_CORTEX_PAT

Models (15)

Model Source
claude-opus-4-7, claude-sonnet-4-6, claude-sonnet-4-5, claude-haiku-4-5 extends anthropic/* + Snowflake output limits
deepseek-r1 extends deepseek/deepseek-reasoner
mistral-large2 extends mistral/mistral-large-2411
openai-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.1 extends openai/*
llama3.1-70b, snowflake-llama-3.3-70b Full definitions

Cost fields

All cost fields are intentionally omitted. Rates defined in the Snowflake Service Consumption Table.

Test plan

  • bun validate passes with no errors
  • All 15 models resolve correctly (verified via bun validate JSON output)
  • logo.svg follows project conventions (width="24", fill="currentColor", Snowflake snowflake mark)
  • Tested locally with opencode against live Snowflake account using SNOWFLAKE_ACCOUNT + SNOWFLAKE_CORTEX_PAT

@kameshsampath kameshsampath marked this pull request as draft May 29, 2026 14:11
@kameshsampath

Copy link
Copy Markdown
Contributor Author

CC: @sfc-gh-kkeller

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
@kameshsampath kameshsampath force-pushed the feat/provider/snowflake-cortex branch from 7012e98 to f3466af Compare May 30, 2026 03:34
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 kameshsampath marked this pull request as ready for review May 30, 2026 04:00
@rekram1-node rekram1-node merged commit 2e58165 into anomalyco:dev May 30, 2026
1 check passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Snowflake Cortex

2 participants