(openrouterModel: string)
| 50 | * Throws if the model has a non-anthropic provider prefix. |
| 51 | */ |
| 52 | export function toAnthropicModelId(openrouterModel: string): string { |
| 53 | // Already an Anthropic model ID (no provider prefix) |
| 54 | if (!openrouterModel.includes('/')) { |
| 55 | return openrouterModel |
| 56 | } |
| 57 | |
| 58 | if (!openrouterModel.startsWith('anthropic/')) { |
| 59 | throw new Error( |
| 60 | `Cannot convert non-Anthropic model to Anthropic model ID: ${openrouterModel}`, |
| 61 | ) |
| 62 | } |
| 63 | |
| 64 | return ( |
| 65 | OPENROUTER_TO_ANTHROPIC_MODEL_MAP[openrouterModel] ?? |
| 66 | openrouterModel.replace('anthropic/', '') |
| 67 | ) |
| 68 | } |
no outgoing calls
no test coverage detected