mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
- Import models from index.ts instead of duplicating the array - Use regex ^\w+\.anthropic\. to match all Bedrock region prefixes (us, eu, ap, and any future regions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import type { AdapterModel } from "@paperclipai/adapter-utils";
|
|
import { models as DIRECT_MODELS } from "../index.js";
|
|
|
|
/** AWS Bedrock model IDs — region-qualified identifiers required by the Bedrock API. */
|
|
const BEDROCK_MODELS: AdapterModel[] = [
|
|
{ id: "us.anthropic.claude-opus-4-6-v1", label: "Bedrock Opus 4.6" },
|
|
{ id: "us.anthropic.claude-sonnet-4-5-20250929-v2:0", label: "Bedrock Sonnet 4.5" },
|
|
{ id: "us.anthropic.claude-haiku-4-5-20251001-v1:0", label: "Bedrock Haiku 4.5" },
|
|
];
|
|
|
|
function isBedrockEnv(): boolean {
|
|
return (
|
|
process.env.CLAUDE_CODE_USE_BEDROCK === "1" ||
|
|
process.env.CLAUDE_CODE_USE_BEDROCK === "true" ||
|
|
(typeof process.env.ANTHROPIC_BEDROCK_BASE_URL === "string" &&
|
|
process.env.ANTHROPIC_BEDROCK_BASE_URL.trim().length > 0)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Return the model list appropriate for the current auth mode.
|
|
* When Bedrock env vars are detected, returns Bedrock-native model IDs;
|
|
* otherwise returns standard Anthropic API model IDs.
|
|
*/
|
|
export async function listClaudeModels(): Promise<AdapterModel[]> {
|
|
return isBedrockEnv() ? BEDROCK_MODELS : DIRECT_MODELS;
|
|
}
|
|
|
|
/** Check whether a model ID is a Bedrock-native identifier (not an Anthropic API short name). */
|
|
/** Bedrock model IDs use region-qualified prefixes (e.g. us.anthropic.*, eu.anthropic.*) or ARNs. */
|
|
export function isBedrockModelId(model: string): boolean {
|
|
return /^\w+\.anthropic\./.test(model) || model.startsWith("arn:aws:bedrock:");
|
|
}
|