Skip to content

Conversation

@AshAnand34
Copy link

Resolves Issue #826 (1M token support for claude sonnet)

@vercel
Copy link

vercel bot commented Sep 6, 2025

@AshAnand34 is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@phy101
Copy link

phy101 commented Sep 6, 2025

I don't think it will work as you propose it.

there is no model "claude-sonnet-4-1m"
you need to add in the "claude-sonnet-4"

"anthropic-beta": "context-1m-2025-08-07",

@phy101
Copy link

phy101 commented Sep 6, 2025

You also need to update the costs according.

Prompts ≤ 200K | $3 / MTok | $15 / MTok
Prompts > 200K | $6 / MTok | $22.50 / MTok

// },
// {
// label: "Claude Opus 4 (Extended Thinking)",
// value: "anthropic:extended-thinking:claude-opus-4-0",

Choose a reason for hiding this comment

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

#833 specifically creating the new model to do a function lookup instead of reliance on the static implementation

// Canonical metadata for all supported models

export type ModelFamily = "Anthropic Claude" | "OpenAI GPT" | "Google Gemini" | "DeepSeek" | "Qwen" | "Meta Llama" | "Grok" | "Other";

export interface ModelMetadata {
 label: string;
 modelName: string;
 modelFamily: ModelFamily;
 maxInternalTokens: number | undefined;
 contextWindow: number;
 notableFeatures?: string[];
 costPerMillionTokens?: {
   input: number;
   output: number;
 };
}

export const MODEL_METADATA: Record<string, ModelMetadata> = {
 "anthropic:claude-sonnet-4-1m": {
   label: "Claude Sonnet 4 (1M Context)",
   modelName: "anthropic:claude-sonnet-4-1m",
   modelFamily: "Anthropic Claude",
   maxInternalTokens: 1_000_000,
   contextWindow: 1_000_000,
   notableFeatures: ["1M token context", "Best for long conversations"],
   costPerMillionTokens: { input: 3.0, output: 15.0 },
 },
 "anthropic:claude-opus-4-1": {
   label: "Claude Opus 4.1",
   modelName: "anthropic:claude-opus-4-1",
   modelFamily: "Anthropic Claude",
   maxInternalTokens: 200_000,
   contextWindow: 200_000,
   notableFeatures: ["High accuracy", "Fast output"],
   costPerMillionTokens: { input: 15.0, output: 75.0 },
 },
 "openai:gpt-4o": {
   label: "GPT-4o",
   modelName: "openai:gpt-4o",
   modelFamily: "OpenAI GPT",
   maxInternalTokens: 128_000,
   contextWindow: 128_000,
   notableFeatures: ["Multimodal", "Fast inference"],
   costPerMillionTokens: { input: 2.5, output: 10.0 },
 },
 "google-genai:gemini-2.5-pro": {
   label: "Gemini 2.5 Pro",
   modelName: "google-genai:gemini-2.5-pro",
   modelFamily: "Google Gemini",
   maxInternalTokens: undefined,
   contextWindow: 1_048_576,
   notableFeatures: ["Multimodal", "1M token context window", "Integrated with Google products"],
   costPerMillionTokens: { input: 2.5, output: 15.0 },
 },
 "deepseek:v3.1": {
   label: "DeepSeek V3.1",
   modelName: "deepseek:v3.1",
   modelFamily: "DeepSeek",
   maxInternalTokens: 671_000_000,
   contextWindow: 128_000,
   notableFeatures: ["High-performance MoE", "Specialized in coding and reasoning"],
   costPerMillionTokens: { input: 0.14, output: 0.28 },
 },
 "qwen:3-1m": {
   label: "Qwen 3 (1M Context)",
   modelName: "qwen:3-1m",
   modelFamily: "Qwen",
   maxInternalTokens: 1_000_000,
   contextWindow: 1_000_000,
   notableFeatures: ["Ultra-long context", "Multilingual", "MoE architecture"],
   costPerMillionTokens: { input: 0.20, output: 0.60 },
 },
 "meta:llama-4-scout": {
   label: "Llama 4 Scout",
   modelName: "meta:llama-4-scout",
   modelFamily: "Meta Llama",
   maxInternalTokens: 109_000_000_000,
   contextWindow: 10_000_000,
   notableFeatures: ["10M context window", "Multimodal (text, image, video)", "Open-weight"],
   costPerMillionTokens: { input: 0.11, output: 0.34 },
 },
 "grok:4": {
   label: "Grok 4",
   modelName: "grok:4",
   modelFamily: "Grok",
   maxInternalTokens: undefined,
   contextWindow: 256_000,
   notableFeatures: ["Multimodal", "Real-time web searches", "Advanced reasoning"],
   costPerMillionTokens: { input: 3.0, output: 15.0 },
 },
 // Add other models here
};

// Utility to get model attributes
export function getMaxInternalTokensForModel(modelName: string): number {
 const model = MODEL_METADATA[modelName];
 if (!model) {
   throw new Error(`Unknown model: ${modelName}`);
 }
 return model.maxInternalTokens ?? model.contextWindow;
}

export function getModelMetadata(modelName: string): ModelMetadata {
 const model = MODEL_METADATA[modelName];
 if (!model) {
   throw new Error(`Unknown model: ${modelName}`);
 }
 return model;
}

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.

3 participants