feat(core): add Snowflake Cortex provider#29901
Open
kameshsampath wants to merge 6 commits into
Open
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Collaborator
|
whoops accidentally moved it out of draft didnt mean to click that my bad Ill monitor all ur prs so whenever they are ready we can merge them all |
Author
|
thanks @rekram1-node appreciate your quick response, I shared the PR with my peers and waiting for their comments/improvements if any before I can turn it ready. Does that sound OK ? and same with anomalyco/models.dev#1902. Is there any SLA to move from DRAFT to READY for review? |
Collaborator
|
You can just @ me when they are ready or move them out of draft, I moved this pr back to draft for u |
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>
addc405 to
691d703
Compare
…to V2 plugin
Cortex returns role:"" in streaming delta chunks for GPT-5 models; the AI
SDK schema validation rejects this because the only valid value is "assistant".
The legacy provider.ts already had the SSE normalizer but used
decoder.decode() without { stream: true }, which corrupts multi-byte chars
at chunk boundaries.
- Fix decoder.decode to use { stream: true } in provider.ts
- Add the same SSE normalizer to cortexFetch in the V2 plugin
- Add test for the role normalization
.... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code)
Co-Authored-By: Cortex Code <noreply@snowflake.com>
Author
|
@rekram1-node please review when you can and can you help with related anomalyco/models.dev#1902? |
Adds setup guide for Snowflake Cortex to the providers page, covering the /connect flow, env var alternative, and a sample opencode.json with model capability flags. .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
Collaborator
|
yep |
- Add trial signup link with UTM tracking - Link to official account identifier and trial account docs - Clarify that the provider is limited to tool-calling capable models - Simplify opencode.json example to rely on models.dev catalog - Remove em dashes and stale model list
Author
|
added docs and updated the PR @rekram1-node |
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.
Issue for this PR
Closes #29900
Type of change
What does this PR do?
Snowflake Cortex exposes an OpenAI-compatible endpoint but can't be supported with a models.dev entry alone. Three things require code:
https://${SNOWFLAKE_ACCOUNT}.snowflakecomputing.com/api/v2/cortex/v1) — no static URL to put in models.devmax_completion_tokensinstead ofmax_tokensChanges:
provider.tscustom() loader: dynamic baseURL, credential resolution from env/auth store/config, fetch interceptor for the two quirks abovepackages/coreSnowflakeCortexPlugin: same via the V2aisdk.sdkhook, registered beforeOpenAICompatiblePluginproviders.ts: dedicated login flow that prompts for both account identifier and PAT, stores both in auth metadata soopencode auth loginis self-containedCompanion models.dev PR: anomalyco/models.dev#1902
How did you verify your code works?
Tested end-to-end with
bun devagainst a real Snowflake account — chat and tool-use requests work withclaude-sonnet-4-6. Themax_completion_tokensrewrite and conversation-complete handling were confirmed by observing requests and responses.11 tests in
packages/core/test/plugin/provider-snowflake-cortex.test.tscover the fetch interceptor and plugin hook behaviors.Screenshots / recordings
No UI changes.
Checklist