Skip to content

Feat/snowflake cortex rest API integration#2864

Open
navnitshukla wants to merge 7 commits intolangfuse:mainfrom
navnitshukla:feat/snowflake-cortex-integration
Open

Feat/snowflake cortex rest API integration#2864
navnitshukla wants to merge 7 commits intolangfuse:mainfrom
navnitshukla:feat/snowflake-cortex-integration

Conversation

@navnitshukla
Copy link
Copy Markdown

@navnitshukla navnitshukla commented Apr 24, 2026

Add Snowflake Cortex as a Model Provider Integration

Summary

  • Add Snowflake Cortex to the Model Providers integration list
  • Snowflake Cortex REST API provides two industry-standard APIs:
    • Chat Completions API (OpenAI-compatible) — all models: Anthropic (Claude), OpenAI (GPT), Meta (Llama), Mistral, DeepSeek, Snowflake
    • Messages API (Anthropic-compatible) — Claude models only
  • Chat Completions uses the existing Langfuse OpenAI SDK wrapper (langfuse.openai)
  • Messages API uses AnthropicInstrumentor (OpenTelemetry) with the native Anthropic SDK

Files Added

  • cookbook/integration_snowflake_cortex_rest_api.ipynb — Example notebook with 6 examples (4 Chat Completions + 2 Messages API)
  • content/integrations/model-providers/snowflake-cortex-rest-api.mdx — Integration docs page
  • public/images/integrations/snowflake_cortex_icon.svg — Logo

Files Modified

  • content/integrations/model-providers/meta.json — Added "snowflake-cortex-rest-api" to page list
  • cookbook/_routes.json — Route mapping for cookbook

How It Works

Chat Completions API (all models):
Snowflake Cortex exposes an OpenAI-compatible endpoint at:
https://<account>.snowflakecomputing.com/api/v2/cortex/v1

The existing from langfuse.openai import OpenAI wrapper works out of the box — just point base_url to Cortex and use a Snowflake PAT as the API key.

Messages API (Claude models only):
Snowflake Cortex exposes an Anthropic-compatible endpoint at:
https://<account>.snowflakecomputing.com/api/v2/cortex/v1/messages

Uses the native anthropic.Anthropic client with AnthropicInstrumentor from opentelemetry-instrumentation-anthropic. Requires httpx to override auth header (Snowflake expects Bearer token, not x-api-key).

For a detailed walkthrough of all authentication methods, see: You Have Three Options to Authenticate to the Cortex REST API

Testing

  • Tested Chat Completions with claude-sonnet-4-5, mistral-large2, openai-gpt-4.1, deepseek-r1, llama4-maverick, and snowflake-llama-3.3-70b
  • Tested Messages API with claude-sonnet-4-5 (simple call + multi-turn conversation)
  • All 6 examples verified — traces appear correctly in Langfuse (simple calls, nested @observe(), custom metadata, streaming)

Disclaimer: Experimental PR review

Greptile Summary

This PR adds a Snowflake Cortex REST API integration to Langfuse docs, including a new MDX page, a 6-example Jupyter notebook, and a Snowflake logo SVG. There are two invalid-JSON issues blocking the build, and a logo path mismatch that will render a broken image.

  • P0 meta.json and _routes.json are both missing commas in the newly added entries, making them invalid JSON and breaking site navigation/routing.
  • P1 The MDX frontmatter references snowflake_cortex_icon.svg but the file actually added is snowflake-logo.svg, resulting in a broken sidebar logo.

Confidence Score: 2/5

Not safe to merge — two invalid-JSON files will break site build/routing.

Two P0 syntax errors (missing commas in meta.json and _routes.json) make both config files unparseable, plus a P1 logo path mismatch. These need to be fixed before merging.

content/integrations/model-providers/meta.json and cookbook/_routes.json (invalid JSON); content/integrations/model-providers/snowflake-cortex-rest-api.mdx (wrong logo path).

Important Files Changed

Filename Overview
content/integrations/model-providers/meta.json Adds "snowflake-cortex-rest-api" to the pages list but is missing the required trailing comma, making the file invalid JSON.
cookbook/_routes.json Adds snowflake cookbook route entry but is missing a comma after docsPath, making the file invalid JSON.
content/integrations/model-providers/snowflake-cortex-rest-api.mdx New integration docs page for Snowflake Cortex; references a logo file (snowflake_cortex_icon.svg) that doesn't match the actual file added (snowflake-logo.svg), causing a broken image.
cookbook/integration_snowflake_cortex_rest_api.ipynb New example notebook covering 6 integration scenarios; well-structured with minor import ordering issue in cell-24.
public/images/integrations/snowflake-logo.svg Adds Snowflake SVG logo; filename differs from the reference in the MDX frontmatter.

Sequence Diagram

sequenceDiagram
    participant User
    participant LangfuseWrapper as langfuse.openai / AnthropicInstrumentor
    participant CortexChatAPI as Snowflake Cortex (Chat Completions)
    participant CortexMsgAPI as Snowflake Cortex (Messages API)
    participant Langfuse as Langfuse Platform

    Note over User,Langfuse: Chat Completions API (all models)
    User->>LangfuseWrapper: client.chat.completions.create(model, messages)
    LangfuseWrapper->>CortexChatAPI: POST /api/v2/cortex/v1/chat/completions (Bearer PAT)
    CortexChatAPI-->>LangfuseWrapper: completion response
    LangfuseWrapper-->>User: response
    LangfuseWrapper->>Langfuse: trace (model, tokens, latency)

    Note over User,Langfuse: Messages API (Claude models only)
    User->>LangfuseWrapper: anthropic_client.messages.create(model, messages)
    LangfuseWrapper->>CortexMsgAPI: POST /api/v2/cortex/v1/messages (Authorization: Bearer PAT)
    CortexMsgAPI-->>LangfuseWrapper: message response
    LangfuseWrapper-->>User: response
    LangfuseWrapper->>Langfuse: OTel span (via AnthropicInstrumentor)
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: content/integrations/model-providers/meta.json
Line: 24

Comment:
**Missing comma breaks JSON parsing**

The `"snowflake-cortex-rest-api"` entry is missing a trailing comma, making `meta.json` invalid JSON. This will cause a parse error when the site tries to read the navigation config.

```suggestion
    "snowflake-cortex-rest-api",
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: cookbook/_routes.json
Line: 494

Comment:
**Missing comma breaks JSON parsing**

The `docsPath` value is missing a trailing comma before `"isGuide"`, making `_routes.json` invalid JSON. This will cause a parse error when the cookbook routing is loaded.

```suggestion
  "docsPath": "integrations/model-providers/snowflake-cortex-rest-api",
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: content/integrations/model-providers/snowflake-cortex-rest-api.mdx
Line: 7

Comment:
**Logo path does not match the added file**

The frontmatter references `snowflake_cortex_icon.svg`, but the actual file added to the repo is `public/images/integrations/snowflake-logo.svg`. This will render a broken image in the sidebar/integration page.

```suggestion
logo: /images/integrations/snowflake-logo.svg
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: content/integrations/model-providers/snowflake-cortex-rest-api.mdx
Line: 204-208

Comment:
**Imports should be at the top of the module**

`import httpx` and `from anthropic import Anthropic` appear after `AnthropicInstrumentor().instrument()` has already been called. Imports should be grouped at the top before any executable statements. The same pattern also appears in the corresponding notebook cell (cell-24).

**Rule Used:** Move imports to the top of the module instead of p... ([source](https://app.greptile.com/review/custom-context?memory=c960fc07-9928-409f-a18b-a780cbdded12))

**Learned From**
[langfuse/langfuse-python#1387](https://github.com/langfuse/langfuse-python/pull/1387)

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Update _routes.json" | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

The Jupyter notebook demonstrates:
- Simple chat completion with Cortex via `langfuse.openai.OpenAI`
- Nested traces with `@observe()` (multi-step document analysis)
- Custom metadata via `propagate_attributes`
- Streaming responses
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

@Nav25oct is attempting to deploy a commit to the langfuse Team on Vercel.

A member of the Team first needs to authorize it.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 24, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 24, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added the documentation Improvements or additions to documentation label Apr 24, 2026
Comment thread content/integrations/model-providers/snowflake-cortex-rest-api.mdx Outdated
navnitshukla and others added 2 commits April 24, 2026 17:02
….mdx

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@sfc-gh-nashukla
Copy link
Copy Markdown

Hi team 👋 — friendly follow-up on this PR. I've addressed the JSON issues flagged by Greptile (missing commas in meta.json and _routes.json) and fixed the logo path reference.

The Vercel preview is pending authorization from a team member. Would someone be able to authorize the deployment and give this a review when you get a chance?

Happy to make any additional changes if needed. Thanks!

@jannikmaierhoefer jannikmaierhoefer self-requested a review May 6, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants